From cc3be5d4289587c7e1b0b29bfe37ab1c94e3aea8 Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 21 Feb 2019 12:25:21 +0100 Subject: [PATCH] InputText: Fixed an edge case crash that would happen if another widget sharing the same ID is being swapped with an InputText that has yet to be activated. --- docs/CHANGELOG.txt | 2 ++ imgui_widgets.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 199882b97..3634bf2c7 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -38,6 +38,8 @@ Other Changes: - InputInt, InputFloat, InputScalar: Fix to keep the label of the +/- buttons centered when style.FramePadding.x is abnormally larger than style.FramePadding.y. Since the buttons are meant to be square (to align with e.g. color button) we always use FramePadding.y. (#2367) +- InputText: Fixed an edge case crash that would happen if another widget sharing the same ID + is being swapped with an InputText that has yet to be activated. - Examples: OpenGL: Fix for OSX not supporting OpenGL 4.5, we don't try to read GL_CLIP_ORIGIN even if the OpenGL headers/loader happens to define the value. (#2366, #2186) diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 4598194f4..6bbd417a6 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -3278,6 +3278,10 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2 clear_active_id = true; } + // We have an edge case if ActiveId was set through another widget (e.g. widget being swapped) + if (g.ActiveId == id && state == NULL) + ClearActiveID(); + bool value_changed = false; bool enter_pressed = false; int backup_current_text_length = 0;