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

* Fixed SourceList assert. Fixed filesize calculation.

This commit is contained in:
Christian Muehlhaeuser
2011-02-25 22:36:11 +01:00
parent b5f52f6c04
commit 4d1afb74bf
4 changed files with 10 additions and 17 deletions

View File

@@ -195,7 +195,7 @@ DBSyncConnection::handleMsg( msg_ptr msg )
QVariantMap m = msg->json().toMap(); QVariantMap m = msg->json().toMap();
if ( m.empty() ) if ( m.empty() )
{ {
qDebug() << "Failed to parse msg in dbsync"; qDebug() << "Failed to parse msg in dbsync" << m_source->id() << m_source->friendlyName();
Q_ASSERT( false ); Q_ASSERT( false );
return; return;
} }

View File

@@ -42,7 +42,7 @@ public:
void addCollection( const Tomahawk::collection_ptr& c ); void addCollection( const Tomahawk::collection_ptr& c );
void removeCollection( const Tomahawk::collection_ptr& c ); void removeCollection( const Tomahawk::collection_ptr& c );
unsigned int id() const { return m_id; } int id() const { return m_id; }
ControlConnection* controlConnection() const { return m_cc; } ControlConnection* controlConnection() const { return m_cc; }
void setControlConnection( ControlConnection* cc ); void setControlConnection( ControlConnection* cc );
@@ -90,7 +90,7 @@ private:
bool m_isLocal; bool m_isLocal;
bool m_online; bool m_online;
QString m_username, m_friendlyname; QString m_username, m_friendlyname;
unsigned int m_id; int m_id;
QList< QSharedPointer<Collection> > m_collections; QList< QSharedPointer<Collection> > m_collections;
QVariantMap m_stats; QVariantMap m_stats;
QString m_lastOpGuid; QString m_lastOpGuid;

View File

@@ -88,6 +88,8 @@ SourceList::add( const source_ptr& source )
{ {
qDebug() << "Adding to sources:" << source->userName() << source->id(); qDebug() << "Adding to sources:" << source->userName() << source->id();
m_sources.insert( source->userName(), source ); m_sources.insert( source->userName(), source );
if ( source->id() > 0 )
m_sources_id2name.insert( source->id(), source->userName() ); m_sources_id2name.insert( source->id(), source->userName() );
connect( source.data(), SIGNAL( syncedWithDatabase() ), SLOT( sourceSynced() ) ); connect( source.data(), SIGNAL( syncedWithDatabase() ), SLOT( sourceSynced() ) );
@@ -101,17 +103,14 @@ SourceList::add( const source_ptr& source )
void void
SourceList::removeAllRemote() SourceList::removeAllRemote()
{ {
foreach( source_ptr s, m_sources ) foreach( const source_ptr& s, m_sources )
{ {
if( s != m_local ) if ( !s->isLocal() && s->controlConnection() )
{
if ( s->controlConnection() )
{ {
s->controlConnection()->shutdown( true ); s->controlConnection()->shutdown( true );
} }
} }
} }
}
QList<source_ptr> QList<source_ptr>
@@ -162,12 +161,6 @@ SourceList::sourceSynced()
{ {
Source* src = qobject_cast< Source* >( sender() ); Source* src = qobject_cast< Source* >( sender() );
qDebug() << "Finding in sources:" << src->userName() << src->id();
qDebug() << "Current sources values:" << m_sources_id2name.values();
qDebug() << "Current sources keys:" << m_sources_id2name.keys();
Q_ASSERT( m_sources_id2name.values().contains( src->userName() ) );
m_sources_id2name.remove( m_sources_id2name.key( src->userName() ) );
m_sources_id2name.insert( src->id(), src->userName() ); m_sources_id2name.insert( src->id(), src->userName() );
} }

View File

@@ -205,7 +205,7 @@ filesizeToString( unsigned int size )
if ( mb ) if ( mb )
{ {
return QString( "%1.%2 Mb" ).arg( mb ).arg( int( ( kb % 1024 ) / 100 ) ); return QString( "%1.%2 Mb" ).arg( mb ).arg( int( ( kb % 1024 ) / 102.4 ) );
} }
else if ( kb ) else if ( kb )
{ {