X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9806a0e71eb2190827e93cd463e9682a3b939eee..6a44bffd1ac68163e4c1cfe8aa8fe4f7f98a02e7:/src/common/docview.cpp?ds=sidebyside diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 36ecc6a51a..0015cce6e0 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -227,16 +227,13 @@ bool wxDocument::OnNewDocument() bool wxDocument::Save() { - bool ret = FALSE; + if (!IsModified() && m_savedYet) + return TRUE; - if (!IsModified() && m_savedYet) return TRUE; - if (m_documentFile == wxT("") || !m_savedYet) - ret = SaveAs(); - else - ret = OnSaveDocument(m_documentFile); - if ( ret ) - SetDocumentSaved(TRUE); - return ret; + if ( m_documentFile.empty() || !m_savedYet ) + return SaveAs(); + + return OnSaveDocument(m_documentFile); } bool wxDocument::SaveAs() @@ -316,6 +313,7 @@ bool wxDocument::OnSaveDocument(const wxString& file) } Modify(FALSE); SetFilename(file); + SetDocumentSaved(TRUE); return TRUE; } @@ -700,6 +698,7 @@ bool wxDocTemplate::FileMatchesTemplate(const wxString& path) BEGIN_EVENT_TABLE(wxDocManager, wxEvtHandler) EVT_MENU(wxID_OPEN, wxDocManager::OnFileOpen) EVT_MENU(wxID_CLOSE, wxDocManager::OnFileClose) + EVT_MENU(wxID_CLOSE_ALL, wxDocManager::OnFileCloseAll) EVT_MENU(wxID_REVERT, wxDocManager::OnFileRevert) EVT_MENU(wxID_NEW, wxDocManager::OnFileNew) EVT_MENU(wxID_SAVE, wxDocManager::OnFileSave) @@ -709,6 +708,7 @@ BEGIN_EVENT_TABLE(wxDocManager, wxEvtHandler) EVT_UPDATE_UI(wxID_OPEN, wxDocManager::OnUpdateFileOpen) EVT_UPDATE_UI(wxID_CLOSE, wxDocManager::OnUpdateFileClose) + EVT_UPDATE_UI(wxID_CLOSE_ALL, wxDocManager::OnUpdateFileClose) EVT_UPDATE_UI(wxID_REVERT, wxDocManager::OnUpdateFileRevert) EVT_UPDATE_UI(wxID_NEW, wxDocManager::OnUpdateFileNew) EVT_UPDATE_UI(wxID_SAVE, wxDocManager::OnUpdateFileSave) @@ -749,7 +749,7 @@ wxDocManager::~wxDocManager() sm_docManager = (wxDocManager*) NULL; } -bool wxDocManager::Clear(bool force) +bool wxDocManager::CloseDocuments(bool force) { wxNode *node = m_docs.First(); while (node) @@ -773,7 +773,15 @@ bool wxDocManager::Clear(bool force) // delete another. node = next; } - node = m_templates.First(); + return TRUE; +} + +bool wxDocManager::Clear(bool force) +{ + if (!CloseDocuments(force)) + return FALSE; + + wxNode *node = m_templates.First(); while (node) { wxDocTemplate *templ = (wxDocTemplate*) node->Data(); @@ -808,6 +816,11 @@ void wxDocManager::OnFileClose(wxCommandEvent& WXUNUSED(event)) } } +void wxDocManager::OnFileCloseAll(wxCommandEvent& WXUNUSED(event)) +{ + CloseDocuments(FALSE); +} + void wxDocManager::OnFileNew(wxCommandEvent& WXUNUSED(event)) { CreateDocument(wxString(""), wxDOC_NEW); @@ -1045,7 +1058,10 @@ wxDocument *wxDocManager::CreateDocument(const wxString& path, long flags) delete doc; } else + { + delete[] templates; return (wxDocument *) NULL; + } } // New document: user chooses a template, unless there's only one.