From ba9fa320c47eaf322abe11e1a6b6708620b65fdf Mon Sep 17 00:00:00 2001
From: Andrea Diamantini <adjam7@gmail.com>
Date: Tue, 3 Jul 2012 19:11:45 +0200
Subject: Get sure UrlBar is deleted well (i.e. later) and in the right place
 (i.e. the WebTab dtor).

I cannot no more reproduce the problems described in #296346, #300892
and #268328

What about you?

CCBUG: 296346
CCBUG: 300892
CCBUG: 268328
---
 src/mainview.cpp | 10 ++++++++++
 src/mainview.h   |  3 ++-
 src/webtab.cpp   |  9 +++++++--
 3 files changed, 19 insertions(+), 3 deletions(-)

(limited to 'src')

diff --git a/src/mainview.cpp b/src/mainview.cpp
index d673b7fa..4733ae3b 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -105,6 +105,16 @@ MainView::MainView(QWidget *parent)
 }
 
 
+MainView::~MainView()
+{
+    // NOTE
+    // we wanna delete m_widgetBar later to get sure
+    // all its children (i.e. the urlbars) got deleted in
+    // WebTab dtor.
+    m_widgetBar->deleteLater();
+}
+
+
 void MainView::addNewTabButton(QAction *newTabAction)
 {
     m_addTabButton->setDefaultAction(newTabAction);
diff --git a/src/mainview.h b/src/mainview.h
index da03bae8..b6cbf2f0 100644
--- a/src/mainview.h
+++ b/src/mainview.h
@@ -63,7 +63,8 @@ class REKONQ_TESTS_EXPORT MainView : public KTabWidget
 
 public:
     MainView(QWidget *parent);
-
+    ~MainView();
+    
     inline StackedUrlBar *widgetBar() const
     {
         return m_widgetBar;
diff --git a/src/webtab.cpp b/src/webtab.cpp
index c049e459..457e9006 100644
--- a/src/webtab.cpp
+++ b/src/webtab.cpp
@@ -103,9 +103,14 @@ WebTab::~WebTab()
     m_walletBar.clear();
     m_previewSelectorBar.clear();
 
+    // NOTE:
+    // Urlbar is reparented when inserted in StackedUrlBar, so we need
+    // to get sure it will be deleted. Deleting it later to ensure everything
+    // will be finished before ;)
+    m_urlBar->deleteLater();
+
+    // Get sure m_part will be deleted
     delete m_part;
-    delete m_urlBar;
-    delete m_webView;
 }
 
 
-- 
cgit v1.2.1