From a0a64c1fb8969996b85cfad2329eb7dde131a68e Mon Sep 17 00:00:00 2001 From: Benjamin Nauck Date: Mon, 24 Feb 2025 09:31:22 +0100 Subject: [PATCH] Base: Make Type::importModule private --- src/App/PropertyStandard.cpp | 13 +++---------- src/Base/Type.h | 2 +- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/App/PropertyStandard.cpp b/src/App/PropertyStandard.cpp index 238df5d8b5..e8471d6d53 100644 --- a/src/App/PropertyStandard.cpp +++ b/src/App/PropertyStandard.cpp @@ -3527,17 +3527,10 @@ unsigned int PropertyPersistentObject::getMemSize() const void PropertyPersistentObject::setValue(const char* type) { - if (!type) { - type = ""; - } - if (type[0]) { - Base::Type::importModule(type); - Base::Type t = Base::Type::fromName(type); + if (!Base::Tools::isNullOrEmpty(type)) { + Base::Type t = Base::Type::getTypeIfDerivedFrom(type, Persistence::getClassTypeId()); if (t.isBad()) { - throw Base::TypeError("Invalid type"); - } - if (!t.isDerivedFrom(Persistence::getClassTypeId())) { - throw Base::TypeError("Type must be derived from Base::Persistence"); + throw Base::TypeError("Invalid type or type must be derived from Base::Persistence"); } if (_pObject && _pObject->getTypeId() == t) { return; diff --git a/src/Base/Type.h b/src/Base/Type.h index 49bedcaa01..adba866cef 100644 --- a/src/Base/Type.h +++ b/src/Base/Type.h @@ -94,7 +94,6 @@ public: [[nodiscard]] bool canInstantiate() const; /// Creates an instance of the named type [[nodiscard]] static void* createInstanceByName(const char* typeName, bool loadModule = false); - static void importModule(const char* TypeName); using instantiationMethod = void* (*)(); @@ -142,6 +141,7 @@ public: private: [[nodiscard]] instantiationMethod getInstantiationMethod() const; + static void importModule(const char* TypeName); TypeId index {BadTypeIndex};