1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 22:26:32 +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 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 class DLLEXPORT NetworkProxyFactory : public QNetworkProxyFactory
{ {
public: public:

View File

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

View File

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