Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opt-in PySide2 via Qt5.py #354

Merged
merged 13 commits into from
Feb 9, 2020
Merged

Opt-in PySide2 via Qt5.py #354

merged 13 commits into from
Feb 9, 2020

Conversation

davidlatwe
Copy link
Collaborator

@davidlatwe davidlatwe commented Feb 3, 2020

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

  • Make QML App able to use PySide2 as Qt binding with the help from Qt5.py.
  • Vendorized Qt5.py.

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).

pyblish_qml/models.py Outdated Show resolved Hide resolved
@mottosso
Copy link
Member

mottosso commented Feb 3, 2020

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

davidlatwe commented Feb 3, 2020

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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
Copy link
Member

mottosso commented Feb 4, 2020

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

@davidlatwe
Copy link
Collaborator Author

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
Copy link
Member

mottosso commented Feb 5, 2020

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.

@davidlatwe davidlatwe mentioned this pull request Feb 9, 2020
@davidlatwe davidlatwe merged commit e0a9015 into pyblish:master Feb 9, 2020
@davidlatwe davidlatwe deleted the Qt5 branch February 9, 2020 10:12
@BigRoy
Copy link
Member

BigRoy commented Feb 9, 2020

@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
Copy link
Collaborator Author

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. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pyblish QML failing to load from Maya after loading Houdin Engine plug-in Doesn't work with Nuke
3 participants