From 4a495794bfc535b83b5bfb5ed172bd19466251e3 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Tue, 12 Jul 2022 13:39:00 +0200 Subject: [PATCH 1/4] TRestMetadata::InstantiateChildMetadata now passes the config filename to the child --- source/framework/core/src/TRestMetadata.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/source/framework/core/src/TRestMetadata.cxx b/source/framework/core/src/TRestMetadata.cxx index 10dda05c3..108e8aeaa 100644 --- a/source/framework/core/src/TRestMetadata.cxx +++ b/source/framework/core/src/TRestMetadata.cxx @@ -705,6 +705,7 @@ TRestMetadata* TRestMetadata::InstantiateChildMetadata(int index, std::string pa if (c) // this means we have the metadata class was found { TRestMetadata* md = (TRestMetadata*)c->New(); + md->SetConfigFile(fConfigFileName); TiXmlElement* rootEle = GetElementFromFile(fConfigFileName); TiXmlElement* Global = GetElement("globals", rootEle); md->LoadConfigFromElement(paraele, Global, {}); From 5f89a9ff090e78142e1ff90fa9fc280d0bf8ff28 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Tue, 12 Jul 2022 13:46:32 +0200 Subject: [PATCH 2/4] TRestProcessRunner::InstantiateProcess now passes the config filename to the process --- source/framework/core/src/TRestProcessRunner.cxx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/source/framework/core/src/TRestProcessRunner.cxx b/source/framework/core/src/TRestProcessRunner.cxx index 14b55b409..4c7913c7f 100644 --- a/source/framework/core/src/TRestProcessRunner.cxx +++ b/source/framework/core/src/TRestProcessRunner.cxx @@ -37,8 +37,6 @@ #include "unistd.h" #endif // !WIN32 - - std::mutex mutex_write; using namespace std; @@ -689,8 +687,7 @@ void TRestProcessRunner::PauseMenu() { fProcStatus = kNormal; RESTInfo << "Continue processing..." << RESTendl; -#endif // WIN32 - +#endif // WIN32 break; } else if (b == 'n') { @@ -1019,6 +1016,7 @@ TRestEventProcess* TRestProcessRunner::InstantiateProcess(TString type, TiXmlEle TRestEventProcess* pc = REST_Reflection::Assembly((string)type); if (pc == nullptr) return nullptr; + pc->SetConfigFile(fConfigFileName); pc->SetRunInfo(this->fRunInfo); pc->SetHostmgr(fHostmgr); pc->SetObservableValidation(fValidateObservables); From dc8f7fb63b3bce38ab1516be1915e1faee5ee7f8 Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Tue, 12 Jul 2022 13:47:50 +0200 Subject: [PATCH 3/4] TRestRun::InitFromConfigFile. Now it will define the config filename at the child metadata classes --- source/framework/core/src/TRestRun.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/source/framework/core/src/TRestRun.cxx b/source/framework/core/src/TRestRun.cxx index ef155f4bd..07937dd19 100644 --- a/source/framework/core/src/TRestRun.cxx +++ b/source/framework/core/src/TRestRun.cxx @@ -328,6 +328,7 @@ void TRestRun::InitFromConfigFile() { //} TRestMetadata* meta = REST_Reflection::Assembly(keydeclare); + meta->SetConfigFile(fConfigFileName); if (meta == nullptr) { RESTWarning << "failed to add metadata \"" << keydeclare << "\"" << RESTendl; e = e->NextSiblingElement(); From 17cbae6e467d90596cea173ec55ef7be9af50fcb Mon Sep 17 00:00:00 2001 From: Javier Galan Date: Tue, 12 Jul 2022 17:04:24 +0200 Subject: [PATCH 4/4] TRestRun::InitFromConfigFile and TRestProcessRunner. Fixing potential seg.fault scenario --- source/framework/core/src/TRestMetadata.cxx | 3 ++- source/framework/core/src/TRestRun.cxx | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source/framework/core/src/TRestMetadata.cxx b/source/framework/core/src/TRestMetadata.cxx index 108e8aeaa..01e4aec78 100644 --- a/source/framework/core/src/TRestMetadata.cxx +++ b/source/framework/core/src/TRestMetadata.cxx @@ -702,9 +702,10 @@ TRestMetadata* TRestMetadata::InstantiateChildMetadata(int index, std::string pa if (pattern == "" || xmlChild.find(pattern) != string::npos) { if (count == index) { TClass* c = TClass::GetClass(xmlChild.c_str()); - if (c) // this means we have the metadata class was found + if (c) // this means that the metadata class was found { TRestMetadata* md = (TRestMetadata*)c->New(); + if (!md) return nullptr; md->SetConfigFile(fConfigFileName); TiXmlElement* rootEle = GetElementFromFile(fConfigFileName); TiXmlElement* Global = GetElement("globals", rootEle); diff --git a/source/framework/core/src/TRestRun.cxx b/source/framework/core/src/TRestRun.cxx index 8d110bc97..4a19258e7 100644 --- a/source/framework/core/src/TRestRun.cxx +++ b/source/framework/core/src/TRestRun.cxx @@ -317,12 +317,12 @@ void TRestRun::InitFromConfigFile() { //} TRestMetadata* meta = REST_Reflection::Assembly(keydeclare); - meta->SetConfigFile(fConfigFileName); if (meta == nullptr) { RESTWarning << "failed to add metadata \"" << keydeclare << "\"" << RESTendl; e = e->NextSiblingElement(); continue; } + meta->SetConfigFile(fConfigFileName); meta->SetHostmgr(fHostmgr); fMetadata.push_back(meta); meta->LoadConfigFromElement(e, fElementGlobal);