Commit e5719f60 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

SequenceWorkflow: Fix resize undo/redo

We now duplicate the clips when resizing, otherwise multiple clips would
share the same begin/end during the resize
parent 48a501d7
......@@ -132,7 +132,15 @@ SequenceWorkflow::resizeClip( const QUuid& uuid, qint64 newBegin, qint64 newEnd,
auto trackId = c->trackId;
auto position = c->pos;
auto t = track( trackId, c->isAudio );
auto ret = t->resizeClip( t->clipIndexAt( position ), newBegin, newEnd );
auto clipIndex = t->clipIndexAt( position );
// This will only duplicate the clip once; no need to panic about endless duplications
if ( c->duplicateClipForResize( newBegin, newEnd ) == true )
{
vlmcDebug() << "Duplicating clip for resize" << c->uuid << "is now using" << c->clip->uuid();
t->remove( clipIndex );
t->insertAt( *c->clip->input(), position );
}
auto ret = t->resizeClip( clipIndex, newBegin, newEnd );
if ( ret == false )
return false;
ret = moveClip( uuid, trackId, newPos );
......@@ -334,5 +342,16 @@ SequenceWorkflow::ClipInstance::ClipInstance(QSharedPointer<::Clip> c, const QUu
, trackId( tId )
, pos( p )
, isAudio( isAudio )
, m_hasClonedClip( false )
{
}
bool
SequenceWorkflow::ClipInstance::duplicateClipForResize( qint64 begin, qint64 end )
{
if ( m_hasClonedClip == true )
return false;
clip = clip->media()->cut( begin, end );
m_hasClonedClip = true;
return true;
}
......@@ -67,6 +67,17 @@ class SequenceWorkflow : public QObject
QVector<QUuid> linkedClips;
// true is this instance represents an audio track, false otherwise
bool isAudio;
///
/// \brief duplicateClipForResize Duplicates the used clip for enabling it to be resize independently
/// \param begin The new begining for this clip
/// \param end The new end for this clip
///
bool duplicateClipForResize( qint64 begin, qint64 end );
private:
// true if this instance now contains its own Clip
bool m_hasClonedClip;
};
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment