diff --git a/lib/base/dynamicobject.cpp b/lib/base/dynamicobject.cpp index 0551eb85b..8be09c20b 100644 --- a/lib/base/dynamicobject.cpp +++ b/lib/base/dynamicobject.cpp @@ -126,7 +126,7 @@ void DynamicObject::InternalApplyUpdate(const Dictionary::Ptr& serializedUpdate, if (!HasAttribute(it->first)) RegisterAttribute(it->first, static_cast(type)); - InternalSetAttribute(it->first, data, tx, suppressEvents); + InternalSetAttribute(it->first, data, tx, suppressEvents, true); } } @@ -160,7 +160,7 @@ Value DynamicObject::Get(const String& name) const } void DynamicObject::InternalSetAttribute(const String& name, const Value& data, - double tx, bool suppressEvent) + double tx, bool suppressEvent, bool allowEditConfig) { DynamicAttribute attr; attr.Type = Attribute_Transient; @@ -172,6 +172,9 @@ void DynamicObject::InternalSetAttribute(const String& name, const Value& data, Value oldValue; + if (!allowEditConfig && (tt.first->second.Type & Attribute_Config)) + throw_exception(runtime_error("Config properties are immutable: '" + name + "'.")); + if (!tt.second && tx >= tt.first->second.Tx) { oldValue = tt.first->second.Data; tt.first->second.Data = data; diff --git a/lib/base/dynamicobject.h b/lib/base/dynamicobject.h index f809f846d..c06973e2b 100644 --- a/lib/base/dynamicobject.h +++ b/lib/base/dynamicobject.h @@ -145,7 +145,7 @@ protected: virtual void OnAttributeChanged(const String& name, const Value& oldValue); private: - void InternalSetAttribute(const String& name, const Value& data, double tx, bool suppressEvent = false); + void InternalSetAttribute(const String& name, const Value& data, double tx, bool suppressEvent = false, bool allowEditConfig = false); Value InternalGetAttribute(const String& name) const; AttributeMap m_Attributes;