diff --git a/launcher/modplatform/helpers/HashUtils.cpp b/launcher/modplatform/helpers/HashUtils.cpp index b40361bcc..f20af1f09 100644 --- a/launcher/modplatform/helpers/HashUtils.cpp +++ b/launcher/modplatform/helpers/HashUtils.cpp @@ -138,24 +138,24 @@ QString hash(QByteArray data, Algorithm type) void Hasher::executeTask() { - m_zip_future = QtConcurrent::run(QThreadPool::globalInstance(), [this]() { return hash(m_path, m_alg); }); - connect(&m_zip_watcher, &QFutureWatcher::finished, this, [this] { - if (m_zip_future.isCanceled()) { + m_future = QtConcurrent::run(QThreadPool::globalInstance(), [this]() { return hash(m_path, m_alg); }); + connect(&m_watcher, &QFutureWatcher::finished, this, [this] { + if (m_future.isCanceled()) { emitAborted(); - } else if (m_result = m_zip_future.result(); m_result.isEmpty()) { + } else if (m_result = m_future.result(); m_result.isEmpty()) { emitFailed("Empty hash!"); } else { emitSucceeded(); emit resultsReady(m_result); } }); - m_zip_watcher.setFuture(m_zip_future); + m_watcher.setFuture(m_future); } bool Hasher::abort() { - if (m_zip_future.isRunning()) { - m_zip_future.cancel(); + if (m_future.isRunning()) { + m_future.cancel(); // NOTE: Here we don't do `emitAborted()` because it will be done when `m_build_zip_future` actually cancels, which may not // occur immediately. return true; diff --git a/launcher/modplatform/helpers/HashUtils.h b/launcher/modplatform/helpers/HashUtils.h index 3402c5c1f..5d8b7d132 100644 --- a/launcher/modplatform/helpers/HashUtils.h +++ b/launcher/modplatform/helpers/HashUtils.h @@ -41,8 +41,8 @@ class Hasher : public Task { QString m_path; Algorithm m_alg; - QFuture m_zip_future; - QFutureWatcher m_zip_watcher; + QFuture m_future; + QFutureWatcher m_watcher; }; Hasher::Ptr createHasher(QString file_path, ModPlatform::ResourceProvider provider);