diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-01-27 11:21:53 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-01-27 20:35:11 +0000 |
commit | fd7f2367515bd243a171ae1234b3443d6f24955d (patch) | |
tree | b543d2e324c5cc2f7ea13cbd78eaa2b425ee3c15 /src/core/url_request_custom_job_delegate.cpp | |
parent | eeb18149fa6d796dd5202f080b828099a9187046 (diff) |
Fix multi-thread protection in custom url handler
The classes were not properly protected against race conditions. To
solve this there is now a class shared between the two thread that is
not deleted until the classes on both threads have been deleted.
Change-Id: I499bd98805ae7a195aca42f30610eb6c2b0fd0f7
Reviewed-by: Michael BrĂ¼ning <michael.bruning@theqtcompany.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'src/core/url_request_custom_job_delegate.cpp')
-rw-r--r-- | src/core/url_request_custom_job_delegate.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/core/url_request_custom_job_delegate.cpp b/src/core/url_request_custom_job_delegate.cpp index 0650242c8..1a3e08e52 100644 --- a/src/core/url_request_custom_job_delegate.cpp +++ b/src/core/url_request_custom_job_delegate.cpp @@ -44,39 +44,40 @@ namespace QtWebEngineCore { -URLRequestCustomJobDelegate::URLRequestCustomJobDelegate(URLRequestCustomJob *job) - : m_job(job) +URLRequestCustomJobDelegate::URLRequestCustomJobDelegate(URLRequestCustomJobShared *shared) + : m_shared(shared) { } URLRequestCustomJobDelegate::~URLRequestCustomJobDelegate() { + m_shared->unsetJobDelegate(); } QUrl URLRequestCustomJobDelegate::url() const { - return toQt(m_job->request()->url()); + return toQt(m_shared->requestUrl()); } QByteArray URLRequestCustomJobDelegate::method() const { - return QByteArray::fromStdString(m_job->request()->method()); + return QByteArray::fromStdString(m_shared->requestMethod()); } void URLRequestCustomJobDelegate::setReply(const QByteArray &contentType, QIODevice *device) { - m_job->setReplyMimeType(contentType.toStdString()); - m_job->setReplyDevice(device); + m_shared->setReplyMimeType(contentType.toStdString()); + m_shared->setReplyDevice(device); } void URLRequestCustomJobDelegate::abort() { - m_job->abort(); + m_shared->abort(); } void URLRequestCustomJobDelegate::redirect(const QUrl &url) { - m_job->redirect(toGurl(url)); + m_shared->redirect(toGurl(url)); } void URLRequestCustomJobDelegate::fail(Error error) @@ -102,7 +103,7 @@ void URLRequestCustomJobDelegate::fail(Error error) break; } if (net_error) - m_job->fail(net_error); + m_shared->fail(net_error); } } // namespace |