X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c4cb3d0f0c41ce86112cf704b3f37f87130e78cf..4b056ef54f29582e2a5154bf148f7ebc5877b51b:/src/motif/window.cpp diff --git a/src/motif/window.cpp b/src/motif/window.cpp index 3d778a7fa6..ccb85596eb 100644 --- a/src/motif/window.cpp +++ b/src/motif/window.cpp @@ -1189,6 +1189,34 @@ bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y) XmMenuPosition (menuWidget, &event); XtManageChild (menuWidget); + XEvent x_event; + // The ID of a pop-up menu is 1 when active, and is set to 0 by the + // idle-time destroy routine. + // Waiting until this ID changes causes this function to block until + // the menu has been dismissed and the widgets cleaned up. + // In other words, once this routine returns, it is safe to delete + // the menu object. + // Ian Brown + while (menu->GetId() == 1) + { + XtAppNextEvent( (XtAppContext) wxTheApp->GetAppContext(), &x_event); + + wxTheApp->ProcessXEvent((WXEvent*) & x_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 + } + } + } return TRUE; }