Show_busy causes nested show_modal dialog to close both itself and parent

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:

sgtk:descriptor:git?path=git://github.com/rfischer-nfa/tk-config-modal-dialog-test.git&version=v1.0.1

The config will pull the “demo app” from the adjacent public git repo and register its command on Asset context.

To reproduce:

  • 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” :grin: 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!
Rhea

1 Like

Hi @Rhea_Fischer

The problem is the try catch in app.py

def sync_workfolder(self):
        # try:
            self.engine.show_busy('Busy', '...please hold')

            engine = sgtk.platform.current_engine()
            engine.clear_busy()
            test = self.import_module("modal_dialogs")

            test.connect()
        # finally:
        #     self.engine.clear_busy()

You could comment those out like the above code.

Best

Loney

Hi Loney,

Thanks for your reply!

I haven’t had time to test your solution, though I thought this was one of the first things I tried early in debugging. I will recheck soon!

Do you have any idea why this outer try finally clause would affect the QEventLoop behavior?

Rhea