]> git.saurik.com Git - wxWidgets.git/commitdiff
no changes, just refactor the code to avoid having the same code for m_textCtrl destr...
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 30 May 2008 00:03:03 +0000 (00:03 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 30 May 2008 00:03:03 +0000 (00:03 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53830 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/listctrl.h
src/msw/listctrl.cpp

index 50b04f98be186d8b82b6d5633a7484136bae719c..635a0af233275b57a0a3871d72c651ea2b654023 100644 (file)
@@ -446,6 +446,9 @@ private:
     // UpdateStyle()), only should be called if InReportView()
     void MSWSetExListStyles();
 
+    // destroy m_textCtrl if it's currently valid and reset it to NULL
+    void DeleteEditControl();
+
 
     DECLARE_DYNAMIC_CLASS(wxListCtrl)
     DECLARE_EVENT_TABLE()
index ab90123b9a2c26286216f9e5772a2858519936f2..16cf30a914243762e2ae98950e08b2209aa03c29 100644 (file)
@@ -488,10 +488,8 @@ void wxListCtrl::FreeAllInternalData()
     }
 }
 
-wxListCtrl::~wxListCtrl()
+void wxListCtrl::DeleteEditControl()
 {
-    FreeAllInternalData();
-
     if ( m_textCtrl )
     {
         m_textCtrl->UnsubclassWin();
@@ -499,6 +497,13 @@ wxListCtrl::~wxListCtrl()
         delete m_textCtrl;
         m_textCtrl = NULL;
     }
+}
+
+wxListCtrl::~wxListCtrl()
+{
+    FreeAllInternalData();
+
+    DeleteEditControl();
 
     if (m_ownsImageListNormal)
         delete m_imageListNormal;
@@ -1465,12 +1470,7 @@ wxTextCtrl* wxListCtrl::EditLabel(long item, wxClassInfo* textControlClass)
     }
 
     // [re]create the text control wrapping the HWND we got
-    if ( m_textCtrl )
-    {
-        m_textCtrl->UnsubclassWin();
-        m_textCtrl->SetHWND(0);
-        delete m_textCtrl;
-    }
+    DeleteEditControl();
 
     m_textCtrl = (wxTextCtrl *)textControlClass->CreateObject();
     m_textCtrl->SetHWND(hWnd);
@@ -2093,16 +2093,9 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
                     const LV_ITEM& lvi = (LV_ITEM)item;
                     if ( !lvi.pszText || lvi.iItem == -1 )
                     {
-                        // don't keep a stale wxTextCtrl around
-                        if ( m_textCtrl )
-                        {
-                            // EDIT control will be deleted by the list control itself so
-                            // prevent us from deleting it as well
-                            m_textCtrl->UnsubclassWin();
-                            m_textCtrl->SetHWND(0);
-                            delete m_textCtrl;
-                            m_textCtrl = NULL;
-                        }
+                        // EDIT control will be deleted by the list control
+                        // itself so prevent us from deleting it as well
+                        DeleteEditControl();
 
                         event.SetEditCanceled(true);
                     }
@@ -2475,16 +2468,9 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
             // logic here is inverted compared to all the other messages
             *result = event.IsAllowed();
 
-            // don't keep a stale wxTextCtrl around
-            if ( m_textCtrl )
-            {
-                // EDIT control will be deleted by the list control itself so
-                // prevent us from deleting it as well
-                m_textCtrl->UnsubclassWin();
-                m_textCtrl->SetHWND(0);
-                delete m_textCtrl;
-                m_textCtrl = NULL;
-            }
+            // EDIT control will be deleted by the list control itself so
+            // prevent us from deleting it as well
+            DeleteEditControl();
 
             return true;
     }