summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2012-06-29 22:40:36 +0200
committerAndrea Diamantini <adjam7@gmail.com>2012-06-29 23:29:58 +0200
commitf1d4cac31c2bc8e429912a497b8405bb287e12fd (patch)
treedd0efeb2a73b23b2b0868802ad27a82e7ffb6eb0 /src
parentSVN_SILENT made messages (.desktop file) (diff)
downloadrekonq-f1d4cac31c2bc8e429912a497b8405bb287e12fd.tar.xz
Get sure we are no more serving requests when deleting page.
CCBUG: 282052
Diffstat (limited to 'src')
-rw-r--r--src/networkaccessmanager.cpp36
-rw-r--r--src/webpage.cpp10
2 files changed, 40 insertions, 6 deletions
diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp
index 99233aa1..3291b6db 100644
--- a/src/networkaccessmanager.cpp
+++ b/src/networkaccessmanager.cpp
@@ -39,6 +39,36 @@
#include <KLocale>
#include <KProtocolManager>
+// Qt Includes
+#include <QNetworkReply>
+#include <QTimer>
+
+
+class NullNetworkReply : public QNetworkReply
+{
+public:
+ NullNetworkReply(const QNetworkRequest &req, QObject* parent = 0)
+ :QNetworkReply(parent)
+ {
+ setRequest(req);
+ setUrl(req.url());
+ setHeader(QNetworkRequest::ContentLengthHeader, 0);
+ setHeader(QNetworkRequest::ContentTypeHeader, "text/plain");
+ setError(QNetworkReply::ContentAccessDenied, i18n("Null reply"));
+ setAttribute(QNetworkRequest::User, QNetworkReply::ContentAccessDenied);
+ QTimer::singleShot(0, this, SIGNAL(finished()));
+ }
+
+ virtual void abort() {}
+ virtual qint64 bytesAvailable() const { return 0; }
+
+protected:
+ virtual qint64 readData(char*, qint64) {return -1;}
+};
+
+
+// ----------------------------------------------------------------------------------------------
+
NetworkAccessManager::NetworkAccessManager(QObject *parent)
: AccessManager(parent)
@@ -60,6 +90,10 @@ QNetworkReply *NetworkAccessManager::createRequest(QNetworkAccessManager::Operat
{
WebPage *parentPage = qobject_cast<WebPage *>(parent());
+ // NOTE: This to get sure we are NOT serving unused requests
+ if (!parentPage)
+ return new NullNetworkReply(request, this);
+
QNetworkReply *reply = 0;
// set our "nice" accept-language header...
@@ -73,7 +107,7 @@ QNetworkReply *NetworkAccessManager::createRequest(QNetworkAccessManager::Operat
if (!reply)
reply = AccessManager::createRequest(op, req, outgoingData);
- if (parentPage && parentPage->hasNetworkAnalyzerEnabled())
+ if (parentPage->hasNetworkAnalyzerEnabled())
emit networkData(op, req, reply);
return reply;
diff --git a/src/webpage.cpp b/src/webpage.cpp
index 9278a897..b4f6e03d 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -128,13 +128,16 @@ WebPage::WebPage(QWidget *parent)
, _networkAnalyzer(false)
, _isOnRekonqPage(false)
{
- // ----- handling unsupported content...
+ // handling unsupported content...
setForwardUnsupportedContent(true);
connect(this, SIGNAL(unsupportedContent(QNetworkReply*)), this, SLOT(handleUnsupportedContent(QNetworkReply*)));
- // ----- rekonq Network Manager
+ // rekonq Network Manager
NetworkAccessManager *manager = new NetworkAccessManager(this);
+ // set network reply object to emit readyRead when it receives meta data
+ manager->setEmitReadyReadOnMetaDataChange(true);
+
// disable QtWebKit cache to just use KIO one..
manager->setCache(0);
@@ -142,9 +145,6 @@ WebPage::WebPage(QWidget *parent)
if (parent && parent->window())
manager->setWindow(parent->window());
- // set network reply object to emit readyRead when it receives meta data
- manager->setEmitReadyReadOnMetaDataChange(true);
-
setNetworkAccessManager(manager);
// activate ssl warnings