1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-07 17:42:35 +02:00

Update dtor logic of other threads

This commit is contained in:
Jeff Mitchell 2011-05-30 09:45:42 -04:00
parent 76aa0461ad
commit d71bdb2fef
3 changed files with 20 additions and 105 deletions

View File

@ -37,23 +37,6 @@ class QNetworkProxy;
namespace TomahawkUtils
{
class DLLEXPORT Sleep : public QThread
{
public:
static void sleep( unsigned long secs )
{
QThread::sleep( secs );
}
static void msleep( unsigned long msecs )
{
QThread::msleep( msecs );
}
static void usleep( unsigned long usecs )
{
QThread::usleep( usecs );
}
};
class DLLEXPORT NetworkProxyFactory : public QNetworkProxyFactory
{
public:

View File

@ -136,29 +136,12 @@ MusicScanner::~MusicScanner()
if ( !m_dirLister.isNull() )
{
QMetaObject::invokeMethod( m_dirLister.data(), "deleteLater", Qt::QueuedConnection );
while( !m_dirLister.isNull() )
{
qDebug() << Q_FUNC_INFO << " scanner not deleted, processing events";
QCoreApplication::processEvents( QEventLoop::AllEvents, 200 );
TomahawkUtils::Sleep::msleep( 100 );
}
m_dirListerThreadController->quit();;
m_dirListerThreadController->wait( 60000 );
if ( m_dirListerThreadController )
m_dirListerThreadController->quit();
if( m_dirListerThreadController )
{
while( !m_dirListerThreadController->isFinished() )
{
qDebug() << Q_FUNC_INFO << " scanner thread controller not finished, processing events";
QCoreApplication::processEvents( QEventLoop::AllEvents, 200 );
TomahawkUtils::Sleep::msleep( 100 );
}
delete m_dirListerThreadController;
m_dirListerThreadController = 0;
}
delete m_dirLister.data();
delete m_dirListerThreadController;
m_dirListerThreadController = 0;
}
}
@ -257,29 +240,12 @@ MusicScanner::deleteLister()
{
if ( !m_dirLister.isNull() )
{
QMetaObject::invokeMethod( m_dirLister.data(), "deleteLater", Qt::QueuedConnection );
while( !m_dirLister.isNull() )
{
qDebug() << Q_FUNC_INFO << " scanner not deleted, processing events";
QCoreApplication::processEvents( QEventLoop::AllEvents, 200 );
TomahawkUtils::Sleep::msleep( 100 );
}
m_dirListerThreadController->quit();;
m_dirListerThreadController->wait( 60000 );
if ( m_dirListerThreadController )
m_dirListerThreadController->quit();
if( m_dirListerThreadController )
{
while( !m_dirListerThreadController->isFinished() )
{
qDebug() << Q_FUNC_INFO << " scanner thread controller not finished, processing events";
QCoreApplication::processEvents( QEventLoop::AllEvents, 200 );
TomahawkUtils::Sleep::msleep( 100 );
}
delete m_dirListerThreadController;
m_dirListerThreadController = 0;
}
delete m_dirLister.data();
delete m_dirListerThreadController;
m_dirListerThreadController = 0;
}
emit finished();
}

View File

@ -85,29 +85,12 @@ ScanManager::~ScanManager()
if ( !m_scanner.isNull() )
{
QMetaObject::invokeMethod( m_scanner.data(), "deleteLater", Qt::QueuedConnection );
while( !m_scanner.isNull() )
{
qDebug() << Q_FUNC_INFO << " scanner not deleted, processing events";
QCoreApplication::processEvents( QEventLoop::AllEvents, 200 );
TomahawkUtils::Sleep::msleep( 100 );
}
m_musicScannerThreadController->quit();
m_musicScannerThreadController->wait( 60000 );
if ( m_musicScannerThreadController )
m_musicScannerThreadController->quit();
if( m_musicScannerThreadController )
{
while( !m_musicScannerThreadController->isFinished() )
{
qDebug() << Q_FUNC_INFO << " scanner thread controller not finished, processing events";
QCoreApplication::processEvents( QEventLoop::AllEvents, 200 );
TomahawkUtils::Sleep::msleep( 100 );
}
delete m_musicScannerThreadController;
m_musicScannerThreadController = 0;
}
delete m_scanner.data();
delete m_musicScannerThreadController;
m_musicScannerThreadController = 0;
}
}
@ -250,29 +233,12 @@ ScanManager::scannerFinished()
{
if ( !m_scanner.isNull() )
{
QMetaObject::invokeMethod( m_scanner.data(), "deleteLater", Qt::QueuedConnection );
while( !m_scanner.isNull() )
{
qDebug() << Q_FUNC_INFO << " scanner not deleted, processing events";
QCoreApplication::processEvents( QEventLoop::AllEvents, 200 );
TomahawkUtils::Sleep::msleep( 100 );
}
m_musicScannerThreadController->quit();
m_musicScannerThreadController->wait( 60000 );
if ( m_musicScannerThreadController )
m_musicScannerThreadController->quit();
if( m_musicScannerThreadController )
{
while( !m_musicScannerThreadController->isFinished() )
{
qDebug() << Q_FUNC_INFO << " scanner thread controller not finished, processing events";
QCoreApplication::processEvents( QEventLoop::AllEvents, 200 );
TomahawkUtils::Sleep::msleep( 100 );
}
delete m_musicScannerThreadController;
m_musicScannerThreadController = 0;
}
delete m_scanner.data();
delete m_musicScannerThreadController;
m_musicScannerThreadController = 0;
}
emit finished();
}