diff options
Diffstat (limited to 'gui/ThemeEngine.cpp')
-rw-r--r-- | gui/ThemeEngine.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index df3f3af4f4..cbcd32fd4c 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -487,18 +487,19 @@ bool ThemeEngine::addDrawData(const Common::String &data, bool cached) { /********************************************************** * Theme XML loading *********************************************************/ -bool ThemeEngine::loadTheme(Common::String fileName) { +bool ThemeEngine::loadTheme(const Common::String &fileName) { unloadTheme(); - if (fileName != "builtin") + bool tryAgain = false; + if (fileName != "builtin") { ImageMan.addArchive(fileName); + if (!loadThemeXML(fileName)) { + warning("Could not parse custom theme '%s'. Falling back to default theme", fileName.c_str()); + tryAgain = true; // Fall back to default builtin theme + } + } - if (fileName == "builtin") { - if (!loadDefaultXML()) - error("Could not load default embedded theme"); - } else if (!loadThemeXML(fileName)) { - warning("Could not parse custom theme '%s'. Falling back to default theme", fileName.c_str()); - + if (fileName == "builtin" || tryAgain) { if (!loadDefaultXML()) // if we can't load the embedded theme, this is a complete failure error("Could not load default embedded theme"); } @@ -571,9 +572,13 @@ bool ThemeEngine::loadThemeXML(const Common::String &themeName) { #endif } else if (node.isDirectory()) { + warning("Don't know how to open theme '%s'", themeName.c_str()); archive = new Common::FSDirectory(node); } + if (!archive) + return false; + Common::File themercFile; // FIXME: Possibly dereferencing a NULL pointer here if the node's // name doesn't have a ".zip" suffix and the node is not a directory. |