From 7e66a4606bb15d98197f71245fe191d03152ee5f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 8 Feb 2016 23:02:06 +0300 Subject: Improve some empty string checks. --- src/gui/theme.cpp | 2 +- src/gui/widgets/popup.cpp | 2 +- src/gui/widgets/radiobutton.cpp | 2 +- src/gui/widgets/scrollarea.cpp | 2 +- src/gui/widgets/window.cpp | 2 +- src/gui/windowmenu.cpp | 2 +- src/gui/windows/chatwindow.cpp | 4 ++-- src/gui/windows/logindialog.cpp | 5 ++++- src/gui/windows/ministatuswindow.cpp | 2 +- src/gui/windows/npcdialog.cpp | 4 ++-- src/gui/windows/updaterwindow.cpp | 2 +- 11 files changed, 16 insertions(+), 13 deletions(-) (limited to 'src/gui') diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 20ec774dc..f36a45579 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -983,7 +983,7 @@ static int readProgressType(const std::string &type) void Theme::loadColors(std::string file) { - if (file == "") + if (file.empty()) file = "colors.xml"; else file.append("/colors.xml"); diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index 2c707b295..bd94236b9 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -55,7 +55,7 @@ Popup::Popup(const std::string &name, addWidgetListener(this); - if (skin == "") + if (skin.empty()) skin = "popup.xml"; if (theme) diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index 0f67bc54b..89b9b2341 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -315,7 +315,7 @@ void RadioButton::mouseDragged(MouseEvent& event) void RadioButton::setGroup(const std::string &group) { - if (mGroup != "") + if (!mGroup.empty()) { for (GroupIterator iter = mGroupMap.lower_bound(mGroup), iterEnd = mGroupMap.upper_bound(mGroup); diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 5bf67bfda..d515f3c66 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -195,7 +195,7 @@ void ScrollArea::init(std::string skinName) } // +++ here probably need move background from static - if (skinName == "") + if (skinName.empty()) skinName = "scroll_background.xml"; if (theme) { diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 450c2e025..886372035 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -174,7 +174,7 @@ Window::Window(const std::string &caption, setPadding(3); setTitleBarHeight(20); - if (skin == "") + if (skin.empty()) skin = "window.xml"; int childPalette = 1; diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 6633fcb90..ec51062eb 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -378,7 +378,7 @@ void WindowMenu::loadButtons() { if (!mSmallWindow) { - if (config.getValue("windowmenu0", "") == "") + if (config.getValue("windowmenu0", "").empty()) { for (std::map ::iterator it = mButtonNames.begin(), diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 1551c10ae..5be54a6f9 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -801,7 +801,7 @@ void ChatWindow::keyPressed(KeyEvent &event) mChatInput->getText().length())); } else if (actionId == InputAction::GUI_INSERT && - mChatInput->getText() != "") + !mChatInput->getText().empty()) { // Add the current message to the history and clear the text if (mHistory.empty() || mChatInput->getText() != mHistory.back()) @@ -1505,7 +1505,7 @@ std::string ChatWindow::autoCompleteHistory(const std::string &partName) const f++; line = line.substr(0, f); - if (line != "") + if (!line.empty()) nameList.push_back(line); ++i; diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp index c39486dda..34f84fee4 100644 --- a/src/gui/windows/logindialog.cpp +++ b/src/gui/windows/logindialog.cpp @@ -125,8 +125,11 @@ LoginDialog::LoginDialog(LoginData &data, } mUpdateHostText->adjustSize(); - if (mPassField->getText().empty() && LoginDialog::savedPassword != "") + if (mPassField->getText().empty() && + !LoginDialog::savedPassword.empty()) + { mPassField->setText(LoginDialog::savedPassword); + } mUpdateTypeDropDown->setActionEventId("updatetype"); mUpdateTypeDropDown->setSelected((mLoginData->updateType diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp index fc2e9a82c..e0fe46bb3 100644 --- a/src/gui/windows/ministatuswindow.cpp +++ b/src/gui/windows/ministatuswindow.cpp @@ -507,7 +507,7 @@ void MiniStatusWindow::loadBars() { const std::string str = config.getValue( "ministatus" + toString(f), ""); - if (str == "") + if (str.empty()) continue; ProgressBar *const bar = mBarNames[str]; if (!bar) diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp index 27386af5b..452567b94 100644 --- a/src/gui/windows/npcdialog.cpp +++ b/src/gui/windows/npcdialog.cpp @@ -489,7 +489,7 @@ void NpcDialog::action(const ActionEvent &event) const int sz = mComplexInventory->getSize(); if (sz == 0) { - str = ""; + str.clear(); } else { @@ -1385,7 +1385,7 @@ std::string NpcDialog::complexItemToStr(const ComplexItem *const item) } else { - str = ""; + str.clear(); } return str; } diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp index e6e97553a..09f529259 100644 --- a/src/gui/windows/updaterwindow.cpp +++ b/src/gui/windows/updaterwindow.cpp @@ -145,7 +145,7 @@ static std::vector loadTxtFile(const std::string &fileName) thisFile.name = name; thisFile.hash = hash; thisFile.type = "data"; - thisFile.group = ""; + thisFile.group.clear(); thisFile.required = true; thisFile.desc.clear(); -- cgit v1.2.3-70-g09d2