Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11016 for code/trunk/src


Ignore:
Timestamp:
Jan 2, 2016, 4:06:30 PM (9 years ago)
Author:
landauf
Message:

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.

Location:
code/trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/SpecialConfig.h.in

    r10624 r11016  
    5151
    5252#cmakedefine ORXONOX_USE_WINMAIN            ///< Whether or not the console window is started as well
     53
     54#cmakedefine DO_NOT_UNLOAD_PLUGINS          ///< If defined then plugins are not unloaded (but merely deactivated) when the reference count drops to zero.
    5355
    5456// Handle default ConfigValues
  • code/trunk/src/libraries/core/module/PluginManager.cc

    r11015 r11016  
    3434#include "Plugin.h"
    3535#include "PluginReference.h"
     36#include "core/CoreIncludes.h"
    3637#include "core/ApplicationPaths.h"
    3738#include "core/command/ConsoleCommandIncludes.h"
     39#include "core/config/ConfigValueIncludes.h"
    3840#include "core/object/Context.h"
     41
     42#ifdef DO_NOT_UNLOAD_PLUGINS
     43#  define MERELY_DEACTIVATE_PLUGINS true
     44#else
     45#  define MERELY_DEACTIVATE_PLUGINS false
     46#endif
    3947
    4048namespace orxonox
     
    4856    PluginManager* PluginManager::singletonPtr_s  = 0;
    4957
     58    RegisterAbstractClass(PluginManager).inheritsFrom<Configurable>();
     59
    5060    PluginManager::PluginManager()
    5161    {
     62        RegisterObject(PluginManager);
     63
    5264        ModifyConsoleCommand("PluginManager", __CC_PluginManager_load_name).setObject(this);
    5365        ModifyConsoleCommand("PluginManager", __CC_PluginManager_unload_name).setObject(this);
     66
     67        this->setConfigValues();
    5468    }
    5569
     
    6377        for (std::map<std::string, Plugin*>::iterator it = this->plugins_.begin(); it != this->plugins_.end(); ++it)
    6478            delete it->second;
     79    }
     80
     81    void PluginManager::setConfigValues()
     82    {
     83        SetConfigValue(bMerelyDeactivatePlugins_, MERELY_DEACTIVATE_PLUGINS);
    6584    }
    6685
     
    99118        Plugin* plugin = this->plugins_[name];
    100119        if (plugin != NULL)
    101             plugin->dereference(false);
     120            plugin->dereference(this->bMerelyDeactivatePlugins_);
    102121        else
    103122            orxout(internal_warning) << "Cannot find plugin with name " << name << endl;
  • code/trunk/src/libraries/core/module/PluginManager.h

    r10580 r11016  
    3535#include <string>
    3636#include "util/Singleton.h"
     37#include "core/config/Configurable.h"
    3738
    3839namespace orxonox
    3940{
    40     class _CoreExport PluginManager : public Singleton<PluginManager>
     41    class _CoreExport PluginManager : public Singleton<PluginManager>, public Configurable
    4142    {
    4243        friend class Singleton<PluginManager>;
     
    4546            PluginManager();
    4647            ~PluginManager();
     48
     49            void setConfigValues();
    4750
    4851            void findPlugins();
     
    5861            std::map<std::string, Plugin*> plugins_;
    5962            std::map<std::string, PluginReference*> references_; // references that were created by console command
     63            bool bMerelyDeactivatePlugins_;
    6064
    6165            static PluginManager* singletonPtr_s;
Note: See TracChangeset for help on using the changeset viewer.