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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sat Oct 7 03:05:26 CEST 2006


Revision: 24153
          http://svn.sourceforge.net/scummvm/?rev=24153&view=rev
Author:   fingolfin
Date:     2006-10-06 18:05:12 -0700 (Fri, 06 Oct 2006)

Log Message:
-----------
Instantiate and hook up the plugin providers in the main() function of the corresponding backends (porters may have to update their ports if they were using the POSIX or Win32 module loading code implicitly); some cleanup

Modified Paths:
--------------
    scummvm/trunk/backends/platform/dc/dcmain.cpp
    scummvm/trunk/backends/platform/sdl/sdl.cpp
    scummvm/trunk/backends/platform/x11/x11.cpp
    scummvm/trunk/backends/plugins/dc/dc-provider.cpp
    scummvm/trunk/backends/plugins/posix/posix-provider.cpp
    scummvm/trunk/backends/plugins/win32/win32-provider.cpp
    scummvm/trunk/base/plugins.cpp
    scummvm/trunk/base/plugins.h

Modified: scummvm/trunk/backends/platform/dc/dcmain.cpp
===================================================================
--- scummvm/trunk/backends/platform/dc/dcmain.cpp	2006-10-07 00:51:16 UTC (rev 24152)
+++ scummvm/trunk/backends/platform/dc/dcmain.cpp	2006-10-07 01:05:12 UTC (rev 24153)
@@ -31,7 +31,9 @@
 #include "DCLauncherDialog.h"
 #include <common/config-manager.h>
 
+#include "backends/plugins/dc/dc-provider.h"
 
+
 Icon icon;
 const char *gGameName;
 
@@ -205,6 +207,10 @@
   g_system = new OSystem_Dreamcast();
   assert(g_system);
 
+#ifdef DYNAMIC_MODULES
+	PluginManager::instance().addPluginProvider(new DCPluginProvider());
+#endif
+
   int res = scummvm_main(argc, argv);
 
   exit(0);

Modified: scummvm/trunk/backends/platform/sdl/sdl.cpp
===================================================================
--- scummvm/trunk/backends/platform/sdl/sdl.cpp	2006-10-07 00:51:16 UTC (rev 24152)
+++ scummvm/trunk/backends/platform/sdl/sdl.cpp	2006-10-07 01:05:12 UTC (rev 24153)
@@ -22,6 +22,7 @@
  */
 
 #include "backends/platform/sdl/sdl-common.h"
+#include "backends/plugins/sdl/sdl-provider.h"
 #include "common/config-manager.h"
 #include "common/util.h"
 #include "base/main.h"
@@ -95,6 +96,10 @@
 #endif
 	assert(g_system);
 
+#ifdef DYNAMIC_MODULES
+	PluginManager::instance().addPluginProvider(new SDLPluginProvider());
+#endif
+
 	// Invoke the actual ScummVM main entry point:
 	int res = scummvm_main(argc, argv);
 	g_system->quit();	// TODO: Consider removing / replacing this!

Modified: scummvm/trunk/backends/platform/x11/x11.cpp
===================================================================
--- scummvm/trunk/backends/platform/x11/x11.cpp	2006-10-07 00:51:16 UTC (rev 24152)
+++ scummvm/trunk/backends/platform/x11/x11.cpp	2006-10-07 01:05:12 UTC (rev 24153)
@@ -30,6 +30,7 @@
 #include "base/main.h"
 #include "backends/intern.h"
 #include "backends/platform/x11/x11.h"
+#include "backends/plugins/posix/posix-provider.h"
 
 #include <stdio.h>
 #include <assert.h>
@@ -62,6 +63,10 @@
 	g_system = OSystem_X11::create(0, 0);
 	assert(g_system);
 
+#ifdef DYNAMIC_MODULES
+	PluginManager::instance().addPluginProvider(new POSIXPluginProvider());
+#endif
+
 	// Invoke the actual ScummVM main entry point:
 	int res = scummvm_main(argc, argv);
 	g_system->quit();	// TODO: Consider removing / replacing this!

Modified: scummvm/trunk/backends/plugins/dc/dc-provider.cpp
===================================================================
--- scummvm/trunk/backends/plugins/dc/dc-provider.cpp	2006-10-07 00:51:16 UTC (rev 24152)
+++ scummvm/trunk/backends/plugins/dc/dc-provider.cpp	2006-10-07 01:05:12 UTC (rev 24153)
@@ -77,6 +77,7 @@
 		if (_dlHandle) {
 			if (dlclose(_dlHandle) != 0)
 				warning("Failed unloading plugin '%s' (%s)", _filename.c_str(), dlerror());
+			_dlHandle = 0;
 		}
 	}
 };

Modified: scummvm/trunk/backends/plugins/posix/posix-provider.cpp
===================================================================
--- scummvm/trunk/backends/plugins/posix/posix-provider.cpp	2006-10-07 00:51:16 UTC (rev 24152)
+++ scummvm/trunk/backends/plugins/posix/posix-provider.cpp	2006-10-07 01:05:12 UTC (rev 24153)
@@ -70,6 +70,7 @@
 		if (_dlHandle) {
 			if (dlclose(_dlHandle) != 0)
 				warning("Failed unloading plugin '%s' (%s)", _filename.c_str(), dlerror());
+			_dlHandle = 0;
 		}
 	}
 };

Modified: scummvm/trunk/backends/plugins/win32/win32-provider.cpp
===================================================================
--- scummvm/trunk/backends/plugins/win32/win32-provider.cpp	2006-10-07 00:51:16 UTC (rev 24152)
+++ scummvm/trunk/backends/plugins/win32/win32-provider.cpp	2006-10-07 01:05:12 UTC (rev 24153)
@@ -71,6 +71,7 @@
 		if (_dlHandle) {
 			if (!FreeLibrary((HMODULE)_dlHandle))
 				warning("Failed unloading plugin '%s'", _filename.c_str());
+			_dlHandle = 0;
 		}
 	}
 };

Modified: scummvm/trunk/base/plugins.cpp
===================================================================
--- scummvm/trunk/base/plugins.cpp	2006-10-07 00:51:16 UTC (rev 24152)
+++ scummvm/trunk/base/plugins.cpp	2006-10-07 01:05:12 UTC (rev 24153)
@@ -21,22 +21,10 @@
  *
  */
 
-#include "common/stdafx.h"
 #include "base/plugins.h"
 #include "common/util.h"
-#include "common/fs.h"
 
-#ifdef DYNAMIC_MODULES
-  #if defined(UNIX)
-  #include "backends/plugins/posix/posix-provider.h"
-  #elif defined(__DC__)
-  #include "backends/plugins/dc/dc-provider.h"
-  #elif defined(_WIN32)
-  #include "backends/plugins/win32/win32-provider.h"
-  #endif
-#endif
 
-
 void DetectedGame::updateDesc(const char *extra) {
 	// TODO: The format used here (LANG/PLATFORM/EXTRA) is not set in stone.
 	// We may want to change the order (PLATFORM/EXTRA/LANG, anybody?), or
@@ -162,8 +150,7 @@
 		#ifndef DISABLE_AGI
 		LINK_PLUGIN(AGI)
 		#endif
-	
-	
+
 		return pl;
 	}
 };
@@ -176,22 +163,9 @@
 DECLARE_SINGLETON(PluginManager);
 
 PluginManager::PluginManager() {
-
-// FIXME: The following code should be moved to the backend specific code,
-// usually into the main() function just before scummvm_main is called
-#ifdef DYNAMIC_MODULES
-
-#if defined(UNIX)
-	addPluginProvider(new POSIXPluginProvider());
-#elif defined(__DC__)
-	addPluginProvider(new DCPluginProvider());
-#elif defined(_WIN32)
-	addPluginProvider(new Win32PluginProvider());
-#else
-#error No support for loading plugins on non-unix systems at this point!
-#endif
-
-#else
+#ifndef DYNAMIC_MODULES
+	// Add the static plugin provider if we do not build with dynamic
+	// plugins.
 	addPluginProvider(new StaticPluginProvider());
 #endif
 }
@@ -199,6 +173,13 @@
 PluginManager::~PluginManager() {
 	// Explicitly unload all loaded plugins
 	unloadPlugins();
+	
+	// Delete the plugin providers
+	for (ProviderList::iterator pp = _providers.begin();
+	                            pp != _providers.end();
+	                            ++pp) {
+		delete *pp;
+	}
 }
 	
 void PluginManager::addPluginProvider(PluginProvider *pp) {
@@ -224,12 +205,13 @@
 void PluginManager::unloadPluginsExcept(const Plugin *plugin) {
 	Plugin *found = NULL;
 	uint i;
+	for (PluginList::iterator p = _plugins.begin(); p != _plugins.end(); ++p)
 	for (i = 0; i < _plugins.size(); i++) {
-		if (_plugins[i] == plugin) {
-			found = _plugins[i];
+		if (*p == plugin) {
+			found = *p;
 		} else {
-			_plugins[i]->unloadPlugin();
-			delete _plugins[i];
+			(**p).unloadPlugin();
+			delete *p;
 		}
 	}
 	_plugins.clear();

Modified: scummvm/trunk/base/plugins.h
===================================================================
--- scummvm/trunk/base/plugins.h	2006-10-07 00:51:16 UTC (rev 24152)
+++ scummvm/trunk/base/plugins.h	2006-10-07 01:05:12 UTC (rev 24153)
@@ -24,6 +24,7 @@
 #ifndef BASE_PLUGINS_H
 #define BASE_PLUGINS_H
 
+#include "common/stdafx.h"
 #include "common/array.h"
 #include "common/list.h"
 #include "common/singleton.h"


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