Remove the sticky exception class.

All sticky exceptions are replaced with the lua jailbreak exceptions.
The code has been lightly tested, too many possibilities to test them
all. Don't expect breakage but mainly the load code looks tricky with
the global variables.
This commit is contained in:
Mark de Wever 2011-03-27 20:55:35 +00:00
parent 85f5ec837f
commit 6dab616793
11 changed files with 3 additions and 74 deletions

View file

@ -1,6 +1,9 @@
Version 1.9.5+svn:
* Language and i18n:
* Updated translations:
* Miscellaneous and bugfixes:
* Changed : replaced all sticky excpetions by lua jailbreak exceptions
(fixes bug #17743).
Version 1.9.5:
* Graphics:

View file

@ -67,7 +67,6 @@ src/dialogs.cpp
src/display.cpp
src/editor/editor_preferences.cpp
src/events.cpp
src/exceptions.cpp
src/filesystem.cpp
src/floating_textbox.cpp
src/formula.cpp

View file

@ -345,7 +345,6 @@ set(wesnoth-main_SRC
editor/map_context.cpp
editor/map_fragment.cpp
editor/mouse_action.cpp
exceptions.cpp
floating_textbox.cpp
formula.cpp
formula_debugger.cpp

View file

@ -213,7 +213,6 @@ wesnoth_sources = Split("""
editor/map_context.cpp
editor/map_fragment.cpp
editor/mouse_action.cpp
exceptions.cpp
floating_textbox.cpp
formula.cpp
formula_debugger.cpp

View file

@ -1,28 +0,0 @@
/* $Id$ */
/*
Copyright (C) 2010 - 2011 by Guillaume Melquiond <guillaume.melquiond@gmail.com>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
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
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#include "exceptions.hpp"
#include "game_errors.hpp"
#include "game_end_exceptions.hpp"
#include "video.hpp"
char const *game::exception::sticky;
void game::exception::rethrow()
{
if (!sticky) return;
throw game::exception("Unknown exception", "unknown");
}

View file

@ -39,42 +39,6 @@ struct error : std::exception
}
};
/**
* Base class for all the exceptions for changing the control flow.
* Its message only carries a description of the exception.
* It also handles sticky exceptions that are automatically rethrown if
* lost; such exceptions cannot have any embedded payload, since it would
* still be lost.
*/
struct exception : std::exception
{
const char *message;
/**
* Rethrows the current sticky exception, if any.
*/
static void rethrow();
/**
* Marks an exception of name @a sticky as a rethrow candidate.
* @note The value should be set to NULL in order to discard the
* sticky exception once it has been handled.
*/
static const char *sticky;
exception(const char *msg, const char *stick = NULL) : message(msg)
{
sticky = stick;
}
~exception() throw() {}
const char *what() const throw()
{
return message;
}
};
}
#endif

View file

@ -2252,8 +2252,6 @@ static int do_gameloop(int argc, char** argv)
for (;;)
{
game::exception::sticky = NULL;
// reset the TC, since a game can modify it, and it may be used
// by images in add-ons or campaigns dialogs
image::set_team_colors();

View file

@ -145,7 +145,6 @@ static LEVEL_RESULT playsingle_scenario(const config& game_config,
playcontroller.linger();
} catch(end_level_exception& e) {
if (e.result == QUIT) {
game::exception::sticky = NULL;
return QUIT;
}
}
@ -192,7 +191,6 @@ static LEVEL_RESULT playmp_scenario(const config& game_config,
playcontroller.linger();
} catch(end_level_exception& e) {
if (e.result == QUIT) {
game::exception::sticky = NULL;
return QUIT;
}
}

View file

@ -403,7 +403,6 @@ LEVEL_RESULT playsingle_controller::play_scenario(
update_rect(0, 0, gui_->video().getx(), gui_->video().gety());
}
game::exception::sticky = NULL;
ai_testing::log_game_end();
LEVEL_RESULT end_level_result = end_level_exn.result;
if (!end_level.custom_endlevel_music.empty()) {

View file

@ -51,7 +51,6 @@ LEVEL_RESULT play_replay_level(const config& game_config,
}
}
catch(end_level_exception&){
game::exception::sticky = NULL;
DBG_NG << "play_replay_level: end_level_exception\n";
}

View file

@ -432,7 +432,6 @@ bool luaW_pcall(lua_State *L
// Call the function.
int res = lua_pcall(L, nArgs, nRets, -2 - nArgs);
tlua_jailbreak_exception::rethrow();
game::exception::rethrow();
if (res)
{