| 136 | } |
| 137 | |
| 138 | void Hasher::executeTask() |
| 139 | { |
| 140 | m_future = QtConcurrent::run( |
| 141 | QThreadPool::globalInstance(), [](QString fileName, Algorithm type) { return hash(fileName, type); }, m_path, m_alg); |
| 142 | connect(&m_watcher, &QFutureWatcher<QString>::finished, this, [this] { |
| 143 | if (m_future.isCanceled()) { |
| 144 | emitAborted(); |
| 145 | } else if (m_result = m_future.result(); m_result.isEmpty()) { |
| 146 | emitFailed("Empty hash!"); |
| 147 | } else { |
| 148 | emitSucceeded(); |
| 149 | emit resultsReady(m_result); |
| 150 | } |
| 151 | }); |
| 152 | m_watcher.setFuture(m_future); |
| 153 | } |
| 154 | |
| 155 | bool Hasher::abort() |
| 156 | { |