diff --git a/include/wx/msw/popupwin.h b/include/wx/msw/popupwin.h index 7a5ce58598..7e486933e5 100644 --- a/include/wx/msw/popupwin.h +++ b/include/wx/msw/popupwin.h @@ -25,6 +25,8 @@ public: bool Create(wxWindow *parent, int flags = wxBORDER_NONE); + virtual ~wxPopupWindow(); + virtual void SetFocus() wxOVERRIDE; virtual bool Show(bool show = true) wxOVERRIDE; diff --git a/src/msw/popupwin.cpp b/src/msw/popupwin.cpp index 6491a6f007..92fc9519b6 100644 --- a/src/msw/popupwin.cpp +++ b/src/msw/popupwin.cpp @@ -59,6 +59,14 @@ bool wxPopupWindow::Create(wxWindow *parent, int flags) flags); } +wxPopupWindow::~wxPopupWindow() +{ + // If the popup is destroyed without being hidden first, ensure that we are + // not left with a dangling pointer. + if ( wxCurrentPopupWindow == this ) + wxCurrentPopupWindow = NULL; +} + WXDWORD wxPopupWindow::MSWGetStyle(long flags, WXDWORD *exstyle) const { // we only honour the border flags, the others don't make sense for us