Why is there a wait period when closing GUI window in the sample host code?



I’m studying the sample host code, and I see that, in gPluginWindow::closeAllCurrentlyOpenWindows(), the following code is executed after deleting the GUI windows:

    Component dummyModalComp;
    MessageManager::getInstance()->runDispatchLoopUntil (50);

I was wondering what was its use? Do some plugins require some time to clean up their GUI? Is there a risk of crashes if I do not do the same in my host?

Thank you very much for your help.

Benjamin Golinvaux


The forum is full of threads about this, but usually talking about it from the other end…

This is important especially on OSX because once a plugin has deleted its windows, there can be OS objects that must be given a few event-loop cycles to allow them to shutdown cleanly before the DLL is unloaded from memory. And on all OSes there could be messages still in the event queue that the plugin has posted, and which will cause a crash if they get delivered after the DLL no longer exists.


Thank you very much. This makes perfect sense, now. I am sorry if I missed the existing forum posts about that issue.