From c194ac96dec4b4703db5b6016c5941f93a03b20f Mon Sep 17 00:00:00 2001
From: Martin Hierholzer <martin.hierholzer@desy.de>
Date: Fri, 4 Jan 2019 11:17:54 +0100
Subject: [PATCH] fixed bug introduced in
 936d7c0d8502742336b590412c9fc5539df1153f

---
 src/VirtualModule.cc                          | 4 +---
 tests/executables_src/testDirectDeviceToCS.cc | 6 ++++++
 tests/test3.map                               | 2 ++
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/VirtualModule.cc b/src/VirtualModule.cc
index f6314663..abf10f30 100644
--- a/src/VirtualModule.cc
+++ b/src/VirtualModule.cc
@@ -127,9 +127,7 @@ namespace ChimeraTK {
     else {
       auto firstSubmodule = moduleName.substr(0,slash);
       auto remainingSubmodules = moduleName.substr(slash+1);
-      auto &sm = createAndGetSubmodule(firstSubmodule);
-      sm.createAndGetSubmoduleRecursive(remainingSubmodules);
-      return sm;
+      return createAndGetSubmodule(firstSubmodule).createAndGetSubmoduleRecursive(remainingSubmodules);
     }
   }
 
diff --git a/tests/executables_src/testDirectDeviceToCS.cc b/tests/executables_src/testDirectDeviceToCS.cc
index 0bb99845..879683c2 100644
--- a/tests/executables_src/testDirectDeviceToCS.cc
+++ b/tests/executables_src/testDirectDeviceToCS.cc
@@ -209,6 +209,8 @@ BOOST_AUTO_TEST_CASE( testConnectTo ) {
   auto devint8 = dev.getScalarRegisterAccessor<int8_t>("/Integers/signed8");
   auto devuint8 = dev.getScalarRegisterAccessor<uint8_t>("/Integers/unsigned8");
   auto devfloat = dev.getScalarRegisterAccessor<double>("/FixedPoint/value");
+  auto devDeep1 = dev.getScalarRegisterAccessor<int32_t>("/Deep/Hierarchies/Need/Tests/As/well");
+  auto devDeep2 = dev.getScalarRegisterAccessor<int32_t>("/Deep/Hierarchies/Need/Another/test");
   auto csActuator = test.getScalar<int32_t>("/MyModule/actuator");
   auto csReadback = test.getScalar<int32_t>("/MyModule/readBack");
   auto csint32 = test.getScalar<int32_t>("/Integers/signed32");
@@ -218,6 +220,8 @@ BOOST_AUTO_TEST_CASE( testConnectTo ) {
   auto csint8 = test.getScalar<int8_t>("/Integers/signed8");
   auto csuint8 = test.getScalar<uint8_t>("/Integers/unsigned8");
   auto csfloat = test.getScalar<double>("/FixedPoint/value");
+  auto csDeep1 = test.getScalar<int32_t>("/Deep/Hierarchies/Need/Tests/As/well");
+  auto csDeep2 = test.getScalar<int32_t>("/Deep/Hierarchies/Need/Another/test");
   test.runApplication();
 
   testDirectRegister(test, csActuator, devActuator, []{});
@@ -229,5 +233,7 @@ BOOST_AUTO_TEST_CASE( testConnectTo ) {
   testDirectRegister(test, csint8, devint8, []{});
   testDirectRegister(test, csuint8, devuint8, []{});
   testDirectRegister(test, csfloat, devfloat, []{}, false);
+  testDirectRegister(test, csDeep1, devDeep1, []{});
+  testDirectRegister(test, csDeep2, devDeep2, []{});
 
 }
diff --git a/tests/test3.map b/tests/test3.map
index d90f9ce5..ba760d59 100644
--- a/tests/test3.map
+++ b/tests/test3.map
@@ -8,3 +8,5 @@
 /Integers/signed8                 1 24 4 1  8 0 1 RW
 /Integers/unsigned8               1 28 4 1  8 0 0 RW
 /FixedPoint/value                 1 32 4 1 32 8 1 RW
+/Deep/Hierarchies/Need/Tests/As/well  1 36 4 1 32 0 1 RW
+/Deep/Hierarchies/Need/Another/test   1 40 4 1 32 0 1 RW
-- 
GitLab