[Scummvm-cvs-logs] SF.net SVN: scummvm: [20940] residual/trunk

marcus_c at users.sourceforge.net marcus_c at users.sourceforge.net
Sun Feb 26 09:57:04 CET 2006


Revision: 20940
Author:   marcus_c
Date:     2006-02-26 09:55:54 -0800 (Sun, 26 Feb 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm?rev=20940&view=rev

Log Message:
-----------
Memory leak fixes:

* Deref the splash screen when we're done with it
* Free all scenes and actors when shutting down the engine
* Changed the destruction order of the engine and the resourceloader,
  since the engine's destructor now needs to call the resourceloader
  (indirectly).

Modified Paths:
--------------
    residual/trunk/dc/main.cpp
    residual/trunk/engine.cpp
    residual/trunk/main.cpp
Modified: residual/trunk/dc/main.cpp
===================================================================
--- residual/trunk/dc/main.cpp	2006-02-26 17:25:37 UTC (rev 20939)
+++ residual/trunk/dc/main.cpp	2006-02-26 17:55:54 UTC (rev 20940)
@@ -74,11 +74,14 @@
 
 	Bitmap *splash_bm = NULL;
 	splash_bm = g_resourceloader->loadBitmap("splash.bm");
+	splash_bm->ref();
 
 	g_driver->clearScreen();
 	splash_bm->draw();
 	g_driver->flipBuffer();
 
+	splash_bm->deref();
+
 	lua_iolibopen();
 	lua_strlibopen();
 	lua_mathlibopen();
@@ -124,14 +127,14 @@
 		delete g_localizer;
 		g_localizer = NULL;
 	}
+	if (g_engine) {
+		delete g_engine;
+		g_engine = NULL;
+	}
 	if (g_resourceloader) {
 		delete g_resourceloader;
 		g_resourceloader = NULL;
 	}
-	if (g_engine) {
-		delete g_engine;
-		g_engine = NULL;
-	}
 	if (g_timer) {
 		delete g_timer;
 		g_timer = NULL;

Modified: residual/trunk/engine.cpp
===================================================================
--- residual/trunk/engine.cpp	2006-02-26 17:25:37 UTC (rev 20939)
+++ residual/trunk/engine.cpp	2006-02-26 17:55:54 UTC (rev 20940)
@@ -25,6 +25,7 @@
 #include "smush.h"
 #include "driver.h"
 #include "savegame.h"
+#include "lipsynch.h"
 
 #include "imuse/imuse.h"
 
@@ -106,9 +107,15 @@
 Engine::~Engine()
 {
 	delete[] _controlsEnabled;
+	for(SceneListType::const_iterator i = _scenes.begin();
+	    i != _scenes.end(); i++)
+		delete (*i);
+	for(ActorListType::const_iterator i = _actors.begin();
+	    i != _actors.end(); i++)
+		delete (*i);
 }
 
-void Engine::handleButton(int operation, int key, int keyModifier, uint16 ascii) {
+void Engine::handleButton(int operation, int key, int /*keyModifier*/, uint16 ascii) {
 	lua_Object handler, system_table, userPaintHandler;
 	
 	// If we're not supposed to handle the key then don't

Modified: residual/trunk/main.cpp
===================================================================
--- residual/trunk/main.cpp	2006-02-26 17:25:37 UTC (rev 20939)
+++ residual/trunk/main.cpp	2006-02-26 17:55:54 UTC (rev 20940)
@@ -174,6 +174,8 @@
 	Bitmap *splash_bm = NULL;
 	if (!(g_flags & GF_DEMO))
 		splash_bm = g_resourceloader->loadBitmap("splash.bm");
+	if(splash_bm != NULL)
+		splash_bm->ref();
 
 	SDL_Event event;
 	
@@ -195,6 +197,8 @@
 	}
 #endif
 
+	splash_bm->deref();
+
 	lua_iolibopen();
 	lua_strlibopen();
 	lua_mathlibopen();
@@ -240,14 +244,14 @@
 		delete g_localizer;
 		g_localizer = NULL;
 	}
+	if (g_engine) {
+		delete g_engine;
+		g_engine = NULL;
+	}
 	if (g_resourceloader) {
 		delete g_resourceloader;
 		g_resourceloader = NULL;
 	}
-	if (g_engine) {
-		delete g_engine;
-		g_engine = NULL;
-	}
 	if (g_timer) {
 		delete g_timer;
 		g_timer = NULL;







More information about the Scummvm-git-logs mailing list