summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-02-16 21:28:08 +0300
committerAndrei Karas <akaras@inbox.ru>2014-02-16 21:28:08 +0300
commit82ac4641828ec7387863bb18cf4493190c4cc68f (patch)
tree54fa2aeeff83109ca289894bf08bc767084050a3 /src/gui
parent07e8275965ccb989e3bcc288e2440bffcbca4a8e (diff)
downloadplus-82ac4641828ec7387863bb18cf4493190c4cc68f.tar.gz
plus-82ac4641828ec7387863bb18cf4493190c4cc68f.tar.bz2
plus-82ac4641828ec7387863bb18cf4493190c4cc68f.tar.xz
plus-82ac4641828ec7387863bb18cf4493190c4cc68f.zip
Remove Exception class.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/base/basiccontainer.cpp10
-rw-r--r--src/gui/base/exception.cpp120
-rw-r--r--src/gui/base/exception.hpp196
-rw-r--r--src/gui/base/focushandler.cpp9
-rw-r--r--src/gui/base/gui.cpp7
-rw-r--r--src/gui/base/widget.cpp26
-rw-r--r--src/gui/base/widgets/button.cpp1
-rw-r--r--src/gui/base/widgets/container.cpp1
-rw-r--r--src/gui/base/widgets/label.cpp1
-rw-r--r--src/gui/base/widgets/scrollarea.cpp9
-rw-r--r--src/gui/base/widgets/window.cpp1
-rw-r--r--src/gui/gui.cpp69
-rw-r--r--src/gui/sdlfont.cpp8
-rw-r--r--src/gui/sdlinput.cpp10
-rw-r--r--src/gui/widgets/popup.cpp8
-rw-r--r--src/gui/widgets/window.cpp7
16 files changed, 32 insertions, 451 deletions
diff --git a/src/gui/base/basiccontainer.cpp b/src/gui/base/basiccontainer.cpp
index 7a937fb42..4a745dc63 100644
--- a/src/gui/base/basiccontainer.cpp
+++ b/src/gui/base/basiccontainer.cpp
@@ -69,7 +69,6 @@
#include <algorithm>
-#include "gui/base/exception.hpp"
#include "gui/base/focushandler.hpp"
#include "gui/base/mouseinput.hpp"
@@ -96,8 +95,6 @@ namespace gcn
return;
}
}
-
- throw GCN_EXCEPTION("There is no such widget in this container.");
}
void BasicContainer::moveToBottom(Widget* widget)
@@ -106,11 +103,10 @@ namespace gcn
iter = std::find(mWidgets.begin(), mWidgets.end(), widget);
if (iter == mWidgets.end())
- throw GCN_EXCEPTION("There is no such widget in this container.");
+ return;
mWidgets.erase(iter);
mWidgets.insert(mWidgets.begin(), widget);
-// mWidgets.push_front(widget);
}
void BasicContainer::death(const Event& event)
@@ -119,7 +115,7 @@ namespace gcn
iter = std::find(mWidgets.begin(), mWidgets.end(), event.getSource());
if (iter == mWidgets.end())
- throw GCN_EXCEPTION("There is no such widget in this container.");
+ return;
mWidgets.erase(iter);
}
@@ -260,8 +256,6 @@ namespace gcn
return;
}
}
-
- throw GCN_EXCEPTION("There is no such widget in this container.");
}
void BasicContainer::clear()
diff --git a/src/gui/base/exception.cpp b/src/gui/base/exception.cpp
deleted file mode 100644
index 998db928d..000000000
--- a/src/gui/base/exception.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * For comments regarding functions please see the header file.
- */
-
-#include "gui/base/exception.hpp"
-
-#include "debug.h"
-
-namespace gcn
-{
- Exception::Exception()
- : mFunction("?"),
- mMessage(""),
- mFilename("?"),
- mLine(0)
- {
- }
-
- Exception::Exception(const std::string& message)
- : mFunction("?"),
- mMessage(message),
- mFilename("?"),
- mLine(0)
- {
- }
-
- Exception::Exception(const std::string& message,
- const std::string& function,
- const std::string& filename,
- const unsigned int line)
- : mFunction(function),
- mMessage(message),
- mFilename(filename),
- mLine(line)
- {
- }
-
- const std::string& Exception::getFunction() const
- {
- return mFunction;
- }
-
- const std::string& Exception::getMessage() const
- {
- return mMessage;
- }
-
- const std::string& Exception::getFilename() const
- {
- return mFilename;
- }
-
- unsigned int Exception::getLine() const
- {
- return mLine;
- }
-} // namespace gcn
diff --git a/src/gui/base/exception.hpp b/src/gui/base/exception.hpp
deleted file mode 100644
index a60152c96..000000000
--- a/src/gui/base/exception.hpp
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * The ManaPlus Client
- * Copyright (C) 2011-2014 The ManaPlus Developers
- *
- * This file is part of The ManaPlus Client.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/* _______ __ __ __ ______ __ __ _______ __ __
- * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
- * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
- * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
- * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
- * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
- * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
- *
- * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
- *
- *
- * Per Larsson a.k.a finalman
- * Olof Naessén a.k.a jansem/yakslem
- *
- * Visit: http://guichan.sourceforge.net
- *
- * License: (BSD)
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name of Guichan nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef GCN_EXCEPTION_HPP
-#define GCN_EXCEPTION_HPP
-
-#include <string>
-
-#include "localconsts.h"
-
-#ifndef __FUNCTION__
-#define __FUNCTION__ "?"
-#endif
-
-/*
- * A macro used to create a standard exception object.
- * What it basicly does is that it creates a new exception
- * and automatically sets the filename and line number where
- * the exception occured by using other compiler macros.
- */
-#define GCN_EXCEPTION(mess) gcn::Exception(mess, \
- __FUNCTION__, \
- __FILE__, \
- __LINE__)
-
-namespace gcn
-{
-
- /**
- * An exception containing a message, a file and a line number
- * where the exception occured. Guichan will only throw exceptions
- * of this class.
- *
- * You can use this class for your own exceptions that has
- * something to do with a GUI exception. A nifty feature of the
- * excpetion class is that it can tell you from which line and
- * file it was thrown. To make things easier when throwing
- * exceptions there exists a macro for creating exceptions
- * which automatically sets the filename and line number.
- *
- * EXAMPLE: @code
- * throw GCN_EXCEPTION("my error message");
- * @endcode
- */
- class Exception final
- {
- public:
- /**
- * Constructor.
- */
- Exception();
-
- /**
- * Constructor.
- *
- * @param message The error message of the exception.
- */
- explicit Exception(const std::string& message);
-
- /**
- * Constructor.
- *
- * NOTE: Don't use this constructor. Use the GCN_EXCEPTION macro instead.
- * This constructor merely exists for the GCN_EXCEPTION macro to
- * use.
- *
- * @param message The error message of the exception.
- * @param function The function name where the exception occured.
- * @param filename The name of the file where the exception occured.
- * @param line The line number in the source code where the exception
- * occured.
- */
- Exception(const std::string& message,
- const std::string& function,
- const std::string& filename,
- const unsigned int line);
-
- /**
- * Gets the function name where the exception occured.
- *
- * @return The function name where the exception occured.
- */
- const std::string& getFunction() const A_WARN_UNUSED;
-
- /**
- * Gets the error message of the exception.
- *
- * @return The error message of the exception.
- */
- const std::string& getMessage() const A_WARN_UNUSED;
-
- /**
- * Gets the filename where the exception occured.
- *
- * @return The filename where the exception occured.
- */
- const std::string& getFilename() const A_WARN_UNUSED;
-
- /**
- * Gets the line number where the exception occured.
- *
- * @return The line number where the exception occured.
- */
- unsigned int getLine() const A_WARN_UNUSED;
-
- protected:
- /**
- * Holds the name of the function name where the
- * exception occured.
- */
- std::string mFunction;
-
- /**
- * Holds the error message of the exception.
- */
- std::string mMessage;
-
- /**
- * Holds the filename where the exception occured.
- */
- std::string mFilename;
-
- /**
- * Holds the line number where the exception occured.
- */
- unsigned int mLine;
- };
-} // namespace gcn
-
-#endif // end GCN_EXCEPTION_HPP
-
-/*
- * "Final Fantasy XI is the BEST!... It's even better then water!"
- * - Astrolite
- * I believe it's WoW now days.
- */
diff --git a/src/gui/base/focushandler.cpp b/src/gui/base/focushandler.cpp
index ff149bf99..3c6978e70 100644
--- a/src/gui/base/focushandler.cpp
+++ b/src/gui/base/focushandler.cpp
@@ -67,7 +67,6 @@
#include "gui/base/focushandler.hpp"
-#include "gui/base/exception.hpp"
#include "gui/base/widget.hpp"
#include "listeners/focuslistener.h"
@@ -106,7 +105,7 @@ namespace gcn
}
if (toBeFocusedIndex < 0)
- throw GCN_EXCEPTION("Trying to focus a none existing widget.");
+ return;
Widget *const oldFocused = mFocusedWidget;
@@ -128,10 +127,9 @@ namespace gcn
void FocusHandler::requestModalFocus(Widget* widget)
{
if (mModalFocusedWidget && mModalFocusedWidget != widget)
- throw GCN_EXCEPTION("Another widget already has modal focus.");
+ return;
mModalFocusedWidget = widget;
-
if (mFocusedWidget && !mFocusedWidget->isModalFocused())
focusNone();
}
@@ -141,8 +139,7 @@ namespace gcn
if (mModalMouseInputFocusedWidget
&& mModalMouseInputFocusedWidget != widget)
{
- throw GCN_EXCEPTION("Another widget already has "
- "modal input focus.");
+ return;
}
mModalMouseInputFocusedWidget = widget;
diff --git a/src/gui/base/gui.cpp b/src/gui/base/gui.cpp
index f16048bbb..e6fc79856 100644
--- a/src/gui/base/gui.cpp
+++ b/src/gui/base/gui.cpp
@@ -68,7 +68,6 @@
#include "gui/base/gui.hpp"
#include "gui/base/basiccontainer.hpp"
-#include "gui/base/exception.hpp"
#include "gui/base/focushandler.hpp"
#include "gui/base/input.hpp"
#include "gui/base/keyinput.hpp"
@@ -532,7 +531,7 @@ namespace gcn
(*it)->mouseClicked(mouseEvent);
break;
default:
- throw GCN_EXCEPTION("Unknown mouse event type.");
+ break;
}
}
@@ -608,7 +607,7 @@ namespace gcn
(*it)->keyReleased(keyEvent);
break;
default:
- throw GCN_EXCEPTION("Unknown key event type.");
+ break;
}
}
}
@@ -641,7 +640,7 @@ namespace gcn
(*it)->keyReleased(keyEvent);
break;
default:
- throw GCN_EXCEPTION("Unknown key event type.");
+ break;
}
if (keyEvent.isConsumed())
diff --git a/src/gui/base/widget.cpp b/src/gui/base/widget.cpp
index 6083fb35a..e0f33d498 100644
--- a/src/gui/base/widget.cpp
+++ b/src/gui/base/widget.cpp
@@ -71,7 +71,6 @@
#include "gui/base/basiccontainer.hpp"
#include "events/event.h"
-#include "gui/base/exception.hpp"
#include "gui/base/focushandler.hpp"
#include "gui/base/keyinput.hpp"
#include "gui/base/mouseinput.hpp"
@@ -276,10 +275,7 @@ namespace gcn
void Widget::requestFocus()
{
if (!mFocusHandler)
- {
- throw GCN_EXCEPTION("No focushandler set (did you add "
- "the widget to the gui?).");
- }
+ return;
if (isFocusable())
mFocusHandler->requestFocus(this);
@@ -521,10 +517,7 @@ namespace gcn
void Widget::requestModalFocus()
{
if (!mFocusHandler)
- {
- throw GCN_EXCEPTION("No focushandler set (did you add "
- "the widget to the gui?).");
- }
+ return;
mFocusHandler->requestModalFocus(this);
}
@@ -532,10 +525,7 @@ namespace gcn
void Widget::requestModalMouseInputFocus()
{
if (!mFocusHandler)
- {
- throw GCN_EXCEPTION("No focushandler set (did you add "
- "the widget to the gui?).");
- }
+ return;
mFocusHandler->requestModalMouseInputFocus(this);
}
@@ -559,10 +549,7 @@ namespace gcn
bool Widget::isModalFocused() const
{
if (!mFocusHandler)
- {
- throw GCN_EXCEPTION("No focushandler set (did you add "
- "the widget to the gui?).");
- }
+ return false;
if (mParent)
{
@@ -576,10 +563,7 @@ namespace gcn
bool Widget::isModalMouseInputFocused() const
{
if (!mFocusHandler)
- {
- throw GCN_EXCEPTION("No focushandler set (did you add "
- "the widget to the gui?).");
- }
+ return false;
if (mParent)
{
diff --git a/src/gui/base/widgets/button.cpp b/src/gui/base/widgets/button.cpp
index 8cf49da4b..1276b82b2 100644
--- a/src/gui/base/widgets/button.cpp
+++ b/src/gui/base/widgets/button.cpp
@@ -67,7 +67,6 @@
#include "gui/base/widgets/button.hpp"
-#include "gui/base/exception.hpp"
#include "gui/base/font.hpp"
#include "gui/base/key.hpp"
#include "gui/base/mouseinput.hpp"
diff --git a/src/gui/base/widgets/container.cpp b/src/gui/base/widgets/container.cpp
index d72f2a682..6026b920d 100644
--- a/src/gui/base/widgets/container.cpp
+++ b/src/gui/base/widgets/container.cpp
@@ -67,7 +67,6 @@
#include "gui/base/widgets/container.hpp"
-#include "gui/base/exception.hpp"
#include "render/graphics.h"
diff --git a/src/gui/base/widgets/label.cpp b/src/gui/base/widgets/label.cpp
index f4576d908..c23666eac 100644
--- a/src/gui/base/widgets/label.cpp
+++ b/src/gui/base/widgets/label.cpp
@@ -67,7 +67,6 @@
#include "gui/base/widgets/label.hpp"
-#include "gui/base/exception.hpp"
#include "gui/base/font.hpp"
#include "render/graphics.h"
diff --git a/src/gui/base/widgets/scrollarea.cpp b/src/gui/base/widgets/scrollarea.cpp
index ffcaffdb1..f76226bc5 100644
--- a/src/gui/base/widgets/scrollarea.cpp
+++ b/src/gui/base/widgets/scrollarea.cpp
@@ -67,7 +67,6 @@
#include "gui/base/widgets/scrollarea.hpp"
-#include "gui/base/exception.hpp"
#include "render/graphics.h"
@@ -300,8 +299,6 @@ namespace gcn
{
if (width > 0)
mScrollbarWidth = width;
- else
- throw GCN_EXCEPTION("Width should be greater then 0.");
}
int ScrollArea::getScrollbarWidth() const
@@ -446,7 +443,7 @@ namespace gcn
break;
default:
- throw GCN_EXCEPTION("Horizontal scroll policy invalid.");
+ break;
}
switch (mVPolicy)
@@ -471,7 +468,7 @@ namespace gcn
}
break;
default:
- throw GCN_EXCEPTION("Vertical scroll policy invalid.");
+ break;
}
}
@@ -491,7 +488,7 @@ namespace gcn
{
const Widget *const content = getContent();
if (widget != content)
- throw GCN_EXCEPTION("Widget not content widget");
+ return;
BasicContainer::showWidgetPart(widget, area);
diff --git a/src/gui/base/widgets/window.cpp b/src/gui/base/widgets/window.cpp
index 02611f819..9207fe449 100644
--- a/src/gui/base/widgets/window.cpp
+++ b/src/gui/base/widgets/window.cpp
@@ -67,7 +67,6 @@
#include "gui/base/widgets/window.hpp"
-#include "gui/base/exception.hpp"
#include "gui/base/font.hpp"
#include "gui/base/mouseinput.hpp"
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 649e547d7..08794d478 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -53,8 +53,6 @@
#include "utils/langs.h"
#include "utils/timer.h"
-#include "gui/base/exception.hpp"
-
#include "debug.h"
// Guichan stuff
@@ -162,16 +160,7 @@ void Gui::postInit(Graphics *const graphics)
if (fontFile.empty())
fontFile = branding.getStringValue("font");
- try
- {
- mGuiFont = new SDLFont(fontFile, fontSize);
- }
- catch (const gcn::Exception &e)
- {
- logger->error(std::string("Unable to load '").append(fontFile)
- .append("': ").append(e.getMessage()));
- }
-
+ mGuiFont = new SDLFont(fontFile, fontSize);
// Set particle font
fontFile = config.getValue("particleFont", "");
@@ -190,65 +179,28 @@ void Gui::postInit(Graphics *const graphics)
if (fontFile.empty())
fontFile = branding.getStringValue("particleFont");
- try
- {
- mInfoParticleFont = new SDLFont(
- fontFile, fontSize, TTF_STYLE_BOLD);
- }
- catch (const gcn::Exception &e)
- {
- logger->error(std::string("Unable to load '").append(fontFile)
- .append("': ").append(e.getMessage()));
- }
-
+ mInfoParticleFont = new SDLFont(fontFile, fontSize, TTF_STYLE_BOLD);
// Set bold font
fontFile = config.getValue("boldFont", "");
if (fontFile.empty())
fontFile = branding.getStringValue("boldFont");
- try
- {
- boldFont = new SDLFont(fontFile, fontSize);
- }
- catch (const gcn::Exception &e)
- {
- logger->error(std::string("Unable to load '").append(fontFile)
- .append("': ").append(e.getMessage()));
- }
-
+ boldFont = new SDLFont(fontFile, fontSize);
// Set help font
fontFile = config.getValue("helpFont", "");
if (fontFile.empty())
fontFile = branding.getStringValue("helpFont");
- try
- {
- mHelpFont = new SDLFont(fontFile, fontSize);
- }
- catch (const gcn::Exception &e)
- {
- logger->error(std::string("Unable to load '").append(fontFile)
- .append("': ").append(e.getMessage()));
- }
-
+ mHelpFont = new SDLFont(fontFile, fontSize);
// Set secure font
fontFile = config.getValue("secureFont", "");
if (fontFile.empty())
fontFile = branding.getStringValue("secureFont");
- try
- {
- mSecureFont = new SDLFont(fontFile, fontSize);
- }
- catch (const gcn::Exception &e)
- {
- logger->error(std::string("Unable to load '").append(fontFile)
- .append("': ").append(e.getMessage()));
- }
-
+ mSecureFont = new SDLFont(fontFile, fontSize);
// Set npc font
const int npcFontSize = config.getIntValue("npcfontSize");
@@ -268,15 +220,7 @@ void Gui::postInit(Graphics *const graphics)
if (fontFile.empty())
fontFile = branding.getStringValue("npcFont");
- try
- {
- mNpcFont = new SDLFont(fontFile, npcFontSize);
- }
- catch (const gcn::Exception &e)
- {
- logger->error(std::string("Unable to load '").append(fontFile)
- .append("': ").append(e.getMessage()));
- }
+ mNpcFont = new SDLFont(fontFile, npcFontSize);
gcn::Widget::setGlobalFont(mGuiFont);
@@ -853,7 +797,6 @@ void Gui::handleMouseInput()
handleMouseWheelMovedUp(mouseInput);
break;
default:
- throw GCN_EXCEPTION("Unknown mouse input type.");
break;
}
}
diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp
index bed4a9f31..95a3df390 100644
--- a/src/gui/sdlfont.cpp
+++ b/src/gui/sdlfont.cpp
@@ -39,8 +39,6 @@
#include "utils/stringutils.h"
#include "utils/timer.h"
-#include "gui/base/exception.hpp"
-
#include "debug.h"
const unsigned int CACHE_SIZE = 256;
@@ -350,7 +348,7 @@ SDLFont::SDLFont(std::string filename,
mSoftMode = imageHelper->useOpenGL() == RENDER_SOFTWARE;
if (TTF_Init() == -1)
{
- throw GCN_EXCEPTION("Unable to initialize SDL_ttf: " +
+ logger->error("Unable to initialize SDL_ttf: " +
std::string(TTF_GetError()));
}
}
@@ -373,8 +371,8 @@ SDLFont::SDLFont(std::string filename,
mFont = openFont(fixDirSeparators(backFile).c_str(), size);
if (!mFont)
{
- throw GCN_EXCEPTION("SDLSDLFont::SDLSDLFont: " +
- std::string(TTF_GetError()));
+ logger->error("SDLSDLFont::SDLSDLFont: " +
+ std::string(TTF_GetError()));
}
}
diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp
index c81f11802..661be07c5 100644
--- a/src/gui/sdlinput.cpp
+++ b/src/gui/sdlinput.cpp
@@ -90,8 +90,6 @@
#include <SDL_keyboard.h>
#include <SDL_timer.h>
-#include "gui/base/exception.hpp"
-
SDLInput::SDLInput() :
mKeyInputQueue(),
mMouseInputQueue(),
@@ -108,9 +106,7 @@ bool SDLInput::isKeyQueueEmpty()
KeyInput SDLInput::dequeueKeyInput2()
{
if (mKeyInputQueue.empty())
- {
- throw GCN_EXCEPTION("The queue is empty.");
- }
+ return KeyInput();
KeyInput keyInput = mKeyInputQueue.front();
mKeyInputQueue.pop();
@@ -128,7 +124,7 @@ gcn::MouseInput SDLInput::dequeueMouseInput()
gcn::MouseInput mouseInput;
if (mMouseInputQueue.empty())
- throw GCN_EXCEPTION("The queue is empty.");
+ return MouseInput();
mouseInput = mMouseInputQueue.front();
mMouseInputQueue.pop();
@@ -141,7 +137,7 @@ MouseInput SDLInput::dequeueMouseInput2()
MouseInput mouseInput;
if (mMouseInputQueue.empty())
- throw GCN_EXCEPTION("The queue is empty.");
+ return MouseInput();
mouseInput = mMouseInputQueue.front();
mMouseInputQueue.pop();
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index a61ba5275..178695891 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -27,8 +27,6 @@
#include "gui/viewport.h"
-#include "gui/base/exception.hpp"
-
#include "debug.h"
Popup::Popup(const std::string &name,
@@ -48,9 +46,6 @@ Popup::Popup(const std::string &name,
{
logger->log("Popup::Popup(\"%s\")", name.c_str());
- if (!windowContainer)
- throw GCN_EXCEPTION("Popup::Popup(): no windowContainer set");
-
addWidgetListener(this);
if (skin == "")
@@ -67,7 +62,8 @@ Popup::Popup(const std::string &name,
}
}
- windowContainer->add(this);
+ if (windowContainer)
+ windowContainer->add(this);
// Popups are invisible by default
setVisible(false);
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index e9e1ed71e..c250e79a1 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -37,7 +37,6 @@
#include "resources/cursor.h"
#include "resources/image.h"
-#include "gui/base/exception.hpp"
#include "gui/base/focushandler.hpp"
#include "gui/base/font.hpp"
@@ -92,9 +91,6 @@ Window::Window(const std::string &caption, const bool modal,
{
logger->log("Window::Window(\"%s\")", caption.c_str());
- if (!windowContainer)
- throw GCN_EXCEPTION("Window::Window(): no windowContainer set");
-
windowInstances++;
setFrameSize(0);
@@ -142,7 +138,8 @@ Window::Window(const std::string &caption, const bool modal,
}
// Add this window to the window container
- windowContainer->add(this);
+ if (windowContainer)
+ windowContainer->add(this);
if (mModal)
{