Skip to content

Commit 8943803

Browse files
committed
Cleanup in dispatcher
1 parent 2fdcb5b commit 8943803

File tree

1 file changed

+5
-24
lines changed

1 file changed

+5
-24
lines changed

editor/src/dispatcher.rs

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ pub struct Dispatcher {
99
message_queues: Vec<VecDeque<Message>>,
1010
pub responses: Vec<FrontendMessage>,
1111
pub frontend_update_messages: Vec<Message>,
12-
pub queue_frontend_updates: bool,
1312
pub message_handlers: DispatcherMessageHandlers,
1413
}
1514

@@ -44,18 +43,11 @@ impl DispatcherMessageHandlers {
4443
/// The last occurrence of the message in the message queue is sufficient to ensure correct behavior.
4544
/// In addition, these messages do not change any state in the backend (aside from caches).
4645
const SIDE_EFFECT_FREE_MESSAGES: &[MessageDiscriminant] = &[
47-
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::PropertiesPanel(
48-
PropertiesPanelMessageDiscriminant::Refresh,
49-
))),
5046
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::DocumentStructureChanged)),
51-
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::Overlays(OverlaysMessageDiscriminant::Draw))),
5247
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::NodeGraph(
5348
NodeGraphMessageDiscriminant::RunDocumentGraph,
5449
))),
5550
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::SubmitActiveGraphRender),
56-
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::RenderRulers)),
57-
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::RenderScrollbars)),
58-
MessageDiscriminant::Frontend(FrontendMessageDiscriminant::UpdateDocumentLayerStructure),
5951
MessageDiscriminant::Frontend(FrontendMessageDiscriminant::TriggerFontLoad),
6052
];
6153
/// For optimization, these are messages guaranteed to be redundant when repeated.
@@ -69,14 +61,14 @@ const FRONTEND_UPDATE_MESSAGES: &[MessageDiscriminant] = &[
6961
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::Overlays(OverlaysMessageDiscriminant::Draw))),
7062
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::RenderRulers)),
7163
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::RenderScrollbars)),
64+
MessageDiscriminant::Frontend(FrontendMessageDiscriminant::UpdateDocumentLayerStructure),
7265
];
7366
const DEBUG_MESSAGE_BLOCK_LIST: &[MessageDiscriminant] = &[
7467
MessageDiscriminant::Broadcast(BroadcastMessageDiscriminant::TriggerEvent(EventMessageDiscriminant::AnimationFrame)),
7568
MessageDiscriminant::Animation(AnimationMessageDiscriminant::IncrementFrameCounter),
7669
];
7770
// TODO: Find a way to combine these with the list above. We use strings for now since these are the standard variant names used by multiple messages. But having these also type-checked would be best.
78-
const DEBUG_MESSAGE_ENDING_BLOCK_LIST: &[&str] = &[];
79-
// "PointerMove", "PointerOutsideViewport", "Overlays", "Draw", "CurrentTime", "Time"];
71+
const DEBUG_MESSAGE_ENDING_BLOCK_LIST: &[&str] = &["PointerMove", "PointerOutsideViewport", "Overlays", "Draw", "CurrentTime", "Time"];
8072

8173
impl Dispatcher {
8274
pub fn new() -> Self {
@@ -120,7 +112,7 @@ impl Dispatcher {
120112

121113
while let Some(message) = self.message_queues.last_mut().and_then(VecDeque::pop_front) {
122114
// Skip processing of this message if it will be processed later (at the end of the shallowest level queue)
123-
if self.queue_frontend_updates && FRONTEND_UPDATE_MESSAGES.contains(&message.to_discriminant()) {
115+
if FRONTEND_UPDATE_MESSAGES.contains(&message.to_discriminant()) {
124116
let already_in_queue = self.message_queues.first().is_some_and(|queue| queue.contains(&message));
125117
if already_in_queue {
126118
self.cleanup_queues(false);
@@ -156,16 +148,10 @@ impl Dispatcher {
156148
// Process the action by forwarding it to the relevant message handler, or saving the FrontendMessage to be sent to the frontend
157149
match message {
158150
Message::Animation(message) => {
159-
self.message_handlers.animation_message_handler.process_message(message.clone(), &mut queue, ());
160-
161151
if let AnimationMessage::IncrementFrameCounter = &message {
162-
// self.queue_frontend_updates = false;
163-
// log::debug!("dispatching {:?}", self.frontend_update_messages);
164-
165-
self.cleanup_queues(true);
166152
self.message_queues[0].extend(self.frontend_update_messages.drain(..));
167-
// self.queue_frontend_updates = true;
168153
}
154+
self.message_handlers.animation_message_handler.process_message(message, &mut queue, ());
169155
}
170156
Message::AppWindow(message) => {
171157
self.message_handlers.app_window_message_handler.process_message(message, &mut queue, ());
@@ -315,11 +301,7 @@ impl Dispatcher {
315301
}
316302

317303
pub fn poll_node_graph_evaluation(&mut self, responses: &mut VecDeque<Message>) -> Result<(), String> {
318-
let result = self.message_handlers.portfolio_message_handler.poll_node_graph_evaluation(responses);
319-
if !responses.is_empty() && result.is_ok() {
320-
self.queue_frontend_updates = true;
321-
}
322-
result
304+
self.message_handlers.portfolio_message_handler.poll_node_graph_evaluation(responses)
323305
}
324306

325307
/// Create the tree structure for logging the messages as a tree
@@ -344,7 +326,6 @@ impl Dispatcher {
344326
if !is_blocked {
345327
match message_logging_verbosity {
346328
MessageLoggingVerbosity::Off => {}
347-
// MessageLoggingVerbosity::Off |
348329
MessageLoggingVerbosity::Names => {
349330
info!("{}{:?}", Self::create_indents(queues), message.to_discriminant());
350331
}

0 commit comments

Comments
 (0)