From 8a74887223f8972aa073f2df039eb3b04ee619d4 Mon Sep 17 00:00:00 2001 From: Nathan Brei Date: Wed, 8 May 2024 01:02:50 -0400 Subject: [PATCH] JEventPool is now responsible for setting JEvent app ptr Previously, it was the JEventSource, which doesn't work in the case of TimesliceExample, because PhysicsEvents come straight from the pool. --- src/libraries/JANA/JEventSource.h | 1 - src/libraries/JANA/JFactory.cc | 3 ++- src/libraries/JANA/Omni/JComponentFwd.h | 7 ++++++- src/libraries/JANA/Services/JComponentManager.cc | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/libraries/JANA/JEventSource.h b/src/libraries/JANA/JEventSource.h index 45d1113ed..c2c740c70 100644 --- a/src/libraries/JANA/JEventSource.h +++ b/src/libraries/JANA/JEventSource.h @@ -192,7 +192,6 @@ class JEventSource : public jana::omni::JComponent, public jana::omni::JHasOutpu // We configure the event event->SetEventNumber(m_event_count); // Default event number to event count - event->SetJApplication(m_app); event->SetJEventSource(this); event->SetSequential(false); event->GetJCallGraphRecorder()->Reset(); diff --git a/src/libraries/JANA/JFactory.cc b/src/libraries/JANA/JFactory.cc index 48a450f53..baa3f6865 100644 --- a/src/libraries/JANA/JFactory.cc +++ b/src/libraries/JANA/JFactory.cc @@ -10,7 +10,8 @@ void JFactory::Create(const std::shared_ptr& event) { // We need this for JMultifactoryHelper. Eventually it should go away - SetApplication(event->GetJApplication()); + auto app = event->GetJApplication(); + if (app != nullptr) SetApplication(app); if (mStatus == Status::Uninitialized) { CallWithJExceptionWrapper("JFactory::Init", [&](){ Init(); }); diff --git a/src/libraries/JANA/Omni/JComponentFwd.h b/src/libraries/JANA/Omni/JComponentFwd.h index 0d1975916..f73bfe8f9 100644 --- a/src/libraries/JANA/Omni/JComponentFwd.h +++ b/src/libraries/JANA/Omni/JComponentFwd.h @@ -85,7 +85,12 @@ struct JComponent { return m_status; } - void SetApplication(JApplication* app) { m_app = app; } + void SetApplication(JApplication* app) { + if (app == nullptr) { + throw JException("Attempting to set a null JApplication pointer!"); + } + m_app = app; + } void SetLogger(JLogger logger) { m_logger = logger; } diff --git a/src/libraries/JANA/Services/JComponentManager.cc b/src/libraries/JANA/Services/JComponentManager.cc index b4c724b7c..5642e8415 100644 --- a/src/libraries/JANA/Services/JComponentManager.cc +++ b/src/libraries/JANA/Services/JComponentManager.cc @@ -108,6 +108,7 @@ void JComponentManager::configure_event(JEvent& event) { event.SetFactorySet(factory_set); event.SetDefaultTags(m_default_tags); event.GetJCallGraphRecorder()->SetEnabled(m_enable_call_graph_recording); + event.SetJApplication(GetApplication()); }