summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qdeclarativecompiledbindings.cpp
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-03-12 02:23:50 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-03-12 02:24:48 (GMT)
commit93b789f196868f958b4d7dcfd45dbe27179b1b0f (patch)
treee53ab16dbd59b5cb53e7276d8375a0646c168760 /src/declarative/qml/qdeclarativecompiledbindings.cpp
parentc9042323b601d54c2cefaee0d28559c83d47841f (diff)
downloadQt-93b789f196868f958b4d7dcfd45dbe27179b1b0f.zip
Qt-93b789f196868f958b4d7dcfd45dbe27179b1b0f.tar.gz
Qt-93b789f196868f958b4d7dcfd45dbe27179b1b0f.tar.bz2
Reenable the QML binding optimizer for "safe" optimizations
Diffstat (limited to 'src/declarative/qml/qdeclarativecompiledbindings.cpp')
-rw-r--r--src/declarative/qml/qdeclarativecompiledbindings.cpp72
1 files changed, 60 insertions, 12 deletions
diff --git a/src/declarative/qml/qdeclarativecompiledbindings.cpp b/src/declarative/qml/qdeclarativecompiledbindings.cpp
index c66a417..aa549a9 100644
--- a/src/declarative/qml/qdeclarativecompiledbindings.cpp
+++ b/src/declarative/qml/qdeclarativecompiledbindings.cpp
@@ -48,12 +48,17 @@
#include <private/qdeclarativejsast_p.h>
#include <private/qdeclarativejsengine_p.h>
#include <private/qdeclarativeexpression_p.h>
+#include <QtCore/qcoreapplication.h>
#include <QtCore/qdebug.h>
#include <QtCore/qnumeric.h>
#include <private/qdeclarativeanchors_p_p.h>
+#include <private/qdeclarativeglobal_p.h>
QT_BEGIN_NAMESPACE
+DEFINE_BOOL_CONFIG_OPTION(qmlExperimental, QML_EXPERIMENTAL);
+DEFINE_BOOL_CONFIG_OPTION(qmlDisableOptimizer, QML_DISABLE_OPTIMIZER);
+
using namespace QDeclarativeJS;
namespace {
@@ -219,7 +224,6 @@ void QDeclarativeCompiledBindingsPrivate::Binding::setEnabled(bool e, QDeclarati
{
if (e) {
addToObject(target);
- update(flags);
} else {
removeFromObject();
}
@@ -274,8 +278,6 @@ void QDeclarativeCompiledBindingsPrivate::run(Binding *binding)
if (!binding->enabled)
return;
- if (binding->updating)
- qWarning("ERROR: Circular binding");
QDeclarativeContext *context = q->QDeclarativeAbstractExpression::context();
if (!context) {
@@ -284,6 +286,25 @@ void QDeclarativeCompiledBindingsPrivate::run(Binding *binding)
}
QDeclarativeContextPrivate *cp = QDeclarativeContextPrivate::get(context);
+ if (binding->updating) {
+ QString name;
+ if (binding->property & 0xFFFF0000) {
+ QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(cp->engine);
+
+ QDeclarativeValueType *vt = ep->valueTypes[(binding->property >> 16) & 0xFF];
+ Q_ASSERT(vt);
+
+ name = QLatin1String(binding->target->metaObject()->property(binding->property & 0xFFFF).name());
+ name.append(QLatin1String("."));
+ name.append(QLatin1String(vt->metaObject()->property(binding->property >> 24).name()));
+ } else {
+ name = binding->target->metaObject()->property(binding->property).name();
+ }
+ qmlInfo(binding->target) << QCoreApplication::translate("QDeclarativeCompiledBindings", "Binding loop detected for property \"%1\"").arg(name);
+ return;
+ }
+
+ binding->updating = true;
if (binding->property & 0xFFFF0000) {
QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(cp->engine);
@@ -299,6 +320,7 @@ void QDeclarativeCompiledBindingsPrivate::run(Binding *binding)
} else {
run(binding->index, cp, binding, binding->scope, binding->target);
}
+ binding->updating = false;
}
namespace {
@@ -624,6 +646,7 @@ void QDeclarativeCompiledBindingsPrivate::subscribeId(QDeclarativeContextPrivate
QDeclarativeCompiledBindingsPrivate::Subscription *sub = (subscriptions + subIndex);
sub->target = q;
sub->targetMethod = methodCount + subIndex;
+ sub->connect(&p->idValues[idIndex].bindings);
}
}
@@ -634,7 +657,10 @@ void QDeclarativeCompiledBindingsPrivate::subscribe(QObject *o, int notifyIndex,
QDeclarativeCompiledBindingsPrivate::Subscription *sub = (subscriptions + subIndex);
sub->target = q;
sub->targetMethod = methodCount + subIndex;
- sub->connect(o, notifyIndex);
+ if (o)
+ sub->connect(o, notifyIndex);
+ else
+ sub->disconnect();
}
// Conversion functions - these MUST match the QtScript expression path
@@ -728,9 +754,9 @@ static QObject *variantToQObject(const QVariant &value, bool *ok)
}
bool QDeclarativeCompiledBindingsPrivate::findproperty(QObject *obj, Register *output,
- QDeclarativeEnginePrivate *enginePriv,
- int subIdx, const QScriptDeclarativeClass::Identifier &name,
- bool isTerminal)
+ QDeclarativeEnginePrivate *enginePriv,
+ int subIdx, const QScriptDeclarativeClass::Identifier &name,
+ bool isTerminal)
{
if (!obj) {
output->setUndefined();
@@ -801,10 +827,10 @@ bool QDeclarativeCompiledBindingsPrivate::findproperty(QObject *obj, Register *o
}
void QDeclarativeCompiledBindingsPrivate::findgeneric(Register *output,
- int subIdx,
- QDeclarativeContextPrivate *context,
- const QScriptDeclarativeClass::Identifier &name,
- bool isTerminal)
+ int subIdx,
+ QDeclarativeContextPrivate *context,
+ const QScriptDeclarativeClass::Identifier &name,
+ bool isTerminal)
{
QDeclarativeEnginePrivate *enginePriv = QDeclarativeEnginePrivate::get(context->engine);
@@ -1529,6 +1555,9 @@ bool QDeclarativeBindingCompilerPrivate::compile(QDeclarativeJS::AST::Node *node
return false;
if (type.unknownType) {
+ if (!qmlExperimental())
+ return false;
+
if (destination->type != QMetaType::QReal &&
destination->type != QVariant::String &&
destination->type != QMetaType::Bool &&
@@ -1812,7 +1841,7 @@ bool QDeclarativeBindingCompilerPrivate::parseName(AST::Node *node, Result &type
if (!fetch(type, component->metaObject(), reg, d1Idx, subscribeName, nameNodes.at(ii)))
return false;
- } else {
+ } else if (qmlExperimental()) {
Instr find;
if (nameParts.count() == 1)
find.common.type = Instr::FindGenericTerminal;
@@ -1968,7 +1997,11 @@ bool QDeclarativeBindingCompilerPrivate::numberArith(Result &type, const Result
int lhsTmp = -1;
int rhsTmp = -1;
+
if (lhs.unknownType) {
+ if (!qmlExperimental())
+ return false;
+
lhsTmp = acquireReg();
Instr conv;
@@ -1979,6 +2012,9 @@ bool QDeclarativeBindingCompilerPrivate::numberArith(Result &type, const Result
}
if (rhs.unknownType) {
+ if (!qmlExperimental())
+ return false;
+
rhsTmp = acquireReg();
Instr conv;
@@ -2024,6 +2060,9 @@ bool QDeclarativeBindingCompilerPrivate::stringArith(Result &type, const Result
int rhsTmp = -1;
if (lhs.unknownType) {
+ if (!qmlExperimental())
+ return false;
+
lhsTmp = acquireReg(Instr::CleanupString);
Instr convert;
@@ -2034,6 +2073,9 @@ bool QDeclarativeBindingCompilerPrivate::stringArith(Result &type, const Result
}
if (rhs.unknownType) {
+ if (!qmlExperimental())
+ return false;
+
rhsTmp = acquireReg(Instr::CleanupString);
Instr convert;
@@ -2554,6 +2596,12 @@ int QDeclarativeBindingCompiler::compile(const Expression &expression, QDeclarat
{
if (!expression.expression.asAST()) return false;
+ if (!qmlExperimental() && expression.property->isValueTypeSubProperty)
+ return -1;
+
+ if (qmlDisableOptimizer())
+ return -1;
+
d->context = expression.context;
d->component = expression.component;
d->destination = expression.property;