mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-15 06:08:35 +00:00
FULLPIPE: Fix memory leak of save game thumbnail
This commit is contained in:
parent
ff96db23df
commit
5c89c39325
@ -180,13 +180,11 @@ SaveStateList FullpipeMetaEngine::listSaves(const char *target) const {
|
||||
int slotNum = atoi(file->c_str() + file->size() - 2);
|
||||
|
||||
if (slotNum >= 0 && slotNum <= getMaximumSaveSlot()) {
|
||||
Common::InSaveFile *in = saveFileMan->openForLoading(*file);
|
||||
Common::ScopedPtr<Common::InSaveFile> in(saveFileMan->openForLoading(*file));
|
||||
if (in) {
|
||||
Fullpipe::FullpipeSavegameHeader header;
|
||||
Fullpipe::readSavegameHeader(in, header);
|
||||
Fullpipe::readSavegameHeader(in.get(), header);
|
||||
saveList.push_back(SaveStateDescriptor(slotNum, header.saveName));
|
||||
delete header.thumbnail;
|
||||
delete in;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -201,13 +199,12 @@ void FullpipeMetaEngine::removeSaveState(const char *target, int slot) const {
|
||||
}
|
||||
|
||||
SaveStateDescriptor FullpipeMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
|
||||
Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(
|
||||
Fullpipe::getSavegameFile(slot));
|
||||
Common::ScopedPtr<Common::InSaveFile> f(g_system->getSavefileManager()->openForLoading(
|
||||
Fullpipe::getSavegameFile(slot)));
|
||||
|
||||
if (f) {
|
||||
Fullpipe::FullpipeSavegameHeader header;
|
||||
Fullpipe::readSavegameHeader(f, header);
|
||||
delete f;
|
||||
Fullpipe::readSavegameHeader(f.get(), header);
|
||||
|
||||
// Create the return descriptor
|
||||
SaveStateDescriptor desc(slot, header.saveName);
|
||||
|
@ -23,6 +23,7 @@
|
||||
#ifndef FULLPIPE_GAMELOADER_H
|
||||
#define FULLPIPE_GAMELOADER_H
|
||||
|
||||
#include "common/ptr.h"
|
||||
#include "engines/savestate.h"
|
||||
|
||||
#include "fullpipe/objects.h"
|
||||
@ -83,7 +84,7 @@ struct FullpipeSavegameHeader {
|
||||
uint32 date;
|
||||
uint16 time;
|
||||
uint32 playtime;
|
||||
Graphics::Surface *thumbnail;
|
||||
Common::SharedPtr<Graphics::Surface> thumbnail;
|
||||
};
|
||||
|
||||
struct SaveHeader {
|
||||
|
@ -195,8 +195,6 @@ void fillDummyHeader(Fullpipe::FullpipeSavegameHeader &header) {
|
||||
}
|
||||
|
||||
bool readSavegameHeader(Common::InSaveFile *in, FullpipeSavegameHeader &header) {
|
||||
header.thumbnail = NULL;
|
||||
|
||||
uint oldPos = in->pos();
|
||||
|
||||
in->seek(-4, SEEK_END);
|
||||
@ -239,7 +237,7 @@ bool readSavegameHeader(Common::InSaveFile *in, FullpipeSavegameHeader &header)
|
||||
header.saveName = Common::String::format("%s %s", desc.getSaveDate().c_str(), desc.getSaveTime().c_str());
|
||||
|
||||
// Get the thumbnail
|
||||
header.thumbnail = Graphics::loadThumbnail(*in);
|
||||
header.thumbnail = Common::SharedPtr<Graphics::Surface>(Graphics::loadThumbnail(*in), Graphics::SurfaceDeleter());
|
||||
|
||||
in->seek(oldPos, SEEK_SET); // Rewind the file
|
||||
|
||||
|
@ -121,6 +121,7 @@ public:
|
||||
* Hence the caller must not delete the surface.
|
||||
*/
|
||||
void setThumbnail(Graphics::Surface *t);
|
||||
void setThumbnail(Common::SharedPtr<Graphics::Surface> t) { _thumbnail = t; }
|
||||
|
||||
/**
|
||||
* Sets the date the save state was created.
|
||||
|
Loading…
Reference in New Issue
Block a user