Fix QtConcurrent use for future Qt version

Qt 6 has a breaking ABI change in relation to QtConcurrent::run()
https://doc.qt.io/qt-6/concurrent-changes-qt6.html
This commit is contained in:
Floris Bos 2021-12-21 22:50:13 +01:00
parent 47d331b664
commit 69f5799145
2 changed files with 8 additions and 0 deletions

View file

@ -171,7 +171,11 @@ void DownloadExtractThread::extractImageRun()
} }
} }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
_writeFuture = QtConcurrent::run(&DownloadThread::_writeFile, static_cast<DownloadThread *>(this), _abuf[_activeBuf], size);
#else
_writeFuture = QtConcurrent::run(static_cast<DownloadThread *>(this), &DownloadThread::_writeFile, _abuf[_activeBuf], size); _writeFuture = QtConcurrent::run(static_cast<DownloadThread *>(this), &DownloadThread::_writeFile, _abuf[_activeBuf], size);
#endif
_activeBuf = _activeBuf ? 0 : 1; _activeBuf = _activeBuf ? 0 : 1;
_writeThreadStarted = true; _writeThreadStarted = true;
} }

View file

@ -526,7 +526,11 @@ size_t DownloadThread::_writeFile(const char *buf, size_t len)
return _file.seek(len) ? len : 0; return _file.seek(len) ? len : 0;
} }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QFuture<void> wh = QtConcurrent::run(&DownloadThread::_hashData, this, buf, len);
#else
QFuture<void> wh = QtConcurrent::run(this, &DownloadThread::_hashData, buf, len); QFuture<void> wh = QtConcurrent::run(this, &DownloadThread::_hashData, buf, len);
#endif
qint64 written = _file.write(buf, len); qint64 written = _file.write(buf, len);
_bytesWritten += written; _bytesWritten += written;