From d79186931e663941f41aad7bb05c8b8f5f538ed9 Mon Sep 17 00:00:00 2001 From: ocornut Date: Sat, 11 Jun 2016 15:42:10 +0200 Subject: [PATCH] ImDrawList: Fixed a (rarely occuring) bug with merging with previous command + unnecessary OverlayDrawList command --- imgui.cpp | 1 - imgui_draw.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index d71e611a..9e392d30 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2066,7 +2066,6 @@ void ImGui::NewFrame() g.OverlayDrawList.Clear(); g.OverlayDrawList.PushTextureID(g.IO.Fonts->TexID); g.OverlayDrawList.PushClipRectFullScreen(); - g.OverlayDrawList.AddDrawCmd(); // Mark rendering data as invalid to prevent user who may have a handle on it to use it g.RenderDrawData.Valid = false; diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 5f485481..ba20abc8 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -196,7 +196,7 @@ void ImDrawList::UpdateClipRect() // Try to merge with previous command if it matches, else use current command ImDrawCmd* prev_cmd = CmdBuffer.Size > 1 ? curr_cmd - 1 : NULL; - if (prev_cmd && memcmp(&prev_cmd->ClipRect, &curr_clip_rect, sizeof(ImVec4)) == 0 && prev_cmd->TextureId == GetCurrentTextureId() && prev_cmd->UserCallback == NULL) + if (curr_cmd->ElemCount == 0 && prev_cmd && memcmp(&prev_cmd->ClipRect, &curr_clip_rect, sizeof(ImVec4)) == 0 && prev_cmd->TextureId == GetCurrentTextureId() && prev_cmd->UserCallback == NULL) CmdBuffer.pop_back(); else curr_cmd->ClipRect = curr_clip_rect;