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

* Prevent source-retrieval from accidentally creating new sources.

This commit is contained in:
Christian Muehlhaeuser
2012-06-22 03:04:43 +02:00
parent a7c3cce720
commit f91d9f30ce
4 changed files with 12 additions and 8 deletions

View File

@@ -67,7 +67,7 @@ Source::Source( int id, const QString& username )
m_currentTrackTimer.setSingleShot( true ); m_currentTrackTimer.setSingleShot( true );
connect( &m_currentTrackTimer, SIGNAL( timeout() ), this, SLOT( trackTimerFired() ) ); connect( &m_currentTrackTimer, SIGNAL( timeout() ), this, SLOT( trackTimerFired() ) );
if ( m_isLocal ) if ( m_isLocal )
{ {
connect( Accounts::AccountManager::instance(), SIGNAL( connected( Tomahawk::Accounts::Account* ) ), SLOT( setOnline() ) ); connect( Accounts::AccountManager::instance(), SIGNAL( connected( Tomahawk::Accounts::Account* ) ), SLOT( setOnline() ) );
@@ -251,7 +251,7 @@ Source::setOffline()
void void
Source::setOnline() Source::setOnline()
{ {
qDebug() << Q_FUNC_INFO << friendlyName(); tDebug( LOGVERBOSE ) << Q_FUNC_INFO << friendlyName();
if ( m_online ) if ( m_online )
return; return;

View File

@@ -185,7 +185,7 @@ SourceList::get( int id ) const
source_ptr source_ptr
SourceList::get( const QString& username, const QString& friendlyName ) SourceList::get( const QString& username, const QString& friendlyName, bool autoCreate )
{ {
QMutexLocker lock( &m_mut ); QMutexLocker lock( &m_mut );
@@ -197,9 +197,13 @@ SourceList::get( const QString& username, const QString& friendlyName )
if ( !m_sources.contains( username ) ) if ( !m_sources.contains( username ) )
{ {
source = source_ptr( new Source( -1, username ) ); if ( autoCreate )
source->setFriendlyName( friendlyName ); {
add( source ); Q_ASSERT( !friendlyName.isEmpty() );
source = source_ptr( new Source( -1, username ) );
source->setFriendlyName( friendlyName );
add( source );
}
} }
else else
{ {

View File

@@ -51,7 +51,7 @@ public:
QList<Tomahawk::source_ptr> sources( bool onlyOnline = false ) const; QList<Tomahawk::source_ptr> sources( bool onlyOnline = false ) const;
unsigned int count() 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; Tomahawk::source_ptr get( int id ) const;
signals: signals:

View File

@@ -129,7 +129,7 @@ ControlConnection::setup()
tDebug() << "Detected name:" << name() << friendlyName << m_sock->peerAddress(); tDebug() << "Detected name:" << name() << friendlyName << m_sock->peerAddress();
// setup source and remote collection for this peer // 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 ); m_source->setControlConnection( this );
// delay setting up collection/etc until source is synced. // delay setting up collection/etc until source is synced.