Sequencer - Fixed yet another dangling pointer
Curves referenced through a pointer were being deleted in batch, causing some of the later curves to point to random shit.
This commit is contained in:
parent
f066299c30
commit
651067ef78
1 changed files with 9 additions and 1 deletions
|
@ -328,10 +328,11 @@ void SyncEditor::DeleteSegment(
|
||||||
|
|
||||||
auto& undo{ dynamic_cast< T_UndoSyncChanges& >(
|
auto& undo{ dynamic_cast< T_UndoSyncChanges& >(
|
||||||
Common::Undo( ).add< T_UndoSyncChanges >( ) ) };
|
Common::Undo( ).add< T_UndoSyncChanges >( ) ) };
|
||||||
|
T_AutoArray< T_String , 8 > dcNames; // Curves to delete
|
||||||
for ( auto i = 0u ; i < nc ; i ++ ) {
|
for ( auto i = 0u ; i < nc ; i ++ ) {
|
||||||
if ( curves[ i ]->segments.size( ) == 1 ) {
|
if ( curves[ i ]->segments.size( ) == 1 ) {
|
||||||
undo.curveDeletion( *curves[ i ] );
|
undo.curveDeletion( *curves[ i ] );
|
||||||
sync.removeCurve( curves[ i ]->name );
|
dcNames.add( curves[ i ]->name );
|
||||||
} else {
|
} else {
|
||||||
auto nCurve{ *curves[ i ] };
|
auto nCurve{ *curves[ i ] };
|
||||||
nCurve.segments.remove( segmentIndex );
|
nCurve.segments.remove( segmentIndex );
|
||||||
|
@ -339,6 +340,13 @@ void SyncEditor::DeleteSegment(
|
||||||
sync.setCurve( std::move( nCurve ) );
|
sync.setCurve( std::move( nCurve ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We delete curves that need to be deleted now, in order to avoid
|
||||||
|
// using dangling curve pointers in the loop above
|
||||||
|
const auto nd{ dcNames.size( ) };
|
||||||
|
for ( auto i = 0u ; i < nd ; i ++ ) {
|
||||||
|
sync.removeCurve( dcNames[ i ] );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
Loading…
Reference in a new issue