Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

assertion failed: "g.ActiveId == id || g.ActiveId == 0 || g.DragDropActive" in ImGui::MarkItemEdited #2389

Closed
ennis opened this issue Feb 28, 2019 · 3 comments
Labels

Comments

@ennis
Copy link

ennis commented Feb 28, 2019

Version/Branch of Dear ImGui:

Version: 1.69 WIP
Branch: master (1d0b4df)

Back-end/Renderer/Compiler/OS

Tested on imgui_impl_dx9.cpp on latest master and on the OpenGL-based renderer of imgui-rs (which uses ImGui 1.66b via cimgui).
Compiler: MSVC 2017
OS: Windows 10 x64

Issue:

The following assertion

imgui/imgui.cpp

Line 2716 in 1d0b4df

IM_ASSERT(g.ActiveId == id || g.ActiveId == 0 || g.DragDropActive);
triggers with this piece of code, when not enclosed in a Begin/End pair (i.e. going in the default "Debug" window):

static float color[4] = { 0.0f };
ImGui::ColorPicker4("PaperColor", color);

and doing the following, in order:

  • collapsing the "Debug" window by clicking on the arrow in the title bar
  • attempting to drag the collapsed title bar

Call stack / locals

example_win32_directx9.exe!ImGui::MarkItemEdited(unsigned int id) Line 2716
example_win32_directx9.exe!ImGui::ColorPicker4(const char * label, float * col, int flags, const float * ref_col) Line 4518
example_win32_directx9.exe!main(int __formal, char * * __formal) Line 176

g.ActiveId = 0xdaade986
g.DragDropActive = false
id = 0x00000000

Minimal example

//  ... backend-specific code ...
ImGui::NewFrame();
// note lack of Begin/End 
static float color[4] = { 0.0f };
ImGui::ColorPicker4("PaperColor", color);
ImGui::EndFrame();
@ennis
Copy link
Author

ennis commented Feb 28, 2019

Note that i'm not sure that creating a widget outside Begin/End is valid API usage, but it seemed to work fine for other widgets

@ocornut ocornut added the bug label Feb 28, 2019
@ocornut
Copy link
Owner

ocornut commented Feb 28, 2019

Thank you @ennis, I confirmed the repro and the bug.

Note that i'm not sure that creating a widget outside Begin/End is valid API usage, but it seemed to work fine for other widget

It is valid api usage, the widgets goes in the fallback "Debug" window that is automatically pushed on the stack. However this issue also happen in regular window.

ocornut added a commit that referenced this issue Feb 28, 2019
@ocornut
Copy link
Owner

ocornut commented Feb 28, 2019

I have pushed a fix for this issue.

However, this is merely hiding a larger issue, which is that several IsItemXXX functions are not reliable when executed inside a collapsed window. I have some partial-fixes for that in the docking branches but they are not enough, and would like to devise a better fix.

The reason it worked for you within a Begin/End is because you probably tested the return value of Begin (rightly so) and not outputing contents otherwise. In the current API we don't require this test to be done, and if the user submit anything we ignore it. This was initially designed a convenience to be able to call Begin/End without braces. This is effectively causing the Begin/BeginChild/End/EndChild apis to be inconsistent with the other BeginXXX functions and various other issues (to be handled separately).

Closing this as fixed and I took note of the larger bug which I would like to find a solution for.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants