[Scummvm-cvs-logs] SF.net SVN: scummvm:[48837] scummvm/trunk/engines/parallaction

wjpalenstijn at users.sourceforge.net wjpalenstijn at users.sourceforge.net
Wed Apr 28 23:50:55 CEST 2010


Revision: 48837
          http://scummvm.svn.sourceforge.net/scummvm/?rev=48837&view=rev
Author:   wjpalenstijn
Date:     2010-04-28 21:50:54 +0000 (Wed, 28 Apr 2010)

Log Message:
-----------
Fix Nippon Safes test result label memory leak

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/callables_ns.cpp
    scummvm/trunk/engines/parallaction/parallaction.h
    scummvm/trunk/engines/parallaction/parallaction_ns.cpp

Modified: scummvm/trunk/engines/parallaction/callables_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/callables_ns.cpp	2010-04-28 21:22:44 UTC (rev 48836)
+++ scummvm/trunk/engines/parallaction/callables_ns.cpp	2010-04-28 21:50:54 UTC (rev 48837)
@@ -409,14 +409,14 @@
 
 	parseLocation("common");
 
-	GfxObj *labels[2];
-	labels[0] = _gfx->createLabel(_menuFont, _location._slideText[0].c_str(), 1);
-	labels[1] = _gfx->createLabel(_menuFont, _location._slideText[1].c_str(), 1);
+	destroyTestResultLabels();
 
-	_gfx->showLabel(labels[0], CENTER_LABEL_HORIZONTAL, 38);
-	_gfx->showLabel(labels[1], CENTER_LABEL_HORIZONTAL, 58);
+	_testResultLabels[0] = _gfx->createLabel(_menuFont, _location._slideText[0].c_str(), 1);
+	_testResultLabels[1] = _gfx->createLabel(_menuFont, _location._slideText[1].c_str(), 1);
 
-	// FIXME: this leaks two labels
+	_gfx->showLabel(_testResultLabels[0], CENTER_LABEL_HORIZONTAL, 38);
+	_gfx->showLabel(_testResultLabels[1], CENTER_LABEL_HORIZONTAL, 58);
+
 	return;
 }
 

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2010-04-28 21:22:44 UTC (rev 48836)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2010-04-28 21:50:54 UTC (rev 48837)
@@ -439,6 +439,7 @@
 	void	loadProgram(AnimationPtr a, const char *filename);
 	void	freeLocation(bool removeAll);
 	void	freeCharacter();
+	void	destroyTestResultLabels();
 	void	startMovingSarcophagus(ZonePtr sarc);
 	void	stopMovingSarcophagus();
 
@@ -460,6 +461,8 @@
 	static const Callable _dosCallables[25];
 	static const Callable _amigaCallables[25];
 
+	GfxObj *_testResultLabels[2];
+
 	PathWalker_NS		*_walker;
 
 	// common callables

Modified: scummvm/trunk/engines/parallaction/parallaction_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2010-04-28 21:22:44 UTC (rev 48836)
+++ scummvm/trunk/engines/parallaction/parallaction_ns.cpp	2010-04-28 21:50:54 UTC (rev 48837)
@@ -228,8 +228,17 @@
 	_location._animations.remove(_char._ani);
 
 	delete _walker;
+
+	destroyTestResultLabels();
 }
 
+void Parallaction_ns::destroyTestResultLabels() {
+	for (int i = 0; i < 2; ++i) {
+		_gfx->unregisterLabel(_testResultLabels[i]);
+		delete _testResultLabels[i];
+		_testResultLabels[i] = 0;
+	}
+}
 
 void Parallaction_ns::freeFonts() {
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list