From 5e376532f7a8150ef5346e2ba38ef2ab18abaf0d Mon Sep 17 00:00:00 2001 From: "Kevin B. McCarty" Date: Sat, 9 May 2015 18:54:55 +0200 Subject: [PATCH] Don't assert in wxGenericFileCtrl if there is no selected file. Don't use the list control item if there is no selection in it. Closes #16684. --- src/generic/filectrlg.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/generic/filectrlg.cpp b/src/generic/filectrlg.cpp index d9ee5a7d5d..d75478c037 100644 --- a/src/generic/filectrlg.cpp +++ b/src/generic/filectrlg.cpp @@ -1064,9 +1064,14 @@ wxFileName wxGenericFileCtrl::DoGetFileName() const wxListItem item; item.m_itemId = m_list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); - m_list->GetItem(item); - fn.Assign(m_list->GetDir(), item.m_text); + // ... if anything is selected in the list + if ( item.m_itemId != wxNOT_FOUND ) + { + m_list->GetItem(item); + + fn.Assign(m_list->GetDir(), item.m_text); + } } else // user entered the value {