fix: Crash when restarting ImHex more than once

This commit is contained in:
WerWolv
2024-02-19 22:06:46 +01:00
parent 218946d5de
commit adc51d3773
5 changed files with 42 additions and 15 deletions

View File

@@ -106,13 +106,15 @@ namespace hex {
if (!loaded)
store();
for (const auto &[category, rest] : *impl::s_onChangeCallbacks) {
for (const auto &[name, callbacks] : rest) {
for (const auto &[id, callback] : callbacks) {
callback(getSetting(category, name, {}));
TaskManager::doLater([] {
for (const auto &[category, rest] : *impl::s_onChangeCallbacks) {
for (const auto &[name, callbacks] : rest) {
for (const auto &[id, callback] : callbacks) {
callback(getSetting(category, name, {}));
}
}
}
}
});
}
void store() {

View File

@@ -471,6 +471,16 @@ namespace hex {
return s_windowResizable;
}
static std::vector<AutoResetBase*> s_autoResetObjects;
void addAutoResetObject(AutoResetBase *object) {
s_autoResetObjects.emplace_back(object);
}
void cleanup() {
for (const auto &object : s_autoResetObjects)
object->reset();
}
}