From 9d81b10ad99005d35723a4d64731c2eed33df5b9 Mon Sep 17 00:00:00 2001 From: Daniel Kristjansson Date: Mon, 8 Aug 2011 09:55:39 -0400 Subject: [PATCH] Convert GameScannerThread to MThread. --- mythplugins/mythgame/mythgame/gamescan.cpp | 22 +++++++++++----------- mythplugins/mythgame/mythgame/gamescan.h | 9 ++++----- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/mythplugins/mythgame/mythgame/gamescan.cpp b/mythplugins/mythgame/mythgame/gamescan.cpp index 667b637562d..7e09ec1aa87 100644 --- a/mythplugins/mythgame/mythgame/gamescan.cpp +++ b/mythplugins/mythgame/mythgame/gamescan.cpp @@ -19,19 +19,19 @@ class MythUIProgressDialog; GameScannerThread::GameScannerThread(QObject *parent) : - m_DBDataChanged(false) + MThread("GameScanner"), m_parent(parent), + m_HasGUI(gCoreContext->HasGUI()), + m_dialog(NULL), m_DBDataChanged(false) { - m_parent = parent; - m_HasGUI = gCoreContext->HasGUI(); } GameScannerThread::~GameScannerThread() { } -void GameScannerThread::run() +void GameScannerThread::run(void) { - threadRegister("GameScanner"); + RunProlog(); LOG(VB_GENERAL, LOG_INFO, QString("Beginning Game Scan.")); @@ -43,7 +43,7 @@ void GameScannerThread::run() verifyFiles(); updateDB(); - threadDeregister(); + RunEpilog(); } @@ -64,7 +64,7 @@ void GameScannerThread::verifyFiles() if (m_HasGUI) SendProgressEvent(counter, (uint)m_dbgames.count(), - tr("Verifying game files")); + GameScanner::tr("Verifying game files")); // For every file we know about, check to see if it still exists. for (QList::iterator p = m_dbgames.begin(); @@ -107,7 +107,7 @@ void GameScannerThread::updateDB() uint counter = 0; if (m_HasGUI) SendProgressEvent(counter, (uint)(m_files.size() + m_remove.size()), - tr("Updating game database")); + GameScanner::tr("Updating game database")); for (QList::iterator p = m_files.begin(); p != m_files.end(); ++p) @@ -142,7 +142,7 @@ bool GameScannerThread::buildFileList() if (m_HasGUI) SendProgressEvent(counter, (uint)m_handlers.size(), - tr("Searching for games...")); + GameScanner::tr("Searching for games...")); for (QList::const_iterator iter = m_handlers.begin(); iter != m_handlers.end(); ++iter) @@ -217,9 +217,9 @@ void GameScanner::doScan(QList handlers) if (progressDlg->Create()) { popupStack->AddScreen(progressDlg, false); - connect(m_scanThread, SIGNAL(finished()), + connect(m_scanThread->qthread(), SIGNAL(finished()), progressDlg, SLOT(Close())); - connect(m_scanThread, SIGNAL(finished()), + connect(m_scanThread->qthread(), SIGNAL(finished()), SLOT(finishedScan())); } else diff --git a/mythplugins/mythgame/mythgame/gamescan.h b/mythplugins/mythgame/mythgame/gamescan.h index cd688b414fa..af27cbff0c3 100644 --- a/mythplugins/mythgame/mythgame/gamescan.h +++ b/mythplugins/mythgame/mythgame/gamescan.h @@ -6,9 +6,10 @@ #include // for moc #include -#include #include +#include "mthread.h" + class QStringList; class MythUIProgressDialog; @@ -27,15 +28,13 @@ struct RomFileInfo typedef QList< RomFileInfo > RomFileInfoList; -class GameScannerThread : public QThread +class GameScannerThread : public MThread { - Q_OBJECT - public: GameScannerThread(QObject *parent); ~GameScannerThread(); - void run(); + virtual void run(void); // MThread void SetHandlers(QList handlers) { m_handlers = handlers; }; void SetProgressDialog(MythUIProgressDialog *dialog) { m_dialog = dialog; };