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

Pyblish QML is unresponsive when opening another file in Blender #360

Closed jasperges closed 4 years ago

jasperges commented 4 years ago

When you open a file in Blender all running modal operators are cancelled. So when Pyblish QML is running, the modal operator responsible for the communication between Blender and Pyblish is also cancelled. This effectively renders Pyblish QML unrepsonsive.

A possible fix would be to quit Pyblish QML when the operator is cancelled. That could be done from the cancel method of the operator. I guess we need to send a function to Pyblish QML with blender_to_qml.put(). But I'm not sure what to send. Any ideas? And maybe there are better ways to tackle this problem.

mottosso commented 4 years ago

Not 100% sure how Blender's operators works, but it looks like one is registered here which may indicate there is an unregistration where we could do things?

Otherwise, it's a class, so perhaps the __del__ operator is called on deletion?

In each case, it looks like the operator's cancel() is the one to call.

jasperges commented 4 years ago

When you open a file the operator is cancelled and then cancel() of the operator is called. This already happens. As mentioned my proposal is to send some sort of 'quit' or 'closeWindows' signal to Pyblish QML so it closes instead of staying open and being unresponsive. But how can we send that signal from the operator's cancel()?

mottosso commented 4 years ago

Ah I see what you mean.

The way hosts like Blender speak to QML is via a "proxy", that looks like this. You can find it in:

from pyblish_qml import api
proxy = api.current_server()
proxy.quit()
jasperges commented 4 years ago

Looking from the code I could simplify it to just quit(), because we're in hosts.py. Works like a charm. No more unresponsive Pyblish QML.