[Scummvm-git-logs] scummvm master -> 1b3ac06f699f3e0e797fb855c1b31a83a422f4b1
bluegr
noreply at scummvm.org
Thu Jan 6 17:36:27 UTC 2022
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:
1b3ac06f69 GUI: Fix various memory leaks related to grid widget
Commit: 1b3ac06f699f3e0e797fb855c1b31a83a422f4b1
https://github.com/scummvm/scummvm/commit/1b3ac06f699f3e0e797fb855c1b31a83a422f4b1
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-01-06T19:36:23+02:00
Commit Message:
GUI: Fix various memory leaks related to grid widget
Changed paths:
gui/gui-manager.cpp
gui/launcher.cpp
gui/widgets/grid.cpp
diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp
index d553d779110..b02d8e64d89 100644
--- a/gui/gui-manager.cpp
+++ b/gui/gui-manager.cpp
@@ -114,7 +114,7 @@ struct ArchiveMemberListBackComparator {
}
};
void GuiManager::initIconsSet() {
- Common::Archive *dat = nullptr;
+ Common::Archive *dat;
_iconsSet.clear();
@@ -138,35 +138,37 @@ void GuiManager::initIconsSet() {
delete iconDir;
}
+ dat = nullptr;
+
const char fname[] = "gui-icons.dat";
- Common::File *file = new Common::File;
if (ConfMan.hasKey("themepath")) {
Common::FSNode *fs = new Common::FSNode(normalizePath(ConfMan.get("themepath") + "/" + fname, '/'));
-
- if (!fs->exists()) {
- delete fs;
- } else {
+ if (fs->exists()) {
dat = Common::makeZipArchive(*fs);
}
+ delete fs;
}
- if (!dat && !file->isOpen() && ConfMan.hasKey("iconspath"))
- file->open(normalizePath(ConfMan.get("iconspath") + "/" + fname, '/'));
+ if (!dat) {
+ Common::File *file = new Common::File;
+ if (ConfMan.hasKey("iconspath"))
+ file->open(normalizePath(ConfMan.get("iconspath") + "/" + fname, '/'));
- if (!dat && !file->isOpen())
- file->open(fname);
+ if (!file->isOpen())
+ file->open(fname);
- if (!dat && file->isOpen())
- dat = Common::makeZipArchive(file);
+ if (file->isOpen())
+ dat = Common::makeZipArchive(file);
- if (!dat) {
- warning("GUI: Could not find '%s'", fname);
- delete file;
- return;
+ if (!dat) {
+ warning("GUI: Could not find '%s'", fname);
+ delete file;
+ return;
+ }
}
- _iconsSet.add(fname, dat, 0, false); // Do not autofree
+ _iconsSet.add(fname, dat);
debug(2, "GUI: Loaded icon file: %s", fname);
}
diff --git a/gui/launcher.cpp b/gui/launcher.cpp
index 0783eec79fa..a49f0cabfa1 100644
--- a/gui/launcher.cpp
+++ b/gui/launcher.cpp
@@ -172,8 +172,8 @@ LauncherDialog::LauncherDialog(const Common::String &dialogName)
}
if (_metadataParser.parse() == false) {
warning("Failed to parse XML file '%s'", (*md)->getDisplayName().encode().c_str());
- _metadataParser.close();
}
+ _metadataParser.close();
}
}
diff --git a/gui/widgets/grid.cpp b/gui/widgets/grid.cpp
index acbf3614be3..07f0c6b4a81 100644
--- a/gui/widgets/grid.cpp
+++ b/gui/widgets/grid.cpp
@@ -317,6 +317,9 @@ Graphics::ManagedSurface *loadSurfaceFromFile(const Common::String &name, int re
Common::SeekableReadStream *stream = g_gui.getIconsSet().createReadStreamForMember(name);
Graphics::SVGBitmap *image = nullptr;
image = new Graphics::SVGBitmap(stream);
+
+ delete stream;
+
surf = new Graphics::ManagedSurface(renderWidth, renderHeight, *image->getPixelFormat());
image->render(*surf, renderWidth, renderHeight);
delete image;
More information about the Scummvm-git-logs
mailing list