summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2011-08-29 15:06:14 +1000
committerQt by Nokia <qt-info@nokia.com>2011-08-29 08:29:24 +0200
commitf29bfda2e609f00fad46160495017168094eff7b (patch)
tree8378dfb9643e96cbfa1c829c315116af6be0cf20
parent438639f9c40311b51a57b501428d2650f21615cf (diff)
Use the optimized QDeclarativeExpression constructor where possible.
Pass in the QDeclarativeScriptString directly, to make use of the precompiled binding. Also does some minor cleanup of the related internal implementation. Change-Id: I4b199298c9da3ee11c51c9c98b384c8324f62c26 Reviewed-on: http://codereview.qt.nokia.com/3696 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Charles Yin <charles.yin@nokia.com>
-rw-r--r--src/declarative/qml/qdeclarativebinding.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeexpression.cpp4
-rw-r--r--src/declarative/util/qdeclarativeanimation.cpp8
-rw-r--r--src/declarative/util/qdeclarativestateoperations.cpp8
4 files changed, 7 insertions, 15 deletions
diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp
index 069744153a..d817990d7b 100644
--- a/src/declarative/qml/qdeclarativebinding.cpp
+++ b/src/declarative/qml/qdeclarativebinding.cpp
@@ -235,7 +235,7 @@ QDeclarativeBinding::createBinding(Identifier id, QObject *obj, QDeclarativeCont
QDeclarativeContextData *ctxtdata = QDeclarativeContextData::get(ctxt);
- QDeclarativeEnginePrivate *engine = QDeclarativeEnginePrivate::get(qmlEngine(obj));
+ QDeclarativeEnginePrivate *engine = QDeclarativeEnginePrivate::get(ctxt->engine());
QDeclarativeCompiledData *cdata = 0;
QDeclarativeTypeData *typeData = 0;
if (engine && ctxtdata && !ctxtdata->url.isEmpty()) {
diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp
index 8806996bd4..a24d46914c 100644
--- a/src/declarative/qml/qdeclarativeexpression.cpp
+++ b/src/declarative/qml/qdeclarativeexpression.cpp
@@ -242,7 +242,7 @@ QDeclarativeExpression::QDeclarativeExpression(const QDeclarativeScriptString &s
} else {
QDeclarativeContextData *ctxtdata = QDeclarativeContextData::get(script.context());
- QDeclarativeEnginePrivate *engine = QDeclarativeEnginePrivate::get(qmlEngine(script.scopeObject()));
+ QDeclarativeEnginePrivate *engine = QDeclarativeEnginePrivate::get(script.context()->engine());
QDeclarativeCompiledData *cdata = 0;
QDeclarativeTypeData *typeData = 0;
if (engine && ctxtdata && !ctxtdata->url.isEmpty()) {
@@ -251,7 +251,7 @@ QDeclarativeExpression::QDeclarativeExpression(const QDeclarativeScriptString &s
}
if (cdata)
- d->init(ctxtdata, cdata->primitives.at(id), cdata, script.scopeObject(),
+ d->init(ctxtdata, cdata->primitives.at(id), true, script.scopeObject(),
cdata->name, script.d.data()->lineNumber);
else
defaultConstruction = true;
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp
index 11e1c7cc0a..6cdba7c5d9 100644
--- a/src/declarative/util/qdeclarativeanimation.cpp
+++ b/src/declarative/util/qdeclarativeanimation.cpp
@@ -827,12 +827,8 @@ void QDeclarativeScriptActionPrivate::execute()
QDeclarativeScriptString scriptStr = hasRunScriptScript ? runScriptScript : script;
- const QString &str = scriptStr.script();
- if (!str.isEmpty()) {
- QDeclarativeExpression expr(scriptStr.context(), scriptStr.scopeObject(), str);
- QDeclarativeData *ddata = QDeclarativeData::get(q);
- if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty())
- expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber);
+ if (!scriptStr.script().isEmpty()) {
+ QDeclarativeExpression expr(scriptStr);
expr.evaluate();
if (expr.hasError())
qmlInfo(q) << expr.error();
diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp
index 6ac21002a5..98f437d9a3 100644
--- a/src/declarative/util/qdeclarativestateoperations.cpp
+++ b/src/declarative/util/qdeclarativestateoperations.cpp
@@ -131,12 +131,8 @@ void QDeclarativeStateChangeScript::setName(const QString &n)
void QDeclarativeStateChangeScript::execute(Reason)
{
Q_D(QDeclarativeStateChangeScript);
- const QString &script = d->script.script();
- if (!script.isEmpty()) {
- QDeclarativeExpression expr(d->script.context(), d->script.scopeObject(), script);
- QDeclarativeData *ddata = QDeclarativeData::get(this);
- if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty())
- expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber);
+ if (!d->script.script().isEmpty()) {
+ QDeclarativeExpression expr(d->script);
expr.evaluate();
if (expr.hasError())
qmlInfo(this, expr.error());