From b9d880d6382e24156cdce4ae0390c843cc6208d9 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sun, 24 Sep 2006 10:06:02 +0000 Subject: [PATCH] [ 1563875 ] wxTreeCtrl::FindItem asserts when item not found git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41404 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/treectlg.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index 0886002dc2..e4d81b2b4c 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -1395,10 +1395,12 @@ wxTreeItemId wxGenericTreeCtrl::FindItem(const wxTreeItemId& idParent, } // and try all the items (stop when we get to the one we started from) - while ( id != idParent && !GetItemText(id).Lower().StartsWith(prefix) ) + while (id.IsOk() && id != idParent && !GetItemText(id).Lower().StartsWith(prefix) ) { id = GetNext(id); } + // If we haven't found the item, id.IsOk() will be false, as per + // documentation } return id; @@ -1890,14 +1892,14 @@ void wxGenericTreeCtrl::SelectItem(const wxTreeItemId& itemId, bool select) { wxGenericTreeItem *item = (wxGenericTreeItem*) itemId.m_pItem; wxCHECK_RET( item, wxT("SelectItem(): invalid tree item") ); - + wxTreeEvent event(wxEVT_COMMAND_TREE_SEL_CHANGING, this, item); if ( GetEventHandler()->ProcessEvent( event ) && !event.IsAllowed() ) return; item->SetHilight(false); RefreshLine(item); - + event.SetEventType(wxEVT_COMMAND_TREE_SEL_CHANGED); GetEventHandler()->ProcessEvent( event ); } -- 2.50.0