From 6f7f0d0a2d882ca8fab9e9c98f9b8e7188b4f426 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 18 Jul 2007 23:42:58 +0000 Subject: [PATCH] don't assert when right/down cursor arrows are used in an empty tree control with wxTR_HIDE_ROOT style (patch 1756184) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47556 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/treectlg.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index 82311285ba..704200e11b 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -2766,7 +2766,11 @@ void wxGenericTreeCtrl::OnChar( wxKeyEvent &event ) case WXK_RIGHT: // this works the same as the down arrow except that we // also expand the item if it wasn't expanded yet - Expand(m_current); + if (m_current != GetRootItem() || !HasFlag(wxTR_HIDE_ROOT)) + Expand(m_current); + //else: don't try to expand hidden root item (which can be the + // current one when the tree is empty) + // fall through case WXK_DOWN: @@ -2775,6 +2779,9 @@ void wxGenericTreeCtrl::OnChar( wxKeyEvent &event ) { wxTreeItemIdValue cookie; wxTreeItemId child = GetFirstChild( m_key_current, cookie ); + if ( !child ) + break; + DoSelectItem( child, unselect_others, extended_select ); m_key_current=(wxGenericTreeItem*) child.m_pItem; } -- 2.45.2