@@ -1431,17 +1431,26 @@ void Timeline::apply_json_to_clips(Json::Value change) {
1431
1431
1432
1432
// Update existing clip
1433
1433
if (existing_clip) {
1434
+ // Calculate start and end frames prior to the update
1435
+ int64_t old_starting_frame = (existing_clip->Position () * info.fps .ToDouble ()) + 1 ;
1436
+ int64_t old_ending_frame = ((existing_clip->Position () + existing_clip->Duration ()) * info.fps .ToDouble ()) + 1 ;
1437
+
1434
1438
// Update clip properties from JSON
1435
1439
existing_clip->SetJsonValue (change[" value" ]);
1436
1440
1437
- // Calculate start and end frames that this impacts, and remove those frames from the cache
1438
- int64_t old_starting_frame = (existing_clip->Position () * info.fps .ToDouble ()) + 1 ;
1439
- int64_t old_ending_frame = ((existing_clip->Position () + existing_clip->Duration ()) * info.fps .ToDouble ()) + 1 ;
1441
+ // Calculate new start and end frames after the update
1442
+ int64_t new_starting_frame = (existing_clip->Position () * info.fps .ToDouble ()) + 1 ;
1443
+ int64_t new_ending_frame = ((existing_clip->Position () + existing_clip->Duration ()) * info.fps .ToDouble ()) + 1 ;
1444
+
1445
+ // Remove both the old and new ranges from the timeline cache
1440
1446
final_cache->Remove (old_starting_frame - 8 , old_ending_frame + 8 );
1447
+ final_cache->Remove (new_starting_frame - 8 , new_ending_frame + 8 );
1441
1448
1442
1449
// Remove cache on clip's Reader (if found)
1443
- if (existing_clip->Reader () && existing_clip->Reader ()->GetCache ())
1450
+ if (existing_clip->Reader () && existing_clip->Reader ()->GetCache ()) {
1444
1451
existing_clip->Reader ()->GetCache ()->Remove (old_starting_frame - 8 , old_ending_frame + 8 );
1452
+ existing_clip->Reader ()->GetCache ()->Remove (new_starting_frame - 8 , new_ending_frame + 8 );
1453
+ }
1445
1454
1446
1455
// Apply framemapper (or update existing framemapper)
1447
1456
if (auto_map_clips) {
@@ -1464,13 +1473,6 @@ void Timeline::apply_json_to_clips(Json::Value change) {
1464
1473
1465
1474
}
1466
1475
1467
- // Calculate start and end frames that this impacts, and remove those frames from the cache
1468
- if (!change[" value" ].isArray () && !change[" value" ][" position" ].isNull ()) {
1469
- int64_t new_starting_frame = (change[" value" ][" position" ].asDouble () * info.fps .ToDouble ()) + 1 ;
1470
- int64_t new_ending_frame = ((change[" value" ][" position" ].asDouble () + change[" value" ][" end" ].asDouble () - change[" value" ][" start" ].asDouble ()) * info.fps .ToDouble ()) + 1 ;
1471
- final_cache->Remove (new_starting_frame - 8 , new_ending_frame + 8 );
1472
- }
1473
-
1474
1476
// Re-Sort Clips (since they likely changed)
1475
1477
sort_clips ();
1476
1478
}
0 commit comments