diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index 86535a229f..64e615f681 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -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 !