@@ -4463,10 +4463,7 @@ fn load_editor_project(path: PathBuf, handle: WindowHandle<EditorWindow>, cx: &m
44634463 ) ;
44644464 log_timeline_model ( & summary. timeline ) ;
44654465 let recordings = summary. recordings . clone ( ) ;
4466- if handle
4467- . update ( cx, |view, window, cx| view. set_summary ( summary, window, cx) )
4468- . is_err ( )
4469- {
4466+ if handle. update ( cx, |_, _, _| ( ) ) . is_err ( ) {
44704467 return ;
44714468 }
44724469
@@ -4548,8 +4545,35 @@ fn load_editor_project(path: PathBuf, handle: WindowHandle<EditorWindow>, cx: &m
45484545 } ;
45494546
45504547 tracing:: info!( path = %path. display( ) , "editor instance ready" ) ;
4548+ let ( total, config) = {
4549+ let config = instance. project_config . 1 . borrow ( ) . clone ( ) ;
4550+ let total = config
4551+ . timeline
4552+ . as_ref ( )
4553+ . map_or ( 0.0 , |timeline| timeline. duration ( ) ) ;
4554+ ( total, config)
4555+ } ;
4556+ let has_camera = instance
4557+ . recordings
4558+ . segments
4559+ . iter ( )
4560+ . any ( |segment| segment. camera . is_some ( ) ) ;
4561+ let multiple_clips = instance. recordings . segments . len ( ) > 1 ;
4562+ log_timeline_model ( & editor_timeline:: TimelineModel :: build (
4563+ & config,
4564+ has_camera,
4565+ multiple_clips,
4566+ ) ) ;
45514567 if handle
4552- . update ( cx, |view, _window, _cx| view. set_instance ( instance. clone ( ) ) )
4568+ . update ( cx, |view, window, cx| {
4569+ // Loading controls can queue a save before the engine is ready.
4570+ // Publish the loaded config and instance together so those edits
4571+ // cannot replace the saved project with the initial defaults.
4572+ view. pending_save ( ) . borrow_mut ( ) . discard ( ) ;
4573+ view. set_summary ( summary, window, cx) ;
4574+ view. set_project ( config, window, cx) ;
4575+ view. set_instance ( instance. clone ( ) ) ;
4576+ } )
45534577 . is_err ( )
45544578 {
45554579 instance. dispose ( ) . await ;
@@ -4659,44 +4683,6 @@ fn load_editor_project(path: PathBuf, handle: WindowHandle<EditorWindow>, cx: &m
46594683 } )
46604684 . detach ( ) ;
46614685
4662- // `totalDuration()` (`context.ts:1374-1380`). Read off the instance
4663- // rather than the pre-flight, because `EditorInstance::new`
4664- // synthesises a timeline for a raw bundle -- and `timeline.duration()`
4665- // is exactly what the playback engine stops at
4666- // (`playback.rs:560-570`).
4667- //
4668- // The whole track model comes from the same read: the config the
4669- // instance actually loaded is the one being rendered, holds, clip
4670- // offsets and all. E4 hands the window the config itself rather than
4671- // the derived model, because it is what every edit mutates and what
4672- // the debounced save writes back.
4673- let ( total, config) = {
4674- let config = instance. project_config . 1 . borrow ( ) . clone ( ) ;
4675- let total = config
4676- . timeline
4677- . as_ref ( )
4678- . map_or ( 0.0 , |timeline| timeline. duration ( ) ) ;
4679- ( total, config)
4680- } ;
4681- {
4682- let has_camera = instance
4683- . recordings
4684- . segments
4685- . iter ( )
4686- . any ( |segment| segment. camera . is_some ( ) ) ;
4687- let multiple_clips = instance. recordings . segments . len ( ) > 1 ;
4688- log_timeline_model ( & editor_timeline:: TimelineModel :: build (
4689- & config,
4690- has_camera,
4691- multiple_clips,
4692- ) ) ;
4693- }
4694- if handle
4695- . update ( cx, |view, window, cx| view. set_project ( config, window, cx) )
4696- . is_err ( )
4697- {
4698- return ;
4699- }
47004686 load_editor_waveforms ( instance. clone ( ) , handle, cx) ;
47014687
47024688 if handle
@@ -4805,14 +4791,7 @@ fn load_editor_waveforms(
48054791 ( & segment. audio , & mut mic) ,
48064792 ( & segment. system_audio , & mut system) ,
48074793 ] {
4808- match loader. get ( ) . await {
4809- Ok ( Some ( audio) ) => {
4810- out. push ( ( audio. samples ( ) . to_vec ( ) , audio. channels ( ) ) )
4811- }
4812- // A failed track is an empty waveform; playback and
4813- // export surface the actual error.
4814- _ => out. push ( ( Vec :: new ( ) , 1 ) ) ,
4815- }
4794+ out. push ( loader. get ( ) . await . ok ( ) . flatten ( ) ) ;
48164795 }
48174796 }
48184797 ( mic, system)
@@ -4824,15 +4803,21 @@ fn load_editor_waveforms(
48244803 let peaks = cx
48254804 . background_executor ( )
48264805 . spawn ( async move {
4827- let extract = | tracks : Vec < ( Vec < f32 > , u16 ) > | {
4806+ let [ mic , system ] = [ mic , system ] . map ( |tracks | {
48284807 tracks
48294808 . into_iter ( )
4830- . map ( |( samples, channels) | {
4831- Arc :: new ( editor_timeline:: waveform_peaks ( & samples, channels) )
4809+ . map ( |audio| {
4810+ Arc :: new ( match audio {
4811+ Some ( audio) => editor_timeline:: waveform_peaks (
4812+ audio. samples ( ) ,
4813+ audio. channels ( ) ,
4814+ ) ,
4815+ None => Vec :: new ( ) ,
4816+ } )
48324817 } )
48334818 . collect :: < Vec < _ > > ( )
4834- } ;
4835- ( extract ( mic) , extract ( system) )
4819+ } ) ;
4820+ ( mic, system)
48364821 } )
48374822 . await ;
48384823 let _ = handle. update ( cx, |view, window, cx| {
0 commit comments