Merge pull request #2609 from Trial97/crash_hash
fix crash with hash task
This commit is contained in:
commit
9596e6fb01
@ -18,8 +18,7 @@ Hasher::Ptr createHasher(QString file_path, ModPlatform::ResourceProvider provid
|
|||||||
case ModPlatform::ResourceProvider::FLAME:
|
case ModPlatform::ResourceProvider::FLAME:
|
||||||
return makeShared<Hasher>(file_path, Algorithm::Murmur2);
|
return makeShared<Hasher>(file_path, Algorithm::Murmur2);
|
||||||
default:
|
default:
|
||||||
qCritical() << "[Hashing]"
|
qCritical() << "[Hashing]" << "Unrecognized mod platform!";
|
||||||
<< "Unrecognized mod platform!";
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,7 +137,8 @@ QString hash(QByteArray data, Algorithm type)
|
|||||||
|
|
||||||
void Hasher::executeTask()
|
void Hasher::executeTask()
|
||||||
{
|
{
|
||||||
m_future = QtConcurrent::run(QThreadPool::globalInstance(), [this]() { return hash(m_path, m_alg); });
|
m_future = QtConcurrent::run(
|
||||||
|
QThreadPool::globalInstance(), [](QString fileName, Algorithm type) { return hash(fileName, type); }, m_path, m_alg);
|
||||||
connect(&m_watcher, &QFutureWatcher<QString>::finished, this, [this] {
|
connect(&m_watcher, &QFutureWatcher<QString>::finished, this, [this] {
|
||||||
if (m_future.isCanceled()) {
|
if (m_future.isCanceled()) {
|
||||||
emitAborted();
|
emitAborted();
|
||||||
|
Loading…
Reference in New Issue
Block a user