Closed uzername closed 1 year ago
I'd suggest, that if char* element is NULL then assume that it's an empty string, for display.
I don't think Dear ImGui should be trying to guess what you meant here. If you want an empty string you should pass in an empty string.
It's pretty typical for C/C++ libraries to allow invalid inputs to simply go bang.
It’s important and intended that we crash on NULL pointer strings. The exception are to accept empty string_view/range, which may force us to backtrack on a few things.
Note that ListBox() is an old wrapper to BeginListBox()/EndListBox(), and using those directly may facilitate things if you need to decide that you want null pointers to be displayed in a specific way.
Version/Branch of Dear ImGui:
Version: 1.89.2 VIP Branch: master. I used download ZIP
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_opengl3.cpp + imgui_impl_glfw.cpp Compiler: Visual Studio 2022 Operating System: Win10
My Issue/Question:
Segfault happening when using ListBox. I have such code for dear ImGui init:
I have such code to be called in main cycle:
Variables are declared like this:
When I try running my project, I get crash in
ImGuiID ImHashStr(const char* data_p, size_t data_size, ImU32 seed)
. On line 1883 I get info thatdata
was null. I guess, it happened because I should initialize my only element of listboxItems. Anyway, I'd like to inform that crash. I'd suggest, that if char* element is NULL then assume that it's an empty string, for display.Screenshots/Video
Standalone, minimal, complete and verifiable example: See above