InputText: fixed a crash when handling ImGuiInputTextFlags_CallbackResize. (#9174)

Fix/amend cb3b7ff.
This commit is contained in:
ocornut
2026-03-18 18:37:04 +01:00
parent 27cacb0e30
commit f4c2f50896
2 changed files with 5 additions and 3 deletions

View File

@@ -87,6 +87,8 @@ Other Changes:
signals to be emitted the same way regardless of that setting. (#9001, #9115) signals to be emitted the same way regardless of that setting. (#9001, #9115)
- Fixed a glitch when using ImGuiInputTextFlags_ElideLeft where the local x offset - Fixed a glitch when using ImGuiInputTextFlags_ElideLeft where the local x offset
would be incorrect during the deactivation frame. (#9298) would be incorrect during the deactivation frame. (#9298)
- Fixed a crash introduced in 1.92.6 when handling ImGuiInputTextFlags_CallbackResize
in certain situations. (#9174)
- Style: - Style:
- Border sizes are now scaled (and rounded) by ScaleAllSizes(). - Border sizes are now scaled (and rounded) by ScaleAllSizes().
- When using large values with ScallAllSizes(), the following items thickness - When using large values with ScallAllSizes(), the following items thickness

View File

@@ -4497,7 +4497,7 @@ static bool InputTextFilterCharacter(ImGuiContext* ctx, ImGuiInputTextState* sta
callback_data.Flags = flags; callback_data.Flags = flags;
callback_data.EventFlag = ImGuiInputTextFlags_CallbackCharFilter; callback_data.EventFlag = ImGuiInputTextFlags_CallbackCharFilter;
callback_data.EventChar = (ImWchar)c; callback_data.EventChar = (ImWchar)c;
callback_data.EventActivated = (g.ActiveId == state->ID && g.ActiveIdIsJustActivated); callback_data.EventActivated = (state && g.ActiveId == state->ID && g.ActiveIdIsJustActivated);
callback_data.UserData = user_data; callback_data.UserData = user_data;
if (callback(&callback_data) != 0) if (callback(&callback_data) != 0)
return false; return false;
@@ -5286,7 +5286,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
callback_data.ID = id; callback_data.ID = id;
callback_data.Flags = flags; callback_data.Flags = flags;
callback_data.EventFlag = event_flag; callback_data.EventFlag = event_flag;
callback_data.EventActivated = (g.ActiveId == state->ID && g.ActiveIdIsJustActivated); callback_data.EventActivated = (state && g.ActiveId == state->ID && g.ActiveIdIsJustActivated);
callback_data.UserData = callback_user_data; callback_data.UserData = callback_user_data;
// FIXME-OPT: Undo stack reconcile needs a backup of the data until we rework API, see #7925 // FIXME-OPT: Undo stack reconcile needs a backup of the data until we rework API, see #7925
@@ -5368,7 +5368,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
callback_data.ID = id; callback_data.ID = id;
callback_data.Flags = flags; callback_data.Flags = flags;
callback_data.EventFlag = ImGuiInputTextFlags_CallbackResize; callback_data.EventFlag = ImGuiInputTextFlags_CallbackResize;
callback_data.EventActivated = (g.ActiveId == state->ID && g.ActiveIdIsJustActivated); callback_data.EventActivated = (state != NULL && g.ActiveId == state->ID && g.ActiveIdIsJustActivated);
callback_data.Buf = buf; callback_data.Buf = buf;
callback_data.BufTextLen = apply_new_text_length; callback_data.BufTextLen = apply_new_text_length;
callback_data.BufSize = ImMax(buf_size, apply_new_text_length + 1); callback_data.BufSize = ImMax(buf_size, apply_new_text_length + 1);