1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-07 06:36:55 +02:00

* Added a few safety checks.

This commit is contained in:
Christian Muehlhaeuser
2011-02-28 08:43:46 +01:00
parent ef995e1306
commit cb06d11b61
4 changed files with 16 additions and 5 deletions

View File

@@ -11,6 +11,7 @@ using namespace Tomahawk;
DatabaseCollection::DatabaseCollection( const source_ptr& src, QObject* parent )
: Collection( src, QString( "dbcollection:%1" ).arg( src->userName() ), parent )
, m_loadedTracks( false )
{
}
@@ -45,6 +46,8 @@ void
DatabaseCollection::loadTracks()
{
qDebug() << Q_FUNC_INFO << source()->userName();
m_loadedTracks = true;
DatabaseCommand_AllTracks* cmd = new DatabaseCommand_AllTracks( source()->collection() );
connect( cmd, SIGNAL( tracks( QList<Tomahawk::query_ptr>, Tomahawk::collection_ptr ) ),
@@ -107,7 +110,7 @@ DatabaseCollection::tracks()
{
qDebug() << Q_FUNC_INFO;
if ( Collection::tracks().isEmpty() )
if ( !m_loadedTracks )
{
loadTracks();
}

View File

@@ -32,6 +32,9 @@ public slots:
private slots:
void dynamicPlaylistCreated( const Tomahawk::source_ptr& source, const QVariantList& data );
private:
bool m_loadedTracks;
};
#endif // DATABASECOLLECTION_H

View File

@@ -134,10 +134,10 @@ ControlConnection::setupDbSyncConnection( bool ondemand )
if ( m_dbsyncconn )
{
connect( m_dbsyncconn, SIGNAL( finished() ),
m_dbsyncconn, SLOT( deleteLater() ) );
m_dbsyncconn, SLOT( deleteLater() ) );
connect( m_dbsyncconn, SIGNAL( destroyed( QObject* ) ),
SLOT( dbSyncConnFinished( QObject* ) ), Qt::DirectConnection );
SLOT( dbSyncConnFinished( QObject* ) ), Qt::DirectConnection );
}
}
@@ -151,6 +151,8 @@ ControlConnection::dbSyncConnFinished( QObject* c )
//qDebug() << "Setting m_dbsyncconn to NULL";
m_dbsyncconn = NULL;
}
else
qDebug() << "Old DbSyncConn destroyed?!";
}
@@ -158,8 +160,11 @@ DBSyncConnection*
ControlConnection::dbSyncConnection()
{
qDebug() << Q_FUNC_INFO;
if( m_dbsyncconn == NULL )
if ( !m_dbsyncconn )
{
setupDbSyncConnection( true );
Q_ASSERT( m_dbsyncconn );
}
return m_dbsyncconn;
}

View File

@@ -711,7 +711,7 @@ Servent::triggerDBSync()
if ( src.isNull() || src->isLocal() )
continue;
if ( src->controlConnection() && src->controlConnection()->dbSyncConnection() ) // source online?
if ( src->controlConnection() ) // source online?
src->controlConnection()->dbSyncConnection()->trigger();
}
}