Skip to content

Commit f15023e

Browse files
TrueDoctorKeavon
andauthored
Fix regression with double-click in the Path tool not working (#2963)
* Fix double click in path tool not working * Remove debug line --------- Co-authored-by: Keavon Chambers <[email protected]>
1 parent 08ec1d0 commit f15023e

File tree

7 files changed

+45
-26
lines changed

7 files changed

+45
-26
lines changed

editor/src/messages/defer/defer_message.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::messages::prelude::*;
33
#[impl_message(Message, Defer)]
44
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
55
pub enum DeferMessage {
6+
SetGraphSubmissionIndex(u64),
67
TriggerGraphRun(u64),
78
AfterGraphRun { messages: Vec<Message> },
89
TriggerNavigationReady,

editor/src/messages/defer/defer_message_handler.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,23 @@ impl MessageHandler<DeferMessage, ()> for DeferMessageHandler {
1717
DeferMessage::AfterNavigationReady { messages } => {
1818
self.after_viewport_resize.extend_from_slice(&messages);
1919
}
20+
DeferMessage::SetGraphSubmissionIndex(execution_id) => {
21+
self.current_graph_submission_id = execution_id + 1;
22+
}
2023
DeferMessage::TriggerGraphRun(execution_id) => {
21-
self.current_graph_submission_id = execution_id;
22-
for message in self.after_graph_run.extract_if(.., |x| x.0 < self.current_graph_submission_id) {
23-
responses.push_front(message.1);
24+
if self.after_graph_run.is_empty() {
25+
return;
26+
}
27+
// Find the index of the last message we can process
28+
let num_elements_to_remove = self.after_graph_run.binary_search_by_key(&(execution_id + 1), |x| x.0).unwrap_or_else(|pos| pos - 1);
29+
let elements = self.after_graph_run.drain(0..=num_elements_to_remove);
30+
for (_, message) in elements.rev() {
31+
responses.add_front(message);
2432
}
2533
}
2634
DeferMessage::TriggerNavigationReady => {
27-
for message in self.after_viewport_resize.drain(..) {
28-
responses.push_front(message);
35+
for message in self.after_viewport_resize.drain(..).rev() {
36+
responses.add_front(message);
2937
}
3038
}
3139
}

editor/src/messages/portfolio/document/document_message_handler.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,14 +1880,15 @@ impl DocumentMessageHandler {
18801880

18811881
let previous_network = std::mem::replace(&mut self.network_interface, network_interface);
18821882

1883+
// Push the UpdateOpenDocumentsList message to the bus in order to update the save status of the open documents
1884+
responses.add(PortfolioMessage::UpdateOpenDocumentsList);
1885+
responses.add(NodeGraphMessage::SelectedNodesUpdated);
1886+
responses.add(NodeGraphMessage::ForceRunDocumentGraph);
1887+
18831888
// TODO: Remove once the footprint is used to load the imports/export distances from the edge
1884-
responses.push_front(NodeGraphMessage::UnloadWires.into());
1885-
responses.push_front(NodeGraphMessage::SetGridAlignedEdges.into());
1889+
responses.add(NodeGraphMessage::UnloadWires);
1890+
responses.add(NodeGraphMessage::SetGridAlignedEdges);
18861891

1887-
// Push the UpdateOpenDocumentsList message to the bus in order to update the save status of the open documents
1888-
responses.push_front(NodeGraphMessage::ForceRunDocumentGraph.into());
1889-
responses.push_front(NodeGraphMessage::SelectedNodesUpdated.into());
1890-
responses.push_front(PortfolioMessage::UpdateOpenDocumentsList.into());
18911892
Some(previous_network)
18921893
}
18931894
pub fn redo_with_history(&mut self, ipp: &InputPreprocessorMessageHandler, responses: &mut VecDeque<Message>) {

editor/src/messages/portfolio/portfolio_message_handler.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -363,13 +363,15 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
363363
self.executor.update_font_cache(self.persistent_data.font_cache.clone());
364364
for document_id in self.document_ids.iter() {
365365
let inspect_node = self.inspect_node_id();
366-
let _ = self.executor.submit_node_graph_evaluation(
366+
if let Ok(message) = self.executor.submit_node_graph_evaluation(
367367
self.documents.get_mut(document_id).expect("Tried to render non-existent document"),
368368
ipp.viewport_bounds.size().as_uvec2(),
369369
timing_information,
370370
inspect_node,
371371
true,
372-
);
372+
) {
373+
responses.add(message);
374+
}
373375
}
374376

375377
if self.active_document_mut().is_some() {
@@ -846,11 +848,14 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
846848
ignore_hash,
847849
);
848850

849-
if let Err(description) = result {
850-
responses.add(DialogMessage::DisplayDialogError {
851-
title: "Unable to update node graph".to_string(),
852-
description,
853-
});
851+
match result {
852+
Err(description) => {
853+
responses.add(DialogMessage::DisplayDialogError {
854+
title: "Unable to update node graph".to_string(),
855+
description,
856+
});
857+
}
858+
Ok(message) => responses.add(message),
854859
}
855860
}
856861
PortfolioMessage::ToggleRulers => {

editor/src/messages/prelude.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,12 @@ pub trait Responses {
6767
}
6868

6969
impl Responses for VecDeque<Message> {
70+
#[inline(always)]
7071
fn add(&mut self, message: impl Into<Message>) {
7172
self.push_back(message.into());
7273
}
7374

75+
#[inline(always)]
7476
fn add_front(&mut self, message: impl Into<Message>) {
7577
self.push_front(message.into());
7678
}

editor/src/messages/tool/tool_messages/path_tool.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,7 +2229,9 @@ impl Fsm for PathToolFsmState {
22292229
tool_data.snapping_axis = None;
22302230
tool_data.sliding_point_info = None;
22312231

2232-
responses.add(DocumentMessage::EndTransaction);
2232+
if drag_occurred || extend_selection {
2233+
responses.add(DocumentMessage::EndTransaction);
2234+
}
22332235
responses.add(PathToolMessage::SelectedPointUpdated);
22342236
tool_data.snap_manager.cleanup(responses);
22352237
tool_data.opposite_handle_position = None;
@@ -2282,7 +2284,9 @@ impl Fsm for PathToolFsmState {
22822284
tool_data.saved_points_before_anchor_convert_smooth_sharp.clear();
22832285

22842286
responses.add(DocumentMessage::EndTransaction);
2285-
responses.add(PathToolMessage::SelectedPointUpdated);
2287+
responses.add(DeferMessage::AfterGraphRun {
2288+
messages: vec![PathToolMessage::SelectedPointUpdated.into()],
2289+
});
22862290
}
22872291

22882292
return PathToolFsmState::Ready;

editor/src/node_graph_executor.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl NodeGraphExecutor {
133133
}
134134

135135
/// Adds an evaluate request for whatever current network is cached.
136-
pub(crate) fn submit_current_node_graph_evaluation(&mut self, document: &mut DocumentMessageHandler, viewport_resolution: UVec2, time: TimingInformation) -> Result<(), String> {
136+
pub(crate) fn submit_current_node_graph_evaluation(&mut self, document: &mut DocumentMessageHandler, viewport_resolution: UVec2, time: TimingInformation) -> Result<Message, String> {
137137
let render_config = RenderConfig {
138138
viewport: Footprint {
139139
transform: document.metadata().document_to_viewport,
@@ -155,7 +155,7 @@ impl NodeGraphExecutor {
155155

156156
self.futures.insert(execution_id, ExecutionContext { export_config: None });
157157

158-
Ok(())
158+
Ok(DeferMessage::SetGraphSubmissionIndex(execution_id).into())
159159
}
160160

161161
/// Evaluates a node graph, computing the entire graph
@@ -166,11 +166,9 @@ impl NodeGraphExecutor {
166166
time: TimingInformation,
167167
inspect_node: Option<NodeId>,
168168
ignore_hash: bool,
169-
) -> Result<(), String> {
169+
) -> Result<Message, String> {
170170
self.update_node_graph(document, inspect_node, ignore_hash)?;
171-
self.submit_current_node_graph_evaluation(document, viewport_resolution, time)?;
172-
173-
Ok(())
171+
self.submit_current_node_graph_evaluation(document, viewport_resolution, time)
174172
}
175173

176174
/// Evaluates a node graph for export

0 commit comments

Comments
 (0)