From e39638ea3b309dcaa2f4797b1bb1a8ba22e7821e Mon Sep 17 00:00:00 2001 From: "Zane U. Ji" Date: Sat, 26 Oct 2013 21:21:47 +0800 Subject: [PATCH] Corrected template names shown in the dialog when creating a new file --- src/xmlcopyeditor.cpp | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/xmlcopyeditor.cpp b/src/xmlcopyeditor.cpp index 0a189db..f8e36f6 100644 --- a/src/xmlcopyeditor.cpp +++ b/src/xmlcopyeditor.cpp @@ -2856,12 +2856,12 @@ void MyFrame::OnNew ( wxCommandEvent& WXUNUSED ( event ) ) if ( wxFileName::DirExists ( templateDir ) ) { wxString templateMask, name, extension, entry; + wxFileName fn; templateMask = templateDir + wxFileName::GetPathSeparator() + _T ( "*.*" ); templateFile = wxFindFirstFile ( templateMask, wxFILE ); - wxFileName fn; - - if ( !templateFile.empty() ) + while ( !templateFile.empty() ) { + templateFile.Replace ( _T("_"), _T(" ") ); fn.Assign ( templateFile ); name = fn.GetName(); extension = fn.GetExt(); @@ -2869,19 +2869,7 @@ void MyFrame::OnNew ( wxCommandEvent& WXUNUSED ( event ) ) entry.Printf ( _T ( "%s (*.%s)" ), name.c_str(), extension.c_str() ); templateArray.Add ( entry ); - for ( ;; ) - { - templateFile = wxFindNextFile(); - if ( templateFile.empty() ) - break; - templateFile.Replace ( _T("_"), _T(" ") ); - fn.Assign ( templateFile ); - name = fn.GetName(); - extension = fn.GetExt(); - - entry.Printf ( _T ( "%s (*.%s)" ), name.c_str(), extension.c_str() ); - templateArray.Add ( entry ); - } + templateFile = wxFindNextFile(); } templateArray.Sort(); templateArray.Insert ( defaultSelection, 0 );