From: Robin Dunn Date: Wed, 5 Jul 2006 01:35:36 +0000 (+0000) Subject: Avoid crash in SelectAll if there are no nodes besides the root X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/065fa541eb40024e105321c072143eee3da3b1ee Avoid crash in SelectAll if there are no nodes besides the root git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39996 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/wxPython/contrib/gizmos/wxCode/src/treelistctrl.cpp b/wxPython/contrib/gizmos/wxCode/src/treelistctrl.cpp index 736eda5d91..3345ac6e5a 100644 --- a/wxPython/contrib/gizmos/wxCode/src/treelistctrl.cpp +++ b/wxPython/contrib/gizmos/wxCode/src/treelistctrl.cpp @@ -2926,7 +2926,7 @@ void wxTreeListMainWindow::SelectItem(const wxTreeItemId& itemId, void wxTreeListMainWindow::SelectAll(bool extended_select) { - wxCHECK_RET( GetWindowStyleFlag() & wxTR_MULTIPLE, wxT("invalid tree style") ); + wxCHECK_RET( GetWindowStyleFlag() & wxTR_MULTIPLE, wxT("invalid tree style, must have wxTR_MULTIPLE style to select all items") ); wxTreeEvent event( wxEVT_COMMAND_TREE_SEL_CHANGING, m_owner->GetId() ); event.SetItem( GetRootItem() ); @@ -2954,6 +2954,7 @@ void wxTreeListMainWindow::SelectAll(bool extended_select) wxTreeItemId root = GetRootItem(); wxTreeListItem *first = (wxTreeListItem *)GetFirstChild (root, cookie).m_pItem; wxTreeListItem *last = (wxTreeListItem *)GetLastChild (GetRootItem()).m_pItem; + if (!first || !last) return; if (TagAllChildrenUntilLast (first, last, true)) return; TagNextChildren (first, last, true);