From fd4618549b4cb22d84930b45853dc09f489e732c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 9 Oct 2009 13:05:10 +0000 Subject: [PATCH] Don't add default extension in wxDocument::SaveAs(). wxFileSelector() takes care of the default extension itself and if it returned a file name without one, it means that the user really wants to create a file without an extension. Adding the default extension here is at best useless and at worst actively dangerous because it may silently overwrite an existing file (although this bug is due to a different problem, see #11256 for a scenario in which this can happen). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62350 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/docview.cpp | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 4e7c562..9e5e65a 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -339,15 +339,6 @@ bool wxDocument::SaveAs() if (fileName.empty()) return false; // cancelled by user - wxString ext; - wxFileName::SplitPath(fileName, NULL, NULL, &ext); - - if (ext.empty()) - { - fileName += wxT("."); - fileName += docTemplate->GetDefaultExtension(); - } - // Files that were not saved correctly are not added to the FileHistory. if (!OnSaveDocument(fileName)) return false; @@ -355,16 +346,16 @@ bool wxDocument::SaveAs() SetTitle(wxFileNameFromPath(fileName)); SetFilename(fileName, true); // will call OnChangeFileName automatically - // A file that doesn't use the default extension of its document template - // cannot be opened via the FileHistory, so we do not add it. - if (docTemplate->FileMatchesTemplate(fileName)) - { - GetDocumentManager()->AddFileToHistory(fileName); - } - //else: the user will probably not be able to open the file again, so we - // could warn about the wrong file-extension here + // A file that doesn't use the default extension of its document template + // cannot be opened via the FileHistory, so we do not add it. + if (docTemplate->FileMatchesTemplate(fileName)) + { + GetDocumentManager()->AddFileToHistory(fileName); + } + //else: the user will probably not be able to open the file again, so we + // could warn about the wrong file-extension here - return true; + return true; } bool wxDocument::OnSaveDocument(const wxString& file) -- 2.7.4