diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-09-18 11:00:38 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-22 01:06:20 +0200 |
commit | 50624234f2c0b6d3b0985edb8ff0b6aad5cad761 (patch) | |
tree | 2852c8917788d870100278d1cdc0129b94c5b599 /src/imports | |
parent | 8b3623ee7b707e1b26ad48bdbf7816b95d9e0e24 (diff) |
Add a Safe<T> class and start using it
The class denotes objects that are stored safely
in areas controlled by the GC. These we can convert
fast to a StringRef etc.
Change-Id: I6b154eccaefddc42d4fafca55b7ee9e77179830c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Diffstat (limited to 'src/imports')
-rw-r--r-- | src/imports/dialogs-private/qquickfontlistmodel.cpp | 8 | ||||
-rw-r--r-- | src/imports/dialogs-private/qquickwritingsystemlistmodel.cpp | 8 | ||||
-rw-r--r-- | src/imports/xmllistmodel/qqmlxmllistmodel.cpp | 3 |
3 files changed, 12 insertions, 7 deletions
diff --git a/src/imports/dialogs-private/qquickfontlistmodel.cpp b/src/imports/dialogs-private/qquickfontlistmodel.cpp index 234a5735ec..233001b723 100644 --- a/src/imports/dialogs-private/qquickfontlistmodel.cpp +++ b/src/imports/dialogs-private/qquickfontlistmodel.cpp @@ -216,13 +216,15 @@ QQmlV4Handle QQuickFontListModel::get(int idx) const QQmlEngine *engine = qmlContext(this)->engine(); QV8Engine *v8engine = QQmlEnginePrivate::getV8Engine(engine); ExecutionEngine *v4engine = QV8Engine::getV4(v8engine); - Object *o = v4engine->newObject(); + Scope scope(v4engine); + ScopedObject o(scope, v4engine->newObject()); + ScopedString s(scope); for (int ii = 0; ii < d->roleNames.keys().count(); ++ii) { - Property *p = o->insertMember(v4engine->newIdentifier(d->roleNames[Qt::UserRole + ii + 1]), PropertyAttributes()); + Property *p = o->insertMember((s = v4engine->newIdentifier(d->roleNames[Qt::UserRole + ii + 1])), PropertyAttributes()); p->value = Value::fromReturnedValue(v8engine->fromVariant(data(index(idx, 0), Qt::UserRole + ii + 1))); } - return QQmlV4Handle(Value::fromObject(o)); + return QQmlV4Handle(o.asValue()); } QQmlV4Handle QQuickFontListModel::pointSizes() diff --git a/src/imports/dialogs-private/qquickwritingsystemlistmodel.cpp b/src/imports/dialogs-private/qquickwritingsystemlistmodel.cpp index 08caa662c2..ffe82fce12 100644 --- a/src/imports/dialogs-private/qquickwritingsystemlistmodel.cpp +++ b/src/imports/dialogs-private/qquickwritingsystemlistmodel.cpp @@ -154,13 +154,15 @@ QQmlV4Handle QQuickWritingSystemListModel::get(int idx) const QQmlEngine *engine = qmlContext(this)->engine(); QV8Engine *v8engine = QQmlEnginePrivate::getV8Engine(engine); ExecutionEngine *v4engine = QV8Engine::getV4(v8engine); - Object *o = v4engine->newObject(); + Scope scope(v4engine); + ScopedObject o(scope, v4engine->newObject()); + ScopedString s(scope); for (int ii = 0; ii < d->roleNames.keys().count(); ++ii) { - Property *p = o->insertMember(v4engine->newIdentifier(d->roleNames[Qt::UserRole + ii + 1]), PropertyAttributes()); + Property *p = o->insertMember((s = v4engine->newIdentifier(d->roleNames[Qt::UserRole + ii + 1])), PropertyAttributes()); p->value = Value::fromReturnedValue(v8engine->fromVariant(data(index(idx, 0), Qt::UserRole + ii + 1))); } - return QQmlV4Handle(Value::fromObject(o)); + return QQmlV4Handle(o.asValue()); } void QQuickWritingSystemListModel::classBegin() diff --git a/src/imports/xmllistmodel/qqmlxmllistmodel.cpp b/src/imports/xmllistmodel/qqmlxmllistmodel.cpp index f87273be40..2991bd9755 100644 --- a/src/imports/xmllistmodel/qqmlxmllistmodel.cpp +++ b/src/imports/xmllistmodel/qqmlxmllistmodel.cpp @@ -926,7 +926,8 @@ QQmlV4Handle QQuickXmlListModel::get(int index) const Scope scope(v4engine); Scoped<Object> o(scope, v4engine->newObject()); for (int ii = 0; ii < d->roleObjects.count(); ++ii) { - Property *p = o->insertMember(v4engine->newIdentifier(d->roleObjects[ii]->name()), PropertyAttributes()); + ScopedString name(scope, v4engine->newIdentifier(d->roleObjects[ii]->name())); + Property *p = o->insertMember(name, PropertyAttributes()); p->value = Value::fromReturnedValue(v8engine->fromVariant(d->data.value(ii).value(index))); } |