Commit bba5a790 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Solved bugs when moving clips between tracks

parent fa3301d4
...@@ -210,13 +210,17 @@ Clip* ClipWorkflow::getClip() ...@@ -210,13 +210,17 @@ Clip* ClipWorkflow::getClip()
void ClipWorkflow::stop() void ClipWorkflow::stop()
{ {
Q_ASSERT( m_mediaPlayer != NULL ); if ( m_mediaPlayer )
m_mediaPlayer->stop(); {
disconnect( m_mediaPlayer, SIGNAL( endReached() ), this, SLOT( clipEndReached() ) ); m_mediaPlayer->stop();
m_mediaPlayer = NULL; disconnect( m_mediaPlayer, SIGNAL( endReached() ), this, SLOT( clipEndReached() ) );
setState( Stopped ); m_mediaPlayer = NULL;
QMutexLocker lock( m_requiredStateLock ); setState( Stopped );
m_requiredState = ClipWorkflow::None; QMutexLocker lock( m_requiredStateLock );
m_requiredState = ClipWorkflow::None;
}
else
qDebug() << "ClipWorkflow has already been stopped";
} }
void ClipWorkflow::setPosition( float pos ) void ClipWorkflow::setPosition( float pos )
......
...@@ -64,7 +64,6 @@ void MainWorkflow::addClip( Clip* clip, unsigned int trackId, qint64 start ) ...@@ -64,7 +64,6 @@ void MainWorkflow::addClip( Clip* clip, unsigned int trackId, qint64 start )
Q_ASSERT_X( trackId < m_trackCount, "MainWorkflow::addClip", Q_ASSERT_X( trackId < m_trackCount, "MainWorkflow::addClip",
"The specified trackId isn't valid, for it's higher than the number of tracks"); "The specified trackId isn't valid, for it's higher than the number of tracks");
// qDebug() << "MainWorkflow: Adding clip" << clip->getUuid() << "to track" << trackId;
//if the track is deactivated, we need to reactivate it : //if the track is deactivated, we need to reactivate it :
if ( m_tracks[trackId].deactivated() == true ) if ( m_tracks[trackId].deactivated() == true )
m_tracks[trackId].activate(); m_tracks[trackId].activate();
...@@ -102,9 +101,7 @@ unsigned char* MainWorkflow::getOutput() ...@@ -102,9 +101,7 @@ unsigned char* MainWorkflow::getOutput()
if ( m_tracks[i].activated() == false ) if ( m_tracks[i].activated() == false )
continue ; continue ;
if ( ( ret = m_tracks[i]->getOutput( m_currentFrame ) ) != NULL ) if ( ( ret = m_tracks[i]->getOutput( m_currentFrame ) ) != NULL )
{
break ; break ;
}
} }
if ( ret == NULL ) if ( ret == NULL )
ret = MainWorkflow::blackOutput; ret = MainWorkflow::blackOutput;
...@@ -198,20 +195,17 @@ void MainWorkflow::clipMoved( QUuid clipUuid, int oldTrack, int newTra ...@@ -198,20 +195,17 @@ void MainWorkflow::clipMoved( QUuid clipUuid, int oldTrack, int newTra
{ {
Q_ASSERT( newTrack < m_trackCount && oldTrack < m_trackCount && oldTrack >= 0 && newTrack >= 0 ); Q_ASSERT( newTrack < m_trackCount && oldTrack < m_trackCount && oldTrack >= 0 && newTrack >= 0 );
//If the frame was stopped, reactivating it, since it can have something to render after
//the clip displacement
if ( m_tracks[newTrack].activated() == false )
m_tracks[newTrack].activate();
if ( oldTrack == newTrack ) if ( oldTrack == newTrack )
{ {
//And now, just move the clip. //And now, just move the clip.
m_tracks[newTrack]->moveClip( clipUuid, startingFrame ); m_tracks[newTrack]->moveClip( clipUuid, startingFrame );
m_tracks[newTrack].activate();
} }
else else
{ {
if ( m_tracks[oldTrack].activated() == false )
m_tracks[oldTrack].activate();
Clip* clip = m_tracks[oldTrack]->removeClip( clipUuid ); Clip* clip = m_tracks[oldTrack]->removeClip( clipUuid );
m_tracks[newTrack]->addClip( clip, startingFrame ); m_tracks[newTrack]->addClip( clip, startingFrame );
m_tracks[oldTrack].activate();
m_tracks[newTrack].activate();
} }
} }
...@@ -190,7 +190,7 @@ void TrackWorkflow::stopClipWorkflow( ClipWorkflow* cw ) ...@@ -190,7 +190,7 @@ void TrackWorkflow::stopClipWorkflow( ClipWorkflow* cw )
} }
else else
{ {
// qDebug() << "Unexpected ClipWorkflow::State when stopping :" << cw->getState(); qDebug() << "Unexpected ClipWorkflow::State when stopping :" << cw->getState();
cw->getStateLock()->unlock(); cw->getStateLock()->unlock();
} }
} }
...@@ -261,7 +261,9 @@ unsigned char* TrackWorkflow::getOutput( qint64 currentFrame ) ...@@ -261,7 +261,9 @@ unsigned char* TrackWorkflow::getOutput( qint64 currentFrame )
} }
//Is it supposed to be stopped ? //Is it supposed to be stopped ?
else else
{
stopClipWorkflow( cw ); stopClipWorkflow( cw );
}
++it; ++it;
} }
...@@ -304,8 +306,11 @@ Clip* TrackWorkflow::removeClip( const QUuid& id ) ...@@ -304,8 +306,11 @@ Clip* TrackWorkflow::removeClip( const QUuid& id )
if ( it.value()->getClip()->getUuid() == id ) if ( it.value()->getClip()->getUuid() == id )
{ {
ClipWorkflow* cw = it.value(); ClipWorkflow* cw = it.value();
Clip* clip = cw->getClip();
m_clips.erase( it ); m_clips.erase( it );
return cw->getClip(); stopClipWorkflow( cw );
delete cw;
return clip;
} }
++it; ++it;
} }
......
...@@ -46,7 +46,7 @@ class Toggleable ...@@ -46,7 +46,7 @@ class Toggleable
} }
T operator->() T operator->()
{ {
Q_ASSERT_X( m_activated == true, "Toggleable<T>::operator->", "Pointer is deactivated" ); // Q_ASSERT_X( m_activated == true, "Toggleable<T>::operator->", "Pointer is deactivated" );
return m_ptr; return m_ptr;
} }
bool activated() const bool activated() const
......
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