mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-25 23:28:11 +08:00
Prevent subsequent panics for already borrowed editor (#689)
Fix double panic
This commit is contained in:
@@ -65,16 +65,21 @@ impl JsEditorHandle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let frontend_messages = EDITOR_INSTANCES.with(|instances| {
|
let frontend_messages = EDITOR_INSTANCES.with(|instances| {
|
||||||
instances
|
instances.try_borrow_mut().map(|mut editors| {
|
||||||
.borrow_mut()
|
editors
|
||||||
.get_mut(&self.editor_id)
|
.get_mut(&self.editor_id)
|
||||||
.expect("EDITOR_INSTANCES does not contain the current editor_id")
|
.expect("EDITOR_INSTANCES does not contain the current editor_id")
|
||||||
.handle_message(message.into())
|
.handle_message(message.into())
|
||||||
|
})
|
||||||
});
|
});
|
||||||
for message in frontend_messages.into_iter() {
|
|
||||||
// Send each FrontendMessage to the JavaScript frontend
|
if let Ok(frontend_messages) = frontend_messages {
|
||||||
self.send_frontend_message_to_js(message);
|
for message in frontend_messages.into_iter() {
|
||||||
|
// Send each FrontendMessage to the JavaScript frontend
|
||||||
|
self.send_frontend_message_to_js(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// If the editor cannot be borrowed then it has encountered a panic - we should just ignore new dispatches
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sends a FrontendMessage to JavaScript
|
// Sends a FrontendMessage to JavaScript
|
||||||
|
|||||||
Reference in New Issue
Block a user