diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-04-15 12:45:59 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-04-20 14:32:58 +0000 |
commit | d56128c315ad89dddf507b10dc4332d05cc42f91 (patch) | |
tree | 65a2b340c82350d95cb29a1576e1053d6ba84a0c /src/core/custom_protocol_handler.h | |
parent | 5b8aad9fa24caeb50ff3640d01590a15ee4e23d8 (diff) |
Improve thread-safety of custom scheme handlers
Avoids accessing the QWebEngineUrlSchemeHandler from any other thread
than the UI thread, since it may be deleted at any time on the UI
thread.
Change-Id: Icb4331b3c36f6f619a9fd975d155a9fd608dc5e9
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'src/core/custom_protocol_handler.h')
-rw-r--r-- | src/core/custom_protocol_handler.h | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/core/custom_protocol_handler.h b/src/core/custom_protocol_handler.h index 94da28673..8b6756715 100644 --- a/src/core/custom_protocol_handler.h +++ b/src/core/custom_protocol_handler.h @@ -42,10 +42,9 @@ #include <QtCore/QByteArray> #include <QtCore/QObject> -#include <QtCore/qcompilerdetection.h> // Needed for Q_DECL_OVERRIDE +#include <QtCore/QWeakPointer> QT_FORWARD_DECLARE_CLASS(QIODevice) -QT_FORWARD_DECLARE_CLASS(QWebEngineUrlSchemeHandler) namespace net { class NetworkDelegate; @@ -61,13 +60,13 @@ class BrowserContextAdapter; class QWEBENGINE_EXPORT CustomProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler { public: - CustomProtocolHandler(QWebEngineUrlSchemeHandler *); + CustomProtocolHandler(QWeakPointer<const BrowserContextAdapter> adapter); virtual net::URLRequestJob *MaybeCreateJob(net::URLRequest *request, net::NetworkDelegate *networkDelegate) const Q_DECL_OVERRIDE; private: DISALLOW_COPY_AND_ASSIGN(CustomProtocolHandler); - QWebEngineUrlSchemeHandler *m_schemeHandler; + QWeakPointer<const BrowserContextAdapter> m_adapter; }; } // namespace |