]> git.saurik.com Git - wxWidgets.git/commitdiff
Invalidate stored wxTreeItemIds when the corresponding item is deleted in wxMSW.
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 18 Jan 2010 00:28:47 +0000 (00:28 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 18 Jan 2010 00:28:47 +0000 (00:28 +0000)
m_htSelStart and m_htClickedItem stored in wxTreeCtrl must be invalidated when
the item they point to is deleted (which also happens when all the items are
deleted), otherwise the selection doesn't behave correctly after doing it.

Closes #11619.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63170 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/treectrl.cpp

index f39b37e5684841372e655c539519c3788b7e80d8..7baecbd622f1f96f58303643553933de902a3f81 100644 (file)
@@ -1667,6 +1667,12 @@ void wxTreeCtrl::Delete(const wxTreeItemId& item)
             return;
         }
 
+        if ( item == m_htSelStart )
+            m_htSelStart.Unset();
+
+        if ( item == m_htClickedItem )
+            m_htClickedItem.Unset();
+
         if ( next.IsOk() )
         {
             wxTreeEvent changingEvent(wxEVT_COMMAND_TREE_SEL_CHANGING, this, next);
@@ -1721,6 +1727,10 @@ void wxTreeCtrl::DeleteAllItems()
     // unlock tree selections on vista for the duration of this call
     TreeItemUnlocker unlock_all;
 
+    // invalidate all the items we store as they're going to become invalid
+    m_htSelStart =
+    m_htClickedItem = wxTreeItemId();
+
     // delete the "virtual" root item.
     if ( GET_VIRTUAL_ROOT() )
     {