From 5ea039987f5083d6cbf16de418be395e1b0b41d9 Mon Sep 17 00:00:00 2001 From: nowrep Date: Sun, 4 Dec 2011 19:15:44 +0100 Subject: [PATCH] [Fix:] Fix crash in PageThumbnailer. Closes #49 - using QObject::deleteLater rather than normal delete --- src/network/networkmanagerproxy.cpp | 6 ++++++ src/network/networkmanagerproxy.h | 2 ++ src/plugins/speeddial.cpp | 3 ++- src/tools/pagethumbnailer.cpp | 8 ++++---- src/webview/webpage.cpp | 1 - src/webview/webview.cpp | 5 +++-- 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/network/networkmanagerproxy.cpp b/src/network/networkmanagerproxy.cpp index 9158184d9..aeb01d89e 100644 --- a/src/network/networkmanagerproxy.cpp +++ b/src/network/networkmanagerproxy.cpp @@ -59,3 +59,9 @@ QNetworkReply* NetworkManagerProxy::createRequest(QNetworkAccessManager::Operati } return QNetworkAccessManager::createRequest(op, request, outgoingData); } + +NetworkManagerProxy::~NetworkManagerProxy() +{ + // Prevent deleting of cookie jar + cookieJar()->setParent(m_manager); +} diff --git a/src/network/networkmanagerproxy.h b/src/network/networkmanagerproxy.h index 3f6102648..a0b217137 100644 --- a/src/network/networkmanagerproxy.h +++ b/src/network/networkmanagerproxy.h @@ -31,6 +31,8 @@ class NetworkManagerProxy : public QNetworkAccessManager Q_OBJECT public: explicit NetworkManagerProxy(QObject* parent = 0); + ~NetworkManagerProxy(); + void setView(WebView* view) { m_view = view; } void setPage(WebPage* page) { m_page = page; } diff --git a/src/plugins/speeddial.cpp b/src/plugins/speeddial.cpp index f4254fe2b..1a2276564 100644 --- a/src/plugins/speeddial.cpp +++ b/src/plugins/speeddial.cpp @@ -155,7 +155,6 @@ void SpeedDial::thumbnailCreated(const QPixmap &image) } m_regenerateScript = true; - delete thumbnailer; foreach(QWebFrame * frame, m_webFrames) { if (!frame) { @@ -166,4 +165,6 @@ void SpeedDial::thumbnailCreated(const QPixmap &image) fileName = QUrl::fromLocalFile(fileName).toString(); frame->evaluateJavaScript(QString("setImageToUrl('%1', '%2');").arg(url, fileName)); } + + thumbnailer->deleteLater(); } diff --git a/src/tools/pagethumbnailer.cpp b/src/tools/pagethumbnailer.cpp index cd26b91d2..98d3db045 100644 --- a/src/tools/pagethumbnailer.cpp +++ b/src/tools/pagethumbnailer.cpp @@ -44,9 +44,9 @@ PageThumbnailer::PageThumbnailer(QObject* parent) , m_page(new QWebPage(this)) , m_size(QSize(231, 130)) { - NetworkManagerProxy* m_networkProxy = new NetworkManagerProxy(); - m_networkProxy->setPrimaryNetworkAccessManager(mApp->networkManager()); - m_page->setNetworkAccessManager(m_networkProxy); + NetworkManagerProxy* networkProxy = new NetworkManagerProxy(this); + networkProxy->setPrimaryNetworkAccessManager(mApp->networkManager()); + m_page->setNetworkAccessManager(networkProxy); m_page->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); m_page->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); @@ -103,5 +103,5 @@ void PageThumbnailer::createThumbnail() PageThumbnailer::~PageThumbnailer() { - delete m_page; + m_page->deleteLater(); } diff --git a/src/webview/webpage.cpp b/src/webview/webpage.cpp index 4d45c8143..68b6011ec 100644 --- a/src/webview/webpage.cpp +++ b/src/webview/webpage.cpp @@ -464,6 +464,5 @@ QString WebPage::chooseFile(QWebFrame* originatingFrame, const QString &oldFile) WebPage::~WebPage() { - setNetworkAccessManager(0); mainFrame()->deleteLater(); } diff --git a/src/webview/webview.cpp b/src/webview/webview.cpp index f6ea3d236..6c0f7b645 100644 --- a/src/webview/webview.cpp +++ b/src/webview/webview.cpp @@ -55,9 +55,9 @@ WebView::WebView(QupZilla* mainClass, WebTab* webTab) , m_rssChecked(false) // , m_loadingTimer(0) { - m_networkProxy = new NetworkManagerProxy(p_QupZilla); + m_networkProxy = new NetworkManagerProxy(this); m_networkProxy->setPrimaryNetworkAccessManager(mApp->networkManager()); - m_networkProxy->setPage(m_page) ; + m_networkProxy->setPage(m_page); m_networkProxy->setView(this); m_page->setNetworkAccessManager(m_networkProxy); m_page->setView(this); @@ -981,6 +981,7 @@ bool WebView::eventFilter(QObject* obj, QEvent* event) WebView::~WebView() { + delete m_networkProxy; history()->clear(); delete m_page; }