From: Mattia Barbon Date: Fri, 18 Jul 2003 19:44:47 +0000 (+0000) Subject: Fix for crash when wxUSE_STL=1. wxDocument::DeleteAllViews might X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/d2e70462f144bba0782f3e4f47ddd6168f32ab7f 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 --- diff --git a/src/common/docview.cpp b/src/common/docview.cpp index c158c43243..e43e8f25d6 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -183,18 +183,20 @@ bool wxDocument::OnCloseDocument() bool wxDocument::DeleteAllViews() { wxDocManager* manager = GetDocumentManager(); + wxList::iterator it, en; - wxList::compatibility_iterator node = m_documentViews.GetFirst(); - while (node) + for ( it = m_documentViews.begin(), en = m_documentViews.end(); + it != en; + ) { - wxView *view = (wxView *)node->GetData(); + wxView *view = (wxView *)*it; if (!view->Close()) return FALSE; - wxList::compatibility_iterator next = node->GetNext(); + wxList::iterator next = it; ++next; delete view; // Deletes node implicitly - node = next; + it = next; } // If we haven't yet deleted the document (for example // if there were no views) then delete it.