-
Notifications
You must be signed in to change notification settings - Fork 346
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
Rework/simplify ListClipper drop impl #610
Comments
The crash happens in
The crashing call to step is happening via the Drop impl on fn drop(&mut self) {
if !self.step() {
unsafe {
sys::ImGuiListClipper_destroy(self.list_clipper);
};
} else if !thread::panicking() {
panic!( This might be a regression in Dear ImGui, but.. Currently the
..would panic in the case Given this..
Then it seems like we should just update the |
This most likely relates to ocornut/imgui#4822 in some way (although not exactly as that problem was hitting an intentional asser) |
Pushed a fix upstream for this and #611 |
This indeed seems like the right thing to do as per #611 (comment) The drop impl should just call end if it's not already - the extra call to check While changing this, should also investigate if the list clipper should act as an iterator, so instead of let mut clip = imgui::ListClipper::new(table.total_rows() as i32).begin(ui);
while clip.step() {
for row_num in clip.display_start()..clip.display_end() {
ui.text("...")
}
} we can instead write: let mut clip = imgui::ListClipper::new(table.total_rows() as i32).begin(ui);
for row in clip.iter_rows() {
ui.text("...")
} Should be easy to retain both interfaces as both are useful |
1. Avoid calling step() in destructor - incorrect and unnecessary, as it is not required to fully "use" the clipper (you can stop rendering half-way through) 2. Add a harder to misuse iterator interface to the clipper as an alterantive to the C++ style .step() interface Closes imgui-rs#610
1. Avoid calling step() in destructor - incorrect and unnecessary, as it is not required to fully "use" the clipper (you can stop rendering half-way through) 2. Add a harder to misuse iterator interface to the clipper as an alterantive to the C++ style .step() interface Closes imgui-rs#610
If you call
.end
on the list clipper, it'll crash when the destructor also calls the sameI don't think this happened in the last imgui-rs release, but happens in latest main branch (e.g 69fb34f)
The
long_list
example works fine as-is, but crashes if you do this:The text was updated successfully, but these errors were encountered: