diff --git a/DDG4/src/Geant4Handle.cpp b/DDG4/src/Geant4Handle.cpp index 63aea536633b4443593678cb890e81002bdb55f7..4e8cf1c54d24dc206bc4eca5b53fa9fc98d5b272 100644 --- a/DDG4/src/Geant4Handle.cpp +++ b/DDG4/src/Geant4Handle.cpp @@ -116,11 +116,14 @@ namespace dd4hep { _ST* object = (_ST*)_create_object<TYPE>(kernel,s_type); CONT& container = (k.*pmf)(); TYPE* value = 0; - // Need to protect the global action sequence! - G4AutoLock protection_lock(&creation_mutex); { + { // Need to protect the global action sequence! + G4AutoLock protection_lock(&creation_mutex); value = container.get(typ.second); - if ( !value ) value = _create_object<TYPE>(k,typ); - container.adopt(value); + if ( !value ) { + value = _create_object<TYPE>(k,typ); + container.adopt(value); + value->release(); + } } object->use(value); value->info("+++ Created shared object for %s of type %s.",