From a516284f67e1910fc6dc5364b289340332d0d35f Mon Sep 17 00:00:00 2001 From: Jaakko Salli Date: Sun, 27 Mar 2011 18:30:56 +0000 Subject: [PATCH] Instead of just deleting m_popupInterface, call Destroy() of its wxWindow-based popup control obtained via GetControl() member function. Also still delete m_popupInterface if there was no popup control, or if it was implemented as a separate class (versus being multiple-inherited along side wxComboPopup, as has been the common practice). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67320 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/combocmn.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/common/combocmn.cpp b/src/common/combocmn.cpp index 67a06eda99..e0a3db75c6 100644 --- a/src/common/combocmn.cpp +++ b/src/common/combocmn.cpp @@ -2089,7 +2089,34 @@ void wxComboCtrlBase::DestroyPopup() wxDELETE(m_popupEvtHandler); - wxDELETE(m_popupInterface); + if ( m_popupInterface ) + { + // Here we make sure that the popup control's Destroy() gets called. + // This is necessary for the wxPersistentWindow to work properly. + wxWindow* popupCtrl = m_popupInterface->GetControl(); + if ( popupCtrl ) + { + // While all wxComboCtrl examples have m_popupInterface and + // popupCtrl as the same class (that will be deleted via the + // Destroy() call below), it is technically still possible to + // have implementations where they are in fact not same + // multiple-inherited class. Here we use C++ RTTI to check for + // this rare case. + #ifndef wxNO_RTTI + // It is probably better to delete m_popupInterface first, so + // that it retains access to its popup control window. + if ( dynamic_cast(m_popupInterface) != + dynamic_cast(popupCtrl) ) + delete m_popupInterface; + #endif + popupCtrl->Destroy(); + } + else + { + delete m_popupInterface; + } + m_popupInterface = NULL; + } if ( m_winPopup ) { -- 2.49.0