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()) {