From 0d7d1ed2f8335a6423e287efb9c253908e53f3c5 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 6 Jan 2020 13:40:24 +0100 Subject: DIRECTOR: Plug memory leak in Cast --- engines/director/cast.cpp | 21 +++++++++++++++------ engines/director/cast.h | 5 ++++- 2 files changed, 19 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp index 825c3b2093..4537742e19 100644 --- a/engines/director/cast.cpp +++ b/engines/director/cast.cpp @@ -21,6 +21,7 @@ */ #include "common/substream.h" +#include "graphics/surface.h" #include "director/director.h" #include "director/cachedmactext.h" @@ -30,6 +31,17 @@ namespace Director { +Cast::Cast() { + _type = kCastTypeNull; + _surface = nullptr; + + _modified = true; +} + +Cast::~Cast() { + delete _surface; +} + BitmapCast::BitmapCast(Common::ReadStreamEndian &stream, uint32 castTag, uint16 version) { _type = kCastBitmap; @@ -106,7 +118,6 @@ BitmapCast::BitmapCast(Common::ReadStreamEndian &stream, uint32 castTag, uint16 stream.readUint32(); } - _modified = 0; _tag = castTag; } @@ -223,10 +234,10 @@ TextCast::TextCast(Common::ReadStreamEndian &stream, uint16 version) { stream.readUint16(); } - _modified = 0; - _cachedMacText = new CachedMacText(this, version, -1, g_director->_wm); // TODO Destroy me + + _modified = false; } void TextCast::importStxt(const Stxt *stxt) { @@ -305,7 +316,7 @@ ShapeCast::ShapeCast(Common::ReadStreamEndian &stream, uint16 version) { _lineThickness = 1; _lineDirection = 0; } - _modified = 0; + _modified = false; debugC(3, kDebugLoading, "ShapeCast: fl: %x unk1: %x type: %d pat: %d fg: %d bg: %d fill: %d thick: %d dir: %d", flags, unk1, _shapeType, _pattern, _fgCol, _bgCol, _fillType, _lineThickness, _lineDirection); @@ -329,7 +340,6 @@ ButtonCast::ButtonCast(Common::ReadStreamEndian &stream, uint16 version) : TextC _buttonType = static_cast(stream.readUint16BE()); } - _modified = 0; } ScriptCast::ScriptCast(Common::ReadStreamEndian &stream, uint16 version) { @@ -363,7 +373,6 @@ ScriptCast::ScriptCast(Common::ReadStreamEndian &stream, uint16 version) { // WIP need to complete this! } - _modified = 0; } RTECast::RTECast(Common::ReadStreamEndian &stream, uint16 version) : TextCast(stream, version) { diff --git a/engines/director/cast.h b/engines/director/cast.h index 3d8db523c7..3e1479d041 100644 --- a/engines/director/cast.h +++ b/engines/director/cast.h @@ -42,6 +42,9 @@ class CachedMacText; class Cast { public: + Cast(); + virtual ~Cast(); + CastType _type; Common::Rect _initialRect; Common::Rect _boundingRect; @@ -49,7 +52,7 @@ public: const Graphics::Surface *_surface; - byte _modified; + bool _modified; }; class BitmapCast : public Cast { -- cgit v1.2.3