diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-09-14 11:25:02 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-18 13:14:13 +0200 |
commit | f79df5da0769836bc866b470cdac43d6363dc7db (patch) | |
tree | 28deb1584b6c43dca92b39328bcf43099a92fcd6 /src/particles | |
parent | e4e90923c93adfafb23c81be7359e8df2a500b4f (diff) |
Convert more methods to return a Returned<>
Change-Id: If294c9c4f574824c308b63a11da1337226180105
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/particles')
-rw-r--r-- | src/particles/qquickcustomaffector.cpp | 9 | ||||
-rw-r--r-- | src/particles/qquickparticleemitter.cpp | 5 | ||||
-rw-r--r-- | src/particles/qquicktrailemitter.cpp | 7 |
3 files changed, 12 insertions, 9 deletions
diff --git a/src/particles/qquickcustomaffector.cpp b/src/particles/qquickcustomaffector.cpp index 40d0df1a22..09f8967045 100644 --- a/src/particles/qquickcustomaffector.cpp +++ b/src/particles/qquickcustomaffector.cpp @@ -146,13 +146,14 @@ void QQuickCustomAffector::affectSystem(qreal dt) QQmlEngine *qmlEngine = ::qmlEngine(this); QV4::ExecutionEngine *v4 = QV8Engine::getV4(qmlEngine->handle()); - QV4::ArrayObject *array = v4->newArrayObject(toAffect.size()); + QV4::Scope scope(v4); + QV4::Scoped<QV4::ArrayObject> array(scope, v4->newArrayObject(toAffect.size())); for (int i=0; i<toAffect.size(); i++) array->putIndexed(i, toAffect[i]->v4Value().toValue()); if (dt >= simulationCutoff || dt <= simulationDelta) { affectProperties(toAffect, dt); - emit affectParticles(QQmlV4Handle(QV4::Value::fromObject(array)), dt); + emit affectParticles(QQmlV4Handle(array.asValue()), dt); } else { int realTime = m_system->timeInt; m_system->timeInt -= dt * 1000.0; @@ -160,12 +161,12 @@ void QQuickCustomAffector::affectSystem(qreal dt) m_system->timeInt += simulationDelta * 1000.0; dt -= simulationDelta; affectProperties(toAffect, simulationDelta); - emit affectParticles(QQmlV4Handle(QV4::Value::fromObject(array)), simulationDelta); + emit affectParticles(QQmlV4Handle(array.asValue()), simulationDelta); } m_system->timeInt = realTime; if (dt > 0.0) { affectProperties(toAffect, dt); - emit affectParticles(QQmlV4Handle(QV4::Value::fromObject(array)), dt); + emit affectParticles(QQmlV4Handle(array.asValue()), dt); } } diff --git a/src/particles/qquickparticleemitter.cpp b/src/particles/qquickparticleemitter.cpp index 6627291c55..404554c9b6 100644 --- a/src/particles/qquickparticleemitter.cpp +++ b/src/particles/qquickparticleemitter.cpp @@ -481,14 +481,15 @@ void QQuickParticleEmitter::emitWindow(int timeStamp) if (isEmitConnected()) { QQmlEngine *qmlEngine = ::qmlEngine(this); QV4::ExecutionEngine *v4 = QV8Engine::getV4(qmlEngine->handle()); + QV4::Scope scope(v4); //Done after emitParticle so that the Painter::load is done first, this allows you to customize its static variables //We then don't need to request another reload, because the first reload isn't scheduled until we get back to the render thread - QV4::ArrayObject *array = v4->newArrayObject(toEmit.size()); + QV4::Scoped<QV4::ArrayObject> array(scope, v4->newArrayObject(toEmit.size())); for (int i=0; i<toEmit.size(); i++) array->putIndexed(i, toEmit[i]->v4Value().toValue()); - emitParticles(QQmlV4Handle(QV4::Value::fromObject(array)));//A chance for arbitrary JS changes + emitParticles(QQmlV4Handle(array.asValue()));//A chance for arbitrary JS changes } m_last_emission = pt; diff --git a/src/particles/qquicktrailemitter.cpp b/src/particles/qquicktrailemitter.cpp index 4f4a05d09a..84caebf5be 100644 --- a/src/particles/qquicktrailemitter.cpp +++ b/src/particles/qquicktrailemitter.cpp @@ -272,14 +272,15 @@ void QQuickTrailEmitter::emitWindow(int timeStamp) QQmlEngine *qmlEngine = ::qmlEngine(this); QV4::ExecutionEngine *v4 = QV8Engine::getV4(qmlEngine->handle()); - QV4::ArrayObject *array = v4->newArrayObject(toEmit.size()); + QV4::Scope scope(v4); + QV4::Scoped<QV4::ArrayObject> array(scope, v4->newArrayObject(toEmit.size())); for (int i=0; i<toEmit.size(); i++) array->putIndexed(i, toEmit[i]->v4Value().toValue()); if (isEmitFollowConnected()) - emitFollowParticles(QQmlV4Handle(QV4::Value::fromObject(array)), d->v4Value());//A chance for many arbitrary JS changes + emitFollowParticles(QQmlV4Handle(array.asValue()), d->v4Value());//A chance for many arbitrary JS changes else if (isEmitConnected()) - emitParticles(QQmlV4Handle(QV4::Value::fromObject(array)));//A chance for arbitrary JS changes + emitParticles(QQmlV4Handle(array.asValue()));//A chance for arbitrary JS changes } m_lastEmission[d->index] = pt; } |