From c7babbea99d100fe534bacf3f05a94c18be567e6 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Sat, 15 Jul 2006 22:42:28 +0000 Subject: Close the current text object when the movie is ended, to avoid potential memory leak, and be a bit more robust about handling text objects in the dummy player. svn-id: r23523 --- engines/sword2/animation.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/sword2/animation.cpp b/engines/sword2/animation.cpp index f13ce959c0..20ac26774e 100644 --- a/engines/sword2/animation.cpp +++ b/engines/sword2/animation.cpp @@ -400,6 +400,9 @@ void MoviePlayer::play(int32 leadIn, int32 leadOut) { updateScreen(); } + // The current text object may still be open + closeTextObject(_textList[_currentText]); + if (!terminate) { // Wait for the voice to stop playing. This is to make sure // that we don't cut off the speech in mid-sentence, and - even @@ -782,12 +785,16 @@ void MoviePlayerDummy::drawFrame() { } void MoviePlayerDummy::drawTextObject(MovieTextObject *t) { - _vm->_screen->drawSurface(t->textSprite, _textSurface); + if (t->textSprite && _textSurface) { + _vm->_screen->drawSurface(t->textSprite, _textSurface); + } } void MoviePlayerDummy::undrawTextObject(MovieTextObject *t) { - memset(_textSurface, 1, t->textSprite->w * t->textSprite->h); - drawTextObject(t); + if (t->textSprite && _textSurface) { + memset(_textSurface, 1, t->textSprite->w * t->textSprite->h); + drawTextObject(t); + } } /////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3