Qt tiles loading failure
For Qt, if unable to load either nhfiles.bmp or x11tiles, quit after giving the can't-load-tiles feedback instead of continuing on and eventually triggering a segfault.
This commit is contained in:
@@ -25,6 +25,7 @@ extern "C" {
|
||||
#endif
|
||||
#include "qt_post.h"
|
||||
#include "qt_glyph.h"
|
||||
#include "qt_bind.h"
|
||||
#include "qt_set.h"
|
||||
#include "qt_str.h"
|
||||
|
||||
@@ -47,6 +48,7 @@ static int tilefile_tile_H=16;
|
||||
NetHackQtGlyphs::NetHackQtGlyphs()
|
||||
{
|
||||
const char* tile_file = PIXMAPDIR "/nhtiles.bmp";
|
||||
|
||||
if ( iflags.wc_tile_file )
|
||||
tile_file = iflags.wc_tile_file;
|
||||
|
||||
@@ -54,13 +56,17 @@ NetHackQtGlyphs::NetHackQtGlyphs()
|
||||
tile_file = PIXMAPDIR "/x11tiles";
|
||||
if (!img.load(tile_file)) {
|
||||
QString msg;
|
||||
msg.sprintf("Cannot load x11tiles or nhtiles.bmp");
|
||||
|
||||
msg.sprintf("Cannot load 'nhtiles.bmp' or 'x11tiles'.");
|
||||
QMessageBox::warning(0, "IO Error", msg);
|
||||
NetHackQtBind::qt_exit_nhwindows((const char *) 0);
|
||||
nh_terminate(EXIT_FAILURE);
|
||||
} else {
|
||||
tiles_per_row = TILES_PER_ROW;
|
||||
if (img.width()%tiles_per_row) {
|
||||
impossible("Tile file \"%s\" has %d columns, not multiple of row count (%d)",
|
||||
tile_file, img.width(), tiles_per_row);
|
||||
if (img.width() % tiles_per_row) {
|
||||
impossible(
|
||||
"Tile file \"%s\" has %d columns, not multiple of row count (%d)",
|
||||
tile_file, img.width(), tiles_per_row);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user