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

Commit 3068b8c

Browse files
authored
Merge pull request #94 from kamirr/kek/dont_crash_on_removed_node
Allow inserting responses in draw_graph_editor
2 parents 943cd4b + 7cf8181 commit 3068b8c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

egui_node_graph/src/editor_ui.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ where
111111
ui: &mut Ui,
112112
all_kinds: impl NodeTemplateIter<Item = NodeTemplate>,
113113
user_state: &mut UserState,
114+
prepend_responses: Vec<NodeResponse<UserResponse, NodeData>>,
114115
) -> GraphResponse<UserResponse, NodeData> {
115116
// This causes the graph editor to use as much free space as it can.
116117
// (so for windows it will use up to the resizeably set limit
@@ -130,7 +131,7 @@ where
130131

131132
// The responses returned from node drawing have side effects that are best
132133
// executed at the end of this function.
133-
let mut delayed_responses: Vec<NodeResponse<UserResponse, NodeData>> = vec![];
134+
let mut delayed_responses: Vec<NodeResponse<UserResponse, NodeData>> = prepend_responses;
134135

135136
// Used to detect when the background was clicked
136137
let mut click_on_background = false;

egui_node_graph_example/src/app.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,12 @@ impl eframe::App for NodeGraphExample {
417417
});
418418
let graph_response = egui::CentralPanel::default()
419419
.show(ctx, |ui| {
420-
self.state
421-
.draw_graph_editor(ui, AllMyNodeTemplates, &mut self.user_state)
420+
self.state.draw_graph_editor(
421+
ui,
422+
AllMyNodeTemplates,
423+
&mut self.user_state,
424+
Vec::default(),
425+
)
422426
})
423427
.inner;
424428
for node_response in graph_response.node_responses {

0 commit comments

Comments
 (0)