Skip to content

Commit d9e60d2

Browse files
committed
Clipper: Fixed a regresssion when not calling End() + calling End() twice as well. (ocornut#4822)
1 parent 5c8f8d0 commit d9e60d2

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

docs/CHANGELOG.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ Breaking changes:
3939

4040
Other Changes:
4141

42+
- Clipper: Fixed a regression in 1.86 when not calling clipper.End() and late destructing the
43+
clipper instance. High-level languages (Lua,Rust etc.) would typically be affected. (#4822)
4244
- Inputs: Fixed IsMouseClicked() repeat mode rate being half of keyboard repeat rate.
4345
- Stack Tool: Added option to copy item path to clipboard. (#4631)
4446
- Misc: Added constexpr to ImVec2/ImVec4 inline constructors. (#4995) [@Myriachan]

imgui.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2565,15 +2565,14 @@ void ImGuiListClipper::Begin(int items_count, float items_height)
25652565

25662566
void ImGuiListClipper::End()
25672567
{
2568-
// In theory here we should assert that we are already at the right position, but it seems saner to just seek at the end and not assert/crash the user.
25692568
ImGuiContext& g = *GImGui;
2570-
if (ItemsCount >= 0 && ItemsCount < INT_MAX && DisplayStart >= 0)
2571-
ImGuiListClipper_SeekCursorForItem(this, ItemsCount);
2572-
ItemsCount = -1;
2573-
2574-
// Restore temporary buffer and fix back pointers which may be invalidated when nesting
25752569
if (ImGuiListClipperData* data = (ImGuiListClipperData*)TempData)
25762570
{
2571+
// In theory here we should assert that we are already at the right position, but it seems saner to just seek at the end and not assert/crash the user.
2572+
if (ItemsCount >= 0 && ItemsCount < INT_MAX && DisplayStart >= 0)
2573+
ImGuiListClipper_SeekCursorForItem(this, ItemsCount);
2574+
2575+
// Restore temporary buffer and fix back pointers which may be invalidated when nesting
25772576
IM_ASSERT(data->ListClipper == this);
25782577
data->StepNo = data->Ranges.Size;
25792578
if (--g.ClipperTempDataStacked > 0)
@@ -2583,6 +2582,7 @@ void ImGuiListClipper::End()
25832582
}
25842583
TempData = NULL;
25852584
}
2585+
ItemsCount = -1;
25862586
}
25872587

25882588
void ImGuiListClipper::ForceDisplayRangeByIndices(int item_min, int item_max)
@@ -2715,8 +2715,8 @@ bool ImGuiListClipper::Step()
27152715
// Advance the cursor to the end of the list and then returns 'false' to end the loop.
27162716
if (ItemsCount < INT_MAX)
27172717
ImGuiListClipper_SeekCursorForItem(this, ItemsCount);
2718-
ItemsCount = -1;
27192718

2719+
End();
27202720
return false;
27212721
}
27222722

imgui.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Index of this file:
6565
// Version
6666
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
6767
#define IMGUI_VERSION "1.88 WIP"
68-
#define IMGUI_VERSION_NUM 18705
68+
#define IMGUI_VERSION_NUM 18706
6969
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
7070
#define IMGUI_HAS_TABLE
7171

0 commit comments

Comments
 (0)