Skip to content
This repository has been archived by the owner on May 10, 2018. It is now read-only.

Commit

Permalink
[Fix:] Fix crash in PageThumbnailer. Closes #49
Browse files Browse the repository at this point in the history
 - using QObject::deleteLater rather than normal delete
  • Loading branch information
nowrep committed Dec 4, 2011
1 parent bb55e08 commit 5ea0399
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
6 changes: 6 additions & 0 deletions src/network/networkmanagerproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 2 additions & 0 deletions src/network/networkmanagerproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
3 changes: 2 additions & 1 deletion src/plugins/speeddial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ void SpeedDial::thumbnailCreated(const QPixmap &image)
}

m_regenerateScript = true;
delete thumbnailer;

foreach(QWebFrame * frame, m_webFrames) {
if (!frame) {
Expand All @@ -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();
}
8 changes: 4 additions & 4 deletions src/tools/pagethumbnailer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -103,5 +103,5 @@ void PageThumbnailer::createThumbnail()

PageThumbnailer::~PageThumbnailer()
{
delete m_page;
m_page->deleteLater();
}
1 change: 0 additions & 1 deletion src/webview/webpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,5 @@ QString WebPage::chooseFile(QWebFrame* originatingFrame, const QString &oldFile)

WebPage::~WebPage()
{
setNetworkAccessManager(0);
mainFrame()->deleteLater();
}
5 changes: 3 additions & 2 deletions src/webview/webview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -981,6 +981,7 @@ bool WebView::eventFilter(QObject* obj, QEvent* event)

WebView::~WebView()
{
delete m_networkProxy;
history()->clear();
delete m_page;
}

0 comments on commit 5ea0399

Please sign in to comment.