I ran into this issue but ended up solving it. Posting here anyway since I had it mostly written up, and it may help someone else who's new to imgui someday.
It seems that any window I create crashes if you either:
click on the caret on the left
double click anywhere in the top bar
It doesn't happen for the "Debug" menu that seems to be built in.
I've attached sample code in demo.go.txt (.txt because github doesn't allow .go attachments).
Example triggering the issue:
The error is:
File: /home/runner/work/cimgui-go/cimgui-go/cimgui/imgui/imgui.cpp, Line: 9932
exit status 1
IM_ASSERT_USER_ERROR(g.CurrentWindowStack.Size == 1, "Mismatched Begin/BeginChild vs End/EndChild calls: did you forget to call End/EndChild?");
I debugged it a bit and figured out the issue. I was definitely holding it wrong, but it also feels like a footgun.
My code was:
if imgui.Begin("Sample window") {
imgui.Text("foo")
imgui.End()
}
The problem is that it was calling imgui.Begin() but not imgui.End(). In retrospect this is obvious, but I had for some reason assumed that the boolean returned by Begin indicated whether it began successfully, and if not then I shouldn't try anything else.
The following works, with indentation to make the UI layout more readable when things start getting nested.
I ran into this issue but ended up solving it. Posting here anyway since I had it mostly written up, and it may help someone else who's new to imgui someday.
It seems that any window I create crashes if you either:
It doesn't happen for the "Debug" menu that seems to be built in.
I've attached sample code in demo.go.txt (.txt because github doesn't allow
.go
attachments).Example triggering the issue:
The error is:
That is: https://github.com/gabstv/cimgui-go/blob/main/cimgui/imgui/imgui.cpp#L9932 which states
I debugged it a bit and figured out the issue. I was definitely holding it wrong, but it also feels like a footgun.
My code was:
The problem is that it was calling
imgui.Begin()
but notimgui.End()
. In retrospect this is obvious, but I had for some reason assumed that the boolean returned byBegin
indicated whether it began successfully, and if not then I shouldn't try anything else.The following works, with indentation to make the UI layout more readable when things start getting nested.