[Scummvm-git-logs] scummvm master -> 72adc6ba2b5e343583502d72e013e1e49f2dd1eb

sev- noreply at scummvm.org
Sun Nov 14 21:54:09 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
72adc6ba2b GUI: Simplify gui-icons.dat searching


Commit: 72adc6ba2b5e343583502d72e013e1e49f2dd1eb
    https://github.com/scummvm/scummvm/commit/72adc6ba2b5e343583502d72e013e1e49f2dd1eb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-11-14T22:53:55+01:00

Commit Message:
GUI: Simplify gui-icons.dat searching

Changed paths:
    gui/gui-manager.cpp


diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp
index 5f0ec3211d..04bea58b61 100644
--- a/gui/gui-manager.cpp
+++ b/gui/gui-manager.cpp
@@ -115,7 +115,7 @@ struct ArchiveMemberListBackComparator {
 	}
 };
 void GuiManager::initIconsSet() {
-	Common::Archive *dat;
+	Common::Archive *dat = nullptr;
 
 	if (ConfMan.hasKey("iconspath")) {
 		Common::FSDirectory *iconDir = new Common::FSDirectory(ConfMan.get("iconspath"));
@@ -139,53 +139,28 @@ void GuiManager::initIconsSet() {
 
 	const char fname[] = "gui-icons.dat";
 	Common::String path;
-	Common::FSNode *fs = nullptr;
+	Common::File *file = new Common::File;
 
-	if (ConfMan.hasKey("themepath")) {
-		path = normalizePath(ConfMan.get("themepath") + "/" + fname, '/');
+	if (ConfMan.hasKey("themepath"))
+		file->open(normalizePath(ConfMan.get("themepath") + "/" + fname, '/'));
 
-		fs = new Common::FSNode(path);
-		if (!fs->exists()) {
-			delete fs;
-			fs = nullptr;
-		}
-	}
-
-	if (!fs && ConfMan.hasKey("iconspath")) {
-		path = normalizePath(ConfMan.get("iconspath") + "/" + fname, '/');
+	if (!file->isOpen() && ConfMan.hasKey("iconspath"))
+		file->open(normalizePath(ConfMan.get("iconspath") + "/" + fname, '/'));
 
-		fs = new Common::FSNode(path);
-		if (!fs->exists()) {
-			delete fs;
-			fs = nullptr;
-		}
-	}
+	if (!file->isOpen())
+		file->open(fname);
 
-	if (!fs)
-		fs = new Common::FSNode(fname);
-
-	if (fs) {
-		dat = Common::makeZipArchive(*fs);
-	} else {
-		// We could be on Windows with gui-icons.dat file as an
-		// embedded resource. Try it.
-		Common::File *in = new Common::File;
-		in->open(fname);
-
-		if (in->isOpen())
-			dat = Common::makeZipArchive(in);
-	}
+	if (file->isOpen())
+		dat = Common::makeZipArchive(file);
 
 	if (!dat) {
-		warning("GUI: Could not find '%s'", path.c_str());
+		warning("GUI: Could not find '%s'", fname);
 		return;
 	}
 
-	_iconsSet.add(path, dat);
+	_iconsSet.add(path, dat, 0, false); // Do not autofree
 
 	debug(2, "GUI: Loaded icon file: %s", path.c_str());
-
-	delete fs;
 }
 
 void GuiManager::computeScaleFactor() {




More information about the Scummvm-git-logs mailing list