fix: ImHex should crash less often now when exiting
This commit is contained in:
parent
e8d77f8269
commit
d345508195
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,6 +4,7 @@
|
||||
cmake-build-debug/
|
||||
cmake-build-release/
|
||||
cmake-build-relwithdebinfo/
|
||||
cmake-build-wsl/
|
||||
|
||||
build-linux/
|
||||
build/
|
||||
|
@ -47,6 +47,10 @@ namespace hex {
|
||||
SharedData::sharedVariables[variableName] = value;
|
||||
}
|
||||
|
||||
static void clearVariables() {
|
||||
SharedData::sharedVariables.clear();
|
||||
}
|
||||
|
||||
public:
|
||||
static std::vector<std::function<void()>> deferredCalls;
|
||||
static prv::Provider *currentProvider;
|
||||
|
@ -10,14 +10,19 @@ namespace hex {
|
||||
/* Settings */
|
||||
|
||||
void ContentRegistry::Settings::load() {
|
||||
bool loaded = false;
|
||||
for (const auto &dir : hex::getPath(ImHexPath::Config)) {
|
||||
std::ifstream settingsFile(dir + "/settings.json");
|
||||
|
||||
if (settingsFile.good()) {
|
||||
settingsFile >> getSettingsData();
|
||||
loaded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!loaded)
|
||||
ContentRegistry::Settings::store();
|
||||
}
|
||||
|
||||
void ContentRegistry::Settings::store() {
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace hex {
|
||||
|
||||
std::map<void*, EventManager::EventList::iterator> EventManager::s_tokenStore;
|
||||
EventManager::EventList EventManager::s_events;
|
||||
std::map<void*, EventManager::EventList::iterator> EventManager::s_tokenStore;
|
||||
|
||||
}
|
@ -98,11 +98,45 @@ namespace hex::init {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool deleteViews() {
|
||||
bool deleteSharedData() {
|
||||
SharedData::deferredCalls.clear();
|
||||
|
||||
delete SharedData::currentProvider;
|
||||
SharedData::currentProvider = nullptr;
|
||||
|
||||
SharedData::settingsEntries.clear();
|
||||
SharedData::settingsJson.clear();
|
||||
|
||||
SharedData::commandPaletteCommands.clear();
|
||||
SharedData::patternLanguageFunctions.clear();
|
||||
|
||||
for (auto &view : SharedData::views)
|
||||
delete view;
|
||||
SharedData::views.clear();
|
||||
|
||||
SharedData::toolsEntries.clear();
|
||||
|
||||
SharedData::dataInspectorEntries.clear();
|
||||
|
||||
SharedData::bookmarkEntries.clear();
|
||||
|
||||
for (auto &pattern : SharedData::patternData)
|
||||
delete pattern;
|
||||
SharedData::patternData.clear();
|
||||
|
||||
SharedData::languageNames.clear();
|
||||
SharedData::languageDefinitions.clear();
|
||||
SharedData::loadedLanguageStrings.clear();
|
||||
|
||||
SharedData::welcomeScreenEntries.clear();
|
||||
SharedData::footerItems.clear();
|
||||
|
||||
SharedData::dataProcessorNodes.clear();
|
||||
|
||||
SharedData::recentFilePaths.clear();
|
||||
|
||||
SharedData::clearVariables();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -160,8 +194,8 @@ namespace hex::init {
|
||||
|
||||
std::vector<Task> getExitTasks() {
|
||||
return {
|
||||
{ "Cleaning up views...", deleteViews },
|
||||
{ "Saving settings...", storeSettings },
|
||||
{ "Cleaning up shared data...", deleteSharedData },
|
||||
{ "Unloading plugins...", unloadPlugins },
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user