Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListClipper doesn't work with big lists #4591

Closed
snhmibby opened this issue Sep 27, 2021 · 2 comments
Closed

ListClipper doesn't work with big lists #4591

snhmibby opened this issue Sep 27, 2021 · 2 comments

Comments

@snhmibby
Copy link

See also: AllenDang/giu#354

Version/Branch of Dear ImGui:
Version: 1.84.2

Back-end/Renderer/Compiler/OS
Back-ends: through giu library (imgui-go wrapper library)
Compiler: gcc
Operating System: linux

My Issue/Question:
I am trying to display a large hexdump of a several GB file.
I wanted to use ListClipper because it makes a nice scrollbar and I don't know how to make a scrollbar :)

However, when the amount of items in the list is very large (about 10**8 items or more), ListClipper behaves weird, due to what i assume are floating point errors (the last X items do not get displayed) and bugs (if the value is large enough and you scroll down, an assertion gets failed

listclippertest: imgui.cpp:2407: bool ImGuiListClipper::Step(): Assertion `ItemsHeight > 0.0f && "Unable to calculate item height! First item hasn't moved the cursor vertically!"' failed.
SIGABRT: abort

Here is example code to reproduce the problem

        {
                ImGui::Begin("window with clipped list");

                ImGuiListClipper clipper;
                clipper.Begin(pow(10, 8));
                while (clipper.Step()) {
                        for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
                                std::string tmp = std::to_string(i);
                                char const *num_char = tmp.c_str();
                                ImGui::Text(num_char);
                        }
                }
                clipper.End();

                ImGui::End();
        }

@snhmibby
Copy link
Author

I am sorry, the issue doesn't seem to be with ListClipper, but rather that textlineheight * number_of_lines would be bigger than INT_MAX, which i guess means there aren't enough logical pixels for this approach.

@snhmibby
Copy link
Author

I just found #3609.
Good to know the inspiration for my pet project had the same issue ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant