impr: Cleanup task progress handling

This commit is contained in:
WerWolv
2024-02-23 22:09:57 +01:00
parent a7d6a4968e
commit 6b14facd29
4 changed files with 9 additions and 22 deletions

View File

@@ -89,14 +89,12 @@ namespace hex::plugin::builtin {
auto provider = ImHexApi::Provider::get();
u64 count = 0;
for (auto &[address, value] : patch->get()) {
provider->write(address, &value, sizeof(value));
count += 1;
task.update(count);
task.increment();
}
provider->getUndoStack().groupOperations(count, "hex.builtin.undo_operation.patches");
provider->getUndoStack().groupOperations(patch->get().size(), "hex.builtin.undo_operation.patches");
});
});
}
@@ -115,14 +113,12 @@ namespace hex::plugin::builtin {
auto provider = ImHexApi::Provider::get();
u64 count = 0;
for (auto &[address, value] : patch->get()) {
provider->write(address, &value, sizeof(value));
count += 1;
task.update(count);
task.increment();
}
provider->getUndoStack().groupOperations(count, "hex.builtin.undo_operation.patches");
provider->getUndoStack().groupOperations(patch->get().size(), "hex.builtin.undo_operation.patches");
});
});
}
@@ -151,14 +147,12 @@ namespace hex::plugin::builtin {
task.setMaxValue(patches.size());
u64 count = 0;
for (auto &[address, value] : patches) {
provider->write(address, &value, sizeof(value));
count += 1;
task.update(count);
task.increment();
}
provider->getUndoStack().groupOperations(count, "hex.builtin.undo_operation.patches");
provider->getUndoStack().groupOperations(patches.size(), "hex.builtin.undo_operation.patches");
});
});
}

View File

@@ -120,10 +120,8 @@ namespace hex::plugin::builtin {
task.setMaxValue(files.size());
u64 fileIndex = 0;
for (const auto &file : files) {
task.update(fileIndex);
fileIndex++;
task.increment();
wolv::io::File input(file, wolv::io::File::Mode::Read);
if (!input.isValid()) {

View File

@@ -30,7 +30,6 @@ namespace hex::plugin::yara {
const auto &ruleFilePaths = romfs::list("rules");
task.setMaxValue(ruleFilePaths.size());
u32 progress = 0;
for (const auto &ruleFilePath : ruleFilePaths) {
const std::string fileContent = romfs::get(ruleFilePath).data<const char>();
@@ -46,8 +45,7 @@ namespace hex::plugin::yara {
}
}
task.update(progress);
progress += 1;
task.increment();
}
}

View File

@@ -247,8 +247,6 @@ namespace hex::plugin::yara {
return;
m_matcherTask = TaskManager::createTask("hex.yara_rules.view.yara.matching", 0, [this, provider](auto &task) {
u32 progress = 0;
std::vector<YaraRule::Result> results;
for (const auto &[fileName, filePath] : *m_rulePaths) {
YaraRule rule(filePath);
@@ -268,8 +266,7 @@ namespace hex::plugin::yara {
results.emplace_back(result.value());
task.update(progress);
progress += 1;
task.increment();
}
TaskManager::doLater([this, results = std::move(results)] {