diff --git a/DDCore/src/DetectorImp.cpp b/DDCore/src/DetectorImp.cpp index 6d0edb1220e14a8af29bb1c54748e48b96db65eb..28d350e30ff0f1faf939a8f76363f8b71d8e37e6 100644 --- a/DDCore/src/DetectorImp.cpp +++ b/DDCore/src/DetectorImp.cpp @@ -135,24 +135,6 @@ namespace { static Instances s_inst; return s_inst; } - - void description_unexpected() { - try { - throw; - } catch( exception& e ) { - cout << "\n" - << "**************************************************** \n" - << "* A runtime error has occured : \n" - << "* " << e.what() << endl - << "* the program will have to be terminated - sorry. \n" - << "**************************************************** \n" - << endl ; - - set_terminate(std::terminate); - // this provokes ROOT seg fault and stack trace (comment out to avoid it) - exit(1) ; - } - } } string dd4hep::versionString(){ @@ -226,11 +208,6 @@ DetectorImp::DetectorImp(const string& name) } #endif - if ( first ) { - first = false; - set_terminate( description_unexpected ); - } - SetName(name.c_str()); SetTitle("DD4hep detector description object"); //DetectorGuard(this).lock(gGeoManager); diff --git a/DDG4/src/Geant4Kernel.cpp b/DDG4/src/Geant4Kernel.cpp index a94f8db228f5d77de96bfdcd11e1ce1780b8e072..b85a3fbfb7c197d8ad237cab69886a5e2743e267 100644 --- a/DDG4/src/Geant4Kernel.cpp +++ b/DDG4/src/Geant4Kernel.cpp @@ -41,6 +41,21 @@ using namespace dd4hep::sim; namespace { G4Mutex kernel_mutex=G4MUTEX_INITIALIZER; dd4hep::dd4hep_ptr<Geant4Kernel> s_main_instance(0); + void description_unexpected() { + try { + throw; + } catch( exception& e ) { + cout << "\n" + << "**************************************************** \n" + << "* A runtime error has occured : \n" + << "* " << e.what() << endl + << "* the program will have to be terminated - sorry. \n" + << "**************************************************** \n" + << endl ; + // this provokes ROOT seg fault and stack trace (comment out to avoid it) + exit(1) ; + } + } } /// Standard constructor @@ -147,6 +162,8 @@ Geant4Kernel& Geant4Kernel::instance(Detector& description) { if ( 0 == s_main_instance.get() ) { G4AutoLock protection_lock(&kernel_mutex); { if ( 0 == s_main_instance.get() ) { // Need to check again! + /// Install here the termination handler + std::set_terminate(description_unexpected); s_main_instance.adopt(new Geant4Kernel(description)); } }