diff --git a/src/libtomahawk/infosystem/infosystem.cpp b/src/libtomahawk/infosystem/infosystem.cpp index b938f4ad6..332493cfb 100644 --- a/src/libtomahawk/infosystem/infosystem.cpp +++ b/src/libtomahawk/infosystem/infosystem.cpp @@ -83,63 +83,32 @@ InfoSystem::InfoSystem(QObject *parent) InfoSystem::~InfoSystem() { qDebug() << Q_FUNC_INFO << " beginning"; - + if ( !m_worker.isNull() ) { - QMetaObject::invokeMethod( m_worker.data(), "deleteLater", Qt::QueuedConnection ); - while( !m_worker.isNull() ) - { - qDebug() << Q_FUNC_INFO << " worker not deleted"; - TomahawkUtils::Sleep::msleep( 50 ); - } - - if ( m_infoSystemWorkerThreadController ) - m_infoSystemWorkerThreadController->quit(); - if( m_infoSystemWorkerThreadController ) { - while( !m_infoSystemWorkerThreadController->isFinished() ) - { - qDebug() << Q_FUNC_INFO << " worker thread controller not finished"; - TomahawkUtils::Sleep::msleep( 50 ); - } - - qDebug() << Q_FUNC_INFO << " worker thread controller finished, deleting worker"; + m_worker.clear(); + m_infoSystemWorkerThreadController->quit(); + m_infoSystemWorkerThreadController->wait( 60000 ); delete m_infoSystemWorkerThreadController; + qDebug() << Q_FUNC_INFO << " worker thread controller finished, deleting worker"; m_infoSystemWorkerThreadController = 0; } } qDebug() << Q_FUNC_INFO << " done deleting worker"; - if ( !m_cache.isNull() ) + if( m_infoSystemCacheThreadController ) { - QMetaObject::invokeMethod( m_cache.data(), "deleteLater", Qt::QueuedConnection ); - while( !m_cache.isNull() ) - { - qDebug() << Q_FUNC_INFO << " cache not deleted"; - TomahawkUtils::Sleep::msleep( 50 ); - } - - qDebug() << Q_FUNC_INFO << " cache deleted, telling cache thread controller to quit"; - - if ( m_infoSystemCacheThreadController ) - m_infoSystemCacheThreadController->quit(); - - if( m_infoSystemCacheThreadController ) - { - while( !m_infoSystemCacheThreadController->isFinished() ) - { - qDebug() << Q_FUNC_INFO << " cache thread controller not finished"; - TomahawkUtils::Sleep::msleep( 50 ); - } - - qDebug() << Q_FUNC_INFO << " cache thread controller finished, deleting cache"; - delete m_infoSystemCacheThreadController; - m_infoSystemCacheThreadController = 0; - } + m_cache.clear(); + m_infoSystemCacheThreadController->quit(); + m_infoSystemCacheThreadController->wait( 60000 ); + delete m_infoSystemCacheThreadController; + qDebug() << Q_FUNC_INFO << " cache thread controller finished, deleting cache"; + m_infoSystemCacheThreadController = 0; } - + qDebug() << Q_FUNC_INFO << " done deleting cache, exiting"; } diff --git a/src/libtomahawk/infosystem/infosystemworker.cpp b/src/libtomahawk/infosystem/infosystemworker.cpp index f1761021f..190b00dbd 100644 --- a/src/libtomahawk/infosystem/infosystemworker.cpp +++ b/src/libtomahawk/infosystem/infosystemworker.cpp @@ -49,6 +49,7 @@ InfoSystemWorker::~InfoSystemWorker() if( plugin ) delete plugin.data(); } + qDebug() << Q_FUNC_INFO << " finished"; } @@ -169,7 +170,7 @@ InfoSystemWorker::nam() const { if ( m_nam.isNull() ) return 0; - + return m_nam.data(); } @@ -187,7 +188,7 @@ InfoSystemWorker::newNam() emit namChanged( m_nam.data() ); return; } - + qDebug() << Q_FUNC_INFO << " no nam exists, or it's a different thread, creating a new one"; QNetworkAccessManager* newNam; #ifdef LIBLASTFM_FOUND