Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- commit 0752531063ebf9be1ef5182e18fd8bab014dd4c0
- Author: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
- Date: Mon Feb 21 17:04:33 2011 -0300
- QScriptQObject: read-only properties
- Don't add setter accessor and set v8::ReadOnly for properties that
- are not writable.
- diff --git a/src/script/api/qscriptqobject.cpp b/src/script/api/qscriptqobject.cpp
- index acc7845..1f27952 100644
- --- a/src/script/api/qscriptqobject.cpp
- +++ b/src/script/api/qscriptqobject.cpp
- @@ -864,7 +864,7 @@ static void QtMetaPropertySetter(v8::Local<v8::String> /*property*/,
- int propertyIndex = v8::Int32::Cast(*info.Data())->Value();
- QMetaProperty prop = meta->property(propertyIndex);
- - Q_ASSERT(prop.isScriptable());
- + Q_ASSERT(prop.isScriptable() && prop.isWritable());
- QVariant cppValue;
- #if 0
- @@ -1316,9 +1316,15 @@ v8::Handle<v8::FunctionTemplate> createQtClassTemplate(QScriptEnginePrivate *eng
- getter = QtMetaPropertyGetter;
- setter = QtMetaPropertySetter;
- }
- +
- + v8::PropertyAttribute attribute = v8::DontDelete;
- + if (!prop.isWritable()) {
- + setter = 0;
- + attribute = v8::PropertyAttribute(v8::DontDelete | v8::ReadOnly);
- + }
- instTempl->SetAccessor(v8::String::New(prop.name()),
- getter, setter, v8::Int32::New(i),
- - v8::DEFAULT, v8::DontDelete);
- + v8::DEFAULT, attribute);
- }
- // Figure out method names (own and inherited).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement