Skip to content

Four color pickers in the same window crashes #5707

@marcakafoddex

Description

@marcakafoddex

Version/Branch of Dear ImGui:

Version: 1.88
Branch: master

Back-end/Renderer/Compiler/OS

Back-ends: GLFW + OpenGL3
Compiler: Visual Studio 2022
Operating System: Windows

My Issue/Question:

I have a window with 4 color pickers in it. There are other controls but you can omit them and the problem still persists.
Clicking the 2nd, and 3rd color picker works as expected.
Clicking the 4th color picker does nothing (no color picker is shown).
Clicking the 1st color picker shows TWO color pickers simultaneously, clicking causes a crash with the following stacktrace:

 	ucrtbased.dll!00007ff8105a7475()	Unknown
 	ucrtbased.dll!00007ff8105a7613()	Unknown
 	ucrtbased.dll!00007ff8105bd86d()	Unknown
 	ucrtbased.dll!00007ff8105c34b5()	Unknown
 	ucrtbased.dll!00007ff8105c3027()	Unknown
 	ucrtbased.dll!00007ff8105c10b8()	Unknown
 	ucrtbased.dll!00007ff8105c3a1f()	Unknown
>	example_glfw_opengl3.exe!ImGui::MarkItemEdited(unsigned int id) Line 3524	C++
 	example_glfw_opengl3.exe!ImGui::ColorPicker4(const char * label, float * col, int flags, const float * ref_col) Line 5580	C++
 	example_glfw_opengl3.exe!ImGui::ColorEdit4(const char * label, float * col, int flags) Line 5126	C++
 	example_glfw_opengl3.exe!ImGui::ColorEdit3(const char * label, float * col, int flags) Line 4933	C++
 	example_glfw_opengl3.exe!main(int __formal, char * * __formal) Line 165	C++

Screenshots/Video

Clicking the first color pickers shows to color pickers:
image

Standalone, minimal, complete and verifiable example:
Add the code below to the GLFW OpenGL3 test, compile + run, and click on the first color picker, then select a color, to crash the application.

        // 4. Bug test
        struct Stuff {
            Stuff() {
                memset(this, 0, sizeof(*this));
            }
            float col1[3], col2[3], col3[3], col4[3];
        };
        static Stuff stuff;
        ImGui::Begin("Render Settings");
        ImGui::ColorEdit3("Color", stuff.col4);
        ImGui::ColorEdit3("Ambient color", stuff.col1);
        ImGui::ColorEdit3("Water color", stuff.col2);
        ImGui::ColorEdit3("Color", stuff.col3);
        ImGui::End();

P.S. Unrelated: I love imgui, amazing work, never expected to like this style of GUI programming but I actually do now that I tried it. Tons of kudos for the hard work, and the ease of adding it to any engine/application! It was literally less than 15 minutes to make it work for me. Amazing job!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions