1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-14 04:51:53 +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

@ -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;

@ -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
{

@ -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:

@ -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.