From 54a60669ff17073e3740cb777b260f1a1989fb03 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Tue, 23 Aug 2011 19:35:35 +0100 Subject: [PATCH] Silence cppcheck warnings in mythgame (minor) --- mythplugins/mythgame/mythgame/gamedetails.cpp | 8 +++- mythplugins/mythgame/mythgame/gamehandler.cpp | 45 +++++++++---------- mythplugins/mythgame/mythgame/gamescan.h | 1 - mythplugins/mythgame/mythgame/gameui.cpp | 12 ++++- mythplugins/mythgame/mythgame/gameui.h | 1 - .../mythgame/mythgame/rom_metadata.cpp | 15 ++++--- mythplugins/mythgame/mythgame/rom_metadata.h | 4 +- 7 files changed, 49 insertions(+), 37 deletions(-) diff --git a/mythplugins/mythgame/mythgame/gamedetails.cpp b/mythplugins/mythgame/mythgame/gamedetails.cpp index c12cd7bfb11..fdff58ea013 100644 --- a/mythplugins/mythgame/mythgame/gamedetails.cpp +++ b/mythplugins/mythgame/mythgame/gamedetails.cpp @@ -12,7 +12,13 @@ GameDetailsPopup::GameDetailsPopup(MythScreenStack *parent, const RomInfo *romInfo) - : MythScreenType (parent, "gamedetailspopup") + : MythScreenType (parent, "gamedetailspopup"), + m_romInfo(romInfo), m_id(""), m_retObject(NULL), + m_gameName(NULL), m_gameType(NULL), m_romName(NULL), + m_crc(NULL), m_romPath(NULL), m_genre(NULL), + m_year(NULL), m_country(NULL), m_plot(NULL), + m_publisher(NULL), m_allSystems(NULL), m_fanartImage(NULL), + m_boxImage(NULL), m_playButton(NULL), m_doneButton(NULL) { m_romInfo = romInfo; } diff --git a/mythplugins/mythgame/mythgame/gamehandler.cpp b/mythplugins/mythgame/mythgame/gamehandler.cpp index 47c53d49865..f48af5507f4 100644 --- a/mythplugins/mythgame/mythgame/gamehandler.cpp +++ b/mythplugins/mythgame/mythgame/gamehandler.cpp @@ -318,12 +318,12 @@ static void UpdateGameCounts(QStringList updatelist) QString System = query.value(1).toString(); int spandisks = query.value(2).toInt(); QString GameName = query.value(3).toString(); - int extlength = 0; basename = RomName; if (spandisks) { + int extlength = 0; pos = RomName.lastIndexOf("."); if (pos > 1) { @@ -517,38 +517,35 @@ void GameHandler::VerifyGameDB(GameHandler *handler) m_progressDlg->SetTotal(query.size()); // For every file we know about, check to see if it still exists. - if (query.isActive() && query.size() > 0) + while (query.next()) { - while (query.next()) + QString RomName = query.value(0).toString(); + QString RomPath = query.value(1).toString(); + QString GameName = query.value(2).toString(); + if (RomName != QString::null) { - QString RomName = query.value(0).toString(); - QString RomPath = query.value(1).toString(); - QString GameName = query.value(2).toString(); - if (RomName != QString::null) + if ((iter = m_GameMap.find(RomName)) != m_GameMap.end()) { - if ((iter = m_GameMap.find(RomName)) != m_GameMap.end()) - { - // If it's both on disk and in the database we're done with it. - m_GameMap.erase(iter); - } - else - { - // If it's only in the database add it to our list and mark it for - // removal. - m_GameMap[RomName] = GameScan(RomName,RomPath + "/" + RomName,inDatabase, - GameName,RomPath); - } + // If it's both on disk and in the database we're done with it. + m_GameMap.erase(iter); + } + else + { + // If it's only in the database add it to our list and mark it for + // removal. + m_GameMap[RomName] = GameScan(RomName,RomPath + "/" + RomName,inDatabase, + GameName,RomPath); } - if (m_progressDlg) - m_progressDlg->SetProgress(++counter); } + if (m_progressDlg) + m_progressDlg->SetProgress(++counter); } if (m_progressDlg) { m_progressDlg->Close(); m_progressDlg = NULL; -} + } } // Recurse through the directory and gather a count on how many files there are to process. @@ -722,7 +719,7 @@ void GameHandler::processGames(GameHandler *handler) if (busyDialog->Create()) popupStack->AddScreen(busyDialog, false); else - delete m_progressDlg; + delete busyDialog; m_GameMap[handler->SystemCmdLine()] = GameScan(handler->SystemCmdLine(), @@ -739,7 +736,7 @@ void GameHandler::processGames(GameHandler *handler) } else { - QString message = QObject::tr("Scanning for %1 game(s)...") + QString message = QObject::tr("Scanning for %1 games...") .arg(handler->SystemName()); CreateProgress(message); diff --git a/mythplugins/mythgame/mythgame/gamescan.h b/mythplugins/mythgame/mythgame/gamescan.h index af27cbff0c3..8ef61687bd7 100644 --- a/mythplugins/mythgame/mythgame/gamescan.h +++ b/mythplugins/mythgame/mythgame/gamescan.h @@ -86,7 +86,6 @@ class GameScanner : public QObject private: GameScannerThread *m_scanThread; - bool m_cancel; }; #endif diff --git a/mythplugins/mythgame/mythgame/gameui.cpp b/mythplugins/mythgame/mythgame/gameui.cpp index 02c7610f500..af23ea956d5 100644 --- a/mythplugins/mythgame/mythgame/gameui.cpp +++ b/mythplugins/mythgame/mythgame/gameui.cpp @@ -42,8 +42,16 @@ class GameTreeInfo Q_DECLARE_METATYPE(GameTreeInfo *) GameUI::GameUI(MythScreenStack *parent) - : MythScreenType(parent, "GameUI"), m_busyPopup(0), - m_scanner(NULL) + : MythScreenType(parent, "GameUI"), + m_showHashed(false), m_gameShowFileName(0), + m_gameTree(NULL), m_favouriteNode(NULL), + m_busyPopup(0), + m_gameUITree(NULL), m_gameTitleText(NULL), + m_gameSystemText(NULL), m_gameYearText(NULL), + m_gameGenreText(NULL), m_gamePlotText(NULL), + m_gameFavouriteState(NULL), m_gameImage(NULL), + m_fanartImage(NULL), m_boxImage(NULL), + m_scanner(NULL) { m_popupStack = GetMythMainWindow()->GetStack("popup stack"); diff --git a/mythplugins/mythgame/mythgame/gameui.h b/mythplugins/mythgame/mythgame/gameui.h index 79e9e3f07fe..93607ae7a2c 100644 --- a/mythplugins/mythgame/mythgame/gameui.h +++ b/mythplugins/mythgame/mythgame/gameui.h @@ -71,7 +71,6 @@ class GameUI : public MythScreenType private: bool m_showHashed; int m_gameShowFileName; - QTimer *timer; MythGenericTree *m_gameTree; MythGenericTree *m_favouriteNode; diff --git a/mythplugins/mythgame/mythgame/rom_metadata.cpp b/mythplugins/mythgame/mythgame/rom_metadata.cpp index f7631a8b1f2..551d7001cc5 100644 --- a/mythplugins/mythgame/mythgame/rom_metadata.cpp +++ b/mythplugins/mythgame/mythgame/rom_metadata.cpp @@ -12,16 +12,19 @@ static int calcOffset(QString GameType, uLong filesize) { result = 0; - if (GameType == "NES") { + if (GameType == "NES") + { result = 16; } - else if (GameType == "SNES") { + else if (GameType == "SNES") + { rom_size = (filesize / 0x2000) * 0x2000; if (rom_size < filesize) result = filesize - rom_size; } - else if (GameType == "PCE") { + else if (GameType == "PCE") + { if (filesize & 0x0FFF) result = filesize & 0x0FFF; @@ -30,7 +33,8 @@ static int calcOffset(QString GameType, uLong filesize) { return result; } -static QString crcStr(uLong crc) { +static QString crcStr(uLong crc) +{ QString tmpcrc(""); tmpcrc = QString("%1").arg( crc, 0, 16 ); @@ -51,7 +55,6 @@ QString crcinfo(QString romname, QString GameType, QString *key, RomDBMap *romDB QString crcRes; char filename_inzip[256]; unz_file_info file_info; - int err; int offset; unzFile zf; int blocksize; @@ -70,7 +73,7 @@ QString crcinfo(QString romname, QString GameType, QString *key, RomDBMap *romDB { if (unzOpenCurrentFile(zf) == UNZ_OK) { - err = unzGetCurrentFileInfo(zf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); + unzGetCurrentFileInfo(zf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); offset = calcOffset(GameType, file_info.uncompressed_size); diff --git a/mythplugins/mythgame/mythgame/rom_metadata.h b/mythplugins/mythgame/mythgame/rom_metadata.h index 2a4ad9c7149..bb5607adc47 100644 --- a/mythplugins/mythgame/mythgame/rom_metadata.h +++ b/mythplugins/mythgame/mythgame/rom_metadata.h @@ -8,7 +8,7 @@ class RomData { -public: + public: RomData(QString lgenre = "", QString lyear = "", QString lcountry = "", QString lgamename = "", QString ldescription = "", QString lpublisher = "", @@ -33,7 +33,7 @@ class RomData QString Platform() const { return platform; } QString Version() const { return version; } -private: + private: QString genre; QString year; QString country;