on xenial help sign in
Use a Qt::QueuedConnection to make sure we don't deadlock with abort calling finished
0074e62Albert Astals
plugins/Dash/croppedimagesizerasyncworker.cpp+4−1
@@ -31,17 +31,19 @@ CroppedImageSizerAsyncWorker::CroppedImageSizerAsyncWorker(CroppedImageSizer *si
31
31
32void CroppedImageSizerAsyncWorker::abort()
32void CroppedImageSizerAsyncWorker::abort()
33{
33{
34+ // This runs on main thread
34 QMutexLocker locker(&m_mutex);
35 QMutexLocker locker(&m_mutex);
35 m_sizer = nullptr;
36 m_sizer = nullptr;
36 // If we already started the future run we can't abort the reply
37 // If we already started the future run we can't abort the reply
37 // since we don't know at which stage the future is, just let it finish
38 // since we don't know at which stage the future is, just let it finish
38 if (!m_ignoreAbort) {
39 if (!m_ignoreAbort) {
39− m_reply->abort();
40+ QMetaObject::invokeMethod(m_reply, "abort", Qt::QueuedConnection);
40 }
41 }
41}
42}
42
43
43void CroppedImageSizerAsyncWorker::requestFinished()
44void CroppedImageSizerAsyncWorker::requestFinished()
44{
45{
46+ // This runs on main thread
45 QMutexLocker locker(&m_mutex);
47 QMutexLocker locker(&m_mutex);
46 if (m_sizer) {
48 if (m_sizer) {
47 m_ignoreAbort = true;
49 m_ignoreAbort = true;
@@ -55,6 +57,7 @@ void CroppedImageSizerAsyncWorker::requestFinished()
55
57
56void CroppedImageSizerAsyncWorker::processRequestFinished(qreal width, qreal height, QUrl source, CroppedImageSizerAsyncWorker *worker)
58void CroppedImageSizerAsyncWorker::processRequestFinished(qreal width, qreal height, QUrl source, CroppedImageSizerAsyncWorker *worker)
57{
59{
60+ // This runs on non main thread
58 QImageReader reader(worker->m_reply);
61 QImageReader reader(worker->m_reply);
59 const QSize imageSize = reader.size();
62 const QSize imageSize = reader.size();
60 QSize sourceSize = QSize(0, 0);
63 QSize sourceSize = QSize(0, 0);