pyblish / pyblish-qml

Pyblish QML frontend for Maya 2013+, Houdini 11+, Nuke 8+ and more
GNU Lesser General Public License v3.0
114 stars 44 forks source link

Opt-in PySide2 via Qt5.py #354

Closed davidlatwe closed 4 years ago

davidlatwe commented 4 years ago

This will fix #313 and fix #301.

Both #313 and #301 were issues that having PyQt5 DLL load failed error on App startup, and through the tests what @BigRoy has done in #313, looks like it's a problem which possibly came from DCC host about how they load those Qt DLLs, and is hard to solve directly from our end.

So since those DCC were holding DLL which was from PySide2, making PySide2 also usable for pyblish_qml could be a good workaround.

Changes

Caveats (Resolved, see comment below)

May lose font when using PySide2.

There's a strange problem after using PySide2, is the QML's comment box may display weird characters on first run.

fontfamily

But if we don't assign font.family in QML here, the text will display correctly (with out custom font of course).

mottosso commented 4 years ago

Stellar work David. Wonder why the tests are failing on import? :O They throw a module not found error, which is a subclass of import error, which is being handled.

For the font, that's an odd one. Maybe best not to assign a font to that one textfield for the time being. Odds are there's an issue loading the font from disk. Could be path related, or even OpenGL related.

We could possibly work around it by packing the font into a Qt Resource instead, but it can wait.

davidlatwe commented 4 years ago

Wonder why the tests are failing on import? :O They throw a module not found error, which is a subclass of import error, which is being handled.

Hmmm, it looks like it will raise eventually, here. Looks like we need to add python3-pyqt5.qtmultimedia this package into Dockerfile for test ?

davidlatwe commented 4 years ago

I have found the solution for weird font appearance !

So it looks like PySide's font loading is a bit different from PyQt, using FontLoader to load font explicitly and reference it on demand solved the issue !

Also for the visual consistency, I set the textRenderType to NativeTextRendering because it's what I got from PyQt at my end before. Let me know if this doesn't work for you.

davidlatwe commented 4 years ago

Also, the CI test was fixed in commit 9205fdd, and sorry for the force push, was trying to keep this kind of commit minimum.

davidlatwe commented 4 years ago

Also for the visual consistency, I set the textRenderType to NativeTextRendering because it's what I got from PyQt at my end before. Let me know if this doesn't work for you.

In fact, PyQt was rendering text in native way only because those texts (local chars) was not found in "Open Sans". I should revert that change.

Should make font family be customizable, but yeah, it could wait till next PR.

mottosso commented 4 years ago

Once you're happy with this @davidlatwe you're welcome to merge and release. Great work. 👍

davidlatwe commented 4 years ago

So I have found and solved one last bug after this PR, it's a random error that raised from QML on window close. This seems only happens when using PySide2 as Qt binding.

Not every time, but often, got these errors when I close the window:

file:///.../pyblish_qml/qml/Footer.qml:50: TypeError: Cannot read property 'hasComment' of null
file:///.../pyblish_qml/qml/Terminal.qml:144: TypeError: Cannot read property 'resultModel' of null
file:///.../pyblish_qml/qml/Terminal.qml:39: TypeError: Cannot read property 'resultProxy' of null
file:///.../pyblish_qml/qml/Overview.qml:117: TypeError: Cannot read property 'pluginProxy' of null
file:///.../pyblish_qml/qml/Overview.qml:84: TypeError: Cannot read property 'instanceProxy' of null
file:///.../pyblish_qml/qml/Overview.qml:125: TypeError: Cannot read property 'pluginProxy' of null
file:///.../pyblish_qml/qml/Overview.qml:125: TypeError: Cannot read property 'pluginProxy' of null
file:///.../pyblish_qml/qml/Overview.qml:92: TypeError: Cannot read property 'instanceProxy' of null
file:///.../pyblish_qml/qml/Overview.qml:125: TypeError: Cannot read property 'pluginProxy' of null
file:///.../pyblish_qml/qml/Overview.qml:125: TypeError: Cannot read property 'pluginProxy' of null
file:///.../pyblish_qml/qml/Perspective/Viewport.qml:31: TypeError: Cannot read property 'errorProxy' of null

QML was complaining about reading properties from a null object, and that object was a root context property called app which exposed from Python, an instance of pyblish_qml.control.Controller.

And it became null in QML was because it's garbage collected before QML component gets destroyed on window close, and that's why the error happens randomly.

The solution was simple, just assign a parent to the pyblish_qml.control.Controller, see commit 900d739.

Since the error happens randomly in our case, here's a small example that proves the point.

Finally, will merge this tomorrow if no other objections. ☺️

mottosso commented 4 years ago

The solution was simple, just assign a parent to the pyblish_qml.control.Controller

Makes sense. :) Good find. Happy to merge when you're happy.

BigRoy commented 4 years ago

@davidlatwe just wondering. Do I need to do anything to make this work inside Houdini, like an environment variable? Or would this magically work already?

I'm expecting I need to change something but I'm not sure what.

davidlatwe commented 4 years ago

Do I need to do anything to make this work inside Houdini

If you mean in Maya with Houdini Engine loaded, like the case in #313, then all you need is installing PySide2 in the place that Python could find.

If not, Houdini should works just fine without doing anything else. :)