summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/QmlChanges.txt5
-rw-r--r--src/declarative/graphicsitems/qdeclarativeloader.cpp1
-rw-r--r--src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp6
-rw-r--r--src/declarative/qml/qdeclarativebinding.cpp4
-rw-r--r--src/declarative/qml/qdeclarativeboundsignal.cpp2
-rw-r--r--src/declarative/qml/qdeclarativecompiledbindings.cpp2
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp51
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeexpression.cpp18
-rw-r--r--src/declarative/qml/qdeclarativeexpression.h6
-rw-r--r--src/declarative/qml/qdeclarativeinclude.cpp3
-rw-r--r--src/declarative/qml/qdeclarativeparser.cpp45
-rw-r--r--src/declarative/qml/qdeclarativeparser_p.h4
-rw-r--r--src/declarative/qml/qdeclarativevme.cpp2
-rw-r--r--src/declarative/qml/qdeclarativewatcher.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript.cpp4
-rw-r--r--src/declarative/qml/qdeclarativexmlhttprequest.cpp2
-rw-r--r--src/declarative/util/qdeclarativeanimation.cpp2
-rw-r--r--src/declarative/util/qdeclarativeconnections.cpp2
-rw-r--r--src/declarative/util/qdeclarativepropertychanges.cpp4
-rw-r--r--src/declarative/util/qdeclarativestateoperations.cpp194
-rw-r--r--src/declarative/util/qdeclarativestateoperations_p.h36
22 files changed, 270 insertions, 127 deletions
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt
index ec8f508..b1f4f1b 100644
--- a/src/declarative/QmlChanges.txt
+++ b/src/declarative/QmlChanges.txt
@@ -18,6 +18,11 @@ C++ API
QDeclarativeExpression::value() has been renamed to
QDeclarativeExpression::evaluate()
+The QDeclarativeExpression constructor has changed from
+ QDeclarativeExpression(context, expression, scope)
+to
+ QDeclarativeExpression(context, scope, expression, parent = 0)
+
QML Launcher
------------
The standalone executable has been renamed to qml launcher. Runtime warnings
diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp
index cbdfd87..94983c4 100644
--- a/src/declarative/graphicsitems/qdeclarativeloader.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp
@@ -366,6 +366,7 @@ QDeclarativeLoader::Status QDeclarativeLoader::status() const
void QDeclarativeLoader::componentComplete()
{
+ QDeclarativeItem::componentComplete();
if (status() == Ready)
emit loaded();
}
diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
index 0e4217e..7abd0a2 100644
--- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
@@ -204,7 +204,7 @@ QVariant QDeclarativeVisualItemModel::evaluate(int index, const QString &express
QDeclarativeContext *ccontext = qmlContext(this);
QDeclarativeContext *ctxt = new QDeclarativeContext(ccontext);
ctxt->setContextObject(d->children.at(index));
- QDeclarativeExpression e(ctxt, expression, objectContext);
+ QDeclarativeExpression e(ctxt, objectContext, expression);
QVariant value = e.evaluate();
delete ctxt;
return value;
@@ -1176,7 +1176,7 @@ QVariant QDeclarativeVisualDataModel::evaluate(int index, const QString &express
if (nobj) {
QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(nobj);
if (item) {
- QDeclarativeExpression e(qmlContext(item), expression, objectContext);
+ QDeclarativeExpression e(qmlContext(item), objectContext, expression);
value = e.evaluate();
}
} else {
@@ -1185,7 +1185,7 @@ QVariant QDeclarativeVisualDataModel::evaluate(int index, const QString &express
QDeclarativeContext *ctxt = new QDeclarativeContext(ccontext);
QDeclarativeVisualDataModelData *data = new QDeclarativeVisualDataModelData(index, this);
ctxt->setContextObject(data);
- QDeclarativeExpression e(ctxt, expression, objectContext);
+ QDeclarativeExpression e(ctxt, objectContext, expression);
value = e.evaluate();
delete data;
delete ctxt;
diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp
index 2e905b9..8230941 100644
--- a/src/declarative/qml/qdeclarativebinding.cpp
+++ b/src/declarative/qml/qdeclarativebinding.cpp
@@ -88,7 +88,7 @@ QDeclarativeBinding::QDeclarativeBinding(void *data, QDeclarativeRefCount *rc, Q
QDeclarativeBinding::QDeclarativeBinding(const QString &str, QObject *obj, QDeclarativeContext *ctxt,
QObject *parent)
-: QDeclarativeExpression(QDeclarativeContextData::get(ctxt), str, obj, *new QDeclarativeBindingPrivate)
+: QDeclarativeExpression(QDeclarativeContextData::get(ctxt), obj, str, *new QDeclarativeBindingPrivate)
{
setParent(parent);
setNotifyOnValueChanged(true);
@@ -96,7 +96,7 @@ QDeclarativeBinding::QDeclarativeBinding(const QString &str, QObject *obj, QDecl
QDeclarativeBinding::QDeclarativeBinding(const QString &str, QObject *obj, QDeclarativeContextData *ctxt,
QObject *parent)
-: QDeclarativeExpression(ctxt, str, obj, *new QDeclarativeBindingPrivate)
+: QDeclarativeExpression(ctxt, obj, str, *new QDeclarativeBindingPrivate)
{
setParent(parent);
setNotifyOnValueChanged(true);
diff --git a/src/declarative/qml/qdeclarativeboundsignal.cpp b/src/declarative/qml/qdeclarativeboundsignal.cpp
index 89f1256..8769122 100644
--- a/src/declarative/qml/qdeclarativeboundsignal.cpp
+++ b/src/declarative/qml/qdeclarativeboundsignal.cpp
@@ -119,7 +119,7 @@ QDeclarativeBoundSignal::QDeclarativeBoundSignal(QDeclarativeContext *ctxt, cons
QDeclarative_setParent_noEvent(this, parent);
QMetaObject::connect(scope, m_signal.methodIndex(), this, evaluateIdx);
- m_expression = new QDeclarativeExpression(ctxt, val, scope);
+ m_expression = new QDeclarativeExpression(ctxt, scope, val);
}
QDeclarativeBoundSignal::~QDeclarativeBoundSignal()
diff --git a/src/declarative/qml/qdeclarativecompiledbindings.cpp b/src/declarative/qml/qdeclarativecompiledbindings.cpp
index f55d330..7ddc735 100644
--- a/src/declarative/qml/qdeclarativecompiledbindings.cpp
+++ b/src/declarative/qml/qdeclarativecompiledbindings.cpp
@@ -1200,7 +1200,7 @@ void QDeclarativeCompiledBindingsPrivate::run(int instrIndex,
const Register &input = registers[instr->unaryop.src];
Register &output = registers[instr->unaryop.output];
if (input.isUndefined()) output.setUndefined();
- else output.setint(int(input.getqreal()));
+ else output.setint(qRound(input.getqreal()));
}
break;
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index a43b9ac..b5bf972 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -180,7 +180,7 @@ bool QDeclarativeCompiler::isSignalPropertyName(const QByteArray &name)
bool QDeclarativeCompiler::testLiteralAssignment(const QMetaProperty &prop,
QDeclarativeParser::Value *v)
{
- QString string = v->value.asScript();
+ QString string = v->value.asString();
if (!prop.isWritable())
COMPILE_EXCEPTION(v, tr("Invalid property assignment: \"%1\" is a read-only property").arg(QString::fromUtf8(prop.name())));
@@ -207,31 +207,31 @@ bool QDeclarativeCompiler::testLiteralAssignment(const QMetaProperty &prop,
break;
case QVariant::UInt:
{
- bool ok;
- string.toUInt(&ok);
- if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: unsigned int expected"));
+ bool ok = v->value.isNumber();
+ if (ok) {
+ double n = v->value.asNumber();
+ if (double(uint(n)) != n)
+ ok = false;
+ }
+ if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: unsigned int expected"));
}
break;
case QVariant::Int:
{
- bool ok;
- string.toInt(&ok);
- if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: int expected"));
+ bool ok = v->value.isNumber();
+ if (ok) {
+ double n = v->value.asNumber();
+ if (double(int(n)) != n)
+ ok = false;
+ }
+ if (!ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: int expected"));
}
break;
case QMetaType::Float:
- {
- bool ok;
- string.toFloat(&ok);
- if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: float expected"));
- }
+ if (!v->value.isNumber()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: float expected"));
break;
case QVariant::Double:
- {
- bool ok;
- string.toDouble(&ok);
- if (!v->value.isNumber() || !ok) COMPILE_EXCEPTION(v, tr("Invalid property assignment: double expected"));
- }
+ if (!v->value.isNumber()) COMPILE_EXCEPTION(v, tr("Invalid property assignment: double expected"));
break;
case QVariant::Color:
{
@@ -319,7 +319,7 @@ bool QDeclarativeCompiler::testLiteralAssignment(const QMetaProperty &prop,
void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
QDeclarativeParser::Value *v)
{
- QString string = v->value.asScript();
+ QString string = v->value.asString();
QDeclarativeInstruction instr;
instr.line = v->location.start.line;
@@ -382,28 +382,28 @@ void QDeclarativeCompiler::genLiteralAssignment(const QMetaProperty &prop,
{
instr.type = QDeclarativeInstruction::StoreInteger;
instr.storeInteger.propertyIndex = prop.propertyIndex();
- instr.storeInteger.value = string.toUInt();
+ instr.storeInteger.value = uint(v->value.asNumber());
}
break;
case QVariant::Int:
{
instr.type = QDeclarativeInstruction::StoreInteger;
instr.storeInteger.propertyIndex = prop.propertyIndex();
- instr.storeInteger.value = string.toInt();
+ instr.storeInteger.value = int(v->value.asNumber());
}
break;
case QMetaType::Float:
{
instr.type = QDeclarativeInstruction::StoreFloat;
instr.storeFloat.propertyIndex = prop.propertyIndex();
- instr.storeFloat.value = string.toFloat();
+ instr.storeFloat.value = float(v->value.asNumber());
}
break;
case QVariant::Double:
{
instr.type = QDeclarativeInstruction::StoreDouble;
instr.storeDouble.propertyIndex = prop.propertyIndex();
- instr.storeDouble.value = string.toDouble();
+ instr.storeDouble.value = v->value.asNumber();
}
break;
case QVariant::Color:
@@ -1187,7 +1187,7 @@ bool QDeclarativeCompiler::buildComponent(QDeclarativeParser::Object *obj,
if (idProp) {
if (idProp->value || idProp->values.count() > 1 || idProp->values.at(0)->object)
COMPILE_EXCEPTION(idProp, tr("Invalid component id specification"));
- COMPILE_CHECK(checkValidId(idProp->values.first(), idProp->values.first()->primitive()));
+ COMPILE_CHECK(checkValidId(idProp->values.first(), idProp->values.first()->primitive()))
QString idVal = idProp->values.first()->primitive();
@@ -1316,6 +1316,9 @@ bool QDeclarativeCompiler::buildSignal(QDeclarativeParser::Property *prop, QDecl
} else {
prop->values.at(0)->type = Value::SignalExpression;
+ if (!prop->values.at(0)->value.isScript())
+ COMPILE_EXCEPTION(prop, tr("Cannot assign a value to a signal (expecting a script to be run)"));
+
QString script = prop->values.at(0)->value.asScript().trimmed();
if (script.isEmpty())
COMPILE_EXCEPTION(prop, tr("Empty signal assignment"));
@@ -1893,7 +1896,7 @@ bool QDeclarativeCompiler::buildScriptStringProperty(QDeclarativeParser::Propert
if (prop->values.count() > 1)
COMPILE_EXCEPTION(prop->values.at(1), tr( "Cannot assign multiple values to a script property"));
- if (prop->values.at(0)->object || !prop->values.at(0)->value.isScript())
+ if (prop->values.at(0)->object)
COMPILE_EXCEPTION(prop->values.at(0), tr( "Invalid property assignment: script expected"));
obj->addScriptStringProperty(prop, ctxt.stack);
diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp
index 69e42f8..7ae0050 100644
--- a/src/declarative/qml/qdeclarativeenginedebug.cpp
+++ b/src/declarative/qml/qdeclarativeenginedebug.cpp
@@ -414,7 +414,7 @@ void QDeclarativeEngineDebugServer::messageReceived(const QByteArray &message)
QDeclarativeContext *context = qmlContext(object);
QVariant result;
if (object && context) {
- QDeclarativeExpression exprObj(context, expr, object);
+ QDeclarativeExpression exprObj(context, object, expr);
bool undefined = false;
QVariant value = exprObj.evaluate(&undefined);
if (undefined)
diff --git a/src/declarative/qml/qdeclarativeexpression.cpp b/src/declarative/qml/qdeclarativeexpression.cpp
index 5ceb918..b1aecfa 100644
--- a/src/declarative/qml/qdeclarativeexpression.cpp
+++ b/src/declarative/qml/qdeclarativeexpression.cpp
@@ -241,15 +241,17 @@ QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, vo
}
/*!
- Create a QDeclarativeExpression object.
+ Create a QDeclarativeExpression object that is a child of \a parent.
The \a expression JavaScript will be executed in the \a ctxt QDeclarativeContext.
If specified, the \a scope object's properties will also be in scope during
the expression's execution.
*/
-QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContext *ctxt, const QString &expression,
- QObject *scope)
-: QObject(*new QDeclarativeExpressionPrivate, 0)
+QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContext *ctxt,
+ QObject *scope,
+ const QString &expression,
+ QObject *parent)
+: QObject(*new QDeclarativeExpressionPrivate, parent)
{
Q_D(QDeclarativeExpression);
d->init(QDeclarativeContextData::get(ctxt), expression, scope);
@@ -258,8 +260,8 @@ QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContext *ctxt, const
/*!
\internal
*/
-QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, const QString &expression,
- QObject *scope)
+QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, QObject *scope,
+ const QString &expression)
: QObject(*new QDeclarativeExpressionPrivate, 0)
{
Q_D(QDeclarativeExpression);
@@ -267,8 +269,8 @@ QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, co
}
/*! \internal */
-QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, const QString &expression,
- QObject *scope, QDeclarativeExpressionPrivate &dd)
+QDeclarativeExpression::QDeclarativeExpression(QDeclarativeContextData *ctxt, QObject *scope,
+ const QString &expression, QDeclarativeExpressionPrivate &dd)
: QObject(dd, 0)
{
Q_D(QDeclarativeExpression);
diff --git a/src/declarative/qml/qdeclarativeexpression.h b/src/declarative/qml/qdeclarativeexpression.h
index 6c72e4d..a8c86da 100644
--- a/src/declarative/qml/qdeclarativeexpression.h
+++ b/src/declarative/qml/qdeclarativeexpression.h
@@ -64,7 +64,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeExpression : public QObject
Q_OBJECT
public:
QDeclarativeExpression();
- QDeclarativeExpression(QDeclarativeContext *, const QString &, QObject *);
+ QDeclarativeExpression(QDeclarativeContext *, QObject *, const QString &, QObject * = 0);
virtual ~QDeclarativeExpression();
QDeclarativeEngine *engine() const;
@@ -92,13 +92,13 @@ Q_SIGNALS:
void valueChanged();
protected:
- QDeclarativeExpression(QDeclarativeContextData *, const QString &, QObject *,
+ QDeclarativeExpression(QDeclarativeContextData *, QObject *, const QString &,
QDeclarativeExpressionPrivate &dd);
QDeclarativeExpression(QDeclarativeContextData *, void *, QDeclarativeRefCount *rc,
QObject *me, const QString &, int, QDeclarativeExpressionPrivate &dd);
private:
- QDeclarativeExpression(QDeclarativeContextData *, const QString &, QObject *);
+ QDeclarativeExpression(QDeclarativeContextData *, QObject *, const QString &);
Q_DISABLE_COPY(QDeclarativeExpression)
Q_DECLARE_PRIVATE(QDeclarativeExpression)
diff --git a/src/declarative/qml/qdeclarativeinclude.cpp b/src/declarative/qml/qdeclarativeinclude.cpp
index 619264a..e37b68b 100644
--- a/src/declarative/qml/qdeclarativeinclude.cpp
+++ b/src/declarative/qml/qdeclarativeinclude.cpp
@@ -140,6 +140,7 @@ void QDeclarativeInclude::finished()
scriptContext->pushScope(m_scope[1]);
scriptContext->setActivationObject(m_scope[1]);
+ QDeclarativeScriptParser::extractPragmas(code);
m_scriptEngine->evaluate(code, urlString, 1);
@@ -230,6 +231,7 @@ QScriptValue QDeclarativeInclude::include(QScriptContext *ctxt, QScriptEngine *e
QScriptValue scope = QScriptDeclarativeClass::scopeChainValue(ctxt, -5);
scriptContext->pushScope(scope);
scriptContext->setActivationObject(scope);
+ QDeclarativeScriptParser::extractPragmas(code);
engine->evaluate(code, urlString, 1);
@@ -291,6 +293,7 @@ QScriptValue QDeclarativeInclude::worker_include(QScriptContext *ctxt, QScriptEn
QScriptValue scope = QScriptDeclarativeClass::scopeChainValue(ctxt, -4);
scriptContext->pushScope(scope);
scriptContext->setActivationObject(scope);
+ QDeclarativeScriptParser::extractPragmas(code);
engine->evaluate(code, urlString, 1);
diff --git a/src/declarative/qml/qdeclarativeparser.cpp b/src/declarative/qml/qdeclarativeparser.cpp
index b38bd76..8d00ef8 100644
--- a/src/declarative/qml/qdeclarativeparser.cpp
+++ b/src/declarative/qml/qdeclarativeparser.cpp
@@ -57,6 +57,7 @@
#include <QPointF>
#include <QSizeF>
#include <QRectF>
+#include <QStringBuilder>
#include <QtDebug>
QT_BEGIN_NAMESPACE
@@ -310,6 +311,49 @@ double QDeclarativeParser::Variant::asNumber() const
return d;
}
+//reverse of Lexer::singleEscape()
+QString escapedString(const QString &string)
+{
+ QString tmp = QLatin1String("\"");
+ for (int i = 0; i < string.length(); ++i) {
+ const QChar &c = string.at(i);
+ switch(c.unicode()) {
+ case 0x08:
+ tmp += QLatin1String("\\b");
+ break;
+ case 0x09:
+ tmp += QLatin1String("\\t");
+ break;
+ case 0x0A:
+ tmp += QLatin1String("\\n");
+ break;
+ case 0x0B:
+ tmp += QLatin1String("\\v");
+ break;
+ case 0x0C:
+ tmp += QLatin1String("\\f");
+ break;
+ case 0x0D:
+ tmp += QLatin1String("\\r");
+ break;
+ case 0x22:
+ tmp += QLatin1String("\\\"");
+ break;
+ case 0x27:
+ tmp += QLatin1String("\\\'");
+ break;
+ case 0x5C:
+ tmp += QLatin1String("\\\\");
+ break;
+ default:
+ tmp += c;
+ break;
+ }
+ }
+ tmp += QLatin1Char('\"');
+ return tmp;
+}
+
QString QDeclarativeParser::Variant::asScript() const
{
switch(type()) {
@@ -324,6 +368,7 @@ QString QDeclarativeParser::Variant::asScript() const
else
return s;
case String:
+ return escapedString(s);
case Script:
return s;
}
diff --git a/src/declarative/qml/qdeclarativeparser_p.h b/src/declarative/qml/qdeclarativeparser_p.h
index 25777f5..d192f3a 100644
--- a/src/declarative/qml/qdeclarativeparser_p.h
+++ b/src/declarative/qml/qdeclarativeparser_p.h
@@ -307,8 +307,8 @@ namespace QDeclarativeParser
};
Type type;
- // ### Temporary
- QString primitive() const { return value.asScript(); }
+ // ### Temporary (for id only)
+ QString primitive() const { return value.isString() ? value.asString() : value.asScript(); }
// Primitive value
Variant value;
diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp
index 8ba79a6..3247f85 100644
--- a/src/declarative/qml/qdeclarativevme.cpp
+++ b/src/declarative/qml/qdeclarativevme.cpp
@@ -627,7 +627,7 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack<QObject *> &stack,
QDeclarativeBoundSignal *bs = new QDeclarativeBoundSignal(target, signal, target);
QDeclarativeExpression *expr =
- new QDeclarativeExpression(ctxt, primitives.at(instr.storeSignal.value), context);
+ new QDeclarativeExpression(ctxt, context, primitives.at(instr.storeSignal.value));
expr->setSourceLocation(comp->name, instr.line);
bs->setExpression(expr);
}
diff --git a/src/declarative/qml/qdeclarativewatcher.cpp b/src/declarative/qml/qdeclarativewatcher.cpp
index 842b3c4..da1419f 100644
--- a/src/declarative/qml/qdeclarativewatcher.cpp
+++ b/src/declarative/qml/qdeclarativewatcher.cpp
@@ -153,7 +153,7 @@ bool QDeclarativeWatcher::addWatch(int id, quint32 objectId, const QString &expr
QObject *object = QDeclarativeDebugService::objectForId(objectId);
QDeclarativeContext *context = qmlContext(object);
if (context) {
- QDeclarativeExpression *exprObj = new QDeclarativeExpression(context, expr, object);
+ QDeclarativeExpression *exprObj = new QDeclarativeExpression(context, object, expr);
exprObj->setNotifyOnValueChanged(true);
QDeclarativeWatchProxy *proxy = new QDeclarativeWatchProxy(id, exprObj, objectId, this);
exprObj->setParent(proxy);
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp
index 4b687a9..8182998 100644
--- a/src/declarative/qml/qdeclarativeworkerscript.cpp
+++ b/src/declarative/qml/qdeclarativeworkerscript.cpp
@@ -527,7 +527,7 @@ void QDeclarativeWorkerScriptEngine::run()
\snippet doc/src/snippets/declarative/workerscript.qml 0
The above worker script specifies a javascript file, "script.js", that handles
- the operations to be performed in the new thread:
+ the operations to be performed in the new thread. Here is \c script.js:
\qml
WorkerScript.onMessage = function(message) {
@@ -538,7 +538,7 @@ void QDeclarativeWorkerScriptEngine::run()
When the user clicks anywhere within the rectangle, \c sendMessage() is
called, triggering the \tt WorkerScript.onMessage() handler in
- \tt source.js. This in turn sends a reply message that is then received
+ \tt script.js. This in turn sends a reply message that is then received
by the \tt onMessage() handler of \tt myWorker.
*/
QDeclarativeWorkerScript::QDeclarativeWorkerScript(QObject *parent)
diff --git a/src/declarative/qml/qdeclarativexmlhttprequest.cpp b/src/declarative/qml/qdeclarativexmlhttprequest.cpp
index 80510f8..acd1f51 100644
--- a/src/declarative/qml/qdeclarativexmlhttprequest.cpp
+++ b/src/declarative/qml/qdeclarativexmlhttprequest.cpp
@@ -995,7 +995,7 @@ private:
int m_status;
QString m_statusText;
QNetworkRequest m_request;
- QNetworkReply *m_network;
+ QDeclarativeGuard<QNetworkReply> m_network;
void destroyNetwork();
QNetworkAccessManager *m_nam;
diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp
index 67440b6..3017e22 100644
--- a/src/declarative/util/qdeclarativeanimation.cpp
+++ b/src/declarative/util/qdeclarativeanimation.cpp
@@ -786,7 +786,7 @@ void QDeclarativeScriptActionPrivate::execute()
const QString &str = scriptStr.script();
if (!str.isEmpty()) {
- QDeclarativeExpression expr(scriptStr.context(), str, scriptStr.scopeObject());
+ 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);
diff --git a/src/declarative/util/qdeclarativeconnections.cpp b/src/declarative/util/qdeclarativeconnections.cpp
index ffa160f..808d196 100644
--- a/src/declarative/util/qdeclarativeconnections.cpp
+++ b/src/declarative/util/qdeclarativeconnections.cpp
@@ -262,7 +262,7 @@ void QDeclarativeConnections::connectSignals()
if (prop.isValid() && (prop.type() & QDeclarativeProperty::SignalProperty)) {
QDeclarativeBoundSignal *signal =
new QDeclarativeBoundSignal(target(), prop.method(), this);
- signal->setExpression(new QDeclarativeExpression(qmlContext(this), script, 0));
+ signal->setExpression(new QDeclarativeExpression(qmlContext(this), 0, script));
d->boundsignals += signal;
} else {
if (!d->ignoreUnknownSignals)
diff --git a/src/declarative/util/qdeclarativepropertychanges.cpp b/src/declarative/util/qdeclarativepropertychanges.cpp
index 12fef36..d99de7a 100644
--- a/src/declarative/util/qdeclarativepropertychanges.cpp
+++ b/src/declarative/util/qdeclarativepropertychanges.cpp
@@ -321,7 +321,7 @@ void QDeclarativePropertyChangesPrivate::decode()
QDeclarativeProperty prop = property(name); //### better way to check for signal property?
if (prop.type() & QDeclarativeProperty::SignalProperty) {
- QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(q), data.toString(), object);
+ QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(q), object, data.toString());
QDeclarativeData *ddata = QDeclarativeData::get(q);
if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty())
expression->setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber);
@@ -330,7 +330,7 @@ void QDeclarativePropertyChangesPrivate::decode()
handler->expression = expression;
signalReplacements << handler;
} else if (isScript) {
- QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(q), data.toString(), object);
+ QDeclarativeExpression *expression = new QDeclarativeExpression(qmlContext(q), object, data.toString());
QDeclarativeData *ddata = QDeclarativeData::get(q);
if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty())
expression->setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber);
diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp
index 0326f6d..b11c0c2 100644
--- a/src/declarative/util/qdeclarativestateoperations.cpp
+++ b/src/declarative/util/qdeclarativestateoperations.cpp
@@ -75,12 +75,12 @@ public:
QDeclarativeItem *rewindParent;
QDeclarativeItem *rewindStackBefore;
- QDeclarativeNullableValue<qreal> x;
- QDeclarativeNullableValue<qreal> y;
- QDeclarativeNullableValue<qreal> width;
- QDeclarativeNullableValue<qreal> height;
- QDeclarativeNullableValue<qreal> scale;
- QDeclarativeNullableValue<qreal> rotation;
+ QDeclarativeNullableValue<QDeclarativeScriptString> xString;
+ QDeclarativeNullableValue<QDeclarativeScriptString> yString;
+ QDeclarativeNullableValue<QDeclarativeScriptString> widthString;
+ QDeclarativeNullableValue<QDeclarativeScriptString> heightString;
+ QDeclarativeNullableValue<QDeclarativeScriptString> scaleString;
+ QDeclarativeNullableValue<QDeclarativeScriptString> rotationString;
void doChange(QDeclarativeItem *targetParent, QDeclarativeItem *stackBefore = 0);
};
@@ -196,112 +196,112 @@ QDeclarativeParentChange::~QDeclarativeParentChange()
These properties hold the new position, size, scale, and rotation
for the item in this state.
*/
-qreal QDeclarativeParentChange::x() const
+QDeclarativeScriptString QDeclarativeParentChange::x() const
{
Q_D(const QDeclarativeParentChange);
- return d->x.isNull ? qreal(0.) : d->x.value;
+ return d->xString.value;
}
-void QDeclarativeParentChange::setX(qreal x)
+void QDeclarativeParentChange::setX(QDeclarativeScriptString x)
{
Q_D(QDeclarativeParentChange);
- d->x = x;
+ d->xString = x;
}
bool QDeclarativeParentChange::xIsSet() const
{
Q_D(const QDeclarativeParentChange);
- return d->x.isValid();
+ return d->xString.isValid();
}
-qreal QDeclarativeParentChange::y() const
+QDeclarativeScriptString QDeclarativeParentChange::y() const
{
Q_D(const QDeclarativeParentChange);
- return d->y.isNull ? qreal(0.) : d->y.value;
+ return d->yString.value;
}
-void QDeclarativeParentChange::setY(qreal y)
+void QDeclarativeParentChange::setY(QDeclarativeScriptString y)
{
Q_D(QDeclarativeParentChange);
- d->y = y;
+ d->yString = y;
}
bool QDeclarativeParentChange::yIsSet() const
{
Q_D(const QDeclarativeParentChange);
- return d->y.isValid();
+ return d->yString.isValid();
}
-qreal QDeclarativeParentChange::width() const
+QDeclarativeScriptString QDeclarativeParentChange::width() const
{
Q_D(const QDeclarativeParentChange);
- return d->width.isNull ? qreal(0.) : d->width.value;
+ return d->widthString.value;
}
-void QDeclarativeParentChange::setWidth(qreal width)
+void QDeclarativeParentChange::setWidth(QDeclarativeScriptString width)
{
Q_D(QDeclarativeParentChange);
- d->width = width;
+ d->widthString = width;
}
bool QDeclarativeParentChange::widthIsSet() const
{
Q_D(const QDeclarativeParentChange);
- return d->width.isValid();
+ return d->widthString.isValid();
}
-qreal QDeclarativeParentChange::height() const
+QDeclarativeScriptString QDeclarativeParentChange::height() const
{
Q_D(const QDeclarativeParentChange);
- return d->height.isNull ? qreal(0.) : d->height.value;
+ return d->heightString.value;
}
-void QDeclarativeParentChange::setHeight(qreal height)
+void QDeclarativeParentChange::setHeight(QDeclarativeScriptString height)
{
Q_D(QDeclarativeParentChange);
- d->height = height;
+ d->heightString = height;
}
bool QDeclarativeParentChange::heightIsSet() const
{
Q_D(const QDeclarativeParentChange);
- return d->height.isValid();
+ return d->heightString.isValid();
}
-qreal QDeclarativeParentChange::scale() const
+QDeclarativeScriptString QDeclarativeParentChange::scale() const
{
Q_D(const QDeclarativeParentChange);
- return d->scale.isNull ? qreal(1.) : d->scale.value;
+ return d->scaleString.value;
}
-void QDeclarativeParentChange::setScale(qreal scale)
+void QDeclarativeParentChange::setScale(QDeclarativeScriptString scale)
{
Q_D(QDeclarativeParentChange);
- d->scale = scale;
+ d->scaleString = scale;
}
bool QDeclarativeParentChange::scaleIsSet() const
{
Q_D(const QDeclarativeParentChange);
- return d->scale.isValid();
+ return d->scaleString.isValid();
}
-qreal QDeclarativeParentChange::rotation() const
+QDeclarativeScriptString QDeclarativeParentChange::rotation() const
{
Q_D(const QDeclarativeParentChange);
- return d->rotation.isNull ? qreal(0.) : d->rotation.value;
+ return d->rotationString.value;
}
-void QDeclarativeParentChange::setRotation(qreal rotation)
+void QDeclarativeParentChange::setRotation(QDeclarativeScriptString rotation)
{
Q_D(QDeclarativeParentChange);
- d->rotation = rotation;
+ d->rotationString = rotation;
}
bool QDeclarativeParentChange::rotationIsSet() const
{
Q_D(const QDeclarativeParentChange);
- return d->rotation.isValid();
+ return d->rotationString.isValid();
}
QDeclarativeItem *QDeclarativeParentChange::originalParent() const
@@ -356,34 +356,118 @@ QDeclarativeStateOperation::ActionList QDeclarativeParentChange::actions()
a.event = this;
actions << a;
- if (d->x.isValid()) {
- QDeclarativeAction xa(d->target, QLatin1String("x"), x());
- actions << xa;
+ if (d->xString.isValid()) {
+ bool ok = false;
+ QString script = d->xString.value.script();
+ qreal x = script.toFloat(&ok);
+ if (ok) {
+ QDeclarativeAction xa(d->target, QLatin1String("x"), x);
+ actions << xa;
+ } else {
+ QDeclarativeBinding *newBinding = new QDeclarativeBinding(script, d->target, qmlContext(this));
+ newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("x")));
+ QDeclarativeAction xa;
+ xa.property = newBinding->property();
+ xa.toBinding = newBinding;
+ xa.fromValue = xa.property.read();
+ xa.deletableToBinding = true;
+ actions << xa;
+ }
}
- if (d->y.isValid()) {
- QDeclarativeAction ya(d->target, QLatin1String("y"), y());
- actions << ya;
+ if (d->yString.isValid()) {
+ bool ok = false;
+ QString script = d->yString.value.script();
+ qreal y = script.toFloat(&ok);
+ if (ok) {
+ QDeclarativeAction ya(d->target, QLatin1String("y"), y);
+ actions << ya;
+ } else {
+ QDeclarativeBinding *newBinding = new QDeclarativeBinding(script, d->target, qmlContext(this));
+ newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("y")));
+ QDeclarativeAction ya;
+ ya.property = newBinding->property();
+ ya.toBinding = newBinding;
+ ya.fromValue = ya.property.read();
+ ya.deletableToBinding = true;
+ actions << ya;
+ }
}
- if (d->scale.isValid()) {
- QDeclarativeAction sa(d->target, QLatin1String("scale"), scale());
- actions << sa;
+ if (d->scaleString.isValid()) {
+ bool ok = false;
+ QString script = d->scaleString.value.script();
+ qreal scale = script.toFloat(&ok);
+ if (ok) {
+ QDeclarativeAction sa(d->target, QLatin1String("scale"), scale);
+ actions << sa;
+ } else {
+ QDeclarativeBinding *newBinding = new QDeclarativeBinding(script, d->target, qmlContext(this));
+ newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("scale")));
+ QDeclarativeAction sa;
+ sa.property = newBinding->property();
+ sa.toBinding = newBinding;
+ sa.fromValue = sa.property.read();
+ sa.deletableToBinding = true;
+ actions << sa;
+ }
}
- if (d->rotation.isValid()) {
- QDeclarativeAction ra(d->target, QLatin1String("rotation"), rotation());
- actions << ra;
+ if (d->rotationString.isValid()) {
+ bool ok = false;
+ QString script = d->rotationString.value.script();
+ qreal rotation = script.toFloat(&ok);
+ if (ok) {
+ QDeclarativeAction ra(d->target, QLatin1String("rotation"), rotation);
+ actions << ra;
+ } else {
+ QDeclarativeBinding *newBinding = new QDeclarativeBinding(script, d->target, qmlContext(this));
+ newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("rotation")));
+ QDeclarativeAction ra;
+ ra.property = newBinding->property();
+ ra.toBinding = newBinding;
+ ra.fromValue = ra.property.read();
+ ra.deletableToBinding = true;
+ actions << ra;
+ }
}
- if (d->width.isValid()) {
- QDeclarativeAction wa(d->target, QLatin1String("width"), width());
- actions << wa;
+ if (d->widthString.isValid()) {
+ bool ok = false;
+ QString script = d->widthString.value.script();
+ qreal width = script.toFloat(&ok);
+ if (ok) {
+ QDeclarativeAction wa(d->target, QLatin1String("width"), width);
+ actions << wa;
+ } else {
+ QDeclarativeBinding *newBinding = new QDeclarativeBinding(script, d->target, qmlContext(this));
+ newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("width")));
+ QDeclarativeAction wa;
+ wa.property = newBinding->property();
+ wa.toBinding = newBinding;
+ wa.fromValue = wa.property.read();
+ wa.deletableToBinding = true;
+ actions << wa;
+ }
}
- if (d->height.isValid()) {
- QDeclarativeAction ha(d->target, QLatin1String("height"), height());
- actions << ha;
+ if (d->heightString.isValid()) {
+ bool ok = false;
+ QString script = d->heightString.value.script();
+ qreal height = script.toFloat(&ok);
+ if (ok) {
+ QDeclarativeAction ha(d->target, QLatin1String("height"), height);
+ actions << ha;
+ } else {
+ QDeclarativeBinding *newBinding = new QDeclarativeBinding(script, d->target, qmlContext(this));
+ newBinding->setTarget(QDeclarativeProperty(d->target, QLatin1String("height")));
+ QDeclarativeAction ha;
+ ha.property = newBinding->property();
+ ha.toBinding = newBinding;
+ ha.fromValue = ha.property.read();
+ ha.deletableToBinding = true;
+ actions << ha;
+ }
}
return actions;
@@ -575,7 +659,7 @@ void QDeclarativeStateChangeScript::execute(Reason)
Q_D(QDeclarativeStateChangeScript);
const QString &script = d->script.script();
if (!script.isEmpty()) {
- QDeclarativeExpression expr(d->script.context(), script, d->script.scopeObject());
+ 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);
diff --git a/src/declarative/util/qdeclarativestateoperations_p.h b/src/declarative/util/qdeclarativestateoperations_p.h
index 21a86f5..05ad052 100644
--- a/src/declarative/util/qdeclarativestateoperations_p.h
+++ b/src/declarative/util/qdeclarativestateoperations_p.h
@@ -62,12 +62,12 @@ class Q_DECLARATIVE_EXPORT QDeclarativeParentChange : public QDeclarativeStateOp
Q_PROPERTY(QDeclarativeItem *target READ object WRITE setObject)
Q_PROPERTY(QDeclarativeItem *parent READ parent WRITE setParent)
- Q_PROPERTY(qreal x READ x WRITE setX)
- Q_PROPERTY(qreal y READ y WRITE setY)
- Q_PROPERTY(qreal width READ width WRITE setWidth)
- Q_PROPERTY(qreal height READ height WRITE setHeight)
- Q_PROPERTY(qreal scale READ scale WRITE setScale)
- Q_PROPERTY(qreal rotation READ rotation WRITE setRotation)
+ Q_PROPERTY(QDeclarativeScriptString x READ x WRITE setX)
+ Q_PROPERTY(QDeclarativeScriptString y READ y WRITE setY)
+ Q_PROPERTY(QDeclarativeScriptString width READ width WRITE setWidth)
+ Q_PROPERTY(QDeclarativeScriptString height READ height WRITE setHeight)
+ Q_PROPERTY(QDeclarativeScriptString scale READ scale WRITE setScale)
+ Q_PROPERTY(QDeclarativeScriptString rotation READ rotation WRITE setRotation)
public:
QDeclarativeParentChange(QObject *parent=0);
~QDeclarativeParentChange();
@@ -80,28 +80,28 @@ public:
QDeclarativeItem *originalParent() const;
- qreal x() const;
- void setX(qreal x);
+ QDeclarativeScriptString x() const;
+ void setX(QDeclarativeScriptString x);
bool xIsSet() const;
- qreal y() const;
- void setY(qreal y);
+ QDeclarativeScriptString y() const;
+ void setY(QDeclarativeScriptString y);
bool yIsSet() const;
- qreal width() const;
- void setWidth(qreal width);
+ QDeclarativeScriptString width() const;
+ void setWidth(QDeclarativeScriptString width);
bool widthIsSet() const;
- qreal height() const;
- void setHeight(qreal height);
+ QDeclarativeScriptString height() const;
+ void setHeight(QDeclarativeScriptString height);
bool heightIsSet() const;
- qreal scale() const;
- void setScale(qreal scale);
+ QDeclarativeScriptString scale() const;
+ void setScale(QDeclarativeScriptString scale);
bool scaleIsSet() const;
- qreal rotation() const;
- void setRotation(qreal rotation);
+ QDeclarativeScriptString rotation() const;
+ void setRotation(QDeclarativeScriptString rotation);
bool rotationIsSet() const;
virtual ActionList actions();