[Scummvm-cvs-logs] SF.net SVN: scummvm:[52080] scummvm/branches/gsoc2010-plugins/base

toneman1138 at users.sourceforge.net toneman1138 at users.sourceforge.net
Sat Aug 14 10:04:41 CEST 2010


Revision: 52080
          http://scummvm.svn.sourceforge.net/scummvm/?rev=52080&view=rev
Author:   toneman1138
Date:     2010-08-14 08:04:40 +0000 (Sat, 14 Aug 2010)

Log Message:
-----------
Ensured getPlugins is not called multiple times on Static Plugin Provider with 'ONE_PLUGIN_AT_A_TIME' defined

Modified Paths:
--------------
    scummvm/branches/gsoc2010-plugins/base/main.cpp
    scummvm/branches/gsoc2010-plugins/base/plugins.cpp
    scummvm/branches/gsoc2010-plugins/base/plugins.h

Modified: scummvm/branches/gsoc2010-plugins/base/main.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/base/main.cpp	2010-08-14 08:03:32 UTC (rev 52079)
+++ scummvm/branches/gsoc2010-plugins/base/main.cpp	2010-08-14 08:04:40 UTC (rev 52080)
@@ -346,7 +346,7 @@
 
 #if defined(ONE_PLUGIN_AT_A_TIME) && defined(DYNAMIC_MODULES)
 	// Only load non-engine plugins and first engine plugin initially in this case.
-	PluginManager::instance().loadFirstPlugin(); //This should be the only call to loadFirstPlugin external to the PluginManager class.
+	PluginManager::instance().loadFirstPlugin();
 #else
  	// Load the plugins.
  	PluginManager::instance().loadPlugins();
@@ -433,7 +433,12 @@
 			ConfMan.setActiveDomain("");
 
 			// PluginManager::instance().unloadPlugins();
+
+#if defined(ONE_PLUGIN_AT_A_TIME) && defined(DYNAMIC_MODULES)
+			PluginManager::instance().loadFirstPlugin();
+#else
 			PluginManager::instance().loadPlugins();
+#endif
 		} else {
 			// A dialog would be nicer, but we don't have any
 			// screen to draw on yet.

Modified: scummvm/branches/gsoc2010-plugins/base/plugins.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/base/plugins.cpp	2010-08-14 08:03:32 UTC (rev 52079)
+++ scummvm/branches/gsoc2010-plugins/base/plugins.cpp	2010-08-14 08:04:40 UTC (rev 52080)
@@ -284,7 +284,7 @@
 PluginManager::PluginManager() {
 	// Always add the static plugin provider.
 	addPluginProvider(new StaticPluginProvider());
-	nonEnginePlugs = -1;
+	_skipStaticPlugs = false;
 }
 
 PluginManager::~PluginManager() {
@@ -304,30 +304,25 @@
 }
 
 void PluginManager::loadFirstPlugin() { //TODO: rename? It's not quite clear that this loads all non-engine plugins and first engine plugin.
+	unloadPluginsExcept(PLUGIN_TYPE_ENGINE, NULL);
 	_allPlugs.clear();
 	for (ProviderList::iterator pp = _providers.begin();
 	                            pp != _providers.end();
 	                            ++pp) {
-		PluginList pl((*pp)->getPlugins());
-		for (PluginList::iterator p = pl.begin(); p != pl.end(); ++p) {
-			_allPlugs.push_back(*p);
+		if ((_skipStaticPlugs && (*pp)->isFilePluginProvider()) || !_skipStaticPlugs) {
+			PluginList pl((*pp)->getPlugins());
+			for (PluginList::iterator p = pl.begin(); p != pl.end(); ++p) {
+				_allPlugs.push_back(*p);
+			}
 		}
 	}
 
+	_nonEnginePlugs = 0;
+	_skipStaticPlugs = true; //Only need to load static plugins once.
+
 	_currentPlugin = _allPlugs.begin();
 
-	bool updateNonEnginePlugs;
-	if (nonEnginePlugs == -1) { //TODO: All of this assumes engine plugins will always be last in "plugs". Is this the case?
-		nonEnginePlugs = 0;
-		updateNonEnginePlugs = true;
-	} else {
-		for (int i=0; i<nonEnginePlugs; i++) {
-			++_currentPlugin;
-		}
-		updateNonEnginePlugs = false;
-	}
-
-	if (_allPlugs.empty()) { //TODO: this case is untested.
+	if (_allPlugs.empty()) {
 		return; //return here if somehow there are no plugins to load.
 	}
 
@@ -337,7 +332,7 @@
 		if ((*_currentPlugin)->getType() == PLUGIN_TYPE_ENGINE) {
 			break;
 		}
-		if (updateNonEnginePlugs) nonEnginePlugs++;
+		_nonEnginePlugs++;
 		++_currentPlugin;
 		if (_currentPlugin == _allPlugs.end()) {
 			break; //break if there were no engine plugins to load.
@@ -347,7 +342,7 @@
 }
 
 bool PluginManager::loadNextPlugin() {
-	if (nonEnginePlugs == _allPlugs.size()) return false; //There are no Engine Plugins in this case.
+	if (_nonEnginePlugs == _allPlugs.size()) return false; //There are no Engine Plugins in this case.
 	//To ensure only one engine plugin is loaded at a time, we unload all engine plugins before trying to load a new one.
 	unloadPluginsExcept(PLUGIN_TYPE_ENGINE, NULL);
 	++_currentPlugin;

Modified: scummvm/branches/gsoc2010-plugins/base/plugins.h
===================================================================
--- scummvm/branches/gsoc2010-plugins/base/plugins.h	2010-08-14 08:03:32 UTC (rev 52079)
+++ scummvm/branches/gsoc2010-plugins/base/plugins.h	2010-08-14 08:04:40 UTC (rev 52080)
@@ -212,6 +212,11 @@
 	 * @return a list of Plugin instances
 	 */
 	virtual PluginList getPlugins() = 0;
+
+	/**
+	 * @return whether or not object is a FilePluginProvider.
+	 */
+	virtual bool isFilePluginProvider() { return false; }
 };
 
 #ifdef DYNAMIC_MODULES
@@ -234,6 +239,11 @@
 	 */
 	virtual PluginList getPlugins();
 
+	/**
+	 * @return whether or not object is a FilePluginProvider.
+	 */
+	bool isFilePluginProvider() { return true; }
+
 protected:
 	/**
 	 * Create a Plugin instance from a loadable code module with the specified name.
@@ -279,8 +289,10 @@
 	PluginList _allPlugs;
 	PluginList::iterator _currentPlugin;
 
-	int nonEnginePlugs;
-	
+	bool _skipStaticPlugs;
+
+	int _nonEnginePlugs;
+
 	bool tryLoadPlugin(Plugin *plugin);
 	
 	friend class Common::Singleton<SingletonBaseType>;


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