]> git.saurik.com Git - wxWidgets.git/commitdiff
Don't assert in wxDataViewCtrl::ItemDeleted() if item doesn't exist.
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 23 Jul 2010 23:33:01 +0000 (23:33 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 23 Jul 2010 23:33:01 +0000 (23:33 +0000)
It seems that it might be valid to delete the items that the GUI control
doesn't know anything about, e.g. this could happen when deleting a child of a
collapsed node in a tree model. So remove the asserts which were triggered in
this case as there doesn't seem to be any way to avoid them with the current
code.

Closes #11802.

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

src/generic/datavgen.cpp

index dd7813621d9f095ad2afcc6792ee110a06fa9d55..3222eb1213a2ca58be7328d6029c8931c1582c8a 100644 (file)
@@ -1989,9 +1989,12 @@ bool wxDataViewMainWindow::ItemDeleted(const wxDataViewItem& parent,
 
     wxDataViewTreeNode * node = FindNode(parent);
 
 
     wxDataViewTreeNode * node = FindNode(parent);
 
-    wxCHECK_MSG( node != NULL, false, "item not found" );
-    wxCHECK_MSG( node->GetChildren().Index( item.GetID() ) != wxNOT_FOUND,
-                 false, "item not found" );
+    // Notice that it is possible that the item being deleted is not in the
+    // tree at all, for example we could be deleting a never shown (because
+    // collapsed) item in a tree model. So it's not an error if we don't know
+    // about this item, just return without doing anything then.
+    if ( !node || node->GetChildren().Index(item.GetID()) == wxNOT_FOUND )
+        return false;
 
     int sub = -1;
     node->GetChildren().Remove( item.GetID() );
 
     int sub = -1;
     node->GetChildren().Remove( item.GetID() );