diff --git a/DDCore/src/DetectorImp.cpp b/DDCore/src/DetectorImp.cpp index a27da8b3b913033c3c31705130a67eebee1df3e3..d32ca45e9e3c2959503bc7f22370961457721035 100644 --- a/DDCore/src/DetectorImp.cpp +++ b/DDCore/src/DetectorImp.cpp @@ -96,7 +96,11 @@ namespace { } return 0; } - } s_instances; + }; + static Instances& detector_instances() { + static Instances s_inst; + return s_inst; + } void description_unexpected() { try { @@ -129,20 +133,20 @@ unique_ptr<Detector> Detector::make_unique(const std::string& name) { } Detector& Detector::getInstance(const std::string& name) { - lock_guard<recursive_mutex> lock(s_instances.lock); - Detector* description = s_instances.get(name); + lock_guard<recursive_mutex> lock(detector_instances().lock); + Detector* description = detector_instances().get(name); if ( 0 == description ) { gGeoManager = 0; description = new DetectorImp(name); - s_instances.insert(name,description); + detector_instances().insert(name,description); } return *description; } /// Destroy the instance void Detector::destroyInstance(const std::string& name) { - lock_guard<recursive_mutex> lock(s_instances.lock); - Detector* description = s_instances.remove(name); + lock_guard<recursive_mutex> lock(detector_instances().lock); + Detector* description = detector_instances().remove(name); if (description) delete description; } @@ -196,11 +200,11 @@ DetectorImp::DetectorImp(const string& name) /// Standard destructor DetectorImp::~DetectorImp() { if ( m_manager ) { - lock_guard<recursive_mutex> lock(s_instances.lock); + lock_guard<recursive_mutex> lock(detector_instances().lock); if ( m_manager == gGeoManager ) gGeoManager = 0; - Detector* description = s_instances.get(m_manager->GetName()); + Detector* description = detector_instances().get(m_manager->GetName()); if ( 0 != description ) { - s_instances.remove(m_manager->GetName()); + detector_instances().remove(m_manager->GetName()); } } deletePtr(m_surfaceManager); diff --git a/DDCore/src/Plugins.cpp b/DDCore/src/Plugins.cpp index 76852ea18c69d794dc2b4c92158dd3679c4e81c7..89141d4867f72709c6b9133a83afd9d6414fd8ed 100644 --- a/DDCore/src/Plugins.cpp +++ b/DDCore/src/Plugins.cpp @@ -118,12 +118,11 @@ namespace { if ( 0 == plugin_name ) { plugin_name = "libDD4hepGaudiPluginMgr"; } -#if !defined(DD4HEP_PARSERS_NO_ROOT) - if ( 0 != gSystem->Load(plugin_name) ) { - printout(DEBUG,"Plugins","Failed to load plugin manager library: %s",plugin_name); + else +#if defined(DD4HEP_PARSERS_NO_ROOT) + { + handle = ::dlopen(plugin_name, RTLD_LAZY | RTLD_GLOBAL); } -#else - handle = ::dlopen(plugin_name, RTLD_LAZY | RTLD_GLOBAL); #endif getDebug = get_func< int (*) ()>(handle, plugin_name,"dd4hep_pluginmgr_getdebug"); setDebug = get_func< int (*) (int)>(handle, plugin_name,"dd4hep_pluginmgr_getdebug"); diff --git a/UtilityApps/src/run_plugin.h b/UtilityApps/src/run_plugin.h index f0d534c4e1c50979b5262a270a6ceda3587b936f..b88dbe761694ad9742cee7a931680da374cab006 100644 --- a/UtilityApps/src/run_plugin.h +++ b/UtilityApps/src/run_plugin.h @@ -276,7 +276,7 @@ namespace dd4hep { else { std::cout << "The geometry was loaded. Application now exiting." << std::endl; } - if ( args.destroy ) delete &description; + if ( args.destroy ) description.destroyInstance(); return 0; } @@ -381,7 +381,7 @@ namespace dd4hep { if ( !arguments.dry_run && interpreter.get() ) { interpreter->Run(); } - if ( arguments.destroy ) delete &description; + if ( arguments.destroy ) description.destroyInstance(); return 0; }