mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-01 03:40:16 +02:00
Cleanup fixes
This commit is contained in:
@@ -47,6 +47,12 @@ Album::~Album()
|
|||||||
#endif
|
#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_ptr
|
||||||
Album::get( const Tomahawk::artist_ptr& artist, const QString& name, bool autoCreate )
|
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 );
|
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;
|
// 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->setWeakRef( album.toWeakRef() );
|
||||||
album->loadId( autoCreate );
|
album->loadId( autoCreate );
|
||||||
|
|
||||||
s_albumsByName[ artist->name() + name ] = album;
|
s_albumsByName[ key ] = album;
|
||||||
|
|
||||||
return album;
|
return album;
|
||||||
}
|
}
|
||||||
|
@@ -44,7 +44,7 @@
|
|||||||
|
|
||||||
|
|
||||||
DatabaseImpl::DatabaseImpl( const QString& dbname, Database* parent )
|
DatabaseImpl::DatabaseImpl( const QString& dbname, Database* parent )
|
||||||
: QObject( 0 )
|
: QObject( parent )
|
||||||
, m_parent( parent )
|
, m_parent( parent )
|
||||||
{
|
{
|
||||||
QTime t;
|
QTime t;
|
||||||
|
@@ -69,7 +69,7 @@ void
|
|||||||
DatabaseWorker::run()
|
DatabaseWorker::run()
|
||||||
{
|
{
|
||||||
m_dbimpl = m_db->impl()->clone();
|
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();
|
exec();
|
||||||
qDebug() << Q_FUNC_INFO << "DatabaseWorker finishing...";
|
qDebug() << Q_FUNC_INFO << "DatabaseWorker finishing...";
|
||||||
}
|
}
|
||||||
|
@@ -39,7 +39,7 @@ static QMutex s_mutex;
|
|||||||
|
|
||||||
struct QueueItem
|
struct QueueItem
|
||||||
{
|
{
|
||||||
boost::promise< unsigned int >* promise;
|
boost::promise< unsigned int > promise;
|
||||||
artist_ptr artist;
|
artist_ptr artist;
|
||||||
album_ptr album;
|
album_ptr album;
|
||||||
QueryType type;
|
QueryType type;
|
||||||
@@ -54,7 +54,7 @@ IdThreadWorker::IdThreadWorker( Database* db )
|
|||||||
, m_db( db )
|
, m_db( db )
|
||||||
, m_stop( false )
|
, 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 )
|
internalGet( const artist_ptr& artist, const album_ptr& album, bool autoCreate, QueryType type )
|
||||||
{
|
{
|
||||||
QueueItem* item = new QueueItem;
|
QueueItem* item = new QueueItem;
|
||||||
item->promise = new boost::promise< unsigned int >();
|
|
||||||
item->artist = artist;
|
item->artist = artist;
|
||||||
item->album = album;
|
item->album = album;
|
||||||
item->type = type;
|
item->type = type;
|
||||||
@@ -102,7 +101,7 @@ IdThreadWorker::getArtistId( const artist_ptr& artist, bool autoCreate )
|
|||||||
s_waitCond.wakeOne();
|
s_waitCond.wakeOne();
|
||||||
// qDebug() << "DONE WOKE UP THREAD:" << artist->name();
|
// 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();
|
s_waitCond.wakeOne();
|
||||||
// qDebug() << "DONE WOKE UP THREAD:" << album->artist()->name() << album->name();
|
// qDebug() << "DONE WOKE UP THREAD:" << album->artist()->name() << album->name();
|
||||||
|
|
||||||
return item->promise->get_future();
|
return item->promise.get_future();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
IdThreadWorker::run()
|
IdThreadWorker::run()
|
||||||
{
|
{
|
||||||
Q_ASSERT( !m_impl );
|
m_impl = m_db->impl()->clone();
|
||||||
|
|
||||||
while ( !m_stop )
|
while ( !m_stop )
|
||||||
{
|
{
|
||||||
@@ -142,7 +141,7 @@ IdThreadWorker::run()
|
|||||||
if ( item->type == ArtistType )
|
if ( item->type == ArtistType )
|
||||||
{
|
{
|
||||||
unsigned int id = m_impl->artistId( item->artist->name(), item->create );
|
unsigned int id = m_impl->artistId( item->artist->name(), item->create );
|
||||||
item->promise->set_value( id );
|
item->promise.set_value( id );
|
||||||
|
|
||||||
item->artist->id();
|
item->artist->id();
|
||||||
delete item;
|
delete item;
|
||||||
@@ -151,7 +150,7 @@ IdThreadWorker::run()
|
|||||||
{
|
{
|
||||||
unsigned int artistId = m_impl->artistId( item->album->artist()->name(), item->create );
|
unsigned int artistId = m_impl->artistId( item->album->artist()->name(), item->create );
|
||||||
unsigned int albumId = m_impl->albumId( artistId, item->album->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();
|
item->album->id();
|
||||||
delete item;
|
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
|
} // ns
|
||||||
|
|
||||||
#include "TomahawkUtils.moc"
|
#include "TomahawkUtils.moc"
|
||||||
|
Reference in New Issue
Block a user