From eaba55ade7d647125070a191d68b6cacfd1d46f0 Mon Sep 17 00:00:00 2001
From: Johannes Josef Junggeburth <johannes.josef.junggeburth@cern.ch>
Date: Tue, 23 Jan 2024 23:39:04 +0100
Subject: [PATCH] Another collapse fix

---
 GeoModelCore/GeoModelKernel/src/GeoShapeShift.cxx | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/GeoModelCore/GeoModelKernel/src/GeoShapeShift.cxx b/GeoModelCore/GeoModelKernel/src/GeoShapeShift.cxx
index 8977f9f5a..037fa96fe 100755
--- a/GeoModelCore/GeoModelKernel/src/GeoShapeShift.cxx
+++ b/GeoModelCore/GeoModelKernel/src/GeoShapeShift.cxx
@@ -14,9 +14,10 @@ GeoShapeShift::GeoShapeShift (const GeoShape* A, const GeoTrf::Transform3D &X):
   m_op{A}, m_shift{X} {
     /// Check whether the given shape also a shape shift. If so then we can simply
     /// take the operand of the sub shift and summarize the transformations of the two into one
-   if (A->refCount() > 1 && getOp()->typeID() == typeID()) {
-       const GeoShapeShift* subShift{static_cast<const GeoShapeShift*>(getOp())};
-       m_shift = subShift->getX() * getX();
+   if (A->refCount() > 1 && A->typeID() == typeID()) {
+       const GeoShapeShift* subShift{dynamic_cast<const GeoShapeShift*>(A)};
+       GeoTrf::Transform3D updatedShift = m_shift * subShift->getX();
+       m_shift = std::move(updatedShift);
        m_op.reset(subShift->getOp());
     }
 }
-- 
GitLab