diff --git a/src/libtomahawk/Source.cpp b/src/libtomahawk/Source.cpp index 38bef3265..4dbc600da 100644 --- a/src/libtomahawk/Source.cpp +++ b/src/libtomahawk/Source.cpp @@ -67,7 +67,7 @@ Source::Source( int id, const QString& username ) m_currentTrackTimer.setSingleShot( true ); connect( &m_currentTrackTimer, SIGNAL( timeout() ), this, SLOT( trackTimerFired() ) ); - + if ( m_isLocal ) { connect( Accounts::AccountManager::instance(), SIGNAL( connected( Tomahawk::Accounts::Account* ) ), SLOT( setOnline() ) ); @@ -251,7 +251,7 @@ Source::setOffline() void Source::setOnline() { - qDebug() << Q_FUNC_INFO << friendlyName(); + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << friendlyName(); if ( m_online ) return; diff --git a/src/libtomahawk/SourceList.cpp b/src/libtomahawk/SourceList.cpp index 7c009602f..c105e940c 100644 --- a/src/libtomahawk/SourceList.cpp +++ b/src/libtomahawk/SourceList.cpp @@ -185,7 +185,7 @@ SourceList::get( int id ) const source_ptr -SourceList::get( const QString& username, const QString& friendlyName ) +SourceList::get( const QString& username, const QString& friendlyName, bool autoCreate ) { QMutexLocker lock( &m_mut ); @@ -197,9 +197,13 @@ SourceList::get( const QString& username, const QString& friendlyName ) if ( !m_sources.contains( username ) ) { - source = source_ptr( new Source( -1, username ) ); - source->setFriendlyName( friendlyName ); - add( source ); + if ( autoCreate ) + { + Q_ASSERT( !friendlyName.isEmpty() ); + source = source_ptr( new Source( -1, username ) ); + source->setFriendlyName( friendlyName ); + add( source ); + } } else { diff --git a/src/libtomahawk/SourceList.h b/src/libtomahawk/SourceList.h index b6f168e59..b0e3d1f06 100644 --- a/src/libtomahawk/SourceList.h +++ b/src/libtomahawk/SourceList.h @@ -51,7 +51,7 @@ public: QList<Tomahawk::source_ptr> sources( bool onlyOnline = false ) const; unsigned int count() const; - Tomahawk::source_ptr get( const QString& username, const QString& friendlyName = QString() ); + Tomahawk::source_ptr get( const QString& username, const QString& friendlyName = QString(), bool autoCreate = false ); Tomahawk::source_ptr get( int id ) const; signals: diff --git a/src/libtomahawk/network/ControlConnection.cpp b/src/libtomahawk/network/ControlConnection.cpp index 384a91cf2..47686fc1a 100644 --- a/src/libtomahawk/network/ControlConnection.cpp +++ b/src/libtomahawk/network/ControlConnection.cpp @@ -129,7 +129,7 @@ ControlConnection::setup() tDebug() << "Detected name:" << name() << friendlyName << m_sock->peerAddress(); // setup source and remote collection for this peer - m_source = SourceList::instance()->get( id(), friendlyName ); + m_source = SourceList::instance()->get( id(), friendlyName, true ); m_source->setControlConnection( this ); // delay setting up collection/etc until source is synced.