Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Cannot use more than one node_graph in an egui app #60

Open
bpostlethwaite opened this issue Sep 1, 2022 · 2 comments
Open

Cannot use more than one node_graph in an egui app #60

bpostlethwaite opened this issue Sep 1, 2022 · 2 comments

Comments

@bpostlethwaite
Copy link
Contributor

NodeIds use slotmaps to hold references. Slotmaps return the same sequence of IDs for a given KeyType.

For example this runs with no panics

use slotmap::SlotMap;

fn main() {
    let mut sm1 = SlotMap::new();
    let mut sm2 = SlotMap::new();
    let sm1_key1 = sm1.insert("foo");
    let sm2_key1 = sm2.insert("bar");

    assert_eq!(sm1_key1, sm2_key1);
}

Egui Node Graph statically assigns the same KeyType to the node_graph slotmap and therefore multiple node_graphs in the same process will return the same keys. Since these keys go into the same "global" egui widget key-space egui complains about identical keys.

@bpostlethwaite
Copy link
Contributor Author

Looking into this more it seems like it should be working. Egui seems to append the ID to the parents ID during hashing, and the parents should be different. I'm not sure why we see ID collisions with multiple node graph instances

@edulecom
Copy link

Hello, I encountered this problem, too. Actually I can have more than one node_graph in the egui app. The problem is when I want to show more than one at the same time. I'm using egui_tiles and until I drag one of them to have two visible at the same time it works. It would be nice to have that fixed. Thanks in advance.

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

No branches or pull requests

2 participants