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

ClipRenderer: Unload previous clip when selecting a new one.

Consistancy: when a clip is removed, use a QUuid. When another action
occured on a clip, use its pointer.
parent d1c5be68
...@@ -97,8 +97,8 @@ ImportController::ImportController(QWidget *parent) : ...@@ -97,8 +97,8 @@ ImportController::ImportController(QWidget *parent) :
m_clipRenderer, SLOT( setClip( Clip* ) ) ); m_clipRenderer, SLOT( setClip( Clip* ) ) );
connect( m_mediaListView, SIGNAL( clipSelected( Clip* ) ), connect( m_mediaListView, SIGNAL( clipSelected( Clip* ) ),
this, SLOT( clipSelection( Clip* ) ) ); this, SLOT( clipSelection( Clip* ) ) );
connect( m_mediaListView, SIGNAL( clipRemoved( const Clip* ) ), connect( m_mediaListView, SIGNAL( clipRemoved( const QUuid& ) ),
m_clipRenderer, SLOT( clipUnloaded( const Clip* ) ) ); m_clipRenderer, SLOT( clipUnloaded( const QUuid& ) ) );
connect( MetaDataManager::getInstance(), SIGNAL( failedToCompute( Media* ) ), connect( MetaDataManager::getInstance(), SIGNAL( failedToCompute( Media* ) ),
this, SLOT( failedToLoad( Media* ) ) ); this, SLOT( failedToLoad( Media* ) ) );
...@@ -132,7 +132,6 @@ ImportController::clipSelection( Clip* clip ) ...@@ -132,7 +132,6 @@ ImportController::clipSelection( Clip* clip )
const QUuid& uuid = clip->uuid(); const QUuid& uuid = clip->uuid();
if ( m_currentUuid == uuid ) if ( m_currentUuid == uuid )
return ; return ;
Media* media = clip->rootClip()->getMedia();
setUIMetaData( clip->rootClip() ); setUIMetaData( clip->rootClip() );
m_preview->stop(); m_preview->stop();
m_currentUuid = uuid; m_currentUuid = uuid;
...@@ -323,7 +322,7 @@ ImportController::failedToLoad( Media *media ) ...@@ -323,7 +322,7 @@ ImportController::failedToLoad( Media *media )
m_ui->errorLabelImg->show(); m_ui->errorLabelImg->show();
m_ui->errorLabel->show(); m_ui->errorLabel->show();
QTimer::singleShot( 3000, this, SLOT( hideErrors() ) ); QTimer::singleShot( 3000, this, SLOT( hideErrors() ) );
delete m_temporaryMedias->removeClip( media->baseClip() ); delete m_temporaryMedias->removeClip( media->baseClip()->uuid() );
delete media; delete media;
} }
......
...@@ -34,8 +34,8 @@ MediaListView::MediaListView( StackViewController* nav, MediaContainer* mc ) : ...@@ -34,8 +34,8 @@ MediaListView::MediaListView( StackViewController* nav, MediaContainer* mc ) :
{ {
connect( mc, SIGNAL( newClipLoaded(Clip*) ), connect( mc, SIGNAL( newClipLoaded(Clip*) ),
this, SLOT( newClipLoaded( Clip* ) ) ); this, SLOT( newClipLoaded( Clip* ) ) );
connect( this, SIGNAL( clipRemoved( const Clip* ) ), connect( this, SIGNAL( clipRemoved( const QUuid& ) ),
mc, SLOT( removeClip( const Clip* ) ) ); mc, SLOT( removeClip( const QUuid& ) ) );
connect( mc, SIGNAL( clipRemoved( const QUuid& ) ), connect( mc, SIGNAL( clipRemoved( const QUuid& ) ),
this, SLOT( __clipRemoved( const QUuid& ) ) ); this, SLOT( __clipRemoved( const QUuid& ) ) );
foreach ( Clip* clip, mc->clips() ) foreach ( Clip* clip, mc->clips() )
...@@ -87,7 +87,7 @@ void MediaListView::cellSelection( const QUuid& uuid ) ...@@ -87,7 +87,7 @@ void MediaListView::cellSelection( const QUuid& uuid )
void MediaListView::removeClip( const Clip* clip ) void MediaListView::removeClip( const Clip* clip )
{ {
__clipRemoved( clip->uuid() ); __clipRemoved( clip->uuid() );
emit clipRemoved( clip ); emit clipRemoved( clip->uuid() );
} }
void void
......
...@@ -69,6 +69,6 @@ private slots: ...@@ -69,6 +69,6 @@ private slots:
signals: signals:
void clipSelected( Clip* ); void clipSelected( Clip* );
void clipRemoved( const Clip* ); void clipRemoved( const QUuid& );
}; };
#endif // MEDIALISTVIEW_H #endif // MEDIALISTVIEW_H
...@@ -163,12 +163,6 @@ MediaContainer::removeClip( const QUuid &uuid ) ...@@ -163,12 +163,6 @@ MediaContainer::removeClip( const QUuid &uuid )
return NULL; return NULL;
} }
Clip*
MediaContainer::removeClip( const Clip* clip )
{
return removeClip( clip->uuid() );
}
const QHash<QUuid, Clip*>& const QHash<QUuid, Clip*>&
MediaContainer::clips() const MediaContainer::clips() const
{ {
......
...@@ -132,9 +132,8 @@ protected: ...@@ -132,9 +132,8 @@ protected:
public slots: public slots:
/** /**
* \brief Delete a Clip from the container * \brief Delete a Clip from the container
* \param clip The clip to remove. * \param uuid The clip to remove's uuid.
*/ */
Clip *removeClip( const Clip* clip );
Clip *removeClip( const QUuid& uuid ); Clip *removeClip( const QUuid& uuid );
/** /**
* \brief Clear the library (remove all the loaded Clip, delete their subclips, and * \brief Clear the library (remove all the loaded Clip, delete their subclips, and
......
...@@ -59,6 +59,10 @@ ClipRenderer::~ClipRenderer() ...@@ -59,6 +59,10 @@ ClipRenderer::~ClipRenderer()
void void
ClipRenderer::setClip( Clip* clip ) ClipRenderer::setClip( Clip* clip )
{ {
if ( m_selectedClip != NULL && clip != NULL &&
clip->uuid() != m_selectedClip->uuid() )
clipUnloaded( m_selectedClip->uuid() );
if ( clip == NULL ) if ( clip == NULL )
{ {
m_selectedClip = NULL; m_selectedClip = NULL;
...@@ -191,12 +195,6 @@ ClipRenderer::clipUnloaded( const QUuid& uuid ) ...@@ -191,12 +195,6 @@ ClipRenderer::clipUnloaded( const QUuid& uuid )
} }
} }
void
ClipRenderer::clipUnloaded( const Clip *clip )
{
clipUnloaded( clip->uuid() );
}
qint64 qint64
ClipRenderer::getCurrentFrame() const ClipRenderer::getCurrentFrame() const
{ {
......
...@@ -77,7 +77,6 @@ public slots: ...@@ -77,7 +77,6 @@ public slots:
*/ */
void setClip( Clip* clip ); void setClip( Clip* clip );
void clipUnloaded( const QUuid& uuid ); void clipUnloaded( const QUuid& uuid );
void clipUnloaded( const Clip* clip );
virtual void previewWidgetCursorChanged( qint64 newFrame ); virtual void previewWidgetCursorChanged( qint64 newFrame );
void updateInfos( Clip* clip ); void updateInfos( Clip* clip );
......
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