]> git.saurik.com Git - wxWidgets.git/commitdiff
unset the window as invoking window of wxCurrentPopupMenu (which now exists in all...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 22 Dec 2007 16:29:38 +0000 (16:29 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 22 Dec 2007 16:29:38 +0000 (16:29 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50903 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/window.h
src/common/wincmn.cpp
src/msw/window.cpp
src/os2/window.cpp
src/palmos/window.cpp

index 17be18c237cffd9dfe2c5039506d82e80c93d646..6bc220b4d3665f6c231944bfec8dfab8cf3e0dff 100644 (file)
@@ -1046,9 +1046,8 @@ public:
     // show popup menu at the given position, generate events for the items
     // selected in it
     bool PopupMenu(wxMenu *menu, const wxPoint& pos = wxDefaultPosition)
-        { return DoPopupMenu(menu, pos.x, pos.y); }
-    bool PopupMenu(wxMenu *menu, int x, int y)
-        { return DoPopupMenu(menu, x, y); }
+        { return PopupMenu(menu, pos.x, pos.y); }
+    bool PopupMenu(wxMenu *menu, int x, int y);
 
     // simply return the id of the selected item or wxID_NONE without
     // generating any events
index dba13d85427e08a0789cfc061d1afe7e9b124c97..8d1432f8f10ac3f42b84a8728877e63035876b40 100644 (file)
 // Windows List
 WXDLLIMPEXP_DATA_CORE(wxWindowList) wxTopLevelWindows;
 
+// globals
+#if wxUSE_MENUS_NATIVE
+wxMenu *wxCurrentPopupMenu = NULL;
+#endif // wxUSE_MENUS_NATIVE
+
 // ----------------------------------------------------------------------------
 // static data
 // ----------------------------------------------------------------------------
@@ -317,6 +322,11 @@ wxWindowBase::~wxWindowBase()
     // we weren't a dialog class
     wxTopLevelWindows.DeleteObject((wxWindow*)this);
 
+    // The associated popup menu can still be alive, disassociate from it in
+    // this case
+    if ( wxCurrentPopupMenu && wxCurrentPopupMenu->GetInvokingWindow() == this )
+        wxCurrentPopupMenu->SetInvokingWindow(NULL);
+
     wxASSERT_MSG( GetChildren().GetCount() == 0, wxT("children not destroyed") );
 
     // notify the parent about this window destruction
@@ -2245,6 +2255,17 @@ void wxWindowBase::OnInitDialog( wxInitDialogEvent &WXUNUSED(event) )
 
 #if wxUSE_MENUS
 
+bool wxWindowBase::PopupMenu(wxMenu *menu, int x, int y)
+{
+    wxCHECK_MSG( menu, false, "can't popup NULL menu" );
+
+    wxCurrentPopupMenu = menu;
+    const bool rc = DoPopupMenu(menu, x, y);
+    wxCurrentPopupMenu = NULL;
+
+    return rc;
+}
+
 // this is used to pass the id of the selected item from the menu event handler
 // to the main function itself
 //
index c4517a2a9479b62fe3d6892e5421fb172a53b1af..ebecabf2ab793ec30f44d415e948b5fae15a6f88 100644 (file)
 // global variables
 // ---------------------------------------------------------------------------
 
-#if wxUSE_MENUS_NATIVE
-wxMenu *wxCurrentPopupMenu = NULL;
-#endif // wxUSE_MENUS_NATIVE
-
 #ifdef __WXWINCE__
 extern       wxChar *wxCanvasClassName;
 #else
@@ -2219,7 +2215,6 @@ bool wxWindowMSW::DoPopupMenu(wxMenu *menu, int x, int y)
     point.x = x;
     point.y = y;
     ::ClientToScreen(hWnd, &point);
-    wxCurrentPopupMenu = menu;
 #if defined(__WXWINCE__)
     static const UINT flags = 0;
 #else // !__WXWINCE__
@@ -2248,8 +2243,6 @@ bool wxWindowMSW::DoPopupMenu(wxMenu *menu, int x, int y)
     // for example) and so we do need to process the event immediately
     wxYieldForCommandsOnly();
 
-    wxCurrentPopupMenu = NULL;
-
     menu->SetInvokingWindow(NULL);
 
     return true;
index d8449e47a028c33ef8582f6e8362ac64d3a2474e..c1ec1c18f648ae9409413d80e9f456e81f52c50b 100644 (file)
@@ -1804,7 +1804,6 @@ bool wxWindowOS2::DoPopupMenu( wxMenu* pMenu, int nX, int nY )
         DoGetSize(0,&nHeight);
         nY = nHeight - nY;
     }
-    wxCurrentPopupMenu = pMenu;
 
     ::WinPopupMenu( hWndParent
                    ,hWndOwner
@@ -1825,7 +1824,6 @@ bool wxWindowOS2::DoPopupMenu( wxMenu* pMenu, int nX, int nY )
         ::WinDispatchMsg(vHabmain, (PQMSG)&vMsg);
     }
 
-    wxCurrentPopupMenu = NULL;
     pMenu->SetInvokingWindow(NULL);
     return true;
 } // end of wxWindowOS2::DoPopupMenu
index 3507888cafefc25d53056c612f5ea76c886b4c19..75ddf0bc243b8074a0a095074101762ed63e87aa 100644 (file)
 // global variables
 // ---------------------------------------------------------------------------
 
-#if wxUSE_MENUS_NATIVE
-wxMenu *wxCurrentPopupMenu = NULL;
-#endif // wxUSE_MENUS_NATIVE
-
 // ---------------------------------------------------------------------------
 // private functions
 // ---------------------------------------------------------------------------