+
+ Show(TRUE);
+
+ if (m_modalShowing)
+ return 0;
+
+ wxModalShowingStack.Insert((wxObject *)TRUE);
+
+ m_modalShowing = TRUE;
+ XtAddGrab((Widget) m_mainWidget, TRUE, FALSE);
+
+ XEvent event;
+
+ // Loop until we signal that the dialog should be closed
+ while ((wxModalShowingStack.Number() > 0) && ((int)(wxModalShowingStack.First()->Data()) != 0))
+ {
+ // XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
+
+ XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
+ wxTheApp->ProcessXEvent((WXEvent*) &event);
+
+ if (XtAppPending( (XtAppContext) wxTheApp->GetAppContext() ) == 0)
+ {
+ if (!wxTheApp->ProcessIdle())
+ {
+#if wxUSE_THREADS
+ // leave the main loop to give other threads a chance to
+ // perform their GUI work
+ wxMutexGuiLeave();
+ wxUsleep(20);
+ wxMutexGuiEnter();
+#endif
+ }
+ }
+ }
+
+ // Remove modal dialog flag from stack
+ wxNode *node = wxModalShowingStack.First();
+ if (node)
+ delete node;
+
+ // Now process all events in case they get sent to a destroyed dialog
+ XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE);
+ while (XtAppPending((XtAppContext) wxTheApp->GetAppContext()))
+ {
+ XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()));
+ XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
+
+ wxTheApp->ProcessXEvent((WXEvent*) &event);
+ }
+
+ // TODO: is it safe to call this, if the dialog may have been deleted
+ // by now? Probably only if we're using delayed deletion of dialogs.
+ return GetReturnCode();