From 0b108d1006326e32f6734ef5c179b7ee7fa453e2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 9 Mar 2009 18:13:04 +0000 Subject: [PATCH] don't call neither OnSaveModified() nor Modify(false) from On{New,Open}Document(): these methods are only ever called for the new wxDocument object which should never be saved, even if they're marked as modified by the user-defined document creation code git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59449 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/docview.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/common/docview.cpp b/src/common/docview.cpp index ca552a2..db24f27 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -246,11 +246,13 @@ wxDocManager *wxDocument::GetDocumentManager() const bool wxDocument::OnNewDocument() { - if ( !OnSaveModified() ) - return false; + // notice that there is no need to neither reset nor even check the + // modified flag here as the document itself is a new object (this is only + // called from CreateDocument()) and so it shouldn't be saved anyhow even + // if it is modified -- this could happen if the user code creates + // documents pre-filled with some user-entered (and which hence must not be + // lost) information - DeleteContents(); - Modify(false); SetDocumentSaved(false); const wxString name = GetDocumentManager()->MakeNewDocumentName(); @@ -379,15 +381,20 @@ bool wxDocument::OnSaveDocument(const wxString& file) bool wxDocument::OnOpenDocument(const wxString& file) { - if ( !OnSaveModified() ) - return false; + // notice that there is no need to check the modified flag here for the + // reasons explained in OnNewDocument() if ( !DoOpenDocument(file) ) return false; SetFilename(file, true); - Modify(false); - m_savedYet = true; + + // stretching the logic a little this does make sense because the document + // had been saved into the file we just loaded it from, it just could have + // happened during a previous program execution, it's just that the name of + // this method is a bit unfortunate, it should probably have been called + // HasAssociatedFileName() + SetDocumentSaved(true); UpdateAllViews(); -- 2.7.4