on xenial help sign in
Use a Qt::QueuedConnection to make sure we don't deadlock with abort calling finished
commit0074e62a4bf21d10176f0af4ff04e5219110659d authorAlbert Astals <albert.astals@canonical.com> dateWed 5 Nov 2014, 16:46 (12 years ago) parent47d4646
1 file changed+4−1
plugins/Dash/croppedimagesizerasyncworker.cpp+4−1
plugins/Dash/croppedimagesizerasyncworker.cpp+4−1
@@ -31,17 +31,19 @@ CroppedImageSizerAsyncWorker::CroppedImageSizerAsyncWorker(CroppedImageSizer *si
3131
3232void CroppedImageSizerAsyncWorker::abort()
3333{
34+ // This runs on main thread
3435 QMutexLocker locker(&m_mutex);
3536 m_sizer = nullptr;
3637 // If we already started the future run we can't abort the reply
3738 // since we don't know at which stage the future is, just let it finish
3839 if (!m_ignoreAbort) {
39− m_reply->abort();
40+ QMetaObject::invokeMethod(m_reply, "abort", Qt::QueuedConnection);
4041 }
4142}
4243
4344void CroppedImageSizerAsyncWorker::requestFinished()
4445{
46+ // This runs on main thread
4547 QMutexLocker locker(&m_mutex);
4648 if (m_sizer) {
4749 m_ignoreAbort = true;
@@ -55,6 +57,7 @@ void CroppedImageSizerAsyncWorker::requestFinished()
5557
5658void CroppedImageSizerAsyncWorker::processRequestFinished(qreal width, qreal height, QUrl source, CroppedImageSizerAsyncWorker *worker)
5759{
60+ // This runs on non main thread
5861 QImageReader reader(worker->m_reply);
5962 const QSize imageSize = reader.size();
6063 QSize sourceSize = QSize(0, 0);