diff --git a/include/wx/docview.h b/include/wx/docview.h index 824e432fdc..ee7067b09d 100644 --- a/include/wx/docview.h +++ b/include/wx/docview.h @@ -129,6 +129,8 @@ public: // deletes the document if this is there are no more views. virtual void OnChangedViewList(); + // Called from OnCloseDocument(), does nothing by default but may be + // overridden. Return value is ignored. virtual bool DeleteContents(); virtual bool Draw(wxDC&); diff --git a/interface/wx/docview.h b/interface/wx/docview.h index 4dd49c4be8..dd5f3bcc19 100644 --- a/interface/wx/docview.h +++ b/interface/wx/docview.h @@ -1141,6 +1141,18 @@ public: */ virtual bool DeleteAllViews(); + /** + Virtual method called from OnCloseDocument(). + + This method may be overridden to perform any additional cleanup which + might be needed when the document is closed. + + The return value of this method is currently ignored. + + The default version does nothing and simply returns @true. + */ + virtual bool DeleteContents(); + /** Returns a pointer to the command processor associated with this document. @@ -1258,10 +1270,10 @@ public: /** This virtual function is called when the document is being closed. - The default implementation calls DeleteContents() (an empty - implementation) and sets the modified flag to @false. You can override - it to supply additional behaviour when the document is closed with - Close(). + The default implementation calls DeleteContents() (which may be + overridden to perform additional cleanup) and sets the modified flag to + @false. You can override it to supply additional behaviour when the + document is closed with Close(). Notice that previous wxWidgets versions used to call this function also from OnNewDocument(), rather counter-intuitively. This is no longer the diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 04b6bb9818..03d455b528 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -135,8 +135,6 @@ bool wxDocument::DeleteContents() wxDocument::~wxDocument() { - DeleteContents(); - delete m_commandProcessor; if (GetDocumentManager())