X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/838dd956a4049c7c95f015ee6b79d3bcf2ec9d6e..844cada1622b2923754493a4c8eb91b82232093e:/src/common/docview.cpp diff --git a/src/common/docview.cpp b/src/common/docview.cpp index db67b46123..11f9b7b673 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -57,6 +57,7 @@ #include "wx/tokenzr.h" #include "wx/filename.h" #include "wx/vector.h" +#include "wx/ptr_scpd.h" #if wxUSE_STD_IOSTREAM #include "wx/ioswrap.h" @@ -111,7 +112,7 @@ wxWindow *wxFindSuitableParent() wxString FindExtension(const wxString& path) { wxString ext; - wxSplitPath(path, NULL, NULL, &ext); + wxFileName::SplitPath(path, NULL, NULL, &ext); // VZ: extensions are considered not case sensitive - is this really a good // idea? @@ -259,7 +260,7 @@ bool wxDocument::OnNewDocument() bool wxDocument::Save() { - if (!IsModified() && m_savedYet) + if ( AlreadySaved() ) return true; if ( m_documentFile.empty() || !m_savedYet ) @@ -322,7 +323,7 @@ bool wxDocument::SaveAs() wxString fileName(tmp); wxString path, name, ext; - wxSplitPath(fileName, & path, & name, & ext); + wxFileName::SplitPath(fileName, & path, & name, & ext); if (ext.empty()) { @@ -779,20 +780,15 @@ wxDocTemplate::InitDocument(wxDocument* doc, const wxString& path, long flags) wxView *wxDocTemplate::CreateView(wxDocument *doc, long flags) { - wxView *view = DoCreateView(); - if ( view == NULL ) + wxScopedPtr view(DoCreateView()); + if ( !view ) return NULL; view->SetDocument(doc); - if (view->OnCreate(doc, flags)) - { - return view; - } - else - { - delete view; + if ( !view->OnCreate(doc, flags) ) return NULL; - } + + return view.release(); } // The default (very primitive) format detection: check is the extension is @@ -1094,8 +1090,8 @@ void wxDocManager::OnUpdateFileNew(wxUpdateUIEvent& event) void wxDocManager::OnUpdateFileSave(wxUpdateUIEvent& event) { - wxDocument *doc = GetCurrentDocument(); - event.Enable( doc && doc->IsModified() ); + wxDocument * const doc = GetCurrentDocument(); + event.Enable( doc && !doc->AlreadySaved() ); } void wxDocManager::OnUpdateUndo(wxUpdateUIEvent& event)