Commit 5912bd9f authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

MediaContainer: Don't add the same clip twice in the same container

parent 961f5e83
......@@ -209,5 +209,6 @@ void PreviewWidget::createNewClipFromMarkers()
Clip* part = new Clip( clip, beg, end );
//Adding the newly created clip to the media
clip->addSubclip( part );
if ( clip->addSubclip( part ) == false )
delete part;
}
......@@ -79,11 +79,19 @@ MediaContainer::mediaAlreadyLoaded( const QFileInfo& fileInfo )
return false;
}
void
bool
MediaContainer::addClip( Clip* clip )
{
foreach ( Clip* c, m_clips.values() )
{
if ( clip->uuid() == c->uuid() ||
( clip->getMedia()->fileInfo() == clip->getMedia()->fileInfo() &&
( clip->begin() == c->begin() && clip->end() == c->end() ) ) )
return false;
}
m_clips[clip->uuid()] = clip;
emit newClipLoaded( clip );
return true;
}
void
......
......@@ -70,15 +70,17 @@ public:
* \param fileInfo The file infos
* \return true if the file is already loaded, false otherwhise
*/
bool mediaAlreadyLoaded( const QFileInfo& fileInfo );
bool mediaAlreadyLoaded( const QFileInfo& fileInfo );
/**
* \brief Add a clip.
*
* This will emit the newClipLoaded signal.
* The method will first check for an identic clip existence.
* This will emit the newClipLoaded signal if the Clip is added.
*
* \param clip The clip to be added.
* \return true if the Clip has been added.
*/
void addClip( Clip* clip );
bool addClip( Clip* clip );
/**
* \return All the loaded Clip
......
......@@ -280,10 +280,10 @@ Clip::getChilds() const
return m_childs;
}
void
bool
Clip::addSubclip( Clip *clip )
{
m_childs->addClip( clip );
return m_childs->addClip( clip );
}
void
......
......@@ -122,7 +122,7 @@ class Clip : public QObject
*/
void clear();
void addSubclip( Clip* clip );
bool addSubclip( Clip* clip );
private:
Media *m_media;
......
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