mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-20 07:49:42 +01:00
Cleanup fixes
This commit is contained in:
parent
75eb35397d
commit
cd3eeb2951
src/libtomahawk
@ -47,6 +47,12 @@ Album::~Album()
|
||||
#endif
|
||||
}
|
||||
|
||||
inline QString
|
||||
albumCacheKey( const Tomahawk::artist_ptr& artist, const QString& albumName )
|
||||
{
|
||||
return QString( "%1\t\t%2" ).arg( artist->name() ).arg( albumName );
|
||||
}
|
||||
|
||||
|
||||
album_ptr
|
||||
Album::get( const Tomahawk::artist_ptr& artist, const QString& name, bool autoCreate )
|
||||
@ -56,9 +62,10 @@ Album::get( const Tomahawk::artist_ptr& artist, const QString& name, bool autoCr
|
||||
|
||||
QMutexLocker l( &s_nameCacheMutex );
|
||||
|
||||
if ( s_albumsByName.contains( artist->name() + name ) )
|
||||
const QString key = albumCacheKey( artist, name );
|
||||
if ( s_albumsByName.contains( key ) )
|
||||
{
|
||||
return s_albumsByName[ artist->name() + name ];
|
||||
return s_albumsByName[ key ];
|
||||
}
|
||||
|
||||
// qDebug() << "LOOKING UP ALBUM:" << artist->name() << name;
|
||||
@ -66,7 +73,7 @@ Album::get( const Tomahawk::artist_ptr& artist, const QString& name, bool autoCr
|
||||
album->setWeakRef( album.toWeakRef() );
|
||||
album->loadId( autoCreate );
|
||||
|
||||
s_albumsByName[ artist->name() + name ] = album;
|
||||
s_albumsByName[ key ] = album;
|
||||
|
||||
return album;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@
|
||||
|
||||
|
||||
DatabaseImpl::DatabaseImpl( const QString& dbname, Database* parent )
|
||||
: QObject( 0 )
|
||||
: QObject( parent )
|
||||
, m_parent( parent )
|
||||
{
|
||||
QTime t;
|
||||
|
@ -69,7 +69,7 @@ void
|
||||
DatabaseWorker::run()
|
||||
{
|
||||
m_dbimpl = m_db->impl()->clone();
|
||||
tDebug() << "New db connection with name:" << m_dbimpl->database().connectionName();
|
||||
tDebug() << "New db connection with name:" << m_dbimpl->database().connectionName() << "this thread:" << thread() << "Parent of dbcon:" << m_dbimpl->parent()->thread();
|
||||
exec();
|
||||
qDebug() << Q_FUNC_INFO << "DatabaseWorker finishing...";
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ static QMutex s_mutex;
|
||||
|
||||
struct QueueItem
|
||||
{
|
||||
boost::promise< unsigned int >* promise;
|
||||
boost::promise< unsigned int > promise;
|
||||
artist_ptr artist;
|
||||
album_ptr album;
|
||||
QueryType type;
|
||||
@ -54,7 +54,7 @@ IdThreadWorker::IdThreadWorker( Database* db )
|
||||
, m_db( db )
|
||||
, m_stop( false )
|
||||
{
|
||||
m_impl = m_db->impl()->clone();
|
||||
moveToThread( this );
|
||||
}
|
||||
|
||||
|
||||
@ -80,7 +80,6 @@ QueueItem*
|
||||
internalGet( const artist_ptr& artist, const album_ptr& album, bool autoCreate, QueryType type )
|
||||
{
|
||||
QueueItem* item = new QueueItem;
|
||||
item->promise = new boost::promise< unsigned int >();
|
||||
item->artist = artist;
|
||||
item->album = album;
|
||||
item->type = type;
|
||||
@ -102,7 +101,7 @@ IdThreadWorker::getArtistId( const artist_ptr& artist, bool autoCreate )
|
||||
s_waitCond.wakeOne();
|
||||
// qDebug() << "DONE WOKE UP THREAD:" << artist->name();
|
||||
|
||||
return item->promise->get_future();
|
||||
return item->promise.get_future();
|
||||
}
|
||||
|
||||
|
||||
@ -118,14 +117,14 @@ IdThreadWorker::getAlbumId( const album_ptr& album, bool autoCreate )
|
||||
s_waitCond.wakeOne();
|
||||
// qDebug() << "DONE WOKE UP THREAD:" << album->artist()->name() << album->name();
|
||||
|
||||
return item->promise->get_future();
|
||||
return item->promise.get_future();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
IdThreadWorker::run()
|
||||
{
|
||||
Q_ASSERT( !m_impl );
|
||||
m_impl = m_db->impl()->clone();
|
||||
|
||||
while ( !m_stop )
|
||||
{
|
||||
@ -142,7 +141,7 @@ IdThreadWorker::run()
|
||||
if ( item->type == ArtistType )
|
||||
{
|
||||
unsigned int id = m_impl->artistId( item->artist->name(), item->create );
|
||||
item->promise->set_value( id );
|
||||
item->promise.set_value( id );
|
||||
|
||||
item->artist->id();
|
||||
delete item;
|
||||
@ -151,7 +150,7 @@ IdThreadWorker::run()
|
||||
{
|
||||
unsigned int artistId = m_impl->artistId( item->album->artist()->name(), item->create );
|
||||
unsigned int albumId = m_impl->albumId( artistId, item->album->name(), item->create );
|
||||
item->promise->set_value( albumId );
|
||||
item->promise.set_value( albumId );
|
||||
|
||||
item->album->id();
|
||||
delete item;
|
||||
|
@ -832,20 +832,6 @@ extractBinaryResolver( const QString& zipFilename, QObject* receiver )
|
||||
}
|
||||
|
||||
|
||||
boost::unique_future< unsigned int >
|
||||
getArtistId( const QString &artistName )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
boost::unique_future< unsigned int >
|
||||
getAlbumId( const QString &artistName, const QString& albumId )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // ns
|
||||
|
||||
#include "TomahawkUtils.moc"
|
||||
|
Loading…
x
Reference in New Issue
Block a user