Skip to content

Commit 4819eae

Browse files
committed
Clipper: Fixed an issue where passing an out of bound index to IncludeItemByIndex() could incorrectly offset the final cursor.
One case where it would manifest was calling Combo() with an out of range index. (#8450)
1 parent c5ade65 commit 4819eae

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

docs/CHANGELOG.txt

+3
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ Other changes:
103103
(#8451, #7660) [@achabense]
104104
- TextLinkOpenURL(): fixed default Win32 io.PlatformOpenInShellFn handler to
105105
handle UTF-8 regardless of system regional settings. (#7660) [@achabense]
106+
- Clipper: Fixed an issue where passing an out of bound index to IncludeItemByIndex()
107+
could incorrectly offset the final cursor, even if that index was not iterated through.
108+
One case where it would manifest was calling Combo() with an out of range index. (#8450)
106109
- Debug Tools: Added io.ConfigDebugHighlightIdConflictsShowItemPicker (defaults to true)
107110
to allow disabled Item Picker suggestion in user facing builds. (#7961, #7669)
108111
- Misc: Added ImGuiMouseCursor_Wait and ImGuiMouseCursor_Progress mouse cursors

imgui.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -3258,11 +3258,11 @@ static bool ImGuiListClipper_StepInternal(ImGuiListClipper* clipper)
32583258
{
32593259
clipper->DisplayStart = ImMax(data->Ranges[data->StepNo].Min, already_submitted);
32603260
clipper->DisplayEnd = ImMin(data->Ranges[data->StepNo].Max, clipper->ItemsCount);
3261-
if (clipper->DisplayStart > already_submitted) //-V1051
3262-
clipper->SeekCursorForItem(clipper->DisplayStart);
32633261
data->StepNo++;
3264-
if (clipper->DisplayStart == clipper->DisplayEnd && data->StepNo < data->Ranges.Size)
3262+
if (clipper->DisplayStart >= clipper->DisplayEnd)
32653263
continue;
3264+
if (clipper->DisplayStart > already_submitted)
3265+
clipper->SeekCursorForItem(clipper->DisplayStart);
32663266
return true;
32673267
}
32683268

@@ -3279,7 +3279,7 @@ bool ImGuiListClipper::Step()
32793279
ImGuiContext& g = *Ctx;
32803280
bool need_items_height = (ItemsHeight <= 0.0f);
32813281
bool ret = ImGuiListClipper_StepInternal(this);
3282-
if (ret && (DisplayStart == DisplayEnd))
3282+
if (ret && (DisplayStart >= DisplayEnd))
32833283
ret = false;
32843284
if (g.CurrentTable && g.CurrentTable->IsUnfrozenRows == false)
32853285
IMGUI_DEBUG_LOG_CLIPPER("Clipper: Step(): inside frozen table row.\n");

0 commit comments

Comments
 (0)