1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-07 14:46:33 +02:00

Try to avoid race conditions

This commit is contained in:
Leo Franchi
2011-10-13 17:16:39 -04:00
parent 658deb3bcd
commit 0736a65f2a
4 changed files with 21 additions and 8 deletions

View File

@@ -123,13 +123,7 @@ EchonestGenerator::EchonestGenerator ( QObject* parent )
loadStylesAndMoods(); loadStylesAndMoods();
// TODO Yes this is a race condition. If multiple threads initialize echonestgenerator at the exact same time we could run into some issues.
// not dealing with that right now.
if ( s_catalogs == 0 )
s_catalogs = new CatalogManager( this );
connect( s_catalogs, SIGNAL( catalogsUpdated() ), this, SLOT( knownCatalogsChanged() ) ); connect( s_catalogs, SIGNAL( catalogsUpdated() ), this, SLOT( knownCatalogsChanged() ) );
// qDebug() << "ECHONEST:" << m_logo.size();
} }
@@ -138,6 +132,15 @@ EchonestGenerator::~EchonestGenerator()
delete m_dynPlaylist; delete m_dynPlaylist;
} }
void
EchonestGenerator::setupCatalogs()
{
// TODO Yes this is a race condition. If multiple threads initialize echonestgenerator at the exact same time we could run into some issues.
// not dealing with that right now.
if ( s_catalogs == 0 )
s_catalogs = new CatalogManager( 0 );
// qDebug() << "ECHONEST:" << m_logo.size();
}
dyncontrol_ptr dyncontrol_ptr
EchonestGenerator::createControl( const QString& type ) EchonestGenerator::createControl( const QString& type )

View File

@@ -84,6 +84,7 @@ public:
static QStringList userCatalogs(); static QStringList userCatalogs();
static QByteArray catalogId( const QString& collectionId ); static QByteArray catalogId( const QString& collectionId );
static void setupCatalogs();
signals: signals:
void paramsGenerated( const Echonest::DynamicPlaylist::PlaylistParams& ); void paramsGenerated( const Echonest::DynamicPlaylist::PlaylistParams& );

View File

@@ -181,7 +181,7 @@ TomahawkApp::init()
new Pipeline( this ); new Pipeline( this );
m_servent = QWeakPointer<Servent>( new Servent( this ) ); m_servent = QWeakPointer<Servent>( new Servent( this ) );
connect( m_servent.data(), SIGNAL( ready() ), SLOT( initSIP() ) ); connect( m_servent.data(), SIGNAL( ready() ), SLOT( serventReady() ) );
tDebug() << "Init Database."; tDebug() << "Init Database.";
initDatabase(); initDatabase();
@@ -500,6 +500,13 @@ TomahawkApp::initServent()
} }
} }
void
TomahawkApp::serventReady()
{
EchonestGenerator::setupCatalogs();
initSIP();
}
void void
TomahawkApp::initSIP() TomahawkApp::initSIP()

View File

@@ -95,10 +95,12 @@ public slots:
private slots: private slots:
void initServent(); void initServent();
void initSIP(); void serventReady();
void spotifyApiCheckFinished(); void spotifyApiCheckFinished();
private: private:
void initSIP();
void registerMetaTypes(); void registerMetaTypes();
void printHelp(); void printHelp();