summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-02-20 11:59:02 +0100
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-02-20 14:16:22 +0000
commit61dec11a8bc36d37ed36acc6ad897653735d4564 (patch)
tree2de013b04c38fd6734f744182d1e40b13521516d /src/core
parentd2b9c003f87e34ca599d3264a9af371e435ad0f8 (diff)
Fix crashes and ownership issues in Custom URL scheme handling
Fixes crashes exposed by implementing the qthelp protocol handler for Qt assistant. Change-Id: I0b1153bc52ff82838cde009f1fe1ac46edc43210 Reviewed-by: Andras Becsi <andras.becsi@theqtcompany.com>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/custom_url_scheme_handler.cpp6
-rw-r--r--src/core/custom_url_scheme_handler.h3
-rw-r--r--src/core/url_request_context_getter_qt.cpp4
-rw-r--r--src/core/url_request_custom_job.cpp2
4 files changed, 8 insertions, 7 deletions
diff --git a/src/core/custom_url_scheme_handler.cpp b/src/core/custom_url_scheme_handler.cpp
index a8701a5d4..edc8000c9 100644
--- a/src/core/custom_url_scheme_handler.cpp
+++ b/src/core/custom_url_scheme_handler.cpp
@@ -39,7 +39,6 @@
CustomUrlSchemeHandler::CustomUrlSchemeHandler(const QByteArray &scheme)
: m_scheme(scheme)
- , m_protocolHandler(new CustomProtocolHandler(this))
{
}
@@ -57,7 +56,8 @@ void CustomUrlSchemeHandler::setScheme(const QByteArray &scheme)
m_scheme = scheme;
}
-CustomProtocolHandler *CustomUrlSchemeHandler::protocolHandler()
+CustomProtocolHandler *CustomUrlSchemeHandler::createProtocolHandler()
{
- return m_protocolHandler.data();
+ // Will be owned by the JobFactory.
+ return new CustomProtocolHandler(this);
}
diff --git a/src/core/custom_url_scheme_handler.h b/src/core/custom_url_scheme_handler.h
index fef29c98a..dbcdf2a60 100644
--- a/src/core/custom_url_scheme_handler.h
+++ b/src/core/custom_url_scheme_handler.h
@@ -55,13 +55,12 @@ public:
QByteArray scheme() const;
void setScheme(const QByteArray &);
- CustomProtocolHandler *protocolHandler();
+ CustomProtocolHandler *createProtocolHandler();
virtual bool handleJob(URLRequestCustomJobDelegate*) = 0;
private:
QByteArray m_scheme;
- QScopedPointer<CustomProtocolHandler> m_protocolHandler;
};
#endif // CUSTOM_URL_SCHEME_HANDLER_H_
diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp
index 41af37e5d..0a604eaaa 100644
--- a/src/core/url_request_context_getter_qt.cpp
+++ b/src/core/url_request_context_getter_qt.cpp
@@ -122,6 +122,8 @@ void URLRequestContextGetterQt::generateStorage()
{
Q_ASSERT(m_urlRequestContext);
Q_ASSERT(m_proxyConfigService);
+ if (!m_proxyConfigService)
+ return;
m_updateStorageSettings = false;
m_storage.reset(new net::URLRequestContextStorage(m_urlRequestContext.get()));
@@ -285,7 +287,7 @@ void URLRequestContextGetterQt::generateJobFactory()
new net::FtpProtocolHandler(new net::FtpNetworkLayer(m_urlRequestContext->host_resolver())));
Q_FOREACH (CustomUrlSchemeHandler* handler, m_browserContext->customUrlSchemeHandlers()) {
- m_jobFactory->SetProtocolHandler(handler->scheme().toStdString(), handler->protocolHandler());
+ m_jobFactory->SetProtocolHandler(handler->scheme().toStdString(), handler->createProtocolHandler());
}
m_urlRequestContext->set_job_factory(m_jobFactory.get());
diff --git a/src/core/url_request_custom_job.cpp b/src/core/url_request_custom_job.cpp
index e97804c2f..f206955f1 100644
--- a/src/core/url_request_custom_job.cpp
+++ b/src/core/url_request_custom_job.cpp
@@ -72,7 +72,7 @@ void URLRequestCustomJob::Start()
void URLRequestCustomJob::Kill()
{
- if (m_device->isOpen())
+ if (m_device && m_device->isOpen())
m_device->close();
m_weakFactory.InvalidateWeakPtrs();