From a9aa84e3a3d0dc47cf7e642463eafd52e821007d Mon Sep 17 00:00:00 2001 From: stephena Date: Fri, 7 Nov 2014 14:26:56 +0000 Subject: [PATCH] Some more nullptr and formatting cleanups. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3051 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- src/cheat/BankRomCheat.hxx | 2 +- src/cheat/Cheat.hxx | 2 +- src/cheat/CheatCodeDialog.cxx | 3 +-- src/cheat/CheatCodeDialog.hxx | 4 ++-- src/cheat/CheatManager.cxx | 8 ++++---- src/cheat/CheetahCheat.hxx | 2 +- src/debugger/CartDebug.cxx | 2 +- src/unix/FSNodePOSIX.cxx | 6 +++--- src/windows/FSNodeWINDOWS.cxx | 36 +++++++++++++++++------------------ 9 files changed, 32 insertions(+), 33 deletions(-) diff --git a/src/cheat/BankRomCheat.hxx b/src/cheat/BankRomCheat.hxx index 62487db21..646d0ded5 100644 --- a/src/cheat/BankRomCheat.hxx +++ b/src/cheat/BankRomCheat.hxx @@ -26,7 +26,7 @@ class BankRomCheat : public Cheat { public: BankRomCheat(OSystem& os, const string& name, const string& code); - ~BankRomCheat(); + virtual ~BankRomCheat(); bool enable(); bool disable(); diff --git a/src/cheat/Cheat.hxx b/src/cheat/Cheat.hxx index 31eef3cfb..5a8377b53 100644 --- a/src/cheat/Cheat.hxx +++ b/src/cheat/Cheat.hxx @@ -53,7 +53,7 @@ class Cheat { int ret = 0; - for(unsigned int i=0; i(this, font, labels); myCheatInput->setTarget(this); addToFocusList(wid); @@ -100,7 +100,6 @@ CheatCodeDialog::CheatCodeDialog(OSystem& osystem, DialogContainer& parent, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CheatCodeDialog::~CheatCodeDialog() { - delete myCheatInput; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/cheat/CheatCodeDialog.hxx b/src/cheat/CheatCodeDialog.hxx index 44f9d5153..8fe3c52e5 100644 --- a/src/cheat/CheatCodeDialog.hxx +++ b/src/cheat/CheatCodeDialog.hxx @@ -41,7 +41,7 @@ class CheatCodeDialog : public Dialog virtual ~CheatCodeDialog(); protected: - virtual void handleCommand(CommandSender* sender, int cmd, int data, int id); + void handleCommand(CommandSender* sender, int cmd, int data, int id); void loadConfig(); void saveConfig(); @@ -53,7 +53,7 @@ class CheatCodeDialog : public Dialog private: CheckListWidget* myCheatList; - InputTextDialog* myCheatInput; + unique_ptr myCheatInput; ButtonWidget* myEditButton; ButtonWidget* myRemoveButton; diff --git a/src/cheat/CheatManager.cxx b/src/cheat/CheatManager.cxx index 8e18656e8..a032be14e 100644 --- a/src/cheat/CheatManager.cxx +++ b/src/cheat/CheatManager.cxx @@ -52,7 +52,7 @@ Cheat* CheatManager::add(const string& name, const string& code, { Cheat* cheat = createCheat(name, code); if(!cheat) - return NULL; + return nullptr; // Delete duplicate entries for(unsigned int i = 0; i < myCheatList.size(); i++) @@ -129,7 +129,7 @@ void CheatManager::addPerFrame(Cheat* cheat, bool enable) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void CheatManager::addOneShot(const string& name, const string& code) { - Cheat* cheat = (Cheat*) createCheat(name, code); + Cheat* cheat = createCheat(name, code); if(!cheat) return; @@ -142,7 +142,7 @@ void CheatManager::addOneShot(const string& name, const string& code) Cheat* CheatManager::createCheat(const string& name, const string& code) const { if(!isValidCode(code)) - return NULL; + return nullptr; // Create new cheat based on string length switch(code.size()) @@ -160,7 +160,7 @@ Cheat* CheatManager::createCheat(const string& name, const string& code) const break; default: - return NULL; + return nullptr; } } diff --git a/src/cheat/CheetahCheat.hxx b/src/cheat/CheetahCheat.hxx index 2756ee67d..c51a7a76c 100644 --- a/src/cheat/CheetahCheat.hxx +++ b/src/cheat/CheetahCheat.hxx @@ -26,7 +26,7 @@ class CheetahCheat : public Cheat { public: CheetahCheat(OSystem& os, const string& name, const string& code); - ~CheetahCheat(); + virtual ~CheetahCheat(); bool enable(); bool disable(); diff --git a/src/debugger/CartDebug.cxx b/src/debugger/CartDebug.cxx index 261dffb6a..2a318dca7 100644 --- a/src/debugger/CartDebug.cxx +++ b/src/debugger/CartDebug.cxx @@ -38,7 +38,7 @@ using namespace Common; CartDebug::CartDebug(Debugger& dbg, Console& console, const OSystem& osystem) : DebuggerSystem(dbg, console), myOSystem(osystem), - myDebugWidget(0), + myDebugWidget(nullptr), myAddrToLineIsROM(true), myRWPortAddress(0), myLabelLength(8) // longest pre-defined label diff --git a/src/unix/FSNodePOSIX.cxx b/src/unix/FSNodePOSIX.cxx index 15f2168fa..a453f6d6d 100644 --- a/src/unix/FSNodePOSIX.cxx +++ b/src/unix/FSNodePOSIX.cxx @@ -121,8 +121,8 @@ bool FilesystemNodePOSIX::getChildren(AbstractFSList& myList, ListMode mode, { assert(_isDirectory); - DIR *dirp = opendir(_path.c_str()); - struct dirent *dp; + DIR* dirp = opendir(_path.c_str()); + struct dirent* dp; if (dirp == NULL) return false; @@ -254,7 +254,7 @@ bool FilesystemNodePOSIX::rename(const string& newfile) AbstractFSNode* FilesystemNodePOSIX::getParent() const { if (_path == "/") - return 0; + return nullptr; const char *start = _path.c_str(); const char *end = lastPathComponent(_path); diff --git a/src/windows/FSNodeWINDOWS.cxx b/src/windows/FSNodeWINDOWS.cxx index 310211ee2..e5fd04aea 100644 --- a/src/windows/FSNodeWINDOWS.cxx +++ b/src/windows/FSNodeWINDOWS.cxx @@ -63,10 +63,10 @@ const char* lastPathComponent(const string& str) if(str.empty()) return ""; - const char *start = str.c_str(); - const char *cur = start + str.size() - 2; + const char* start = str.c_str(); + const char* cur = start + str.size() - 2; - while (cur >= start && *cur != '\\') + while(cur >= start && *cur != '\\') --cur; return cur + 1; @@ -103,7 +103,7 @@ void FilesystemNodeWINDOWS::setFlags() // Check whether it is a directory, and whether the file actually exists DWORD fileAttribs = GetFileAttributes(toUnicode(_path.c_str())); - if (fileAttribs == INVALID_FILE_ATTRIBUTES) + if(fileAttribs == INVALID_FILE_ATTRIBUTES) { _isDirectory = _isFile = _isValid = false; } @@ -129,14 +129,14 @@ void FilesystemNodeWINDOWS::addFile(AbstractFSList& list, ListMode mode, bool isDirectory, isFile; // Skip local directory (.) and parent (..) - if (!strncmp(asciiName, ".", 1) || !strncmp(asciiName, "..", 2)) + if(!strncmp(asciiName, ".", 1) || !strncmp(asciiName, "..", 2)) return; isDirectory = (find_data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? true : false); isFile = !isDirectory;//(find_data->dwFileAttributes & FILE_ATTRIBUTE_NORMAL ? true : false); - if ((isFile && mode == FilesystemNode::kListDirectoriesOnly) || - (isDirectory && mode == FilesystemNode::kListFilesOnly)) + if((isFile && mode == FilesystemNode::kListDirectoriesOnly) || + (isDirectory && mode == FilesystemNode::kListFilesOnly)) return; entry._isDirectory = isDirectory; @@ -144,7 +144,7 @@ void FilesystemNodeWINDOWS::addFile(AbstractFSList& list, ListMode mode, entry._displayName = asciiName; entry._path = base; entry._path += asciiName; - if (entry._isDirectory) + if(entry._isDirectory) entry._path += "\\"; entry._isValid = true; entry._isPseudoRoot = false; @@ -224,14 +224,14 @@ bool FilesystemNodeWINDOWS:: //TODO: honor the hidden flag - if (_isPseudoRoot) + if(_isPseudoRoot) { // Drives enumeration TCHAR drive_buffer[100]; GetLogicalDriveStrings(sizeof(drive_buffer) / sizeof(TCHAR), drive_buffer); - for (TCHAR *current_drive = drive_buffer; *current_drive; - current_drive += _tcslen(current_drive) + 1) + for(TCHAR *current_drive = drive_buffer; *current_drive; + current_drive += _tcslen(current_drive) + 1) { FilesystemNodeWINDOWS entry; char drive_name[2]; @@ -258,12 +258,12 @@ bool FilesystemNodeWINDOWS:: handle = FindFirstFile(toUnicode(searchPath), &desc); - if (handle == INVALID_HANDLE_VALUE) + if(handle == INVALID_HANDLE_VALUE) return false; addFile(myList, mode, _path.c_str(), &desc); - while (FindNextFile(handle, &desc)) + while(FindNextFile(handle, &desc)) addFile(myList, mode, _path.c_str(), &desc); FindClose(handle); @@ -299,14 +299,14 @@ bool FilesystemNodeWINDOWS::rename(const string& newfile) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - AbstractFSNode* FilesystemNodeWINDOWS::getParent() const { - if (!_isValid || _isPseudoRoot) - return 0; + if(!_isValid || _isPseudoRoot) + return nullptr; FilesystemNodeWINDOWS* p = new FilesystemNodeWINDOWS(); - if (_path.size() > 3) + if(_path.size() > 3) { - const char *start = _path.c_str(); - const char *end = lastPathComponent(_path); + const char* start = _path.c_str(); + const char* end = lastPathComponent(_path); p->_path = string(start, end - start); p->_isValid = true;