]> git.saurik.com Git - wxWidgets.git/commitdiff
Reset m_lastItem to avoid crashes
authorJulian Smart <julian@anthemion.co.uk>
Thu, 1 May 2003 15:38:55 +0000 (15:38 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Thu, 1 May 2003 15:38:55 +0000 (15:38 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20407 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/treectrl/treetest.cpp
samples/treectrl/treetest.h

index 8731c603462ed07cc9f9aa7d3dadf7c086a18598..351c59f045840d93e1c0141dbe0289de52d5ea57 100644 (file)
@@ -836,6 +836,7 @@ void MyTreeCtrl::DoToggleIcon(const wxTreeItemId& item)
 void MyTreeCtrl::name(wxTreeEvent& event)                        \
 {                                                                \
     wxLogMessage(wxT(#name));                                    \
+    SetLastItem(wxTreeItemId());                                 \
     event.Skip();                                                \
 }
 
index b6b9a7551acf56e3ab066882adbf0e5e77f4dd22..39aa38955aa6a86ca1c78893db94816509f67447 100644 (file)
@@ -97,7 +97,7 @@ public:
 
     void DoSortChildren(const wxTreeItemId& item, bool reverse = FALSE)
         { m_reverseSort = reverse; wxTreeCtrl::SortChildren(item); }
-    void DoEnsureVisible() { EnsureVisible(m_lastItem); }
+    void DoEnsureVisible() { if (m_lastItem.IsOk()) EnsureVisible(m_lastItem); }
 
     void DoToggleIcon(const wxTreeItemId& item);
 
@@ -105,6 +105,8 @@ public:
 
     int ImageSize(void) const { return m_imageSize; }
 
+    void SetLastItem(wxTreeItemId id) { m_lastItem = id; }
+
 protected:
     virtual int OnCompareItems(const wxTreeItemId& i1, const wxTreeItemId& i2);