summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-05-18 05:40:53 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2010-05-18 05:46:07 (GMT)
commit9a111f72362b39be9b10d5d365faa21dfebf770e (patch)
tree648d262281ded09ca811e84fdc69d1dbd69a9fc8
parent3d1a6596c6a381b71718af22eb8a861830ec7b6b (diff)
downloadQt-9a111f72362b39be9b10d5d365faa21dfebf770e.zip
Qt-9a111f72362b39be9b10d5d365faa21dfebf770e.tar.gz
Qt-9a111f72362b39be9b10d5d365faa21dfebf770e.tar.bz2
Prevent assignment of values (string, number, bool) to signal handlers.
Task-number: QTBUG-10764 Reviewed-by: Aaron Kennedy
-rw-r--r--src/declarative/qml/qdeclarativecompiler.cpp3
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.errors.txt1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.qml (renamed from tests/auto/declarative/qdeclarativelanguage/data/emptySignal.2.qml)3
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/emptySignal.2.errors.txt1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/emptySignal.errors.txt2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/emptySignal.qml3
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp5
7 files changed, 10 insertions, 8 deletions
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
index d880844..b5bf972 100644
--- a/src/declarative/qml/qdeclarativecompiler.cpp
+++ b/src/declarative/qml/qdeclarativecompiler.cpp
@@ -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"));
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.errors.txt
new file mode 100644
index 0000000..eb1430a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.errors.txt
@@ -0,0 +1 @@
+4:5:Cannot assign a value to a signal (expecting a script to be run)
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.qml
index c84fea3..6fa1259 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.2.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/assignValueToSignal.qml
@@ -1,7 +1,6 @@
import Test 1.0
MyQmlObject {
- onBasicSignal {
- }
+ onBasicSignal: "hello world"
}
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.2.errors.txt
deleted file mode 100644
index 8b20434..0000000
--- a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.2.errors.txt
+++ /dev/null
@@ -1 +0,0 @@
-4:5:Incorrectly specified signal assignment
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.errors.txt
index 353bbf5..8b20434 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.errors.txt
+++ b/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.errors.txt
@@ -1 +1 @@
-4:5:Empty signal assignment
+4:5:Incorrectly specified signal assignment
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.qml b/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.qml
index ba3545e..c84fea3 100644
--- a/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.qml
+++ b/tests/auto/declarative/qdeclarativelanguage/data/emptySignal.qml
@@ -1,6 +1,7 @@
import Test 1.0
MyQmlObject {
- onBasicSignal: " "
+ onBasicSignal {
+ }
}
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index cb2764f..200f016 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -351,9 +351,8 @@ void tst_qdeclarativelanguage::errors_data()
QTest::newRow("invalidAttachedProperty.12") << "invalidAttachedProperty.12.qml" << "invalidAttachedProperty.12.errors.txt" << false;
QTest::newRow("invalidAttachedProperty.13") << "invalidAttachedProperty.13.qml" << "invalidAttachedProperty.13.errors.txt" << false;
- //### this is no longer considered empty (and should produce a different error: QTBUG-10764)
- //QTest::newRow("emptySignal") << "emptySignal.qml" << "emptySignal.errors.txt" << false;
- QTest::newRow("emptySignal.2") << "emptySignal.2.qml" << "emptySignal.2.errors.txt" << false;
+ QTest::newRow("assignValueToSignal") << "assignValueToSignal.qml" << "assignValueToSignal.errors.txt" << false;
+ QTest::newRow("emptySignal") << "emptySignal.qml" << "emptySignal.errors.txt" << false;
QTest::newRow("nestedErrors") << "nestedErrors.qml" << "nestedErrors.errors.txt" << false;
QTest::newRow("defaultGrouped") << "defaultGrouped.qml" << "defaultGrouped.errors.txt" << false;