Plugin editor and combobox windows not displaying under some circumstances

I'm getting a very strange behaviour which is intermittent - and appears to be connected with whether a certain number of plugins have been instantiated and loaded or not. 

 

In my host app written in JUCE - in OSX - hosting AudioUnits only - If I launch my app using no saved preferences - thus no plugins get loaded ( like an empty music project )  then plugin windows and combo box drop downs open as one would expect. 

 

If however I launch my app with some saved preferences  in which certain plugins will automatically load ( as if i have a music project with tracks on it which contain plugin VI's )  then  after my app loads as normal - and all plugins get loaded and instantiated ( Kontakt, Ivory, BFD currently ) then   I find that when I click a button intended to open a plugin editor ( AudioUnits ) then the editor window no longer displays.  

Also - none of my combo-box popups will display their drop down menus.  

 

Now i've followed through the code in BOTH cases and far as I can tell - the code executes exactly the same - particularly in the case of the combo-boxes. 

 

Now heres a strange thing that happened on a hunch.   I decided to create a button which simply launches a JUCE modal dialog box ( native mac style ).  As soon as i click this button.   The editor for the Plugin i just tried to open earlier magically appears ! ( followed by the dialog box ) or the other way round.   This doesnt solve the combo-box bug though which refuses to display. 

 

Something tells me this is something to do with message loops or timers or something.   I'm baffeld why it affets popups as well as plugin editors though.  

 

I do not get any asserts tellgin me the messagemanager has been locked wrongly ( or needs locking ) dunno ? 

 

Anyone else come across this ?   exactly the same code seems to execute in both cases - and I even traced correct combobox behaviour down the the paint()  method being called for popupmenu::MenuWindow::Paint() 

 

weird and flummoxing !!  HEEEEEEEEEELLLL P !!

 

it appears to be the final line here :  return [alert runModal];  that magically makes the plugin editor window display.

I cannot trace in any further than here since it goes straight into Cocoa OSX assembler code.   

 NSInteger getRawResult() const

    {

        NSAlert* alert = [[[NSAlert alloc] init] autorelease];

 

        [alert setMessageText:     juceStringToNS (title)];

        [alert setInformativeText: juceStringToNS (message)];

 

        [alert setAlertStyle: iconType == AlertWindow::WarningIcon ? NSCriticalAlertStyle

                                                                   : NSInformationalAlertStyle];

        addButton (alert, button1);

        addButton (alert, button2);

        addButton (alert, button3);

 

        return [alert runModal];

    }