@@ -239,7 +239,7 @@ impl EditorHandle {
239239 wasm_bindgen_futures:: spawn_local ( poll_node_graph_evaluation ( ) ) ;
240240
241241 if !EDITOR_HAS_CRASHED . load ( Ordering :: SeqCst ) {
242- editor_and_handle ( |_ , handle| {
242+ handle ( | handle| {
243243 handle. dispatch ( InputPreprocessorMessage :: CurrentTime {
244244 timestamp : js_sys:: Date :: now ( ) as u64 ,
245245 } ) ;
@@ -914,27 +914,37 @@ fn set_timeout(f: &Closure<dyn FnMut()>, delay: Duration) {
914914fn editor < T : Default > ( callback : impl FnOnce ( & mut editor:: application:: Editor ) -> T ) -> T {
915915 EDITOR . with ( |editor| {
916916 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+ } ;
918921
919922 callback ( editor)
920923 } )
921924}
922925
923926/// Provides access to the `Editor` and its `EditorHandle` by calling the given closure with them as arguments.
924927pub ( crate ) fn editor_and_handle ( callback : impl FnOnce ( & mut Editor , & mut EditorHandle ) ) {
925- EDITOR_HANDLE . with ( |editor_handle| {
928+ handle ( |editor_handle| {
926929 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-
933930 // Call the closure with the editor and its handle
934931 callback ( editor, editor_handle) ;
935932 } )
936933 } ) ;
937934}
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+ }
938948
939949async fn poll_node_graph_evaluation ( ) {
940950 // Process no further messages after a crash to avoid spamming the console
0 commit comments