aboutsummaryrefslogtreecommitdiff
path: root/gui/ThemeEngine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gui/ThemeEngine.cpp')
-rw-r--r--gui/ThemeEngine.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index a08e019668..fb2603eb16 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -393,11 +393,9 @@ bool ThemeEngine::init() {
Common::FSNode node(_themeFile);
if (node.getName().hasSuffix(".zip") && !node.isDirectory()) {
#ifdef USE_ZLIB
- Common::ZipArchive *zipArchive = new Common::ZipArchive(node);
+ Common::Archive *zipArchive = Common::makeZipArchive(node);
- if (!zipArchive || !zipArchive->isOpen()) {
- delete zipArchive;
- zipArchive = 0;
+ if (!zipArchive) {
warning("Failed to open Zip archive '%s'.", node.getPath().c_str());
}
_themeArchive = zipArchive;
@@ -1444,10 +1442,18 @@ bool ThemeEngine::themeConfigUsable(const Common::FSNode &node, Common::String &
if (node.getName().hasSuffix(".zip") && !node.isDirectory()) {
#ifdef USE_ZLIB
- Common::ZipArchive zipArchive(node);
- if (zipArchive.hasFile("THEMERC")) {
- stream.open("THEMERC", zipArchive);
+ Common::Archive *zipArchive = Common::makeZipArchive(node);
+ if (zipArchive && zipArchive->hasFile("THEMERC")) {
+ // Open THEMERC from the ZIP file.
+ stream.open("THEMERC", *zipArchive);
}
+ // Delete the ZIP archive again. Note: This only works because
+ // stream.open() only uses ZipArchive::createReadStreamForMember,
+ // and that in turn happens to read all the data for a given
+ // archive member into a memory block. So there will be no dangling
+ // reference to zipArchive anywhere. This could change if we
+ // ever modify ZipArchive::createReadStreamForMember.
+ delete zipArchive;
#endif
} else if (node.isDirectory()) {
Common::FSNode headerfile = node.getChild("THEMERC");