diff --git a/imgui.cpp b/imgui.cpp index 45e0e2a..1025054 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -6570,8 +6570,9 @@ return; ImGuiWindow* window = g.CurrentWindow; - g.LogEnabled = true; + IM_ASSERT(g.LogFile == NULL); g.LogFile = stdout; + g.LogEnabled = true; g.LogStartDepth = window->DC.TreeDepth; if (max_depth >= 0) g.LogAutoExpandMaxDepth = max_depth; @@ -6592,6 +6593,7 @@ return; } + IM_ASSERT(g.LogFile == NULL); g.LogFile = ImFileOpen(filename, "ab"); if (!g.LogFile) { @@ -6612,8 +6614,9 @@ return; ImGuiWindow* window = g.CurrentWindow; - g.LogEnabled = true; + IM_ASSERT(g.LogFile == NULL); g.LogFile = NULL; + g.LogEnabled = true; g.LogStartDepth = window->DC.TreeDepth; if (max_depth >= 0) g.LogAutoExpandMaxDepth = max_depth; @@ -6626,7 +6629,6 @@ return; LogText(IM_NEWLINE); - g.LogEnabled = false; if (g.LogFile != NULL) { if (g.LogFile == stdout) @@ -6640,6 +6642,7 @@ SetClipboardText(g.LogClipboard->begin()); g.LogClipboard->clear(); } + g.LogEnabled = false; } // Helper to display logging buttons