diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 7fa1b7299d..551e02f516 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -187,17 +187,15 @@ bool wxDocument::DeleteAllViews() for ( it = m_documentViews.begin(), en = m_documentViews.end(); it != en; - ) + ++it ) { wxView *view = (wxView *)*it; if (!view->Close()) return false; - wxList::iterator next = it; ++next; - delete view; // Deletes node implicitly - it = next; } + // If we haven't yet deleted the document (for example // if there were no views) then delete it. if (manager && manager->GetDocuments().Member(this))