fixbug 22611: don't close the program if we can't find button image
If the main button image could not be loaded, the previous code would throw an exception of an obscure type "error". It appears that this was not caught anywhere except the main function in wesnoth.cpp and so the program would close immediately. I first tried to go into the gui initialization and construct buttons in try catch blocks, skipping ones that have problems, but rather than being able to proceed, this just causes a segfault because other parts of the code assume that all buttons have been constructed successfully. This means that not finding the image is necessarily a fatal error. My fix for the problem is, instead of throwing error, we throw the more standard "game::game_error". The new behavior is, if you try to load a theme with nonexistant images, then a black screen will appear with a dialog "error initializing button images! filename: buttons/dontexist.png" The game then returns to the title screen. Conflicts: src/widgets/button.cpp (just the #include reorder)
This commit is contained in:
parent
1c69131937
commit
28fe7e440c
1 changed files with 13 additions and 9 deletions
|
@ -14,22 +14,23 @@
|
||||||
|
|
||||||
#define GETTEXT_DOMAIN "wesnoth-lib"
|
#define GETTEXT_DOMAIN "wesnoth-lib"
|
||||||
|
|
||||||
|
#include "widgets/button.hpp"
|
||||||
|
|
||||||
#include "global.hpp"
|
#include "global.hpp"
|
||||||
|
|
||||||
#include "widgets/button.hpp"
|
#include "filesystem.hpp"
|
||||||
#include "game_config.hpp"
|
|
||||||
#include "font.hpp"
|
#include "font.hpp"
|
||||||
#include "text.hpp"
|
#include "game_config.hpp"
|
||||||
#include "marked-up_text.hpp"
|
#include "game_errors.hpp"
|
||||||
#include "image.hpp"
|
#include "image.hpp"
|
||||||
#include "log.hpp"
|
#include "log.hpp"
|
||||||
|
#include "marked-up_text.hpp"
|
||||||
|
#include "sdl/rect.hpp"
|
||||||
#include "serialization/string_utils.hpp"
|
#include "serialization/string_utils.hpp"
|
||||||
#include "sound.hpp"
|
#include "sound.hpp"
|
||||||
#include "video.hpp"
|
#include "video.hpp"
|
||||||
|
#include "text.hpp"
|
||||||
#include "wml_separators.hpp"
|
#include "wml_separators.hpp"
|
||||||
#include "sdl/rect.hpp"
|
|
||||||
|
|
||||||
#include "filesystem.hpp"
|
|
||||||
|
|
||||||
static lg::log_domain log_display("display");
|
static lg::log_domain log_display("display");
|
||||||
#define ERR_DP LOG_STREAM(err, log_display)
|
#define ERR_DP LOG_STREAM(err, log_display)
|
||||||
|
@ -237,8 +238,11 @@ void button::load_images() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (button_image.null()) {
|
if (button_image.null()) {
|
||||||
ERR_DP << "error initializing button!" << std::endl;
|
std::string err_msg = "error initializing button images! file name: ";
|
||||||
throw error();
|
err_msg += button_image_name_;
|
||||||
|
err_msg += ".png";
|
||||||
|
ERR_DP << err_msg << std::endl;
|
||||||
|
throw game::game_error(err_msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
base_height_ = button_image->h;
|
base_height_ = button_image->h;
|
||||||
|
|
Loading…
Add table
Reference in a new issue