From 33f7769d85fc12c5255919a59d88ec8d540e2589 Mon Sep 17 00:00:00 2001 From: omar Date: Wed, 3 Jan 2018 14:38:01 +0100 Subject: [PATCH] Columns: Clear offsets data when columns count changed. (#1525) --- imgui.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index 71a40d1f..c4239190 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -11004,6 +11004,10 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag window->DC.ColumnsOffsetX = 0.0f; window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.IndentX + window->DC.ColumnsOffsetX); + // Clear data if columns count changed + if (columns->Columns.Size != 0 && columns->Columns.Size != columns_count + 1) + columns->Columns.resize(0); + // Initialize defaults columns->IsFirstFrame = (columns->Columns.Size == 0); if (columns->Columns.Size == 0) @@ -11016,7 +11020,6 @@ void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiColumnsFlag columns->Columns.push_back(column); } } - IM_ASSERT(columns->Columns.Size == columns_count + 1); for (int n = 0; n < columns_count + 1; n++) {