From 4acf5bc1bd8483c5e1267f051d8786d922ca643a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 6 Feb 2015 19:28:46 +0000 Subject: [PATCH] Allow documents without template nor views be deleted correctly again. The changes of r78282 didn't take into account the case of a document without any views nor template and, consequently, without the associated manager. Such documents were not deleted at all any longer. Fix this by ensuring that a document is always associated with a manager: if not with the one specified by its template, then with the global one. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78453 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/docview.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 6ae949e19f..939eb1f390 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -276,7 +276,13 @@ wxDocManager *wxDocument::GetDocumentManager() const if ( m_documentParent ) return m_documentParent->GetDocumentManager(); - return m_documentTemplate ? m_documentTemplate->GetDocumentManager() : NULL; + if ( m_documentTemplate ) + return m_documentTemplate->GetDocumentManager(); + + // Fall back on the global manager if the document doesn't have a template, + // code elsewhere, notably in DeleteAllViews(), relies on the document + // always being managed by some manager. + return wxDocManager::GetDocumentManager(); } bool wxDocument::OnNewDocument()