From b82e99c0327456fdb14b7db1314314a8084696c9 Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 17 Jun 2019 11:06:36 +0200 Subject: [PATCH] ImDrawList: Fixed CloneOutput() helper crashing. Also removed unnecessary risk from ImDrawList::Clear(), draw lists are being clear before use each frame anyway. (#1860) --- docs/CHANGELOG.txt | 3 ++- imgui_draw.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index cac9990d0..6ee2083ae 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -42,7 +42,8 @@ Breaking Changes: the new names and equivalent. Other Changes: -- ImDrawList::ChannelsSplit(), ImDrawListSlitter: Fixed an issue with merging draw commands between channel 0 and 1. (#2624) +- ImDrawList: Fixed CloneOutput() helper crashing. (#1860) [@gviot] +- ImDrawListSlitter, ImDrawList::ChannelsSplit(), : Fixed an issue with merging draw commands between channel 0 and 1. (#2624) ----------------------------------------------------------------------- diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 53fd4171b..478819cc6 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -365,7 +365,7 @@ void ImDrawList::Clear() CmdBuffer.resize(0); IdxBuffer.resize(0); VtxBuffer.resize(0); - Flags = _Data->InitialFlags; + Flags = _Data ? _Data->InitialFlags : ImDrawListFlags_None; _VtxCurrentOffset = 0; _VtxCurrentIdx = 0; _VtxWritePtr = NULL; @@ -392,7 +392,7 @@ void ImDrawList::ClearFreeMemory() ImDrawList* ImDrawList::CloneOutput() const { - ImDrawList* dst = IM_NEW(ImDrawList(NULL)); + ImDrawList* dst = IM_NEW(ImDrawList(_Data)); dst->CmdBuffer = CmdBuffer; dst->IdxBuffer = IdxBuffer; dst->VtxBuffer = VtxBuffer;