+ wxCHECK_MSG(!IsModal(),GetReturnCode(),wxT("wxDialog::ShowModal called within its own modal loop"));
+
+ // Show(true) will set m_isShown = true
+ m_isShown = false;
+ m_isModal = true;
+ wxModalDialogs.Append(this);
+
+ wxLogTrace(wxTRACE_COCOA,wxT("runModal"));
+ NSApplication *theNSApp = wxTheApp->GetNSApplication();
+ // If the app hasn't started, flush the event queue
+ // If we don't do this, the Dock doesn't get the message that
+ // the app has started so will refuse to activate it.
+ if(![theNSApp isRunning])
+ {
+ // We should only do a few iterations so one pool should be okay
+ wxAutoNSAutoreleasePool pool;
+ while(NSEvent *event = [theNSApp
+ nextEventMatchingMask:NSAnyEventMask
+ untilDate:[NSDate distantPast]
+ inMode:NSDefaultRunLoopMode
+ dequeue: YES])
+ {
+ [theNSApp sendEvent: event];
+ }
+ }
+