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

Library: Don't load unexistant file.

parent c2ac25bd
......@@ -99,9 +99,11 @@ Library::deleteMedia( const QUuid& uuid )
delete m_medias.take( uuid );
}
void
bool
Library::addMedia( const QFileInfo& fileInfo, const QString& uuid )
{
if ( QFile::exists( fileInfo.absoluteFilePath() ) == false )
return false;
Media* media = new Media( fileInfo.filePath(), uuid );
foreach( Media* it, m_medias.values() )
......@@ -109,11 +111,12 @@ Library::addMedia( const QFileInfo& fileInfo, const QString& uuid )
if ( it->fileInfo()->filePath() == media->fileInfo()->filePath() )
{
delete media;
return;
return false;
}
}
MetaDataManager::getInstance()->computeMediaMetadata( media );
addMedia( media );
return true;
}
......@@ -200,7 +203,11 @@ Library::loadProject( const QDomElement& medias )
}
else
{
addMedia( path, uuid );
if ( addMedia( path, uuid ) == false )
{
elem = elem.nextSibling().toElement();
continue ;
}
}
if ( clipList.size() != 0 )
{
......@@ -224,7 +231,6 @@ Library::loadProject( const QDomElement& medias )
}
}
}
elem = elem.nextSibling().toElement();
}
emit projectLoaded();
......
......@@ -87,11 +87,12 @@ public:
/**
* \brief Add a file to the media library
* \param fileInfo the file info of the media
* \return true if the media was successfully loaded. false otherwise.
* \sa addClip( Clip* clip )
* \sa media( const QUuid& uuid)
* \sa clip( const QUuid& uuid )
*/
void addMedia( const QFileInfo& fileInfo, const QString& uuid = QString() );
bool addMedia( const QFileInfo& fileInfo, const QString& uuid = QString() );
/**
* \brief Add the clip to the library
......
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