Question about closeAllCurrentlyOpenWindows() in PluginHost

Hi,

I was looking at the code of the Plugin Host application, and got intrigued by the following lines:

void PluginWindow::closeAllCurrentlyOpenWindows()
{
    if (activePluginWindows.size() > 0)
    {
        for (int i = activePluginWindows.size(); --i >= 0;)
            delete activePluginWindows.getUnchecked(i);

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

Why is there a dummy modal component here? And is it necessary to run a few dispatch loops when closing plugin windows?

Cheers,

Well, the modal component tries to stop any UI responding to user input while that message loops spins. And the message loop is there to allow the plugins to finish processing any pending messages before their DLL gets unloaded.

Ok thanks Jules.

I’m going to try something similar in my application to see if this prevents weird crashes with some AUs when they get deleted:

[attachment=0]audio-unit-window-destruction-bug-stripped.png[/attachment]