From b8cdabbd20690d57930dce9dda949fca21a6233a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 1 Sep 2011 20:04:35 +0300 Subject: Eliminate asserts from most files. --- src/gui/charselectdialog.cpp | 5 ++--- src/gui/popupmenu.cpp | 2 -- src/gui/quitdialog.cpp | 15 +++++---------- src/gui/widgets/layout.cpp | 7 +++++-- src/gui/widgets/window.cpp | 3 ++- 5 files changed, 14 insertions(+), 18 deletions(-) (limited to 'src/gui') diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index 28c7a083c..1942ebaeb 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -60,7 +60,6 @@ #include #include -#include #include "debug.h" @@ -342,8 +341,8 @@ void CharSelectDialog::setCharacters(const Net::Characters &characters) void CharSelectDialog::lock() { - assert(!mLocked); - setLocked(true); + if (!mLocked) + setLocked(true); } void CharSelectDialog::unlock() diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 6db4a408f..0eac0a4f9 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -78,8 +78,6 @@ #include "utils/gettext.h" #include "utils/stringutils.h" -#include - #include "debug.h" std::string tradePartnerName(""); diff --git a/src/gui/quitdialog.cpp b/src/gui/quitdialog.cpp index f66872b5d..04f43fb88 100644 --- a/src/gui/quitdialog.cpp +++ b/src/gui/quitdialog.cpp @@ -41,23 +41,17 @@ #include "utils/gettext.h" -#include - #include "debug.h" QuitDialog::QuitDialog(QuitDialog** pointerToMe): Window(_("Quit"), true, NULL), mMyPointer(pointerToMe) { -// int width = 200; -// int height = 120; - mForceQuit = new RadioButton(_("Quit"), "quitdialog"); mLogoutQuit = new RadioButton(_("Quit"), "quitdialog"); mSwitchAccountServer = new RadioButton(_("Switch server"), "quitdialog"); mSwitchCharacter = new RadioButton(_("Switch character"), "quitdialog"); mOkButton = new Button(_("OK"), "ok", this); mCancelButton = new Button(_("Cancel"), "cancel", this); -// setContentSize(width, height); addKeyListener(this); @@ -149,10 +143,11 @@ void QuitDialog::action(const gcn::ActionEvent &event) } else if (mSwitchCharacter->isSelected()) { - assert(Client::getState() == STATE_GAME); - - Net::getCharHandler()->switchCharacter(); - Client::closeDialogs(); + if (Client::getState() == STATE_GAME) + { + Net::getCharHandler()->switchCharacter(); + Client::closeDialogs(); + } } } scheduleDelete(); diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp index 382d169dc..a14b416ce 100644 --- a/src/gui/widgets/layout.cpp +++ b/src/gui/widgets/layout.cpp @@ -68,7 +68,9 @@ LayoutArray &LayoutCell::getArray() void LayoutCell::reflow(int nx, int ny, int nw, int nh) { - assert(mType != NONE); + if (mType == NONE) + return; + nx += mHPadding; ny += mVPadding; nw -= 2 * mHPadding; @@ -81,7 +83,8 @@ void LayoutCell::reflow(int nx, int ny, int nw, int nh) void LayoutCell::computeSizes() { - assert(mType == ARRAY); + if (mType != ARRAY) + return; std::vector< std::vector< LayoutCell * > >::iterator i = mArray->mCells.begin(); diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 7508d4e4b..0a3779307 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -663,7 +663,8 @@ void Window::setModal(bool modal) void Window::loadWindowState() { const std::string &name = mWindowName; - assert(!name.empty()); + if (name.empty()) + return; setPosition(config.getValueInt(name + "WinX", mDefaultX), config.getValueInt(name + "WinY", mDefaultY)); -- cgit v1.2.3-70-g09d2