From f19259fce02ed19263b3bad7269c11546ce95e07 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 18 Jan 2010 00:28:47 +0000 Subject: [PATCH] Invalidate stored wxTreeItemIds when the corresponding item is deleted in wxMSW. 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 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index f39b37e568..7baecbd622 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -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() ) { -- 2.45.2