Skip to content

Commit

Permalink
Don't call preprocess_file() on an empty path if fonts.cfg can't be f…
Browse files Browse the repository at this point in the history
…ound

get_wml_location() returns an empty string on failure, and there is
really no point in calling preprocess_file() on that -- it only results
in a confusing error message.

Replaces this sequence often found when Wesnoth can't resolve the path
to its data directory:

  20140612 23:37:05 error filesystem: Trying to open file with empty name.
  20140612 23:37:05 error config: Could not open file
  could not initialize fonts

... with the following one:

  20140612 23:38:52 error font: could not resolve path to fonts.cfg, file not found
  could not initialize fonts

... which should be a little bit more helpful in pointing users in the
right direction in the aforementioned case.
  • Loading branch information
irydacea committed Jun 13, 2014
1 parent 80be563 commit 1b483bb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/font.cpp
Expand Up @@ -1258,7 +1258,13 @@ bool load_font_config()
//config when changing languages
config cfg;
try {
scoped_istream stream = preprocess_file(get_wml_location("hardwired/fonts.cfg"));
const std::string& cfg_path = get_wml_location("hardwired/fonts.cfg");
if(cfg_path.empty()) {
ERR_FT << "could not resolve path to fonts.cfg, file not found\n";
return false;
}

scoped_istream stream = preprocess_file(cfg_path);
read(cfg, *stream);
} catch(config::error &e) {
ERR_FT << "could not read fonts.cfg:\n"
Expand Down

0 comments on commit 1b483bb

Please sign in to comment.