From ee1b001c12f71db1c9161bc81dbec633405c5b64 Mon Sep 17 00:00:00 2001
From: Mikhail Svechnikov <m.svechnikov@fz-juelich.de>
Date: Mon, 5 Dec 2022 16:31:44 +0100
Subject: [PATCH] SelectionProperty: vector of used catalog types is stored in
 property

---
 GUI/Model/Descriptor/SelectionProperty.h | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/GUI/Model/Descriptor/SelectionProperty.h b/GUI/Model/Descriptor/SelectionProperty.h
index 7871e93bd5e..9713f839863 100644
--- a/GUI/Model/Descriptor/SelectionProperty.h
+++ b/GUI/Model/Descriptor/SelectionProperty.h
@@ -65,7 +65,7 @@ public:
               ArgsForCreation... argsForCreation)
     {
         m_persistentTag = persistentTag;
-        initDescriptor(label, tooltip, Catalog::types(), argsForCreation...);
+        initDescriptor(label, tooltip, argsForCreation...);
         m_descriptor.setCurrentIndex(0);
     }
 
@@ -87,7 +87,7 @@ public:
         m_initializer = initializer;
         m_persistentTag = persistentTag;
 
-        initDescriptor(label, tooltip, Catalog::types());
+        initDescriptor(label, tooltip);
         m_descriptor.setCurrentIndex(0);
     }
 
@@ -111,8 +111,9 @@ public:
     {
         m_initializer = initializer;
         m_persistentTag = persistentTag;
+        m_types = types;
 
-        initDescriptor(label, tooltip, types);
+        initDescriptor(label, tooltip);
         m_descriptor.setCurrentIndex(0);
     }
 
@@ -163,12 +164,11 @@ public:
 private:
     template <typename... ArgsForCreation>
     void initDescriptor(const QString& label, const QString& tooltip,
-                        const QVector<typename Catalog::Type>& types,
                         ArgsForCreation... argsForCreation)
 
     {
         auto setCurrentIndex = [=](int current) {
-            auto* p = Catalog::create(types[current], argsForCreation...);
+            auto* p = Catalog::create(m_types[current], argsForCreation...);
             if (m_initializer)
                 m_initializer(p, m_p);
             m_p = p;
@@ -176,10 +176,10 @@ private:
 
         m_descriptor.label = label;
         m_descriptor.tooltip = tooltip;
-        for (const auto type : types)
+        for (const auto type : m_types)
             m_descriptor.options << Catalog::uiInfo(type).menuEntry;
         m_descriptor.currentIndexSetter = setCurrentIndex;
-        m_descriptor.currentIndexGetter = [=]() { return types.indexOf(Catalog::type(m_p)); };
+        m_descriptor.currentIndexGetter = [=]() { return m_types.indexOf(Catalog::type(m_p)); };
         m_descriptor.currentItem = [=] { return m_p; };
     }
 
@@ -188,6 +188,8 @@ private:
     SelectionDescriptor<CatalogedType*> m_descriptor; //!< descriptor, holding attributes like label, tooltip
     CatalogedType* m_p = nullptr;                     //!< Current selection
 
+    QVector<typename Catalog::Type> m_types = Catalog::types();
+
     //! initializer function. Can be empty.
     //! The first argument is the new item, the second is the old one if present; can be null.
     //! This is intended to maybe copy values from the old to the new selection. oldItem also can be
-- 
GitLab