]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix for crash when wxUSE_STL=1. wxDocument::DeleteAllViews might
authorMattia Barbon <mbarbon@cpan.org>
Fri, 18 Jul 2003 19:44:47 +0000 (19:44 +0000)
committerMattia Barbon <mbarbon@cpan.org>
Fri, 18 Jul 2003 19:44:47 +0000 (19:44 +0000)
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

src/common/docview.cpp

index c158c432432ff8b2dd7ad8373ad65a80d39d9829..e43e8f25d659c91f3e4600126bee02e5af9955c5 100644 (file)
@@ -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.