From 3b75bce2453ab1d47979a0d038b5b861c6af95ad Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 25 Aug 2018 22:30:46 +0200 Subject: [PATCH] Fix annoying assertion failure in the treectrl sample Don't pass invalid item to wxTreeCtrl::SelectItem(), just don't select anything if there is no current item. --- samples/treectrl/treetest.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/samples/treectrl/treetest.cpp b/samples/treectrl/treetest.cpp index 18a5c2797a..5ae5061252 100644 --- a/samples/treectrl/treetest.cpp +++ b/samples/treectrl/treetest.cpp @@ -594,7 +594,9 @@ void MyFrame::OnDumpSelected(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnSelect(wxCommandEvent& WXUNUSED(event)) { - m_treeCtrl->SelectItem(m_treeCtrl->GetFocusedItem()); + const wxTreeItemId focus = m_treeCtrl->GetFocusedItem(); + if ( focus.IsOk() ) + m_treeCtrl->SelectItem(focus); } void MyFrame::OnSelectRoot(wxCommandEvent& WXUNUSED(event))