From: Julian Smart Date: Fri, 12 Jul 2002 09:05:57 +0000 (+0000) Subject: Added Ian Brown's fix for PopupMenu not blocking X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/e41e1385597a8864c8ae2876c25f7c21065b71e1 Added Ian Brown's fix for PopupMenu not blocking git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16142 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- 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; }