1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-07 06:36:55 +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

@@ -251,7 +251,7 @@ Source::setOffline()
void
Source::setOnline()
{
qDebug() << Q_FUNC_INFO << friendlyName();
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << friendlyName();
if ( m_online )
return;

View File

@@ -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,10 +197,14 @@ SourceList::get( const QString& username, const QString& friendlyName )
if ( !m_sources.contains( username ) )
{
if ( autoCreate )
{
Q_ASSERT( !friendlyName.isEmpty() );
source = source_ptr( new Source( -1, username ) );
source->setFriendlyName( friendlyName );
add( source );
}
}
else
{
source = m_sources.value( username );

View File

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

View File

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