]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/treectlg.cpp
don't crash in UnselectAll() if the tree has no root
[wxWidgets.git] / src / generic / treectlg.cpp
index 86535a229f259bd1632dd079e237f7b4c2287d97..64e615f681265e10b08053d1ab5fa417486ba7e5 100644 (file)
@@ -1477,7 +1477,13 @@ void wxGenericTreeCtrl::UnselectAllChildren(wxGenericTreeItem *item)
 
 void wxGenericTreeCtrl::UnselectAll()
 {
-    UnselectAllChildren((wxGenericTreeItem*) GetRootItem().m_pItem);
+    wxTreeItemId rootItem = GetRootItem();
+
+    // the tree might not have the root item at all
+    if ( rootItem )
+    {
+        UnselectAllChildren((wxGenericTreeItem*) rootItem.m_pItem);
+    }
 }
 
 // Recursive function !