Skip to content

Commit

Permalink
Avoid some Id clashes by seeding auto-ids with child id (#4840)
Browse files Browse the repository at this point in the history
I was having trouble with id collisions and was not able to resolve it
using `push_id` and `child_ui_with_id_source`.

When investigating the issue I found
#2262 which matched the issues I had
so I forked egui and implemented the changes from that PR for the latest
version.

It solved the issue for me.

I did not notice any regressions in my project or the egui web viewer.

Co-authored-by: Emil Ernerfeldt <[email protected]>
  • Loading branch information
ironpeak and emilk authored Aug 27, 2024
1 parent 82814c4 commit 0f8614d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crates/egui/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,11 @@ impl Ui {
}

debug_assert!(!max_rect.any_nan());
let next_auto_id_source = Id::new(self.next_auto_id_source).with("child").value();
let new_id = self.id.with(id_source);
let next_auto_id_source = new_id.with(self.next_auto_id_source).value();

self.next_auto_id_source = self.next_auto_id_source.wrapping_add(1);

let new_id = self.id.with(id_source);
let placer = Placer::new(max_rect, layout);
let ui_stack = UiStack {
id: new_id,
Expand Down

0 comments on commit 0f8614d

Please sign in to comment.