From a14f044daa9210c55431a9683610064fa3594054 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Tue, 12 Jan 2010 18:43:10 +0000 Subject: SCI: deleting _font when changing active font svn-id: r47269 --- engines/sci/graphics/text.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'engines/sci/graphics/text.cpp') diff --git a/engines/sci/graphics/text.cpp b/engines/sci/graphics/text.cpp index c0bb8d8e00..a65bd36339 100644 --- a/engines/sci/graphics/text.cpp +++ b/engines/sci/graphics/text.cpp @@ -41,7 +41,8 @@ Text::Text(ResourceManager *resMan, Gfx *gfx, Screen *screen) } Text::~Text() { - delete _font; + if (_font != NULL) + delete _font; } void Text::init() { @@ -57,15 +58,21 @@ GuiResourceId Text::GetFontId() { } Font *Text::GetFont() { - if ((_font == NULL) || (_font->getResourceId() != _gfx->_curPort->fontId)) + if ((_font == NULL) || (_font->getResourceId() != _gfx->_curPort->fontId)) { + if (_font != NULL) + delete _font; _font = new Font(_resMan, _gfx->_curPort->fontId); + } return _font; } void Text::SetFont(GuiResourceId fontId) { - if ((_font == NULL) || (_font->getResourceId() != fontId)) + if ((_font == NULL) || (_font->getResourceId() != fontId)) { + if (_font != NULL) + delete _font; _font = new Font(_resMan, fontId); + } _gfx->_curPort->fontId = _font->getResourceId(); _gfx->_curPort->fontHeight = _font->getHeight(); -- cgit v1.2.3