Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. commit 0752531063ebf9be1ef5182e18fd8bab014dd4c0
  2. Author: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
  3. Date: Mon Feb 21 17:04:33 2011 -0300
  4.  
  5. QScriptQObject: read-only properties
  6.  
  7. Don't add setter accessor and set v8::ReadOnly for properties that
  8. are not writable.
  9.  
  10. diff --git a/src/script/api/qscriptqobject.cpp b/src/script/api/qscriptqobject.cpp
  11. index acc7845..1f27952 100644
  12. --- a/src/script/api/qscriptqobject.cpp
  13. +++ b/src/script/api/qscriptqobject.cpp
  14. @@ -864,7 +864,7 @@ static void QtMetaPropertySetter(v8::Local<v8::String> /*property*/,
  15. int propertyIndex = v8::Int32::Cast(*info.Data())->Value();
  16.  
  17. QMetaProperty prop = meta->property(propertyIndex);
  18. - Q_ASSERT(prop.isScriptable());
  19. + Q_ASSERT(prop.isScriptable() && prop.isWritable());
  20.  
  21. QVariant cppValue;
  22. #if 0
  23. @@ -1316,9 +1316,15 @@ v8::Handle<v8::FunctionTemplate> createQtClassTemplate(QScriptEnginePrivate *eng
  24. getter = QtMetaPropertyGetter;
  25. setter = QtMetaPropertySetter;
  26. }
  27. +
  28. + v8::PropertyAttribute attribute = v8::DontDelete;
  29. + if (!prop.isWritable()) {
  30. + setter = 0;
  31. + attribute = v8::PropertyAttribute(v8::DontDelete | v8::ReadOnly);
  32. + }
  33. instTempl->SetAccessor(v8::String::New(prop.name()),
  34. getter, setter, v8::Int32::New(i),
  35. - v8::DEFAULT, v8::DontDelete);
  36. + v8::DEFAULT, attribute);
  37. }
  38.  
  39. // Figure out method names (own and inherited).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement