aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2018-02-15 14:23:11 +0100
committerMitch Curtis <mitch.curtis@qt.io>2018-02-17 20:49:58 +0000
commitb2c71d6518143b3d2a9bd3aef1d72ee5929891fc (patch)
treeb386c7752998885f4318dd90d003237ff3de7e3e /tests/auto/qml
parent97d1db53394077b5e5c159f5eb14af5e3ddb9158 (diff)
Fix "Expression depends on non-NOTIFYable properties" regression
CONSTANT properties are by nature non-NOTIFYable. The issue behind the regression is caused by the fact that we were capturing a property regardless of whether or not it was const. There were two states that captureRequired was expressing: true: We're reading the property of a QObject, and we're not quite sure where the QObject comes from or what it is. So, when reading that property at run-time, make sure that we capture where we read that property so that if it changes we can re-evaluate the entire expression. false: We're reading the property of a QObject, and we know that it's the scope object or context object, which we know very well. Instead of registering a property capture every time, we can do that ahead of time and then register all those captures in one shot in registerQmlDependencies(). There is a third state that is only relevant when captureRequired is false: We're reading a property from the scope or context object, but it's a CONSTANT property, so we don't need to register a dependency at all. This patch adds replaces captureRequired with the PropertyCapturePolicy enum, which accounts for the third state and, as a bonus, makes the code easier to understand. Task-number: QTBUG-66361 Change-Id: I6cef1deb76538fbdacf1324b4467403dd40dd7de Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/qml')
-rw-r--r--tests/auto/qml/qqmlecmascript/data/nonNotifyableConstant.qml5
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp13
2 files changed, 18 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/data/nonNotifyableConstant.qml b/tests/auto/qml/qqmlecmascript/data/nonNotifyableConstant.qml
new file mode 100644
index 0000000000..424b3e8b07
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/nonNotifyableConstant.qml
@@ -0,0 +1,5 @@
+import Qt.test 1.0
+
+MyQmlObject {
+ objectName: trueProperty ? "foo" : "bar"
+}
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index b7d5db9914..5e752d124b 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -261,6 +261,7 @@ private slots:
void doubleEvaluate();
void forInLoop();
void nonNotifyable();
+ void nonNotifyableConstant();
void deleteWhileBindingRunning();
void callQtInvokables();
void resolveClashingProperties();
@@ -6889,6 +6890,18 @@ void tst_qqmlecmascript::nonNotifyable()
delete object;
}
+void tst_qqmlecmascript::nonNotifyableConstant()
+{
+ QQmlComponent component(&engine, testFileUrl("nonNotifyableConstant.qml"));
+ QQmlTestMessageHandler messageHandler;
+
+ // Shouldn't produce an error message about non-NOTIFYable properties,
+ // as the property has the CONSTANT attribute.
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(object);
+ QCOMPARE(messageHandler.messages().size(), 0);
+}
+
void tst_qqmlecmascript::forInLoop()
{
QQmlComponent component(&engine, testFileUrl("forInLoop.qml"));