From f3ec608c19462e4829ca2bf5833511290ea770b0 Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 28 Nov 2017 00:32:25 +0100 Subject: [PATCH] Settings: Initializing ImGuiSettingsWindow so external users don't end up with uncleared data. Exposed MarkIniSettingsDirty() in imgui_internal.h --- imgui.cpp | 7 +++++++ imgui_internal.h | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/imgui.cpp b/imgui.cpp index 41b3b621..72dda932 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2725,6 +2725,13 @@ static void SaveIniSettingsToMemory(ImVector& out_buf) out_buf.swap(buf.Buf); } +void ImGui::MarkIniSettingsDirty() +{ + ImGuiContext& g = *GImGui; + if (g.SettingsDirtyTimer <= 0.0f) + g.SettingsDirtyTimer = g.IO.IniSavingRate; +} + static void MarkIniSettingsDirty(ImGuiWindow* window) { ImGuiContext& g = *GImGui; diff --git a/imgui_internal.h b/imgui_internal.h index e5ecb8b0..249dff85 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -378,6 +378,8 @@ struct ImGuiSettingsWindow ImVec2 Pos; ImVec2 Size; bool Collapsed; + + ImGuiSettingsWindow() { Name = NULL; Id = 0; Pos = Size = ImVec2(0,0); Collapsed = false; } }; struct ImGuiSettingsHandler @@ -801,6 +803,8 @@ namespace ImGui IMGUI_API void Initialize(); + IMGUI_API void MarkIniSettingsDirty(); + IMGUI_API void SetActiveID(ImGuiID id, ImGuiWindow* window); IMGUI_API void ClearActiveID(); IMGUI_API void SetHoveredID(ImGuiID id);