Fix for crash when wxUSE_STL=1. wxDocument::DeleteAllViews might

delete "this", together with the list it is iterating over.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@22090 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Mattia Barbon
2003-07-18 19:44:47 +00:00
parent a0749355ca
commit d2e70462f1

View File

@@ -183,18 +183,20 @@ bool wxDocument::OnCloseDocument()
bool wxDocument::DeleteAllViews() bool wxDocument::DeleteAllViews()
{ {
wxDocManager* manager = GetDocumentManager(); wxDocManager* manager = GetDocumentManager();
wxList::iterator it, en;
wxList::compatibility_iterator node = m_documentViews.GetFirst(); for ( it = m_documentViews.begin(), en = m_documentViews.end();
while (node) it != en;
)
{ {
wxView *view = (wxView *)node->GetData(); wxView *view = (wxView *)*it;
if (!view->Close()) if (!view->Close())
return FALSE; return FALSE;
wxList::compatibility_iterator next = node->GetNext(); wxList::iterator next = it; ++next;
delete view; // Deletes node implicitly delete view; // Deletes node implicitly
node = next; it = next;
} }
// If we haven't yet deleted the document (for example // If we haven't yet deleted the document (for example
// if there were no views) then delete it. // if there were no views) then delete it.