Hi fellow sgtk enthusiasts,
Here’s a weird one! Hope the repro is easy and clear.
While rewriting the Perforce support ran into some odd behavior. If a show_busy is active then the second of two popped show_modal dialogs will close both, rather than just itself. Tracing reveals this is because the outer dialog’s QEventLoop has exited.
Published an sgtk app on github to demo the problem, along with a minimally modified tk-config-default2 to demo it as a command on Asset context:
Add the following pipeline configuration descriptor to a shotgun test server where you have at least one asset:
The config will pull the “demo app” from the adjacent public git repo and register its command on Asset context.
- Start SG desktop
- Browse to asset page.
- Right mouse on the asset to the command “Test Nested Modal Dialogs”
- (this pops a first modal dialog)
- Click OK
- (this pops a second modal dialog)
- However, when the second modal dialog is closed it closes both dialogs.
What’s happening is that the outer show_modal’s QEventLoop is exiting, though it probably should not. This may be related to engine cleanup code called from its widget wrapper classes.
Calling clear_busy before popping the dialog, or never calling show_busy, brings the expected behavior.
While the workaround is “clear” it would be nice if a note where attached to the show_busy doc indicating that it should be cleared before using show_modal.
Note 1: This does not happen for dialogs popped with, e.g. QMessageDialog, likely because it avoids the class wrappers in the engine.
Note 2: I wrote a pytest for this. However, even using the tk-shotgun engine in there I can’t reproduce the error!
Note 3: the mockgun should have a get_info method
Best to you!