X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5276b0a53cef4815230e39b54d2ecda14f72cbd1..2e49a8074e7c9179b642852ff00ed8fdf0768bb1:/src/common/docview.cpp diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 6544987b1b..86d1783490 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -1036,14 +1036,8 @@ wxFileHistory *wxDocManager::OnCreateFileHistory() void wxDocManager::OnFileClose(wxCommandEvent& WXUNUSED(event)) { wxDocument *doc = GetCurrentDocument(); - if (!doc) - return; - if (doc->Close()) - { - doc->DeleteAllViews(); - if (m_docs.Member(doc)) - delete doc; - } + if (doc) + CloseDocument(doc); } void wxDocManager::OnFileCloseAll(wxCommandEvent& WXUNUSED(event)) @@ -1093,7 +1087,7 @@ void wxDocManager::OnMRUFile(wxCommandEvent& event) // Check if the id is in the range assigned to MRU list entries. const int id = event.GetId(); if ( id >= wxID_FILE1 && - id < wxID_FILE1 + m_fileHistory->GetBaseId() ) + id < wxID_FILE1 + static_cast(m_fileHistory->GetCount()) ) { DoOpenMRUFile(id - wxID_FILE1); } @@ -1414,6 +1408,7 @@ wxDocument *wxDocManager::CreateDocument(const wxString& pathOrig, long flags) { // file already open, just activate it and return ActivateDocument(doc); + return doc; } } } @@ -1899,6 +1894,20 @@ void wxDocManager::DisassociateTemplate(wxDocTemplate *temp) m_templates.DeleteObject(temp); } +wxDocTemplate* wxDocManager::FindTemplate(const wxClassInfo* classinfo) +{ + for ( wxList::compatibility_iterator node = m_templates.GetFirst(); + node; + node = node->GetNext() ) + { + wxDocTemplate* t = wxStaticCast(node->GetData(), wxDocTemplate); + if ( t->GetDocClassInfo() == classinfo ) + return t; + } + + return NULL; +} + // Add and remove a document from the manager's list void wxDocManager::AddDocument(wxDocument *doc) {