]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/combocmn.cpp
Added wxComboPopup::DestroyPopup(), which responsibility is to call Destroy() for...
[wxWidgets.git] / src / common / combocmn.cpp
index e0a3db75c6c8d8a488474f868ad628b209305146..bf1ad43c3ab7b82528fcdf0eb8425bc66d12e428 100644 (file)
@@ -674,6 +674,34 @@ void wxComboPopup::Dismiss()
     m_combo->HidePopup(true);
 }
 
+void wxComboPopup::DestroyPopup()
+{
+    // Here we make sure that the popup control's Destroy() gets called.
+    // This is necessary for the wxPersistentWindow to work properly.
+    wxWindow* popupCtrl = 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<void*>(this) !=
+             dynamic_cast<void*>(popupCtrl) )
+            delete this;
+      #endif
+        popupCtrl->Destroy();
+    }
+    else
+    {
+        delete this;
+    }
+}
+
 // ----------------------------------------------------------------------------
 // input handling
 // ----------------------------------------------------------------------------
@@ -2091,30 +2119,8 @@ void wxComboCtrlBase::DestroyPopup()
 
     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<void*>(m_popupInterface) !=
-                 dynamic_cast<void*>(popupCtrl) )
-                delete m_popupInterface;
-          #endif
-            popupCtrl->Destroy();
-        }
-        else
-        {
-            delete m_popupInterface;
-        }
+        // NB: DestroyPopup() performs 'delete this'.
+        m_popupInterface->DestroyPopup();
         m_popupInterface = NULL;
     }