[Scummvm-git-logs] scummvm master -> 529e9fc7a76a7a488369aa01b3e378b66ec9d6fa
sev-
sev at scummvm.org
Thu Apr 2 15:41:03 UTC 2020
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:
529e9fc7a7 DIRECTOR: Plug leaked resources
Commit: 529e9fc7a76a7a488369aa01b3e378b66ec9d6fa
https://github.com/scummvm/scummvm/commit/529e9fc7a76a7a488369aa01b3e378b66ec9d6fa
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-02T17:40:45+02:00
Commit Message:
DIRECTOR: Plug leaked resources
Changed paths:
engines/director/cachedmactext.cpp
engines/director/cachedmactext.h
engines/director/cast.cpp
engines/director/resource.cpp
engines/director/score.cpp
diff --git a/engines/director/cachedmactext.cpp b/engines/director/cachedmactext.cpp
index 93e7caf840..e35f163427 100644
--- a/engines/director/cachedmactext.cpp
+++ b/engines/director/cachedmactext.cpp
@@ -53,7 +53,10 @@ void CachedMacText::makeMacText() {
uint color = _wm->findBestColor(_textCast->_palinfo1 & 0xff, _textCast->_palinfo2 & 0xff, _textCast->_palinfo3 & 0xff);
_macText = new Graphics::MacText(_textCast->_ftext, _wm, macFont, color, _bgcolor, _width, _align, 1);
- // TODO destroy me
+}
+
+CachedMacText::~CachedMacText() {
+ delete _macText;
}
CachedMacText::CachedMacText(TextCast *const textCast, int32 bgcolor, int version, int defaultWidth,
diff --git a/engines/director/cachedmactext.h b/engines/director/cachedmactext.h
index 2795536539..2b4c3a27ca 100644
--- a/engines/director/cachedmactext.h
+++ b/engines/director/cachedmactext.h
@@ -50,6 +50,8 @@ private:
public:
CachedMacText(TextCast *const textCast, int32 bgcolor, int version, int defaultWidth = -1,
Graphics::MacWindowManager *const wm = NULL);
+ ~CachedMacText();
+
void setWm(Graphics::MacWindowManager *wm);
void clip(int width);
void setBgColor(int color) { _bgcolor = color; }
diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp
index d610c33757..66cae0cf75 100644
--- a/engines/director/cast.cpp
+++ b/engines/director/cast.cpp
@@ -423,6 +423,8 @@ void RTECast::loadChunks() {
buffer[rte1->size()] = '\n';
buffer[rte1->size() + 1] = '\0';
_loadedText->getVal(id)->importRTE(buffer);
+
+ delete rte1;
#endif
}
diff --git a/engines/director/resource.cpp b/engines/director/resource.cpp
index 1796e302f3..984f18b760 100644
--- a/engines/director/resource.cpp
+++ b/engines/director/resource.cpp
@@ -276,6 +276,8 @@ void DirectorEngine::loadSharedCastsFrom(Common::String filename) {
return;
}
+ Common::SeekableSubReadStreamEndian *r;
+
clearSharedCast();
Archive *sharedCast = createArchive();
@@ -302,11 +304,13 @@ void DirectorEngine::loadSharedCastsFrom(Common::String filename) {
_wm->_fontMan->loadFonts(filename);
}
- _sharedScore->loadConfig(*sharedCast->getResource(MKTAG('V','W','C','F'), 1024));
+ _sharedScore->loadConfig(*(r = sharedCast->getResource(MKTAG('V','W','C','F'), 1024)));
+ delete r;
if (getVersion() < 4) {
_sharedScore->_castIDoffset = sharedCast->getResourceIDList(MKTAG('V', 'W', 'C', 'R'))[0];
- _sharedScore->loadCastDataVWCR(*sharedCast->getResource(MKTAG('V','W','C','R'), _sharedScore->_castIDoffset));
+ _sharedScore->loadCastDataVWCR(*(r = sharedCast->getResource(MKTAG('V','W','C','R'), _sharedScore->_castIDoffset)));
+ delete r;
}
// Try to load script context
@@ -316,7 +320,8 @@ void DirectorEngine::loadSharedCastsFrom(Common::String filename) {
debugC(2, kDebugLoading, "****** Loading %d Lctx resources", lctx.size());
for (Common::Array<uint16>::iterator iterator = lctx.begin(); iterator != lctx.end(); ++iterator) {
- _sharedScore->loadLingoContext(*sharedCast->getResource(MKTAG('L','c','t','x'), *iterator));
+ _sharedScore->loadLingoContext(*(r = sharedCast->getResource(MKTAG('L','c','t','x'), *iterator)));
+ delete r;
}
}
}
@@ -331,7 +336,8 @@ void DirectorEngine::loadSharedCastsFrom(Common::String filename) {
maxLnam = MAX(maxLnam, (int)*iterator);
}
debugC(2, kDebugLoading, "****** Loading Lnam resource with highest ID (%d)", maxLnam);
- _sharedScore->loadLingoNames(*sharedCast->getResource(MKTAG('L','n','a','m'), maxLnam));
+ _sharedScore->loadLingoNames(*(r = sharedCast->getResource(MKTAG('L','n','a','m'), maxLnam)));
+ delete r;
}
}
@@ -340,7 +346,8 @@ void DirectorEngine::loadSharedCastsFrom(Common::String filename) {
debug(0, "****** Loading %d CastInfo resources", vwci.size());
for (Common::Array<uint16>::iterator iterator = vwci.begin(); iterator != vwci.end(); ++iterator)
- _sharedScore->loadCastInfo(*sharedCast->getResource(MKTAG('V', 'W', 'C', 'I'), *iterator), *iterator);
+ _sharedScore->loadCastInfo(*(r = sharedCast->getResource(MKTAG('V', 'W', 'C', 'I'), *iterator)), *iterator);
+ delete r;
}
Common::Array<uint16> cast = sharedCast->getResourceIDList(MKTAG('C','A','S','t'));
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 2854bb2ace..23131078e0 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -116,12 +116,15 @@ void Score::setArchive(Archive *archive) {
// Frame Labels
if (archive->hasResource(MKTAG('V', 'W', 'L', 'B'), -1)) {
- loadLabels(*archive->getFirstResource(MKTAG('V', 'W', 'L', 'B')));
+ Common::SeekableSubReadStreamEndian *r;
+ loadLabels(*(r = archive->getFirstResource(MKTAG('V', 'W', 'L', 'B'))));
+ delete r;
}
}
void Score::loadArchive() {
Common::Array<uint16> clutList = _movieArchive->getResourceIDList(MKTAG('C', 'L', 'U', 'T'));
+ Common::SeekableSubReadStreamEndian *r = nullptr;
if (clutList.size() > 1)
warning("More than one palette was found (%d)", clutList.size());
@@ -134,6 +137,8 @@ void Score::loadArchive() {
debugC(2, kDebugLoading, "****** Loading Palette CLUT, #%d", clutList[0]);
loadPalette(*pal);
+
+ delete pal;
}
// Font Directory
@@ -146,11 +151,13 @@ void Score::loadArchive() {
warning("Score::loadArchive(): Wrong movie format. VWSC resource missing");
return;
}
- loadFrames(*_movieArchive->getFirstResource(MKTAG('V', 'W', 'S', 'C')));
+ loadFrames(*(r = _movieArchive->getFirstResource(MKTAG('V', 'W', 'S', 'C'))));
+ delete r;
// Configuration Information
if (_movieArchive->hasResource(MKTAG('V', 'W', 'C', 'F'), -1)) {
- loadConfig(*_movieArchive->getFirstResource(MKTAG('V', 'W', 'C', 'F')));
+ loadConfig(*(r = _movieArchive->getFirstResource(MKTAG('V', 'W', 'C', 'F'))));
+ delete r;
} else {
// TODO: Source this from somewhere!
_movieRect = Common::Rect(0, 0, 640, 480);
@@ -160,24 +167,28 @@ void Score::loadArchive() {
// Cast Information Array
if (_movieArchive->hasResource(MKTAG('V', 'W', 'C', 'R'), -1)) {
_castIDoffset = _movieArchive->getResourceIDList(MKTAG('V', 'W', 'C', 'R'))[0];
- loadCastDataVWCR(*_movieArchive->getResource(MKTAG('V', 'W', 'C', 'R'), _castIDoffset));
+ loadCastDataVWCR(*(r = _movieArchive->getResource(MKTAG('V', 'W', 'C', 'R'), _castIDoffset)));
+ delete r;
}
// Action list
if (_movieArchive->hasResource(MKTAG('V', 'W', 'A', 'C'), -1)) {
- loadActions(*_movieArchive->getFirstResource(MKTAG('V', 'W', 'A', 'C')));
+ loadActions(*(r = _movieArchive->getFirstResource(MKTAG('V', 'W', 'A', 'C'))));
+ delete r;
}
// File Info
if (_movieArchive->hasResource(MKTAG('V', 'W', 'F', 'I'), -1)) {
- loadFileInfo(*_movieArchive->getFirstResource(MKTAG('V', 'W', 'F', 'I')));
+ loadFileInfo(*(r = _movieArchive->getFirstResource(MKTAG('V', 'W', 'F', 'I'))));
+ delete r;
}
// Font Mapping
if (_movieArchive->hasResource(MKTAG('V', 'W', 'F', 'M'), -1)) {
_vm->_wm->_fontMan->clearFontMapping();
- loadFontMap(*_movieArchive->getFirstResource(MKTAG('V', 'W', 'F', 'M')));
+ loadFontMap(*(r = _movieArchive->getFirstResource(MKTAG('V', 'W', 'F', 'M'))));
+ delete r;
}
// Pattern Tiles
@@ -202,7 +213,8 @@ void Score::loadArchive() {
debugC(2, kDebugLoading, "****** Loading %d Lctx resources", lctx.size());
for (Common::Array<uint16>::iterator iterator = lctx.begin(); iterator != lctx.end(); ++iterator) {
- loadLingoContext(*_movieArchive->getResource(MKTAG('L','c','t','x'), *iterator));
+ loadLingoContext(*(r = _movieArchive->getResource(MKTAG('L','c','t','x'), *iterator)));
+ delete r;
}
}
}
@@ -217,7 +229,8 @@ void Score::loadArchive() {
maxLnam = MAX(maxLnam, (int)*iterator);
}
debugC(2, kDebugLoading, "****** Loading Lnam resource with highest ID (%d)", maxLnam);
- loadLingoNames(*_movieArchive->getResource(MKTAG('L','n','a','m'), maxLnam));
+ loadLingoNames(*(r = _movieArchive->getResource(MKTAG('L','n','a','m'), maxLnam)));
+ delete r;
}
}
@@ -225,8 +238,10 @@ void Score::loadArchive() {
if (vwci.size() > 0) {
debugC(2, kDebugLoading, "****** Loading %d CastInfos VWCI", vwci.size());
- for (Common::Array<uint16>::iterator iterator = vwci.begin(); iterator != vwci.end(); ++iterator)
- loadCastInfo(*_movieArchive->getResource(MKTAG('V', 'W', 'C', 'I'), *iterator), *iterator);
+ for (Common::Array<uint16>::iterator iterator = vwci.begin(); iterator != vwci.end(); ++iterator) {
+ loadCastInfo(*(r = _movieArchive->getResource(MKTAG('V', 'W', 'C', 'I'), *iterator)), *iterator);
+ delete r;
+ }
}
Common::Array<uint16> cast = _movieArchive->getResourceIDList(MKTAG('C', 'A', 'S', 't'));
@@ -240,6 +255,7 @@ void Score::loadArchive() {
Common::SeekableSubReadStreamEndian *stream = _movieArchive->getResource(MKTAG('C', 'A', 'S', 't'), *iterator);
Resource res = _movieArchive->getResourceDetail(MKTAG('C', 'A', 'S', 't'), *iterator);
loadCastData(*stream, *iterator, &res);
+ delete stream;
}
}
@@ -266,11 +282,14 @@ void Score::loadArchive() {
for (Common::Array<uint16>::iterator iterator = stxt.begin(); iterator != stxt.end(); ++iterator) {
_loadedStxts->setVal(*iterator,
- new Stxt(*_movieArchive->getResource(MKTAG('S','T','X','T'), *iterator)));
+ new Stxt(*(r = _movieArchive->getResource(MKTAG('S','T','X','T'), *iterator))));
+
+ delete r;
// Try to load movie script, it starts with a comment
if (_vm->getVersion() <= 3) {
- loadScriptText(*_movieArchive->getResource(MKTAG('S','T','X','T'), *iterator));
+ loadScriptText(*(r = _movieArchive->getResource(MKTAG('S','T','X','T'), *iterator)));
+ delete r;
}
}
@@ -413,6 +432,7 @@ void Score::loadSpriteSounds(bool isSharedCast) {
if (sndData != NULL && soundCast != NULL) {
SNDDecoder *audio = new SNDDecoder();
audio->loadStream(*sndData);
+ delete sndData;
soundCast->_audio = audio;
}
}
@@ -914,7 +934,9 @@ void Score::loadCastData(Common::SeekableSubReadStreamEndian &stream, uint16 id,
uint scriptId = ((ScriptCast *)(*_loadedCast)[id])->_id - 1;
if (scriptId < _castScriptIds.size()) {
int resourceId = _castScriptIds[scriptId];
- _lingo->addCodeV4(*_movieArchive->getResource(MKTAG('L', 's', 'c', 'r'), resourceId), ((ScriptCast *)_loadedCast->getVal(id))->_scriptType, id);
+ Common::SeekableSubReadStreamEndian *r;
+ _lingo->addCodeV4(*(r = _movieArchive->getResource(MKTAG('L', 's', 'c', 'r'), resourceId)), ((ScriptCast *)_loadedCast->getVal(id))->_scriptType, id);
+ delete r;
} else {
warning("Score::loadCastData(): Lingo context missing a resource entry for script %d referenced in cast %d", scriptId, id);
}
More information about the Scummvm-git-logs
mailing list