aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Comstedt2004-08-29 19:08:08 +0000
committerMarcus Comstedt2004-08-29 19:08:08 +0000
commitf6af7cdcc7530149bf976cb69a2aa7aab21abb84 (patch)
treede63fc7423f2932307fab545a7fbad08af5a0e11
parentca6ad7a76fe48737b6daf6ce3259227850fc5d27 (diff)
downloadscummvm-rg350-f6af7cdcc7530149bf976cb69a2aa7aab21abb84.tar.gz
scummvm-rg350-f6af7cdcc7530149bf976cb69a2aa7aab21abb84.tar.bz2
scummvm-rg350-f6af7cdcc7530149bf976cb69a2aa7aab21abb84.zip
Provide unloading of unneeded plugins.
svn-id: r14829
-rw-r--r--base/main.cpp6
-rw-r--r--base/plugins.cpp16
-rw-r--r--base/plugins.h1
3 files changed, 21 insertions, 2 deletions
diff --git a/base/main.cpp b/base/main.cpp
index 749d62a5fa..68ca73a4be 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -381,8 +381,14 @@ extern "C" int scummvm_main(GameDetector &detector, int argc, char *argv[]) {
//while(1) {
// Verify the given game name is a valid supported game
if (detector.detectMain()) {
+ // Unload all plugins not needed for this game,
+ // to save memory
+ PluginManager::instance().unloadPluginsExcept(detector._plugin);
+
runGame(detector, system);
+ // PluginManager::instance().unloadPlugins();
+ // PluginManager::instance().loadPlugins();
// launcherDialog(detector, system);
}
//}
diff --git a/base/plugins.cpp b/base/plugins.cpp
index cab71bf20a..ddc00320c7 100644
--- a/base/plugins.cpp
+++ b/base/plugins.cpp
@@ -265,12 +265,24 @@ void PluginManager::loadPlugins() {
}
void PluginManager::unloadPlugins() {
+ unloadPluginsExcept(NULL);
+}
+
+void PluginManager::unloadPluginsExcept(const Plugin *plugin) {
+ Plugin *found = NULL;
uint i;
for (i = 0; i < _plugins.size(); i++) {
- _plugins[i]->unloadPlugin();
- delete _plugins[i];
+ if (_plugins[i] == plugin) {
+ found = _plugins[i];
+ } else {
+ _plugins[i]->unloadPlugin();
+ delete _plugins[i];
+ }
}
_plugins.clear();
+ if (found != NULL) {
+ _plugins.push_back(found);
+ }
}
bool PluginManager::tryLoadPlugin(Plugin *plugin) {
diff --git a/base/plugins.h b/base/plugins.h
index 5c5e94559f..d760eae148 100644
--- a/base/plugins.h
+++ b/base/plugins.h
@@ -123,6 +123,7 @@ public:
void loadPlugins();
void unloadPlugins();
+ void unloadPluginsExcept(const Plugin *plugin);
const PluginList &getPlugins() { return _plugins; }