mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-02 13:38:13 +08:00
Fix broken animations by removing deadlock (#2993)
* Fix animations not working by removing deadlock * Remove log
This commit is contained in:
@@ -3,6 +3,7 @@ target/
|
|||||||
*.exrc
|
*.exrc
|
||||||
perf.data*
|
perf.data*
|
||||||
profile.json
|
profile.json
|
||||||
|
profile.json.gz
|
||||||
flamegraph.svg
|
flamegraph.svg
|
||||||
.idea/
|
.idea/
|
||||||
.direnv
|
.direnv
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ impl EditorHandle {
|
|||||||
wasm_bindgen_futures::spawn_local(poll_node_graph_evaluation());
|
wasm_bindgen_futures::spawn_local(poll_node_graph_evaluation());
|
||||||
|
|
||||||
if !EDITOR_HAS_CRASHED.load(Ordering::SeqCst) {
|
if !EDITOR_HAS_CRASHED.load(Ordering::SeqCst) {
|
||||||
editor_and_handle(|_, handle| {
|
handle(|handle| {
|
||||||
handle.dispatch(InputPreprocessorMessage::CurrentTime {
|
handle.dispatch(InputPreprocessorMessage::CurrentTime {
|
||||||
timestamp: js_sys::Date::now() as u64,
|
timestamp: js_sys::Date::now() as u64,
|
||||||
});
|
});
|
||||||
@@ -914,7 +914,10 @@ fn set_timeout(f: &Closure<dyn FnMut()>, delay: Duration) {
|
|||||||
fn editor<T: Default>(callback: impl FnOnce(&mut editor::application::Editor) -> T) -> T {
|
fn editor<T: Default>(callback: impl FnOnce(&mut editor::application::Editor) -> T) -> T {
|
||||||
EDITOR.with(|editor| {
|
EDITOR.with(|editor| {
|
||||||
let mut guard = editor.try_lock();
|
let mut guard = editor.try_lock();
|
||||||
let Ok(Some(editor)) = guard.as_deref_mut() else { return T::default() };
|
let Ok(Some(editor)) = guard.as_deref_mut() else {
|
||||||
|
log::error!("Failed to borrow editor");
|
||||||
|
return T::default();
|
||||||
|
};
|
||||||
|
|
||||||
callback(editor)
|
callback(editor)
|
||||||
})
|
})
|
||||||
@@ -922,19 +925,26 @@ fn editor<T: Default>(callback: impl FnOnce(&mut editor::application::Editor) ->
|
|||||||
|
|
||||||
/// Provides access to the `Editor` and its `EditorHandle` by calling the given closure with them as arguments.
|
/// Provides access to the `Editor` and its `EditorHandle` by calling the given closure with them as arguments.
|
||||||
pub(crate) fn editor_and_handle(callback: impl FnOnce(&mut Editor, &mut EditorHandle)) {
|
pub(crate) fn editor_and_handle(callback: impl FnOnce(&mut Editor, &mut EditorHandle)) {
|
||||||
EDITOR_HANDLE.with(|editor_handle| {
|
handle(|editor_handle| {
|
||||||
editor(|editor| {
|
editor(|editor| {
|
||||||
let mut guard = editor_handle.try_lock();
|
|
||||||
let Ok(Some(editor_handle)) = guard.as_deref_mut() else {
|
|
||||||
log::error!("Failed to borrow editor handle");
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Call the closure with the editor and its handle
|
// Call the closure with the editor and its handle
|
||||||
callback(editor, editor_handle);
|
callback(editor, editor_handle);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
/// Provides access to the `EditorHandle` by calling the given closure with them as arguments.
|
||||||
|
pub(crate) fn handle(callback: impl FnOnce(&mut EditorHandle)) {
|
||||||
|
EDITOR_HANDLE.with(|editor_handle| {
|
||||||
|
let mut guard = editor_handle.try_lock();
|
||||||
|
let Ok(Some(editor_handle)) = guard.as_deref_mut() else {
|
||||||
|
log::error!("Failed to borrow editor handle");
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Call the closure with the editor and its handle
|
||||||
|
callback(editor_handle);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async fn poll_node_graph_evaluation() {
|
async fn poll_node_graph_evaluation() {
|
||||||
// Process no further messages after a crash to avoid spamming the console
|
// Process no further messages after a crash to avoid spamming the console
|
||||||
|
|||||||
Reference in New Issue
Block a user