[Orxonox-commit 6359] r11016 - in code/trunk: cmake src src/libraries/core/module
landauf at orxonox.net
landauf at orxonox.net
Sat Jan 2 16:06:30 CET 2016
Author: landauf
Date: 2016-01-02 16:06:30 +0100 (Sat, 02 Jan 2016)
New Revision: 11016
Modified:
code/trunk/cmake/LibraryConfigTardis.cmake
code/trunk/src/SpecialConfig.h.in
code/trunk/src/libraries/core/module/PluginManager.cc
code/trunk/src/libraries/core/module/PluginManager.h
Log:
Added config value to PluginManager to define whether a dereferenced plugin should be completely unloaded (i.e. the shared library is closed) or merely deactivated (i.e. the library remains in the process, but Identifiers and other framework components are removed).
This option is true by default on tardis machines because there it seems impossible to completely unload a shared library due to the use of STB_GNU_UNIQUE which prevents that dlclose() unloads the library. This caused errors when a plugin should have been reloaded, e.g. when the pong level was restarted.
Modified: code/trunk/cmake/LibraryConfigTardis.cmake
===================================================================
--- code/trunk/cmake/LibraryConfigTardis.cmake 2016-01-02 14:36:10 UTC (rev 11015)
+++ code/trunk/cmake/LibraryConfigTardis.cmake 2016-01-02 15:06:30 UTC (rev 11016)
@@ -34,6 +34,8 @@
IF(TARDIS)
MESSAGE(STATUS "Running on D-ITET isg.ee Tardis Computer. Using customized paths.")
+ SET(DO_NOT_UNLOAD_PLUGINS ON)
+
# SET(CMAKE_C_COMPILER "gcc-4.1.1")
# SET(CMAKE_CXX_COMPILER "g++-4.1.1")
Modified: code/trunk/src/SpecialConfig.h.in
===================================================================
--- code/trunk/src/SpecialConfig.h.in 2016-01-02 14:36:10 UTC (rev 11015)
+++ code/trunk/src/SpecialConfig.h.in 2016-01-02 15:06:30 UTC (rev 11016)
@@ -51,6 +51,8 @@
#cmakedefine ORXONOX_USE_WINMAIN ///< Whether or not the console window is started as well
+#cmakedefine DO_NOT_UNLOAD_PLUGINS ///< If defined then plugins are not unloaded (but merely deactivated) when the reference count drops to zero.
+
// Handle default ConfigValues
namespace orxonox { namespace specialConfig
{
Modified: code/trunk/src/libraries/core/module/PluginManager.cc
===================================================================
--- code/trunk/src/libraries/core/module/PluginManager.cc 2016-01-02 14:36:10 UTC (rev 11015)
+++ code/trunk/src/libraries/core/module/PluginManager.cc 2016-01-02 15:06:30 UTC (rev 11016)
@@ -33,10 +33,18 @@
#include "SpecialConfig.h"
#include "Plugin.h"
#include "PluginReference.h"
+#include "core/CoreIncludes.h"
#include "core/ApplicationPaths.h"
#include "core/command/ConsoleCommandIncludes.h"
+#include "core/config/ConfigValueIncludes.h"
#include "core/object/Context.h"
+#ifdef DO_NOT_UNLOAD_PLUGINS
+# define MERELY_DEACTIVATE_PLUGINS true
+#else
+# define MERELY_DEACTIVATE_PLUGINS false
+#endif
+
namespace orxonox
{
static const std::string __CC_PluginManager_load_name = "load";
@@ -47,10 +55,16 @@
PluginManager* PluginManager::singletonPtr_s = 0;
+ RegisterAbstractClass(PluginManager).inheritsFrom<Configurable>();
+
PluginManager::PluginManager()
{
+ RegisterObject(PluginManager);
+
ModifyConsoleCommand("PluginManager", __CC_PluginManager_load_name).setObject(this);
ModifyConsoleCommand("PluginManager", __CC_PluginManager_unload_name).setObject(this);
+
+ this->setConfigValues();
}
PluginManager::~PluginManager()
@@ -64,6 +78,11 @@
delete it->second;
}
+ void PluginManager::setConfigValues()
+ {
+ SetConfigValue(bMerelyDeactivatePlugins_, MERELY_DEACTIVATE_PLUGINS);
+ }
+
void PluginManager::findPlugins()
{
const std::vector<std::string>& pluginPaths = ApplicationPaths::getInstance().getPluginPaths();
@@ -98,7 +117,7 @@
{
Plugin* plugin = this->plugins_[name];
if (plugin != NULL)
- plugin->dereference(false);
+ plugin->dereference(this->bMerelyDeactivatePlugins_);
else
orxout(internal_warning) << "Cannot find plugin with name " << name << endl;
}
Modified: code/trunk/src/libraries/core/module/PluginManager.h
===================================================================
--- code/trunk/src/libraries/core/module/PluginManager.h 2016-01-02 14:36:10 UTC (rev 11015)
+++ code/trunk/src/libraries/core/module/PluginManager.h 2016-01-02 15:06:30 UTC (rev 11016)
@@ -34,10 +34,11 @@
#include <map>
#include <string>
#include "util/Singleton.h"
+#include "core/config/Configurable.h"
namespace orxonox
{
- class _CoreExport PluginManager : public Singleton<PluginManager>
+ class _CoreExport PluginManager : public Singleton<PluginManager>, public Configurable
{
friend class Singleton<PluginManager>;
@@ -45,6 +46,8 @@
PluginManager();
~PluginManager();
+ void setConfigValues();
+
void findPlugins();
void referencePlugin(const std::string& name);
@@ -57,6 +60,7 @@
private:
std::map<std::string, Plugin*> plugins_;
std::map<std::string, PluginReference*> references_; // references that were created by console command
+ bool bMerelyDeactivatePlugins_;
static PluginManager* singletonPtr_s;
};
More information about the Orxonox-commit
mailing list