aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/platform/dc/dcmain.cpp6
-rw-r--r--backends/platform/sdl/sdl.cpp5
-rw-r--r--backends/platform/x11/x11.cpp5
-rw-r--r--backends/plugins/dc/dc-provider.cpp1
-rw-r--r--backends/plugins/posix/posix-provider.cpp1
-rw-r--r--backends/plugins/win32/win32-provider.cpp1
-rw-r--r--base/plugins.cpp50
-rw-r--r--base/plugins.h1
8 files changed, 36 insertions, 34 deletions
diff --git a/backends/platform/dc/dcmain.cpp b/backends/platform/dc/dcmain.cpp
index 4b03ec1551..4ba5338dfa 100644
--- a/backends/platform/dc/dcmain.cpp
+++ b/backends/platform/dc/dcmain.cpp
@@ -31,6 +31,8 @@
#include "DCLauncherDialog.h"
#include <common/config-manager.h>
+#include "backends/plugins/dc/dc-provider.h"
+
Icon icon;
const char *gGameName;
@@ -205,6 +207,10 @@ int main()
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);
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 5f76d21c9d..21f5935c58 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -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 @@ int main(int argc, char *argv[]) {
#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!
diff --git a/backends/platform/x11/x11.cpp b/backends/platform/x11/x11.cpp
index ce020c7a8e..7db5066c44 100644
--- a/backends/platform/x11/x11.cpp
+++ b/backends/platform/x11/x11.cpp
@@ -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 @@ int main(int argc, char *argv[]) {
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!
diff --git a/backends/plugins/dc/dc-provider.cpp b/backends/plugins/dc/dc-provider.cpp
index bf7a607d99..46e4b84674 100644
--- a/backends/plugins/dc/dc-provider.cpp
+++ b/backends/plugins/dc/dc-provider.cpp
@@ -77,6 +77,7 @@ public:
if (_dlHandle) {
if (dlclose(_dlHandle) != 0)
warning("Failed unloading plugin '%s' (%s)", _filename.c_str(), dlerror());
+ _dlHandle = 0;
}
}
};
diff --git a/backends/plugins/posix/posix-provider.cpp b/backends/plugins/posix/posix-provider.cpp
index 52bc7751b1..395968918b 100644
--- a/backends/plugins/posix/posix-provider.cpp
+++ b/backends/plugins/posix/posix-provider.cpp
@@ -70,6 +70,7 @@ public:
if (_dlHandle) {
if (dlclose(_dlHandle) != 0)
warning("Failed unloading plugin '%s' (%s)", _filename.c_str(), dlerror());
+ _dlHandle = 0;
}
}
};
diff --git a/backends/plugins/win32/win32-provider.cpp b/backends/plugins/win32/win32-provider.cpp
index 5eb607dc71..b88f900027 100644
--- a/backends/plugins/win32/win32-provider.cpp
+++ b/backends/plugins/win32/win32-provider.cpp
@@ -71,6 +71,7 @@ public:
if (_dlHandle) {
if (!FreeLibrary((HMODULE)_dlHandle))
warning("Failed unloading plugin '%s'", _filename.c_str());
+ _dlHandle = 0;
}
}
};
diff --git a/base/plugins.cpp b/base/plugins.cpp
index a1c73560a9..326b56be82 100644
--- a/base/plugins.cpp
+++ b/base/plugins.cpp
@@ -21,20 +21,8 @@
*
*/
-#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) {
@@ -162,8 +150,7 @@ public:
#ifndef DISABLE_AGI
LINK_PLUGIN(AGI)
#endif
-
-
+
return pl;
}
};
@@ -176,22 +163,9 @@ public:
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() {
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::unloadPlugins() {
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();
diff --git a/base/plugins.h b/base/plugins.h
index acaa637162..e5a6882e39 100644
--- a/base/plugins.h
+++ b/base/plugins.h
@@ -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"