[Scummvm-cvs-logs] SF.net SVN: scummvm:[53734] scummvm/trunk/engines/sword25

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sat Oct 23 17:44:04 CEST 2010


Revision: 53734
          http://scummvm.svn.sourceforge.net/scummvm/?rev=53734&view=rev
Author:   fingolfin
Date:     2010-10-23 15:44:04 +0000 (Sat, 23 Oct 2010)

Log Message:
-----------
SWORD25: Get rid of global SharedPtr instances

Modified Paths:
--------------
    scummvm/trunk/engines/sword25/gfx/graphicengine.cpp
    scummvm/trunk/engines/sword25/gfx/graphicengine.h
    scummvm/trunk/engines/sword25/gfx/graphicengine_script.cpp
    scummvm/trunk/engines/sword25/input/inputengine.cpp
    scummvm/trunk/engines/sword25/input/inputengine.h
    scummvm/trunk/engines/sword25/input/inputengine_script.cpp

Modified: scummvm/trunk/engines/sword25/gfx/graphicengine.cpp
===================================================================
--- scummvm/trunk/engines/sword25/gfx/graphicengine.cpp	2010-10-23 14:37:26 UTC (rev 53733)
+++ scummvm/trunk/engines/sword25/gfx/graphicengine.cpp	2010-10-23 15:44:04 UTC (rev 53734)
@@ -85,6 +85,7 @@
 }
 
 GraphicEngine::~GraphicEngine() {
+	unregisterScriptBindings();
 	_backSurface.free();
 	_frameBuffer.free();
 	delete _thumbnail;

Modified: scummvm/trunk/engines/sword25/gfx/graphicengine.h
===================================================================
--- scummvm/trunk/engines/sword25/gfx/graphicengine.h	2010-10-23 14:37:26 UTC (rev 53733)
+++ scummvm/trunk/engines/sword25/gfx/graphicengine.h	2010-10-23 15:44:04 UTC (rev 53734)
@@ -363,6 +363,7 @@
 
 private:
 	bool registerScriptBindings();
+	void unregisterScriptBindings();
 
 	// LastFrameDuration Variables
 	// ---------------------------

Modified: scummvm/trunk/engines/sword25/gfx/graphicengine_script.cpp
===================================================================
--- scummvm/trunk/engines/sword25/gfx/graphicengine_script.cpp	2010-10-23 14:37:26 UTC (rev 53733)
+++ scummvm/trunk/engines/sword25/gfx/graphicengine_script.cpp	2010-10-23 15:44:04 UTC (rev 53734)
@@ -71,8 +71,8 @@
 	}
 };
 
-Common::ScopedPtr<LuaCallback> loopPointCallbackPtr;
-Common::ScopedPtr<ActionCallback> actionCallbackPtr;
+static LuaCallback *loopPointCallbackPtr = 0;	// FIXME: should be turned into GraphicEngine member var
+static ActionCallback *actionCallbackPtr = 0;	// FIXME: should be turned into GraphicEngine member var
 
 struct CallbackfunctionRegisterer {
 	CallbackfunctionRegisterer() {
@@ -1289,10 +1289,21 @@
 
 	if (!LuaBindhelper::addFunctionsToLib(L, GFX_LIBRARY_NAME, GFX_FUNCTIONS)) return false;
 
-	loopPointCallbackPtr.reset(new LuaCallback(L));
-	actionCallbackPtr.reset(new ActionCallback(L));
+	assert(loopPointCallbackPtr == 0);
+	loopPointCallbackPtr = new LuaCallback(L);
 
+	assert(actionCallbackPtr == 0);
+	actionCallbackPtr = new ActionCallback(L);
+
 	return true;
 }
 
+void GraphicEngine::unregisterScriptBindings() {
+	delete loopPointCallbackPtr;
+	loopPointCallbackPtr = 0;
+
+	delete actionCallbackPtr;
+	actionCallbackPtr = 0;
+}
+
 } // End of namespace Sword25

Modified: scummvm/trunk/engines/sword25/input/inputengine.cpp
===================================================================
--- scummvm/trunk/engines/sword25/input/inputengine.cpp	2010-10-23 14:37:26 UTC (rev 53733)
+++ scummvm/trunk/engines/sword25/input/inputengine.cpp	2010-10-23 15:44:04 UTC (rev 53734)
@@ -76,6 +76,10 @@
 		BS_LOGLN("Script bindings registered.");
 }
 
+InputEngine::~InputEngine() {
+	unregisterScriptBindings();
+}
+
 Service *InputEngine_CreateObject(Kernel *pKernel) {
 	return new InputEngine(pKernel);
 }

Modified: scummvm/trunk/engines/sword25/input/inputengine.h
===================================================================
--- scummvm/trunk/engines/sword25/input/inputengine.h	2010-10-23 14:37:26 UTC (rev 53733)
+++ scummvm/trunk/engines/sword25/input/inputengine.h	2010-10-23 15:44:04 UTC (rev 53734)
@@ -57,7 +57,7 @@
 class InputEngine : public Service, public Persistable {
 public:
 	InputEngine(Kernel *pKernel);
-	~InputEngine() {}
+	~InputEngine();
 
 	// NOTE: These codes are registered in inputengine_script.cpp
 	// Any changes to these enums must also adjust the above file.
@@ -303,6 +303,7 @@
 
 private:
 	bool registerScriptBindings();
+	void unregisterScriptBindings();
 
 private:
 	void testForLeftDoubleClick();

Modified: scummvm/trunk/engines/sword25/input/inputengine_script.cpp
===================================================================
--- scummvm/trunk/engines/sword25/input/inputengine_script.cpp	2010-10-23 14:37:26 UTC (rev 53733)
+++ scummvm/trunk/engines/sword25/input/inputengine_script.cpp	2010-10-23 15:44:04 UTC (rev 53734)
@@ -63,8 +63,9 @@
 		return 1;
 	}
 };
-Common::SharedPtr<CharacterCallbackClass> characterCallbackPtr;
 
+static CharacterCallbackClass *characterCallbackPtr = 0;	// FIXME: should be turned into InputEngine member var
+
 class CommandCallbackClass : public LuaCallback {
 public:
 	CommandCallbackClass(lua_State *L) : LuaCallback(L) {
@@ -79,8 +80,9 @@
 		return 1;
 	}
 };
-Common::SharedPtr<CommandCallbackClass> commandCallbackPtr;
 
+static CommandCallbackClass *commandCallbackPtr = 0;	// FIXME: should be turned into InputEngine member var
+
 struct CallbackfunctionRegisterer {
 	CallbackfunctionRegisterer() {
 		CallbackRegistry::instance().registerCallbackFunction("LuaCommandCB", theCommandCallback);
@@ -290,10 +292,21 @@
 	if (!LuaBindhelper::addFunctionsToLib(L, PACKAGE_LIBRARY_NAME, PACKAGE_FUNCTIONS)) return false;
 	if (!LuaBindhelper::addConstantsToLib(L, PACKAGE_LIBRARY_NAME, PACKAGE_CONSTANTS)) return false;
 
-	characterCallbackPtr = Common::SharedPtr<CharacterCallbackClass>(new CharacterCallbackClass(L));
-	commandCallbackPtr = Common::SharedPtr<CommandCallbackClass>(new CommandCallbackClass(L));
+	assert(characterCallbackPtr == 0);
+	characterCallbackPtr = new CharacterCallbackClass(L);
 
+	assert(commandCallbackPtr == 0);
+	commandCallbackPtr = new CommandCallbackClass(L);
+
 	return true;
 }
 
+void InputEngine::unregisterScriptBindings() {
+	delete characterCallbackPtr;
+	characterCallbackPtr = 0;
+
+	delete commandCallbackPtr;
+	commandCallbackPtr = 0;
+}
+
 } // End of namespace Sword25


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