From 0f88c5ffe6ffa4f8a34f2557d67f7232b6f018f8 Mon Sep 17 00:00:00 2001
From: Martin Hierholzer <martin.hierholzer@desy.de>
Date: Wed, 19 May 2021 11:21:11 +0200
Subject: [PATCH] TestFacility: throw exception if attempting to set default
 value after start of application

---
 include/TestFacility.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/TestFacility.h b/include/TestFacility.h
index b8c0f033..cf409066 100644
--- a/include/TestFacility.h
+++ b/include/TestFacility.h
@@ -229,6 +229,9 @@ namespace ChimeraTK {
     /** Set default value for scalar process variable. */
     template<typename T>
     void setScalarDefault(const ChimeraTK::RegisterPath& name, const T& value) {
+      if(Application::getInstance().testFacilityRunApplicationCalled) {
+        throw ChimeraTK::logic_error("TestFacility::setScalarDefault() called after runApplication().");
+      }
       std::vector<T> vv;
       vv.push_back(value);
       setArrayDefault(name, vv);
@@ -237,6 +240,9 @@ namespace ChimeraTK {
     /** Set default value for array process variable. */
     template<typename T>
     void setArrayDefault(const ChimeraTK::RegisterPath& name, const std::vector<T>& value) {
+      if(Application::getInstance().testFacilityRunApplicationCalled) {
+        throw ChimeraTK::logic_error("TestFacility::setArrayDefault() called after runApplication().");
+      }
       // check if PV exists
       auto pv = pvManager->getProcessArray<T>(name);
       if(pv == nullptr) {
-- 
GitLab