diff --git a/src/lib/app/browserwindow.cpp b/src/lib/app/browserwindow.cpp index acea32877..0c04bb014 100644 --- a/src/lib/app/browserwindow.cpp +++ b/src/lib/app/browserwindow.cpp @@ -147,6 +147,13 @@ BrowserWindow::BrowserWindow(Qz::BrowserWindowType type, const QUrl &startUrl) BrowserWindow::~BrowserWindow() { + mApp->plugins()->emitMainWindowDeleted(this); + + foreach (const QPointer &pointer, m_deleteOnCloseWidgets) { + if (pointer) { + pointer->deleteLater(); + } + } } void BrowserWindow::setStartTab(WebTab* tab) @@ -1453,7 +1460,6 @@ void BrowserWindow::closeEvent(QCloseEvent* event) #ifndef Q_OS_MAC if (mApp->windowCount() == 1) { if (quitApp()) { - disconnectObjects(); event->accept(); } else { @@ -1464,7 +1470,6 @@ void BrowserWindow::closeEvent(QCloseEvent* event) } #endif - disconnectObjects(); event->accept(); } @@ -1480,37 +1485,6 @@ SearchToolBar* BrowserWindow::searchToolBar() const return toolBar; } -void BrowserWindow::disconnectObjects() -{ - // Disconnecting all important widgets before deleting this window - // so it cannot happen that slots will be invoked after the object - // is deleted. - // We have to do it this way, because ~QObject is deleting all child - // objects with plain delete - not deleteLater(). - // - // Also using own disconnectObjects() method, not default disconnect() - // because we need to retain connections to destroyed(QObject*) signal - // in order to avoid crashes for example with setting stylesheets - // (QStyleSheet backend is holding list of all widgets) - - m_tabWidget->disconnectObjects(); - m_tabWidget->getTabBar()->disconnectObjects(); - - foreach (WebTab* tab, m_tabWidget->allTabs()) { - tab->disconnectObjects(); - tab->view()->disconnectObjects(); - tab->view()->page()->disconnectObjects(); - } - - foreach (const QPointer &pointer, m_deleteOnCloseWidgets) { - if (pointer) { - pointer.data()->deleteLater(); - } - } - - mApp->plugins()->emitMainWindowDeleted(this); -} - void BrowserWindow::closeWindow() { #ifdef Q_OS_MAC diff --git a/src/lib/app/browserwindow.h b/src/lib/app/browserwindow.h index 795bb6dd1..be82443d6 100644 --- a/src/lib/app/browserwindow.h +++ b/src/lib/app/browserwindow.h @@ -175,8 +175,6 @@ private: void setupUi(); void setupMenu(); - void disconnectObjects(); - bool m_isClosing; bool m_isStarting; QUrl m_startUrl; diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index 82fe05cac..ce7112b58 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -626,7 +626,6 @@ void MainApplication::quitApplication() } m_isClosing = true; - m_networkManager->disconnectObjects(); // Saving settings in saveSettings() slot called from quit() so // everything gets saved also when quitting application in other @@ -704,7 +703,6 @@ void MainApplication::saveSettings() } m_isClosing = true; - m_networkManager->disconnectObjects(); Settings settings; settings.beginGroup("SessionRestore"); diff --git a/src/lib/network/networkmanager.cpp b/src/lib/network/networkmanager.cpp index 6943bc206..7261d4edf 100644 --- a/src/lib/network/networkmanager.cpp +++ b/src/lib/network/networkmanager.cpp @@ -748,8 +748,3 @@ void NetworkManager::loadCertificates() new CaBundleUpdater(this, this); #endif } - -void NetworkManager::disconnectObjects() -{ - disconnect(this); -} diff --git a/src/lib/network/networkmanager.h b/src/lib/network/networkmanager.h index 310c6916d..d9f722af0 100644 --- a/src/lib/network/networkmanager.h +++ b/src/lib/network/networkmanager.h @@ -57,8 +57,6 @@ public: bool registerSchemeHandler(const QString &scheme, SchemeHandler* handler); bool unregisterSchemeHandler(const QString &scheme, SchemeHandler* handler); - void disconnectObjects(); - signals: void sslDialogClosed(); diff --git a/src/lib/network/networkmanagerproxy.cpp b/src/lib/network/networkmanagerproxy.cpp index 883454ace..5bcab6f86 100644 --- a/src/lib/network/networkmanagerproxy.cpp +++ b/src/lib/network/networkmanagerproxy.cpp @@ -57,10 +57,3 @@ QNetworkReply* NetworkManagerProxy::createRequest(QNetworkAccessManager::Operati return QNetworkAccessManager::createRequest(op, request, outgoingData); } - -void NetworkManagerProxy::disconnectObjects() -{ - m_page = 0; - - disconnect(m_manager); -} diff --git a/src/lib/network/networkmanagerproxy.h b/src/lib/network/networkmanagerproxy.h index 8a075445e..b7c543733 100644 --- a/src/lib/network/networkmanagerproxy.h +++ b/src/lib/network/networkmanagerproxy.h @@ -35,8 +35,6 @@ public: QNetworkReply* createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice* outgoingData); - void disconnectObjects(); - private: WebPage* m_page; NetworkManager* m_manager; diff --git a/src/lib/popupwindow/popupwindow.cpp b/src/lib/popupwindow/popupwindow.cpp index 6d91037ab..56ba49c3b 100644 --- a/src/lib/popupwindow/popupwindow.cpp +++ b/src/lib/popupwindow/popupwindow.cpp @@ -210,7 +210,6 @@ void PopupWindow::closeEvent(QCloseEvent* event) return; } - m_page->disconnectObjects(); m_view->deleteLater(); event->accept(); diff --git a/src/lib/webview/tabbar.cpp b/src/lib/webview/tabbar.cpp index 8de3808d9..93fa291e5 100644 --- a/src/lib/webview/tabbar.cpp +++ b/src/lib/webview/tabbar.cpp @@ -746,8 +746,3 @@ void TabBar::dropEvent(QDropEvent* event) } } } - -void TabBar::disconnectObjects() -{ - disconnect(this); -} diff --git a/src/lib/webview/tabbar.h b/src/lib/webview/tabbar.h index 155438949..152e1e1d4 100644 --- a/src/lib/webview/tabbar.h +++ b/src/lib/webview/tabbar.h @@ -44,8 +44,6 @@ public: void updatePinnedTabCloseButton(int index); - void disconnectObjects(); - void wheelEvent(QWheelEvent* event); signals: diff --git a/src/lib/webview/tabbedwebview.cpp b/src/lib/webview/tabbedwebview.cpp index 23db6553f..e9f1dbe32 100644 --- a/src/lib/webview/tabbedwebview.cpp +++ b/src/lib/webview/tabbedwebview.cpp @@ -305,11 +305,3 @@ void TabbedWebView::mouseMoveEvent(QMouseEvent* event) WebView::mouseMoveEvent(event); } - -void TabbedWebView::disconnectObjects() -{ - disconnect(this); - disconnect(m_window->statusBar()); - - WebView::disconnectObjects(); -} diff --git a/src/lib/webview/tabbedwebview.h b/src/lib/webview/tabbedwebview.h index 67140ebfe..218c8cfc3 100644 --- a/src/lib/webview/tabbedwebview.h +++ b/src/lib/webview/tabbedwebview.h @@ -49,7 +49,6 @@ public: void moveToWindow(BrowserWindow* window); QWidget* overlayForJsAlert(); - void disconnectObjects(); signals: void wantsCloseTab(int); diff --git a/src/lib/webview/tabwidget.cpp b/src/lib/webview/tabwidget.cpp index c4fe1bd4f..4d20aba7c 100644 --- a/src/lib/webview/tabwidget.cpp +++ b/src/lib/webview/tabwidget.cpp @@ -464,7 +464,6 @@ void TabWidget::closeTab(int index, bool force) } TabbedWebView* webView = webTab->view(); - WebPage* webPage = webView->page(); // Don't close restore page! if (!force && webView->url().toString() == QL1S("qupzilla:restore") && mApp->restoreManager()) { @@ -506,10 +505,6 @@ void TabWidget::closeTab(int index, bool force) m_lastBackgroundTabIndex = -1; - webPage->disconnectObjects(); - webView->disconnectObjects(); - webTab->disconnectObjects(); - if (!m_closedInsteadOpened && m_menuTabs->isVisible()) { QAction* labelAction = m_menuTabs->actions().last(); labelAction->setText(tr("Currently you have %n opened tab(s)", "", count() - 1)); @@ -1033,14 +1028,6 @@ void TabWidget::closeRecoveryTab() } } -void TabWidget::disconnectObjects() -{ - disconnect(this); - disconnect(mApp); - disconnect(m_window); - disconnect(m_window->ipLabel()); -} - TabWidget::~TabWidget() { delete m_closedTabsManager; diff --git a/src/lib/webview/tabwidget.h b/src/lib/webview/tabwidget.h index 4f2892250..30ab412fb 100644 --- a/src/lib/webview/tabwidget.h +++ b/src/lib/webview/tabwidget.h @@ -103,8 +103,6 @@ public: ToolButton* buttonListTabs() const; AddTabButton* buttonAddTab() const; - void disconnectObjects(); - public slots: int addView(const QUrl &url, const Qz::NewTabPositionFlags &openFlags, bool selectLine = false, bool pinned = false); int addView(const QNetworkRequest &req, const Qz::NewTabPositionFlags &openFlags, bool selectLine = false, bool pinned = false); diff --git a/src/lib/webview/webpage.cpp b/src/lib/webview/webpage.cpp index 3da0416e3..69c34828a 100644 --- a/src/lib/webview/webpage.cpp +++ b/src/lib/webview/webpage.cpp @@ -116,6 +116,18 @@ WebPage::WebPage(QObject* parent) s_livingPages.append(this); } +WebPage::~WebPage() +{ + mApp->plugins()->emitWebPageDeleted(this); + + if (m_runningLoop) { + m_runningLoop->exit(1); + m_runningLoop = 0; + } + + s_livingPages.removeOne(this); +} + QUrl WebPage::url() const { return mainFrame()->url(); @@ -1044,28 +1056,3 @@ bool WebPage::isPointerSafeToUse(WebPage* page) return page == 0 ? false : s_livingPages.contains(page); } - -void WebPage::disconnectObjects() -{ - if (m_runningLoop) { - m_runningLoop->exit(1); - m_runningLoop = 0; - } - - s_livingPages.removeOne(this); - - disconnect(this); - m_networkProxy->disconnectObjects(); - - mApp->plugins()->emitWebPageDeleted(this); -} - -WebPage::~WebPage() -{ - if (m_runningLoop) { - m_runningLoop->exit(1); - m_runningLoop = 0; - } - - s_livingPages.removeOne(this); -} diff --git a/src/lib/webview/webpage.h b/src/lib/webview/webpage.h index 265eaa7ed..a9d042cb1 100644 --- a/src/lib/webview/webpage.h +++ b/src/lib/webview/webpage.h @@ -84,7 +84,6 @@ public: QString userAgentForUrl(const QUrl &url) const; static bool isPointerSafeToUse(WebPage* page); - void disconnectObjects(); signals: void privacyChanged(bool status); diff --git a/src/lib/webview/webtab.cpp b/src/lib/webview/webtab.cpp index ffcdca0b3..1f41c9286 100644 --- a/src/lib/webview/webtab.cpp +++ b/src/lib/webview/webtab.cpp @@ -380,13 +380,6 @@ void WebTab::pinTab(int index) tabWidget->setCurrentIndex(index); } -void WebTab::disconnectObjects() -{ - disconnect(this); - disconnect(m_locationBar.data()); - disconnect(m_view); -} - WebTab::~WebTab() { delete m_locationBar.data(); diff --git a/src/lib/webview/webtab.h b/src/lib/webview/webtab.h index 4c96a7a07..2915603f6 100644 --- a/src/lib/webview/webtab.h +++ b/src/lib/webview/webtab.h @@ -95,8 +95,6 @@ public: QPixmap renderTabPreview(); - void disconnectObjects(); - private slots: void showNotification(QWidget* notif); void slotRestore(); diff --git a/src/lib/webview/webview.cpp b/src/lib/webview/webview.cpp index fe96bb8c8..619770fbd 100644 --- a/src/lib/webview/webview.cpp +++ b/src/lib/webview/webview.cpp @@ -1533,8 +1533,3 @@ bool WebView::eventFilter(QObject* obj, QEvent* event) #endif return QWebView::eventFilter(obj, event); } - -void WebView::disconnectObjects() -{ - disconnect(this); -} diff --git a/src/lib/webview/webview.h b/src/lib/webview/webview.h index 6564669b8..e4b21f834 100644 --- a/src/lib/webview/webview.h +++ b/src/lib/webview/webview.h @@ -59,7 +59,6 @@ public: bool eventFilter(QObject* obj, QEvent* event); virtual QWidget* overlayForJsAlert() = 0; - virtual void disconnectObjects(); static bool isUrlValid(const QUrl &url); static QUrl guessUrlFromString(const QString &string);