QWidget: Must construct a QApplication before a QPaintDevice
Python exited unexpectedly.
Critical: The Shotgun integration has unexpectedly shut down. Specifically, the python process that handles the communication with Shotgun has been terminated.
All of this works great in the Shotgun Python Console.
I know this is executing as a hook, is there some other way I need to do this?
I was just reading through a related post about core hooks, specifically the response from Phillip.
Seems this is not possible in a core hook?
I will move my logic to the engine’s post_app_init and see how that works. Wanted to avoid having to branch the engines and handle it all in one place.
No better luck moving this to the engine. This is at the end of post_app_init().
if len(list(self.adobe.app.documents)) == 0:
# check for the File Open command
if 'File Open...' in self.commands :
self.logger.info ('Opening WorkFiles2...')
uid = self.commands['File Open...']['properties']['uid']
self.logger.info (' uid: %s' % uid)
self._handle_command(uid)
…generates the same errors as in the hook. Help.
Opening WorkFiles2...
uid: 4
QWidget: Must construct a QApplication before a QPaintDevice
Python exited unexpectedly.
Critical: The Shotgun integration has unexpectedly shut down. Specifically, the python process that handles the communication with Shotgun has been terminated.
if len(list(self.adobe.app.documents)) == 0:
# check for the File Open command
if 'File Open...' in self.commands :
self.logger.info ('Opening WorkFiles2...')
callback = self.commands['File Open...']['callback']
callback()
I’m not sure which engines you’re hoping to set this up for, but I want to make sure that you’re aware of the launch_at_startup setting for tk-multi-workfiles2. It only works for the engines that support it, but if they do, then you just have to set the setting to True in your config to get the behavior you’re after.
Unfortunately, you’ve discovered that we’ve not implemented the launch_at_startup feature for the Photoshop engine. Unfortunately, as well, is that the core hook you were hoping to use to get the same result is executed too early in the process of bootstrapping Toolkit and there’s no Qt event loop up and running yet.
This is going to be tricky, because the process of getting the Adobe integration and its RPC connection up and running is much more complex than in integrations that are able to make use of fully embedded Python and Qt environments (like in Maya, as an example).
Off the top of my head, you could try one of two things, with the former being quicker to test:
You can try doing exactly what you were doing in post_app_init, but do it in post_qt_init instead. However, I’m concerned this might also not work. At that point there is definitely a QApplication, but Qt’s event loop hasn’t yet been started. It’s worth a shot, though, to see if the app launch will work and pop up shortly after it’s called when the event loop is started.
You could try instantiating a QTimer in post_qt_init and asking it to run your code as a single-shot event with a delay of 1ms, which should cause it to fire your code that launches Workfiles2 1ms after the Qt event loop starts. That’s obviously getting slightly more into depth with Qt, but hopefully my brief description there makes sense.
Very sorry there’s not an easier answer than that, but I hope that at least helps!