mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
impr: Cleanup task progress handling
This commit is contained in:
@@ -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");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)] {
|
||||
|
||||
Reference in New Issue
Block a user