Provide unloading of unneeded plugins.

svn-id: r14829
This commit is contained in:
Marcus Comstedt 2004-08-29 19:08:08 +00:00
parent ca6ad7a76f
commit f6af7cdcc7
3 changed files with 21 additions and 2 deletions

View File

@ -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);
}
//}

View File

@ -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) {

View File

@ -123,6 +123,7 @@ public:
void loadPlugins();
void unloadPlugins();
void unloadPluginsExcept(const Plugin *plugin);
const PluginList &getPlugins() { return _plugins; }