@@ -239,7 +239,7 @@ impl EditorHandle {
239
239
wasm_bindgen_futures:: spawn_local ( poll_node_graph_evaluation ( ) ) ;
240
240
241
241
if !EDITOR_HAS_CRASHED . load ( Ordering :: SeqCst ) {
242
- editor_and_handle ( |_ , handle| {
242
+ handle ( | handle| {
243
243
handle. dispatch ( InputPreprocessorMessage :: CurrentTime {
244
244
timestamp : js_sys:: Date :: now ( ) as u64 ,
245
245
} ) ;
@@ -914,27 +914,37 @@ fn set_timeout(f: &Closure<dyn FnMut()>, delay: Duration) {
914
914
fn editor < T : Default > ( callback : impl FnOnce ( & mut editor:: application:: Editor ) -> T ) -> T {
915
915
EDITOR . with ( |editor| {
916
916
let mut guard = editor. try_lock ( ) ;
917
- let Ok ( Some ( editor) ) = guard. as_deref_mut ( ) else { return T :: default ( ) } ;
917
+ let Ok ( Some ( editor) ) = guard. as_deref_mut ( ) else {
918
+ log:: error!( "Failed to borrow editor" ) ;
919
+ return T :: default ( ) ;
920
+ } ;
918
921
919
922
callback ( editor)
920
923
} )
921
924
}
922
925
923
926
/// Provides access to the `Editor` and its `EditorHandle` by calling the given closure with them as arguments.
924
927
pub ( crate ) fn editor_and_handle ( callback : impl FnOnce ( & mut Editor , & mut EditorHandle ) ) {
925
- EDITOR_HANDLE . with ( |editor_handle| {
928
+ handle ( |editor_handle| {
926
929
editor ( |editor| {
927
- let mut guard = editor_handle. try_lock ( ) ;
928
- let Ok ( Some ( editor_handle) ) = guard. as_deref_mut ( ) else {
929
- log:: error!( "Failed to borrow editor handle" ) ;
930
- return ;
931
- } ;
932
-
933
930
// Call the closure with the editor and its handle
934
931
callback ( editor, editor_handle) ;
935
932
} )
936
933
} ) ;
937
934
}
935
+ /// Provides access to the `EditorHandle` by calling the given closure with them as arguments.
936
+ pub ( crate ) fn handle ( callback : impl FnOnce ( & mut EditorHandle ) ) {
937
+ EDITOR_HANDLE . with ( |editor_handle| {
938
+ let mut guard = editor_handle. try_lock ( ) ;
939
+ let Ok ( Some ( editor_handle) ) = guard. as_deref_mut ( ) else {
940
+ log:: error!( "Failed to borrow editor handle" ) ;
941
+ return ;
942
+ } ;
943
+
944
+ // Call the closure with the editor and its handle
945
+ callback ( editor_handle) ;
946
+ } ) ;
947
+ }
938
948
939
949
async fn poll_node_graph_evaluation ( ) {
940
950
// Process no further messages after a crash to avoid spamming the console
0 commit comments