Skip to content

Commit d4ddc46

Browse files
committed
InputText: Fixed a crash on deactivating a ReadOnly buffer. (#6570, #6292, #4714)
This will be part of 1.89.7 Tagged relase.
1 parent 40aac58 commit d4ddc46

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

docs/CHANGELOG.txt

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ Other changes:
9292
- CollapsingHeader/TreeNode: Fixed text padding when using _Framed+_Leaf flags. (#6549) [@BobbyAnguelov]
9393
- InputText: Fixed not returning true when buffer is cleared while using the
9494
ImGuiInputTextFlags_EscapeClearsAll flag. (#5688, #2620)
95+
- InputText: Fixed a crash on deactivating a ReadOnly buffer. (#6570, #6292, #4714)
9596
- InputText: ImGuiInputTextCallbackData::InsertChars() accept (NULL,NULL) range, in order to conform
9697
to common idioms (e.g. passing .data(), .data() + .size() from a null string). (#6565, #6566, #3615)
9798
- Combo: Made simple/legacy Combo() function not returns true when picking already selected item.

imgui.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
// Library Version
2626
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
2727
#define IMGUI_VERSION "1.89.7"
28-
#define IMGUI_VERSION_NUM 18970
28+
#define IMGUI_VERSION_NUM 18971
2929
#define IMGUI_HAS_TABLE
3030

3131
/*

imgui_widgets.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -4052,8 +4052,16 @@ void ImGui::InputTextDeactivateHook(ImGuiID id)
40524052
if (id == 0 || state->ID != id)
40534053
return;
40544054
g.InputTextDeactivatedState.ID = state->ID;
4055-
g.InputTextDeactivatedState.TextA.resize(state->CurLenA + 1);
4056-
memcpy(g.InputTextDeactivatedState.TextA.Data, state->TextA.Data ? state->TextA.Data : "", state->CurLenA + 1);
4055+
if (state->Flags & ImGuiInputTextFlags_ReadOnly)
4056+
{
4057+
g.InputTextDeactivatedState.TextA.resize(0); // In theory this data won't be used, but clear to be neat.
4058+
}
4059+
else
4060+
{
4061+
IM_ASSERT(state->TextA.Data != 0);
4062+
g.InputTextDeactivatedState.TextA.resize(state->CurLenA + 1);
4063+
memcpy(g.InputTextDeactivatedState.TextA.Data, state->TextA.Data, state->CurLenA + 1);
4064+
}
40574065
}
40584066

40594067
// Edit a string of text

0 commit comments

Comments
 (0)