Document wxDocument::DeleteContents().

This method purpose was not quite clear as it was only mentioned in passing in
documentation of OnCloseDocument() but not really documented itself.

Also don't call it from wxDocument dtor as this is useless: the user-defined
overridden version will never be called from here and the base class version
does nothing.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64299 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-05-13 14:37:00 +00:00
parent 17c02cc8e6
commit 2954883593
3 changed files with 18 additions and 6 deletions

View File

@@ -129,6 +129,8 @@ public:
// deletes the document if this is there are no more views. // deletes the document if this is there are no more views.
virtual void OnChangedViewList(); virtual void OnChangedViewList();
// Called from OnCloseDocument(), does nothing by default but may be
// overridden. Return value is ignored.
virtual bool DeleteContents(); virtual bool DeleteContents();
virtual bool Draw(wxDC&); virtual bool Draw(wxDC&);

View File

@@ -1141,6 +1141,18 @@ public:
*/ */
virtual bool DeleteAllViews(); 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 Returns a pointer to the command processor associated with this
document. document.
@@ -1258,10 +1270,10 @@ public:
/** /**
This virtual function is called when the document is being closed. This virtual function is called when the document is being closed.
The default implementation calls DeleteContents() (an empty The default implementation calls DeleteContents() (which may be
implementation) and sets the modified flag to @false. You can override overridden to perform additional cleanup) and sets the modified flag to
it to supply additional behaviour when the document is closed with @false. You can override it to supply additional behaviour when the
Close(). document is closed with Close().
Notice that previous wxWidgets versions used to call this function also Notice that previous wxWidgets versions used to call this function also
from OnNewDocument(), rather counter-intuitively. This is no longer the from OnNewDocument(), rather counter-intuitively. This is no longer the

View File

@@ -135,8 +135,6 @@ bool wxDocument::DeleteContents()
wxDocument::~wxDocument() wxDocument::~wxDocument()
{ {
DeleteContents();
delete m_commandProcessor; delete m_commandProcessor;
if (GetDocumentManager()) if (GetDocumentManager())