1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-12 00:54:20 +02:00

Revert usage of boost::threads to speed up id loading. Our MinGW boost package is broken.

Revert "Set future on artist/album immediately after creating promise"

This reverts commit 9d9fae75b5.

Revert "Remove duplicate function, and fix copy link from sidebar track page"

This reverts commit 1fe28714cb.

Revert "Catch by const ref and assert to check hypothesis"

This reverts commit a8f0053fc8.

Revert "Reimplement QApplication::notify() to print out something about the exception if we can"

This reverts commit 7b8136a36e.

Revert "Catch boost::unitialized_future if it is thrown"

This reverts commit c1d678e2b1.

Revert "Another boost/thread.hpp include rather than specific boost headers"

This reverts commit ee8d3e6a92.

Revert "One include to (hopefully) rule them all"

This reverts commit 52752cd234.

Revert "Add another boost include"

This reverts commit 7bec03560a.

Revert "Try some more includes"

This reverts commit e56f2f7ee0.

Revert "Remove old code"

This reverts commit 69b56e0836.

Revert "Fix oversight in queue draining"

This reverts commit 8c48af423c.

Revert "Safer locking of id() to prevent deadlocks"

This reverts commit 3f2906d4d1.

Revert "Cleanup fixes"

This reverts commit cd3eeb2951.

Revert "Experimental asynchronous artist and album id loading"

This reverts commit 75eb35397d.

Conflicts:

	src/libtomahawk/CMakeLists.txt
This commit is contained in:
Leo Franchi
2012-06-19 00:43:08 +02:00
parent 1e0a00dbe2
commit 8558cdfc8e
17 changed files with 45 additions and 508 deletions

View File

@@ -115,7 +115,7 @@ macro_log_feature(TAGLIB_FOUND "TagLib" "Audio Meta-Data Library" "http://develo
include( CheckTagLibFileName )
check_taglib_filename( COMPLEX_TAGLIB_FILENAME )
macro_optional_find_package( Boost COMPONENTS thread )
macro_optional_find_package(Boost)
macro_log_feature(Boost_FOUND "Boost" "Provides free peer-reviewed portable C++ source libraries" "http://www.boost.org" TRUE "" "") #FIXME: give useful explaination
macro_optional_find_package(QCA2)

View File

@@ -707,27 +707,6 @@ TomahawkApp::loadUrl( const QString& url )
}
bool
TomahawkApp::notify( QObject *receiver, QEvent *e )
{
try
{
return TOMAHAWK_APPLICATION::notify( receiver, e );
}
catch ( const std::exception& e )
{
qWarning( "TomahawkApp::notify caught a std exception in a Qt event handler: " );
qFatal( e.what() );
}
catch ( ... )
{
qFatal( "TomahawkApp::notify caught a non-std-exception from a Qt event handler. Aborting." );
}
return false;
}
void
TomahawkApp::instanceStarted( KDSingleApplicationGuard::Instance instance )
{

View File

@@ -99,9 +99,6 @@ public:
bool isTomahawkLoaded() const { return m_loaded; }
// reimplemented from QApplication/QCoreApplication
virtual bool notify( QObject* receiver, QEvent* e );
signals:
void tomahawkLoaded();

View File

@@ -23,22 +23,13 @@
#include "AlbumPlaylistInterface.h"
#include "database/Database.h"
#include "database/DatabaseImpl.h"
#include "database/IdThreadWorker.h"
#include "Query.h"
#include "Source.h"
#include "utils/Logger.h"
#include <QReadWriteLock>
using namespace Tomahawk;
QHash< QString, album_ptr > Album::s_albumsByName = QHash< QString, album_ptr >();
QHash< unsigned int, album_ptr > Album::s_albumsById = QHash< unsigned int, album_ptr >();
static QMutex s_nameCacheMutex;
static QMutex s_idCacheMutex;
static QReadWriteLock s_idMutex;
Album::~Album()
{
@@ -49,12 +40,6 @@ 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 )
@@ -62,22 +47,11 @@ Album::get( const Tomahawk::artist_ptr& artist, const QString& name, bool autoCr
if ( !Database::instance() || !Database::instance()->impl() )
return album_ptr();
QMutexLocker l( &s_nameCacheMutex );
int albid = Database::instance()->impl()->albumId( artist->id(), name, autoCreate );
if ( albid < 1 && autoCreate )
return album_ptr();
const QString key = albumCacheKey( artist, name );
if ( s_albumsByName.contains( key ) )
{
return s_albumsByName[ key ];
}
// qDebug() << "LOOKING UP ALBUM:" << artist->name() << name;
album_ptr album = album_ptr( new Album( name, artist ) );
album->setWeakRef( album.toWeakRef() );
album->loadId( autoCreate );
s_albumsByName[ key ] = album;
return album;
return Album::get( albid, name, artist );
}
@@ -87,17 +61,17 @@ Album::get( unsigned int id, const QString& name, const Tomahawk::artist_ptr& ar
static QHash< unsigned int, album_ptr > s_albums;
static QMutex s_mutex;
QMutexLocker lock( &s_idCacheMutex );
if ( s_albumsById.contains( id ) )
QMutexLocker lock( &s_mutex );
if ( s_albums.contains( id ) )
{
return s_albumsById.value( id );
return s_albums.value( id );
}
album_ptr a = album_ptr( new Album( id, name, artist ), &QObject::deleteLater );
a->setWeakRef( a.toWeakRef() );
if ( id > 0 )
s_albumsById.insert( id, a );
s_albums.insert( id, a );
return a;
}
@@ -105,7 +79,6 @@ Album::get( unsigned int id, const QString& name, const Tomahawk::artist_ptr& ar
Album::Album( unsigned int id, const QString& name, const Tomahawk::artist_ptr& artist )
: QObject()
, m_waitingForId( false )
, m_id( id )
, m_name( name )
, m_artist( artist )
@@ -119,20 +92,6 @@ Album::Album( unsigned int id, const QString& name, const Tomahawk::artist_ptr&
}
Album::Album( const QString& name, const Tomahawk::artist_ptr& artist )
: QObject()
, m_waitingForId( true )
, m_name( name )
, m_artist( artist )
, m_coverLoaded( false )
, m_coverLoading( false )
#ifndef ENABLE_HEADLESS
, m_cover( 0 )
#endif
{
m_sortname = DatabaseImpl::sortname( name );
}
void
Album::onTracksLoaded( Tomahawk::ModelMode mode, const Tomahawk::collection_ptr& collection )
{
@@ -147,56 +106,6 @@ Album::artist() const
}
void
Album::loadId( bool autoCreate )
{
Q_ASSERT( m_waitingForId );
IdThreadWorker::getAlbumId( m_ownRef.toStrongRef(), autoCreate );
}
void
Album::setIdFuture( boost::unique_future< unsigned int > future )
{
m_idFuture = boost::move( future );
}
unsigned int
Album::id() const
{
s_idMutex.lockForRead();
const bool waiting = m_waitingForId;
unsigned int finalId = m_id;
s_idMutex.unlock();
if ( waiting )
{
try
{
finalId = m_idFuture.get();
s_idMutex.lockForWrite();
m_id = finalId;
m_waitingForId = false;
if ( m_id > 0 )
s_albumsById[ m_id ] = m_ownRef.toStrongRef();
s_idMutex.unlock();
}
catch( const boost::future_uninitialized& e )
{
qWarning() << "Caught boost::future_uninitialized when trying to get artist id from future, WTF?";
qWarning() << "Potential race condition, do we have an ID?" << m_id << "and waiting?" << m_waitingForId << e.what();
Q_ASSERT( !m_waitingForId );
}
}
return finalId;
}
#ifndef ENABLE_HEADLESS
QPixmap
Album::cover( const QSize& size, bool forceLoad ) const
@@ -330,4 +239,4 @@ Album::infoid() const
m_uuid = uuid();
return m_uuid;
}
}

View File

@@ -28,16 +28,12 @@
#include <QtGui/QPixmap>
#endif
#include <boost/thread.hpp>
#include "Typedefs.h"
#include "PlaylistInterface.h"
#include "DllMacro.h"
#include "Collection.h"
#include "infosystem/InfoSystem.h"
class IdThreadWorker;
namespace Tomahawk
{
@@ -49,11 +45,10 @@ public:
static album_ptr get( const Tomahawk::artist_ptr& artist, const QString& name, bool autoCreate = false );
static album_ptr get( unsigned int id, const QString& name, const Tomahawk::artist_ptr& artist );
Album( unsigned int id, const QString& name, const Tomahawk::artist_ptr& artist );
Album( const QString& name, const Tomahawk::artist_ptr& artist );
explicit Album( unsigned int id, const QString& name, const Tomahawk::artist_ptr& artist );
virtual ~Album();
unsigned int id() const;
unsigned int id() const { return m_id; }
QString name() const { return m_name; }
QString sortname() const { return m_sortname; }
@@ -69,7 +64,6 @@ public:
QWeakPointer< Tomahawk::Album > weakRef() { return m_ownRef; }
void setWeakRef( QWeakPointer< Tomahawk::Album > weakRef ) { m_ownRef = weakRef; }
void loadId( bool autoCreate );
signals:
void tracksAdded( const QList<Tomahawk::query_ptr>& tracks, Tomahawk::ModelMode mode, const Tomahawk::collection_ptr& collection );
void updated();
@@ -84,11 +78,8 @@ private slots:
private:
Q_DISABLE_COPY( Album )
QString infoid() const;
void setIdFuture( boost::unique_future< unsigned int > future );
mutable bool m_waitingForId;
mutable boost::unique_future< unsigned int > m_idFuture;
mutable unsigned int m_id;
unsigned int m_id;
QString m_name;
QString m_sortname;
@@ -107,11 +98,6 @@ private:
QHash< Tomahawk::ModelMode, QHash< Tomahawk::collection_ptr, Tomahawk::playlistinterface_ptr > > m_playlistInterface;
QWeakPointer< Tomahawk::Album > m_ownRef;
static QHash< QString, album_ptr > s_albumsByName;
static QHash< unsigned int, album_ptr > s_albumsById;
friend class ::IdThreadWorker;
};
} // ns

View File

@@ -25,21 +25,12 @@
#include "database/DatabaseImpl.h"
#include "database/DatabaseCommand_AllAlbums.h"
#include "database/DatabaseCommand_TrackStats.h"
#include "database/IdThreadWorker.h"
#include "Source.h"
#include "utils/Logger.h"
#include <QReadWriteLock>
using namespace Tomahawk;
QHash< QString, artist_ptr > Artist::s_artistsByName = QHash< QString, artist_ptr >();
QHash< unsigned int, artist_ptr > Artist::s_artistsById = QHash< unsigned int, artist_ptr >();
static QMutex s_nameCacheMutex;
static QMutex s_idCacheMutex;
static QReadWriteLock s_idMutex;
Artist::~Artist()
{
@@ -54,40 +45,34 @@ Artist::~Artist()
artist_ptr
Artist::get( const QString& name, bool autoCreate )
{
if ( name.isEmpty() )
return artist_ptr();
QMutexLocker lock( &s_nameCacheMutex );
if ( s_artistsByName.contains( name ) )
return s_artistsByName.value( name );
if ( !Database::instance() || !Database::instance()->impl() )
return artist_ptr();
artist_ptr artist = artist_ptr( new Artist( name ), &QObject::deleteLater );
artist->setWeakRef( artist.toWeakRef() );
artist->loadId( autoCreate );
int artid = Database::instance()->impl()->artistId( name, autoCreate );
if ( artid < 1 && autoCreate )
return artist_ptr();
s_artistsByName[ name ] = artist;
return artist;
return Artist::get( artid, name );
}
artist_ptr
Artist::get( unsigned int id, const QString& name )
{
QMutexLocker lock( &s_idCacheMutex );
if ( s_artistsById.contains( id ) )
static QHash< unsigned int, artist_ptr > s_artists;
static QMutex s_mutex;
QMutexLocker lock( &s_mutex );
if ( s_artists.contains( id ) )
{
return s_artistsById.value( id );
return s_artists.value( id );
}
artist_ptr a = artist_ptr( new Artist( id, name ), &QObject::deleteLater );
a->setWeakRef( a.toWeakRef() );
if ( id > 0 )
s_artistsById.insert( id, a );
s_artists.insert( id, a );
return a;
}
@@ -95,7 +80,6 @@ Artist::get( unsigned int id, const QString& name )
Artist::Artist( unsigned int id, const QString& name )
: QObject()
, m_waitingForFuture( false )
, m_id( id )
, m_name( name )
, m_coverLoaded( false )
@@ -111,24 +95,6 @@ Artist::Artist( unsigned int id, const QString& name )
}
Artist::Artist( const QString& name )
: QObject()
, m_waitingForFuture( true )
, m_id( 0 )
, m_name( name )
, m_coverLoaded( false )
, m_coverLoading( false )
, m_simArtistsLoaded( false )
, m_biographyLoaded( false )
, m_infoJobs( 0 )
#ifndef ENABLE_HEADLESS
, m_cover( 0 )
#endif
{
m_sortname = DatabaseImpl::sortname( name, true );
}
void
Artist::onTracksLoaded( Tomahawk::ModelMode mode, const Tomahawk::collection_ptr& collection )
{
@@ -226,57 +192,6 @@ Artist::similarArtists() const
}
void
Artist::loadId( bool autoCreate )
{
Q_ASSERT( m_waitingForFuture );
IdThreadWorker::getArtistId( m_ownRef.toStrongRef(), autoCreate );
}
void
Artist::setIdFuture( boost::unique_future< unsigned int > future )
{
m_idFuture = boost::move(future);
}
unsigned int
Artist::id() const
{
s_idMutex.lockForRead();
const bool waiting = m_waitingForFuture;
unsigned int finalid = m_id;
s_idMutex.unlock();
if ( waiting )
{
try
{
finalid = m_idFuture.get();
s_idMutex.lockForWrite();
m_id = finalid;
m_waitingForFuture = false;
if ( m_id > 0 )
s_artistsById[ m_id ] = m_ownRef.toStrongRef();
s_idMutex.unlock();
}
catch( const boost::future_uninitialized& e )
{
qWarning() << "Caught boost::future_uninitialized when trying to get artist id from future, WTF?";
qWarning() << "Potential race condition, do we have an ID?" << m_id << "and waiting?" << m_waitingForFuture << e.what();
Q_ASSERT( !m_waitingForFuture );
}
}
return m_id;
}
QString
Artist::biography() const
{

View File

@@ -31,10 +31,6 @@
#include "DllMacro.h"
#include "Query.h"
#include <boost/thread.hpp>
class IdThreadWorker;
namespace Tomahawk
{
@@ -46,11 +42,10 @@ public:
static artist_ptr get( const QString& name, bool autoCreate = false );
static artist_ptr get( unsigned int id, const QString& name );
Artist( unsigned int id, const QString& name );
explicit Artist( const QString& name );
explicit Artist( unsigned int id, const QString& name );
virtual ~Artist();
unsigned int id() const;
unsigned int id() const { return m_id; }
QString name() const { return m_name; }
QString sortname() const { return m_sortname; }
@@ -77,7 +72,6 @@ public:
QWeakPointer< Tomahawk::Artist > weakRef() { return m_ownRef; }
void setWeakRef( QWeakPointer< Tomahawk::Artist > weakRef ) { m_ownRef = weakRef; }
void loadId( bool autoCreate );
signals:
void tracksAdded( const QList<Tomahawk::query_ptr>& tracks, Tomahawk::ModelMode mode, const Tomahawk::collection_ptr& collection );
void albumsAdded( const QList<Tomahawk::album_ptr>& albums, Tomahawk::ModelMode mode );
@@ -99,12 +93,7 @@ private:
Artist();
QString infoid() const;
void setIdFuture( boost::unique_future< unsigned int > future );
mutable bool m_waitingForFuture;
mutable boost::unique_future< unsigned int > m_idFuture;
mutable unsigned int m_id;
unsigned int m_id;
QString m_name;
QString m_sortname;
@@ -134,11 +123,6 @@ private:
QHash< Tomahawk::ModelMode, QHash< Tomahawk::collection_ptr, Tomahawk::playlistinterface_ptr > > m_playlistInterface;
QWeakPointer< Tomahawk::Artist > m_ownRef;
static QHash< QString, artist_ptr > s_artistsByName;
static QHash< unsigned int, artist_ptr > s_artistsById;
friend class ::IdThreadWorker;
};
} // ns

View File

@@ -256,7 +256,6 @@ set( libSources
database/DatabaseCommand_SetTrackAttributes.cpp
database/Database.cpp
database/TomahawkSqlQuery.cpp
database/IdThreadWorker.cpp
infosystem/InfoSystem.cpp
infosystem/InfoSystemCache.cpp
@@ -455,7 +454,6 @@ TARGET_LINK_LIBRARIES( tomahawklib
${OS_SPECIFIC_LINK_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${LINK_LIBRARIES}
${Boost_LIBRARIES}
${SQLITE_LIBRARIES}
)

View File

@@ -97,6 +97,20 @@ GlobalActionManager::openLinkFromQuery( const query_ptr& query ) const
}
QUrl
GlobalActionManager::copyOpenLink( const query_ptr& query ) const
{
const QUrl link = openLinkFromQuery( query );
QClipboard* cb = QApplication::clipboard();
QByteArray data = link.toEncoded();
data.replace( "'", "%27" ); // QUrl doesn't encode ', which it doesn't have to. Some apps don't like ' though, and want %27. Both are valid.
cb->setText( data );
return link;
}
QUrl
GlobalActionManager::copyOpenLink( const artist_ptr& artist ) const
{

View File

@@ -46,6 +46,7 @@ public:
QUrl copyOpenLink( const Tomahawk::artist_ptr& artist ) const;
QUrl copyOpenLink( const Tomahawk::album_ptr& album ) const;
QUrl copyOpenLink( const Tomahawk::query_ptr& query ) const;
QUrl openLink( const QString& title, const QString& artist, const QString& album ) const;
@@ -60,10 +61,7 @@ public slots:
/// Takes a spotify link and performs the default open action on it
bool openRdioLink( const QString& link );
/// Creates a link from the requested data and copies it to the clipboard
void copyToClipboard( const Tomahawk::query_ptr& query );
QString copyPlaylistToClipboard( const Tomahawk::dynplaylist_ptr& playlist );
void savePlaylistToFile( const Tomahawk::playlist_ptr& playlist, const QString& filename );

View File

@@ -22,7 +22,6 @@
#include "DatabaseCommand.h"
#include "DatabaseImpl.h"
#include "DatabaseWorker.h"
#include "IdThreadWorker.h"
#include "utils/Logger.h"
#include "Source.h"
@@ -44,7 +43,6 @@ Database::Database( const QString& dbname, QObject* parent )
, m_ready( false )
, m_impl( new DatabaseImpl( dbname, this ) )
, m_workerRW( new DatabaseWorker( this, true ) )
, m_idWorker( new IdThreadWorker( this ) )
{
s_instance = this;
@@ -60,7 +58,6 @@ Database::Database( const QString& dbname, QObject* parent )
connect( m_impl, SIGNAL( indexReady() ), SLOT( setIsReadyTrue() ) );
m_workerRW->start();
m_idWorker->start();
}
@@ -70,8 +67,6 @@ Database::~Database()
qDeleteAll( m_workers );
delete m_workerRW;
m_idWorker->stop();
delete m_idWorker;
delete m_impl;
}

View File

@@ -31,7 +31,6 @@
class DatabaseImpl;
class DatabaseWorker;
class IdThreadWorker;
/*
This class is really a firewall/pimpl - the public functions of LibraryImpl
@@ -80,7 +79,6 @@ private:
DatabaseImpl* m_impl;
DatabaseWorker* m_workerRW;
QList<DatabaseWorker*> m_workers;
IdThreadWorker* m_idWorker;
bool m_indexReady;
int m_maxConcurrentThreads;

View File

@@ -45,7 +45,7 @@
#define CURRENT_SCHEMA_VERSION 28
DatabaseImpl::DatabaseImpl( const QString& dbname, Database* parent )
: QObject( parent )
: QObject( (QObject*) parent )
, m_parent( parent )
{
QTime t;

View File

@@ -69,7 +69,7 @@ void
DatabaseWorker::run()
{
m_dbimpl = m_db->impl()->clone();
tDebug() << "New db connection with name:" << m_dbimpl->database().connectionName() << "this thread:" << thread() << "Parent of dbcon:" << m_dbimpl->parent()->thread();
tDebug() << "New db connection with name:" << m_dbimpl->database().connectionName();
exec();
qDebug() << Q_FUNC_INFO << "DatabaseWorker finishing...";
}

View File

@@ -1,180 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2012 Leo Franchi <lfranchi@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "IdThreadWorker.h"
#include "Artist.h"
#include "Album.h"
#include "Database.h"
#include "DatabaseImpl.h"
#include "Source.h"
#define ID_THREAD_DEBUG 0
using namespace Tomahawk;
namespace {
enum QueryType {
ArtistType,
AlbumType
};
}
static QWaitCondition s_waitCond;
static QMutex s_mutex;
struct QueueItem
{
boost::promise< unsigned int > promise;
artist_ptr artist;
album_ptr album;
QueryType type;
bool create;
};
// TODO Q_GLOBAL_STATIC
QQueue< QueueItem* > IdThreadWorker::s_workQueue = QQueue< QueueItem* >();
IdThreadWorker::IdThreadWorker( Database* db )
: QThread()
, m_db( db )
, m_stop( false )
{
moveToThread( this );
}
IdThreadWorker::~IdThreadWorker()
{
wait();
}
void
IdThreadWorker::stop()
{
{
QMutexLocker l( &s_mutex );
m_stop = true;
}
s_waitCond.wakeOne();
}
QueueItem*
internalGet( const artist_ptr& artist, const album_ptr& album, bool autoCreate, QueryType type )
{
QueueItem* item = new QueueItem;
item->artist = artist;
item->album = album;
item->type = type;
item->create = autoCreate;
return item;
}
void
IdThreadWorker::getArtistId( const artist_ptr& artist, bool autoCreate )
{
QueueItem* item = internalGet( artist, album_ptr(), autoCreate, ArtistType );
artist->setIdFuture( item->promise.get_future() );
#if ID_THREAD_DEBUG
qDebug() << "QUEUEING ARTIST:" << artist->name();
#endif
s_mutex.lock();
s_workQueue.enqueue( item );
s_mutex.unlock();
s_waitCond.wakeOne();
#if ID_THREAD_DEBUG
qDebug() << "DONE WOKE UP THREAD:" << artist->name();
#endif
}
void
IdThreadWorker::getAlbumId( const album_ptr& album, bool autoCreate )
{
QueueItem* item = internalGet( artist_ptr(), album, autoCreate, AlbumType );
album->setIdFuture( item->promise.get_future() );
#if ID_THREAD_DEBUG
qDebug() << "QUEUEING ALUBM:" << album->artist()->name() << album->name();
#endif
s_mutex.lock();
s_workQueue.enqueue( item );
s_mutex.unlock();
s_waitCond.wakeOne();
#if ID_THREAD_DEBUG
qDebug() << "DONE WOKE UP THREAD:" << album->artist()->name() << album->name();
#endif
}
void
IdThreadWorker::run()
{
m_impl = m_db->impl()->clone();
while ( !m_stop )
{
s_mutex.lock();
#if ID_THREAD_DEBUG
qDebug() << "IdWorkerThread waiting on condition...";
#endif
s_waitCond.wait( &s_mutex );
#if ID_THREAD_DEBUG
qDebug() << "IdWorkerThread WOKEN UP";
#endif
while ( !s_workQueue.isEmpty() )
{
QueueItem* item = s_workQueue.dequeue();
s_mutex.unlock();
#if ID_THREAD_DEBUG
qDebug() << "WITH CONTENTS:" << (item->type == ArtistType ? item->artist->name() : item->album->artist()->name() + " _ " + item->album->name());
#endif
if ( item->type == ArtistType )
{
unsigned int id = m_impl->artistId( item->artist->name(), item->create );
item->promise.set_value( id );
item->artist->id();
delete item;
}
else if ( item->type == AlbumType )
{
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->album->id();
delete item;
}
s_mutex.lock();
}
s_mutex.unlock();
}
}

View File

@@ -1,56 +0,0 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2012 Leo Franchi <lfranchi@kde.org>
*
* Tomahawk is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Tomahawk is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef IDTHREADWORKER_H
#define IDTHREADWORKER_H
#include "DllMacro.h"
#include "Typedefs.h"
#include <QThread>
#include <QQueue>
#include <QWaitCondition>
#include <QMutex>
#include <boost/thread.hpp>
class QueueItem;
class Database;
class DatabaseImpl;
class DLLEXPORT IdThreadWorker : public QThread
{
Q_OBJECT
public:
explicit IdThreadWorker( Database* db );
virtual ~IdThreadWorker();
void run();
void stop();
static void getArtistId( const Tomahawk::artist_ptr& artist, bool autoCreate = false );
static void getAlbumId( const Tomahawk::album_ptr& album, bool autoCreate = false );
private:
Database* m_db;
DatabaseImpl* m_impl;
bool m_stop;
static QQueue< QueueItem* > s_workQueue;
};
#endif // IDTHREADWORKER_H

View File

@@ -165,7 +165,7 @@ TemporaryPageItem::linkActionTriggered( QAction* action )
{
TrackInfoWidget* tPage = dynamic_cast< TrackInfoWidget* >( m_page );
Q_ASSERT( tPage );
GlobalActionManager::instance()->copyToClipboard( tPage->query() );
GlobalActionManager::instance()->copyOpenLink( tPage->query() );
break;
}