Disallow DynamicObject::Set() for config variables.

Fixes #3573
This commit is contained in:
Gunnar Beutner 2013-01-25 10:12:55 +01:00
parent 0449c66afc
commit 9413466cef
2 changed files with 6 additions and 3 deletions

View File

@ -126,7 +126,7 @@ void DynamicObject::InternalApplyUpdate(const Dictionary::Ptr& serializedUpdate,
if (!HasAttribute(it->first))
RegisterAttribute(it->first, static_cast<DynamicAttributeType>(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;

View File

@ -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;