From 3d68c787aa93dd464cff6c7f66fa28ae2139845d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 19 Jul 2000 07:14:28 +0000 Subject: [PATCH] use filter index first, then the path to find the correct template git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7762 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/docview.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/common/docview.cpp b/src/common/docview.cpp index cf02ef0e08..b70b21bd34 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -1364,7 +1364,7 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates, wxString descrBuf = wxT("*.*"); #endif - int FilterIndex = 0; + int FilterIndex = -1; wxWindow* parent = wxFindSuitableParent(); @@ -1396,13 +1396,13 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates, path = pathTmp; - // This is dodgy in that we're selecting the template on the - // basis of the file extension, which may not be a standard - // one. We really want to know exactly which template was - // chosen by using a more advanced file selector. - wxDocTemplate *theTemplate = FindTemplateForPath(path); - if ( !theTemplate ) + // first choose the template using the extension, if this fails (i.e. + // wxFileSelectorEx() didn't fill it), then use the path + wxDocTemplate *theTemplate = (wxDocTemplate *)NULL; + if ( FilterIndex != -1 ) theTemplate = templates[FilterIndex]; + if ( !theTemplate ) + theTemplate = FindTemplateForPath(path); return theTemplate; }