Commit 94e97152 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Library: Ensure every media are loaded before emiting projectLoaded() signal

parent 494f1396
......@@ -38,6 +38,10 @@
#include <QUuid>
#include <QXmlStreamWriter>
Library::Library() : m_nbMediaToLoad( 0 )
{
}
void
Library::loadProject( const QDomElement& doc )
{
......@@ -53,7 +57,10 @@ Library::loadProject( const QDomElement& doc )
{
QString mrl = media.attribute( "mrl" );
Media* m = addMedia( mrl );
connect( m, SIGNAL( metaDataComputed( const Media* ) ),
this, SLOT( mediaLoaded( const Media* ) ), Qt::QueuedConnection );
m_medias[mrl] = m;
++m_nbMediaToLoad;
}
media = media.nextSibling().toElement();
}
......@@ -61,7 +68,6 @@ Library::loadProject( const QDomElement& doc )
if ( clips.isNull() == true )
return ;
load( clips, this );
emit projectLoaded();
}
void
......@@ -81,3 +87,13 @@ Library::saveProject( QXmlStreamWriter& project )
save( project );
project.writeEndElement();
}
void
Library::mediaLoaded( const Media* media )
{
disconnect( media, SIGNAL( metaDataComputed( const Media* ) ),
this, SLOT( mediaLoaded( const Media* ) ) );
--m_nbMediaToLoad;
if ( m_nbMediaToLoad == 0 )
emit projectLoaded();
}
......@@ -57,9 +57,12 @@ class Library : public MediaContainer, public Singleton<Library>
Q_DISABLE_COPY( Library );
private:
Library(){}
Library();
virtual ~Library(){}
private:
quint32 m_nbMediaToLoad;
public slots:
/**
* \brief
......@@ -70,6 +73,9 @@ public slots:
*/
void saveProject( QXmlStreamWriter& project );
private slots:
void mediaLoaded( const Media* m );
signals:
/**
* \brief
......
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