From b26caf222a3129963f4149e165253a046eaa199a Mon Sep 17 00:00:00 2001
From: Frank Winklmeier <frank.winklmeier@cern.ch>
Date: Sun, 20 Oct 2024 14:08:57 +0200
Subject: [PATCH] IdDictDetDescrCnv: service pointer migration (ATEAM-1020)

---
 .../IdDictDetDescrCnv/src/IdDictDetDescrCnv.cxx           | 8 +++++---
 .../IdDictDetDescrCnv/src/IdDictDetDescrCnv.h             | 2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/DetectorDescription/IdDictDetDescrCnv/src/IdDictDetDescrCnv.cxx b/DetectorDescription/IdDictDetDescrCnv/src/IdDictDetDescrCnv.cxx
index 9e69018b2535..b10eba04a886 100755
--- a/DetectorDescription/IdDictDetDescrCnv/src/IdDictDetDescrCnv.cxx
+++ b/DetectorDescription/IdDictDetDescrCnv/src/IdDictDetDescrCnv.cxx
@@ -39,6 +39,10 @@ StatusCode IdDictDetDescrCnv::initialize() {
     ATH_MSG_INFO("in initialize");
     // Must set indet tag to EMPTY
     m_inDetIDTag = "EMPTY";
+
+    m_detDescrProxy = serviceLocator()->service("DetDescrCnvSvc");
+    ATH_CHECK(m_detDescrProxy.isValid());
+
     return StatusCode::SUCCESS;
 }
 StatusCode IdDictDetDescrCnv::finalize() {
@@ -634,9 +638,7 @@ StatusCode IdDictDetDescrCnv::registerInfoWithDicts() {
 template <class dType>
 StatusCode IdDictDetDescrCnv::loadProperty(const std::string &propertyName,
                                            dType &pipeTo) {
-    if (!m_detDescrProxy)
-        ATH_CHECK(serviceLocator()->service("DetDescrCnvSvc", m_detDescrProxy));
-    // cppcheck-suppress nullPointerRedundantCheck; false positive
+
     if (!m_detDescrProxy->hasProperty(propertyName)) {
         ATH_MSG_FATAL("DetDescrSvc does not have the property "
                       << propertyName);
diff --git a/DetectorDescription/IdDictDetDescrCnv/src/IdDictDetDescrCnv.h b/DetectorDescription/IdDictDetDescrCnv/src/IdDictDetDescrCnv.h
index ed535f10dfef..c95bf69d56a2 100755
--- a/DetectorDescription/IdDictDetDescrCnv/src/IdDictDetDescrCnv.h
+++ b/DetectorDescription/IdDictDetDescrCnv/src/IdDictDetDescrCnv.h
@@ -59,7 +59,7 @@ class IdDictDetDescrCnv : public DetDescrConverter {
     ServiceHandle<IRDBAccessSvc> m_rdbAccessSvc{"RDBAccessSvc/RDBAccessSvc", "IdDictDetDescrCnv"};
 
     /// Propxy to the DetDescrCnvSvc
-    const IProperty *m_detDescrProxy{nullptr};
+    SmartIF<IProperty> m_detDescrProxy;
 
     /// Loads the property from the DetDecrCnvSvc and pipes its value
     /// Returns failure if either the service, the property don't exist or
-- 
GitLab