zakarumych / egui-snarl

Customizable egui node-graph library
https://crates.io/crates/egui-snarl
MIT License
252 stars 25 forks source link

Adding a body or footer causes a panic #27

Closed pepperoni505 closed 2 months ago

pepperoni505 commented 2 months ago

Adding the following functions to DemoViewer in the sample results in the program panicking: assertion failed: max_rect.is_finite() from egui-0.28.1\src\layout.rs:420:9

fn has_footer(&mut self, node: &DemoNode) -> bool {
    true
}

fn show_footer(
    &mut self,
    node: NodeId,
    inputs: &[InPin],
    outputs: &[OutPin],
    ui: &mut Ui,
    scale: f32,
    snarl: &mut Snarl<DemoNode>,
) {
    ui.button("test");
}

The issue stems from these lines which pass infinity as a parameter to the rect allocation: https://github.com/zakarumych/egui-snarl/blob/b61a98041ad67ab2e9eaabf8cf72352efab81d86/src/ui.rs#L1391-L1392 https://github.com/zakarumych/egui-snarl/blob/b61a98041ad67ab2e9eaabf8cf72352efab81d86/src/ui.rs#L1131-L1134

A suitable (untested!) solution could be to change f32::INFINITY to f32::MAX

zakarumych commented 2 months ago

Thank you for making this issue. It is the same error that was fixed for a header. Caused by new debug assert in egui v0.28.

I fixed in 9aec7c0f395b69823c0d46bf0bba6721cf224386