X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e58eaff7617f0936b1b8c448dd381f8e2d7ccf78..d31d30d791201146a5e224d3bf0f0cd909300bba:/src/common/docview.cpp diff --git a/src/common/docview.cpp b/src/common/docview.cpp index e308d867c0..dbc0e56630 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -259,7 +259,7 @@ bool wxDocument::OnNewDocument() bool wxDocument::Save() { - if (!IsModified() && m_savedYet) + if ( AlreadySaved() ) return true; if ( m_documentFile.empty() || !m_savedYet ) @@ -582,10 +582,10 @@ bool wxDocument::DoSaveDocument(const wxString& file) { #if wxUSE_STD_IOSTREAM wxSTD ofstream store(file.mb_str(), wxSTD ios::binary); - if (store.fail() || store.bad()) + if ( !store ) #else wxFileOutputStream store(file); - if (store.GetLastError() != wxSTREAM_NO_ERROR) + if ( store.GetLastError() != wxSTREAM_NO_ERROR ) #endif { wxLogError(_("File \"%s\" could not be opened for writing."), file); @@ -605,7 +605,7 @@ bool wxDocument::DoOpenDocument(const wxString& file) { #if wxUSE_STD_IOSTREAM wxSTD ifstream store(file.mb_str(), wxSTD ios::binary); - if ( store.fail() || store.bad() ) + if ( !store ) #else wxFileInputStream store(file); if (store.GetLastError() != wxSTREAM_NO_ERROR) @@ -617,7 +617,7 @@ bool wxDocument::DoOpenDocument(const wxString& file) #if wxUSE_STD_IOSTREAM LoadObject(store); - if ( store.fail() || store.bad() ) + if ( !store ) #else int res = LoadObject(store).GetLastError(); if ( res != wxSTREAM_NO_ERROR && res != wxSTREAM_EOF ) @@ -972,7 +972,7 @@ void wxDocManager::OnFileCloseAll(wxCommandEvent& WXUNUSED(event)) void wxDocManager::OnFileNew(wxCommandEvent& WXUNUSED(event)) { - CreateDocument( wxEmptyString, wxDOC_NEW ); + CreateNewDocument(); } void wxDocManager::OnFileOpen(wxCommandEvent& WXUNUSED(event)) @@ -1094,8 +1094,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) @@ -2013,24 +2013,22 @@ void wxFileHistory::AddFileToHistory(const wxString& file) { RemoveFileFromHistory(--numFiles); } - else // add a new menu item to all file menus (will be updated below) + + // add a new menu item to all file menus (they will be updated below) + for ( wxList::compatibility_iterator node = m_fileMenus.GetFirst(); + node; + node = node->GetNext() ) { - for ( wxList::compatibility_iterator node = m_fileMenus.GetFirst(); - node; - node = node->GetNext() ) - { - wxMenu * const menu = (wxMenu *)node->GetData(); + wxMenu * const menu = (wxMenu *)node->GetData(); - if ( !numFiles && menu->GetMenuItemCount() ) - menu->AppendSeparator(); + if ( !numFiles && menu->GetMenuItemCount() ) + menu->AppendSeparator(); - // label doesn't matter, it will be set below anyhow, but it can't - // be empty (this is supposed to indicate a stock item) - menu->Append(m_idBase + numFiles, " "); - } + // label doesn't matter, it will be set below anyhow, but it can't + // be empty (this is supposed to indicate a stock item) + menu->Append(m_idBase + numFiles, " "); } - // insert the new file in the beginning of the file history m_fileHistory.insert(m_fileHistory.begin(), file); numFiles++;