Prevent subsequent panics for already borrowed editor (#689)
Fix double panic
This commit is contained in:
parent
91219cbe64
commit
581ed81747
|
|
@ -65,17 +65,22 @@ impl JsEditorHandle {
|
|||
}
|
||||
|
||||
let frontend_messages = EDITOR_INSTANCES.with(|instances| {
|
||||
instances
|
||||
.borrow_mut()
|
||||
instances.try_borrow_mut().map(|mut editors| {
|
||||
editors
|
||||
.get_mut(&self.editor_id)
|
||||
.expect("EDITOR_INSTANCES does not contain the current editor_id")
|
||||
.handle_message(message.into())
|
||||
})
|
||||
});
|
||||
|
||||
if let Ok(frontend_messages) = frontend_messages {
|
||||
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
|
||||
fn send_frontend_message_to_js(&self, message: FrontendMessage) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue