Skip to content

Commit c0d852d

Browse files
committed
🚧 fixed partial port of native commit cc2177de
Debug Tools: Added io.ConfigDebugBeginReturnValueOnce / io.ConfigDebugBeginReturnValueLoop options.
1 parent d44d214 commit c0d852d

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

core/src/main/kotlin/imgui/api/demoDebugInformations.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@ interface demoDebugInformations {
281281
}
282282
unindent()
283283
}
284+
285+
checkbox("Debug Begin/BeginChild return value", io::configDebugBeginReturnValueLoop)
286+
sameLine()
287+
metricsHelpMarker("Some calls to Begin()/BeginChild() will return false.\n\nWill cycle through window depths then repeat. Windows should be flickering while running.")
284288
}
285289

286290
// Windows

core/src/main/kotlin/imgui/api/windows.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,14 @@ interface windows {
736736
}
737737
}
738738

739+
// [DEBUG] io.ConfigDebugBeginReturnValue override return value to test Begin/End and BeginChild/EndChild behaviors.
740+
// (The implicit fallback window is NOT automatically ended allowing it to always be able to receive commands without crashing)
741+
if (!window.isFallbackWindow && (g.io.configDebugBeginReturnValueOnce && windowJustCreated || g.io.configDebugBeginReturnValueLoop && g.debugBeginReturnValueCullDepth == g.currentWindowStack.size)) {
742+
if (window.autoFitFrames.x > 0) window.autoFitFrames.x++
743+
if (window.autoFitFrames.y > 0) window.autoFitFrames.y++
744+
return false
745+
}
746+
739747
return !window.skipItems
740748
}
741749

core/src/main/kotlin/imgui/statics/errorCheckingAndDebugTools.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ fun errorCheckEndFrameSanityChecks() {
6767
// to always call End/EndChild even if Begin/BeginChild returns false! (this is unfortunately inconsistent with most other Begin* API).
6868
if (g.currentWindowStack.size != 1)
6969
if (g.currentWindowStack.size > 1) {
70+
val window = g.currentWindowStack.last().window // <-- This window was not Ended!
7071
assert(g.currentWindowStack.size == 1) { "Mismatched Begin/BeginChild vs End/EndChild calls: did you forget to call End/EndChild?" }
72+
// IM_UNUSED(window);
7173
while (g.currentWindowStack.size > 1)
7274
end()
7375
} else

0 commit comments

Comments
 (0)