diff options
| -rw-r--r-- | gui/ThemeEngine.cpp | 21 | ||||
| -rw-r--r-- | gui/ThemeEngine.h | 4 | 
2 files changed, 15 insertions, 10 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. diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h index f164b8831c..0b054c53f5 100644 --- a/gui/ThemeEngine.h +++ b/gui/ThemeEngine.h @@ -476,8 +476,8 @@ public:  		return _initOk && _themeOk;  	} -	/** Custom implementation of the GUI::Theme API, changed to use the XML parser. */ -	bool loadTheme(Common::String themeName); +	/** Load the them from the file with the specified name. */ +	bool loadTheme(const Common::String &fileName);  	/**  	 *	Changes the active graphics mode of the GUI; may be used to either | 
