From 7d42f4d61b1acd6c9b6d8869b4bbb34c9f0821b2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 6 Oct 2007 00:14:21 +0000 Subject: [PATCH] fix GetPaths() and GetFilenames() too git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49059 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/filectrlg.cpp | 40 +++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/generic/filectrlg.cpp b/src/generic/filectrlg.cpp index 1974401fab..dc82dcba88 100644 --- a/src/generic/filectrlg.cpp +++ b/src/generic/filectrlg.cpp @@ -1082,42 +1082,42 @@ wxFileName wxGenericFileCtrl::DoGetFileName() const void wxGenericFileCtrl::DoGetFilenames( wxArrayString& filenames, const bool fullPath ) const { - filenames.Empty(); + filenames.clear(); const wxString dir = m_list->GetDir(); - const wxString value = m_text->GetValue(); + const wxString value = m_text->GetValue(); if ( !value.empty() ) { - if ( fullPath ) - filenames.Add( dir + value ); - else - filenames.Add( value ); + wxFileName fn(value); + if ( fn.IsRelative() ) + fn.MakeAbsolute(dir); + + filenames.push_back(fullPath ? fn.GetFullPath() : fn.GetFullName()); return; } - if ( m_list->GetSelectedItemCount() == 0 ) - { + const int numSel = m_list->GetSelectedItemCount(); + if ( !numSel ) return; - } - filenames.Alloc( m_list->GetSelectedItemCount() ); + filenames.reserve(numSel); wxListItem item; item.m_mask = wxLIST_MASK_TEXT; - - item.m_itemId = m_list->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED ); - while ( item.m_itemId != -1 ) + item.m_itemId = -1; + for ( ;; ) { - m_list->GetItem( item ); + item.m_itemId = m_list->GetNextItem(item.m_itemId, wxLIST_NEXT_ALL, + wxLIST_STATE_SELECTED); - if ( fullPath ) - filenames.Add( dir + item.m_text ); - else - filenames.Add( item.m_text ); + if ( item.m_itemId == -1 ) + break; + + m_list->GetItem(item); - item.m_itemId = m_list->GetNextItem( item.m_itemId, - wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED ); + const wxFileName fn(dir, item.m_text); + filenames.push_back(fullPath ? fn.GetFullPath() : fn.GetFullName()); } } -- 2.47.2