Save imgui.ini to %APPDATA%\UsdLayerManager\ instead of CWD
Sets io.IniFilename to %APPDATA%\UsdLayerManager\imgui.ini right after CreateContext so ImGui never touches the working directory for layout persistence. The directory is created on first run via create_directories. m_iniFilePath on ImGuiContext holds the string so the pointer stays valid for the lifetime of the context. Also removes imgui.ini from version control and adds it to .gitignore. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <imgui.h>
|
||||
#include <imgui_impl_win32.h>
|
||||
#include <imgui_impl_opengl3.h>
|
||||
#include <filesystem>
|
||||
|
||||
// Forward declare message handler from imgui_impl_win32.cpp
|
||||
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
@@ -94,6 +95,15 @@ bool ImGuiContext::Initialize(const std::string& windowTitle, int width, int hei
|
||||
// ImGui window is focused, which would block all viewport hotkeys (F, A, etc.).
|
||||
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
||||
|
||||
// Store imgui.ini in %APPDATA%\UsdLayerManager\ so it doesn't litter the CWD.
|
||||
if (const char* appData = getenv("APPDATA")) {
|
||||
std::filesystem::path iniDir =
|
||||
std::filesystem::path(appData) / "UsdLayerManager";
|
||||
std::filesystem::create_directories(iniDir);
|
||||
m_iniFilePath = (iniDir / "imgui.ini").string();
|
||||
io.IniFilename = m_iniFilePath.c_str();
|
||||
}
|
||||
|
||||
// Load Inter font.
|
||||
// The build directory copies the font as Inter.ttc; the install step renames
|
||||
// it to Inter.ttf. Try .ttf first (install layout), fall back to .ttc (build).
|
||||
|
||||
Reference in New Issue
Block a user