From a0f523a8b19360d875c4055398dc7191eda08f5d Mon Sep 17 00:00:00 2001
From: Timothy Pearson <kb9vqf@pearsoncomputing.net>
Date: Sun, 5 Oct 2014 16:03:36 -0500
Subject: Do not delete referenced MainWindow in document destructor This
 resolves Bug 1729

---
 lib/kofficecore/KoMainWindow.cpp | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

(limited to 'lib/kofficecore/KoMainWindow.cpp')

diff --git a/lib/kofficecore/KoMainWindow.cpp b/lib/kofficecore/KoMainWindow.cpp
index 18916b57..a2189c88 100644
--- a/lib/kofficecore/KoMainWindow.cpp
+++ b/lib/kofficecore/KoMainWindow.cpp
@@ -184,7 +184,7 @@ public:
 };
 
 KoMainWindow::KoMainWindow( TDEInstance *instance, const char* name )
-    : KParts::MainWindow( name )
+    : KParts::MainWindow( 0, 0L, name )
 {
     setStandardToolBarMenuEnabled(true); // should there be a check for >= 3.1 ?
     Q_ASSERT(instance);
@@ -310,13 +310,19 @@ KoMainWindow::KoMainWindow( TDEInstance *instance, const char* name )
 
 KoMainWindow::~KoMainWindow()
 {
+    if (!d) {
+        return;
+    }
+
     // The doc and view might still exist (this is the case when closing the window)
-    if (d->m_rootDoc)
+    if (d->m_rootDoc) {
         d->m_rootDoc->removeShell(this);
+    }
 
     if (d->m_docToOpen) {
       d->m_docToOpen->removeShell(this);
       delete d->m_docToOpen;
+      d->m_docToOpen=0L;
     }
 
     // safety first ;)
@@ -337,10 +343,13 @@ KoMainWindow::~KoMainWindow()
     {
         //kdDebug(30003) << "Destructor. No more views, deleting old doc " << d->m_rootDoc << endl;
         delete d->m_rootDoc;
+        d->m_rootDoc=0L;
     }
 
     delete d->m_manager;
+    d->m_manager=0L;
     delete d;
+    d=0L;
 }
 
 void KoMainWindow::setRootDocument( KoDocument *doc )
-- 
cgit v1.2.1