Added plugin priority so there's just one plugin that provides a module functionality.
svn-id: r32121
This commit is contained in:
parent
c834bbba06
commit
b35941c3c2
2 changed files with 22 additions and 13 deletions
|
@ -317,16 +317,26 @@ bool PluginManager::tryLoadPlugin(Plugin *plugin) {
|
||||||
assert(plugin);
|
assert(plugin);
|
||||||
// Try to load the plugin
|
// Try to load the plugin
|
||||||
if (plugin->loadPlugin()) {
|
if (plugin->loadPlugin()) {
|
||||||
// If successful, add it to the list of known plugins and return.
|
// The plugin is valid, see if it provides the same module as an
|
||||||
_plugins[plugin->getType()].push_back(plugin);
|
// already loaded one and should replace it.
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
// TODO/FIXME: We should perform some additional checks here:
|
PluginList::iterator pl = _plugins[plugin->getType()].begin();
|
||||||
// * Check for some kind of "API version" (possibly derived from the
|
while (!found && pl != _plugins[plugin->getType()].end()) {
|
||||||
// SVN tree revision?)
|
if (!strcmp(plugin->getName(), (*pl)->getName())) {
|
||||||
// * If two plugins provide the same engine, we should only load one.
|
// Found a duplicated module. Replace the old one.
|
||||||
// To detect this situation, we could just compare the plugin name.
|
found = true;
|
||||||
// To handle it, simply prefer modules loaded earlier to those coming.
|
delete *pl;
|
||||||
// Or vice versa... to be determined... :-)
|
*pl = plugin;
|
||||||
|
debug(1, "Replaced the duplicated plugin: '%s'", plugin->getName());
|
||||||
|
}
|
||||||
|
pl++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
// If it provides a new module, just add it to the list of known plugins.
|
||||||
|
_plugins[plugin->getType()].push_back(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -27,9 +27,8 @@
|
||||||
#define BASE_PLUGINS_H
|
#define BASE_PLUGINS_H
|
||||||
|
|
||||||
#include "common/error.h"
|
#include "common/error.h"
|
||||||
#include "common/list.h"
|
|
||||||
#include "common/singleton.h"
|
#include "common/singleton.h"
|
||||||
#include "base/game.h"
|
#include "common/util.h"
|
||||||
|
|
||||||
#ifdef DYNAMIC_MODULES
|
#ifdef DYNAMIC_MODULES
|
||||||
#include "common/fs.h"
|
#include "common/fs.h"
|
||||||
|
@ -69,7 +68,7 @@ enum PluginType {
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Make the engine API version depend on ScummVM's version
|
// TODO: Make the engine API version depend on ScummVM's version
|
||||||
// because of the backlinking
|
// because of the backlinking (posibly from the SVN revision)
|
||||||
#define PLUGIN_TYPE_ENGINE_VERSION 1
|
#define PLUGIN_TYPE_ENGINE_VERSION 1
|
||||||
#define PLUGIN_TYPE_MIDI_VERSION 1
|
#define PLUGIN_TYPE_MIDI_VERSION 1
|
||||||
|
|
||||||
|
@ -274,7 +273,7 @@ protected:
|
||||||
* managing all Plugin class instances, and unloading them.
|
* managing all Plugin class instances, and unloading them.
|
||||||
*/
|
*/
|
||||||
class PluginManager : public Common::Singleton<PluginManager> {
|
class PluginManager : public Common::Singleton<PluginManager> {
|
||||||
typedef Common::List<PluginProvider *> ProviderList;
|
typedef Common::Array<PluginProvider *> ProviderList;
|
||||||
private:
|
private:
|
||||||
PluginList _plugins[PLUGIN_TYPE_MAX];
|
PluginList _plugins[PLUGIN_TYPE_MAX];
|
||||||
ProviderList _providers;
|
ProviderList _providers;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue