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