1
0
mirror of synced 2025-01-18 17:14:13 +01:00

fix: imgui.ini file being created in the working directory sometimes

Fixes #450
This commit is contained in:
WerWolv 2022-02-21 21:55:04 +01:00
parent 75bd7805c9
commit bdb2ac3a0b
2 changed files with 9 additions and 3 deletions

View File

@ -52,6 +52,8 @@ namespace hex {
std::list<std::string> m_popupsToOpen;
std::vector<int> m_pressedKeys;
fs::path m_imguiSettingsPath;
};
}

View File

@ -720,14 +720,16 @@ namespace hex {
handler.UserData = this;
ImGui::GetCurrentContext()->SettingsHandlers.push_back(handler);
static std::string iniFileName;
for (const auto &dir : hex::getPath(ImHexPath::Config)) {
if (std::filesystem::exists(dir)) {
iniFileName = (dir / "interface.ini").string();
this->m_imguiSettingsPath = dir / "interface.ini";
break;
}
}
io.IniFilename = iniFileName.c_str();
io.IniFilename = nullptr;
if (!this->m_imguiSettingsPath.empty() && fs::exists(this->m_imguiSettingsPath))
ImGui::LoadIniSettingsFromDisk(this->m_imguiSettingsPath.string().c_str());
ImGui_ImplGlfw_InitForOpenGL(this->m_window, true);
@ -748,6 +750,8 @@ namespace hex {
ImNodes::PopAttributeFlag();
ImNodes::PopAttributeFlag();
ImGui::SaveIniSettingsToDisk(this->m_imguiSettingsPath.string().c_str());
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImNodes::DestroyContext();