Fix bug in template selection in docview framework

Don't use the template specified by the filter in the file open dialog
if it's incapable of actually handling the current file.

This fixes a regression compared to 2.8 in docview code and allows
opening a file using the correct template for its extension even if an
incorrect (e.g. default) filter is chosen in the file open dialog.

Closes #18123.
This commit is contained in:
jwiesemann
2018-12-07 03:34:21 +01:00
committed by Vadim Zeitlin
parent b650c9e536
commit 3d75541662
2 changed files with 12 additions and 0 deletions

View File

@@ -143,6 +143,7 @@ All (GUI):
- Add wxToolbook::EnablePage() (Stefan Ziegler). - Add wxToolbook::EnablePage() (Stefan Ziegler).
- Adapt AUI colours to system colour changes (Daniel Kulp). - Adapt AUI colours to system colour changes (Daniel Kulp).
- Fix removing and inserting pages in wxToolbook (Stefan Ziegler). - Fix removing and inserting pages in wxToolbook (Stefan Ziegler).
- Fix bug in template selection in docview framework (jwiesemann).
wxGTK: wxGTK:

View File

@@ -1805,7 +1805,18 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates,
// first choose the template using the extension, if this fails (i.e. // first choose the template using the extension, if this fails (i.e.
// wxFileSelectorEx() didn't fill it), then use the path // wxFileSelectorEx() didn't fill it), then use the path
if ( FilterIndex != -1 ) if ( FilterIndex != -1 )
{
theTemplate = templates[FilterIndex]; theTemplate = templates[FilterIndex];
if ( theTemplate )
{
// But don't use this template if it doesn't match the path as
// can happen if the user specified the extension explicitly
// but didn't bother changing the filter.
if ( !theTemplate->FileMatchesTemplate(path) )
theTemplate = NULL;
}
}
if ( !theTemplate ) if ( !theTemplate )
theTemplate = FindTemplateForPath(path); theTemplate = FindTemplateForPath(path);
if ( !theTemplate ) if ( !theTemplate )