]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/wincmn.cpp
Fix from Hartwig
[wxWidgets.git] / src / common / wincmn.cpp
index dba13d85427e08a0789cfc061d1afe7e9b124c97..04ee2969608ff32e0f26ea107d6581ac311a6855 100644 (file)
@@ -44,6 +44,7 @@
     #include "wx/scrolbar.h"
     #include "wx/layout.h"
     #include "wx/sizer.h"
+    #include "wx/menu.h"
 #endif //WX_PRECOMP
 
 #if wxUSE_DRAG_AND_DROP
 // Windows List
 WXDLLIMPEXP_DATA_CORE(wxWindowList) wxTopLevelWindows;
 
+// globals
+#if wxUSE_MENUS_NATIVE
+wxMenu *wxCurrentPopupMenu = NULL;
+#endif // wxUSE_MENUS_NATIVE
+
 // ----------------------------------------------------------------------------
 // static data
 // ----------------------------------------------------------------------------
@@ -317,6 +323,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 +2256,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
 //