fix: Occasional error when loading recent files

This commit is contained in:
WerWolv 2023-02-12 17:52:09 +01:00
parent 0b18930017
commit 3003dea409
4 changed files with 15 additions and 6 deletions

View File

@ -36,6 +36,7 @@ namespace hex {
static bool hasPath(); static bool hasPath();
static void clearPath(); static void clearPath();
static std::fs::path getPath(); static std::fs::path getPath();
static void setPath(const std::fs::path &path);
static void registerHandler(const Handler &handler) { static void registerHandler(const Handler &handler) {
getHandlers().push_back(handler); getHandlers().push_back(handler);

View File

@ -144,9 +144,13 @@ namespace hex {
void ProjectFile::clearPath() { void ProjectFile::clearPath() {
ProjectFile::s_currProjectPath.clear(); ProjectFile::s_currProjectPath.clear();
} }
std::fs::path ProjectFile::getPath() { std::fs::path ProjectFile::getPath() {
return ProjectFile::s_currProjectPath; return ProjectFile::s_currProjectPath;
} }
void ProjectFile::setPath(const std::fs::path &path) {
ProjectFile::s_currProjectPath = path;
}
} }

View File

@ -816,9 +816,6 @@ namespace hex {
void Window::exitImGui() { void Window::exitImGui() {
delete static_cast<ImGui::ImHexCustomData *>(ImGui::GetIO().UserData); delete static_cast<ImGui::ImHexCustomData *>(ImGui::GetIO().UserData);
ImNodes::PopAttributeFlag();
ImNodes::PopAttributeFlag();
ImGui::SaveIniSettingsToDisk(hex::toUTF8String(this->m_imguiSettingsPath).c_str()); ImGui::SaveIniSettingsToDisk(hex::toUTF8String(this->m_imguiSettingsPath).c_str());
ImGui_ImplOpenGL3_Shutdown(); ImGui_ImplOpenGL3_Shutdown();

View File

@ -480,8 +480,15 @@ namespace hex::plugin::builtin {
if (!recentFile.isValid()) if (!recentFile.isValid())
continue; continue;
if (auto settings = provider->storeSettings(); !settings.is_null()) {
recentFile.write(settings.dump(4)); auto path = ProjectFile::getPath();
ProjectFile::clearPath();
if (auto settings = provider->storeSettings(); !settings.is_null())
recentFile.write(settings.dump(4));
ProjectFile::setPath(path);
}
} }
} }