mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-10-05 18:11:36 +02:00
Check thread when scanning.
This commit is contained in:
@@ -138,21 +138,23 @@ ScanManager::runFullRescan()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
void
|
||||||
ScanManager::runNormalScan( bool manualFull )
|
ScanManager::runNormalScan( bool manualFull )
|
||||||
{
|
{
|
||||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||||
|
|
||||||
|
if ( QThread::currentThread() != ScanManager::instance()->thread() )
|
||||||
|
return;
|
||||||
|
|
||||||
if ( !Database::instance() || ( Database::instance() && !Database::instance()->isReady() ) )
|
if ( !Database::instance() || ( Database::instance() && !Database::instance()->isReady() ) )
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
if ( m_musicScannerThreadController || !m_scanner.isNull() ) //still running if these are not zero
|
if ( m_musicScannerThreadController || !m_scanner.isNull() ) //still running if these are not zero
|
||||||
{
|
{
|
||||||
tDebug( LOGVERBOSE ) << "Could not run dir scan, old scan still running";
|
tDebug( LOGVERBOSE ) << "Could not run dir scan, old scan still running";
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
m_scanTimer->stop();
|
m_scanTimer->stop();
|
||||||
m_musicScannerThreadController = new QThread( this );
|
m_musicScannerThreadController = new QThread( this );
|
||||||
m_currScanMode = DirScan;
|
m_currScanMode = DirScan;
|
||||||
@@ -162,7 +164,7 @@ ScanManager::runNormalScan( bool manualFull )
|
|||||||
DatabaseCommand_DeleteFiles *cmd = new DatabaseCommand_DeleteFiles( SourceList::instance()->getLocal() );
|
DatabaseCommand_DeleteFiles *cmd = new DatabaseCommand_DeleteFiles( SourceList::instance()->getLocal() );
|
||||||
connect( cmd, SIGNAL( finished() ), SLOT( filesDeleted() ) );
|
connect( cmd, SIGNAL( finished() ), SLOT( filesDeleted() ) );
|
||||||
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DatabaseCommand_FileMtimes *cmd = new DatabaseCommand_FileMtimes( true );
|
DatabaseCommand_FileMtimes *cmd = new DatabaseCommand_FileMtimes( true );
|
||||||
@@ -170,26 +172,26 @@ ScanManager::runNormalScan( bool manualFull )
|
|||||||
SLOT( fileMtimesCheck( const QMap< QString, QMap< unsigned int, unsigned int > >& ) ) );
|
SLOT( fileMtimesCheck( const QMap< QString, QMap< unsigned int, unsigned int > >& ) ) );
|
||||||
|
|
||||||
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
Database::instance()->enqueue( QSharedPointer< DatabaseCommand >( cmd ) );
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
void
|
||||||
ScanManager::runFileScan( const QStringList &paths )
|
ScanManager::runFileScan( const QStringList &paths )
|
||||||
{
|
{
|
||||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||||
|
if ( QThread::currentThread() != ScanManager::instance()->thread() )
|
||||||
|
return;
|
||||||
|
|
||||||
foreach( const QString& path, paths )
|
foreach( const QString& path, paths )
|
||||||
m_currScannerPaths.insert( path );
|
m_currScannerPaths.insert( path );
|
||||||
|
|
||||||
if ( !Database::instance() || ( Database::instance() && !Database::instance()->isReady() ) )
|
if ( !Database::instance() || ( Database::instance() && !Database::instance()->isReady() ) )
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
if ( m_musicScannerThreadController || !m_scanner.isNull() ) //still running if these are not zero
|
if ( m_musicScannerThreadController || !m_scanner.isNull() ) //still running if these are not zero
|
||||||
{
|
{
|
||||||
tDebug( LOGVERBOSE ) << "Could not run file scan, old scan still running";
|
tDebug( LOGVERBOSE ) << "Could not run file scan, old scan still running";
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_scanTimer->stop();
|
m_scanTimer->stop();
|
||||||
@@ -197,8 +199,6 @@ ScanManager::runFileScan( const QStringList &paths )
|
|||||||
m_currScanMode = FileScan;
|
m_currScanMode = FileScan;
|
||||||
|
|
||||||
QMetaObject::invokeMethod( this, "runScan", Qt::QueuedConnection );
|
QMetaObject::invokeMethod( this, "runScan", Qt::QueuedConnection );
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -51,9 +51,9 @@ signals:
|
|||||||
void finished();
|
void finished();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool runFileScan( const QStringList &paths );
|
void runFileScan( const QStringList &paths );
|
||||||
void runFullRescan();
|
void runFullRescan();
|
||||||
bool runNormalScan( bool manualFull = false );
|
void runNormalScan( bool manualFull = false );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void runStartupScan();
|
void runStartupScan();
|
||||||
|
Reference in New Issue
Block a user