aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2011-06-23 11:20:00 +1000
committerAaron Kennedy <aaron.kennedy@nokia.com>2011-06-23 11:20:00 +1000
commitb35d6b475333fc2fabd0e91f1bfcf2f65aa4d4f4 (patch)
tree8557e5935bf724138f1bb67cfb3da905373c1a15
parentf153846b160fc6a18d513e492ed671aeb21a3061 (diff)
Fix regression against 4.7
Task-number: QTBUG-19136
-rw-r--r--src/declarative/qml/qdeclarativevme.cpp1
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/importScope.1.js1
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/importScope.2.js3
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/data/importScope.qml7
-rw-r--r--tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp14
5 files changed, 26 insertions, 0 deletions
diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp
index a9b303c94f..8959f1775f 100644
--- a/src/declarative/qml/qdeclarativevme.cpp
+++ b/src/declarative/qml/qdeclarativevme.cpp
@@ -988,6 +988,7 @@ QScriptValue QDeclarativeVME::run(QDeclarativeContextData *parentCtxt, QDeclarat
ctxt->imports = script->importCache;
} else {
ctxt->imports = parentCtxt->imports;
+ ctxt->importedScripts = parentCtxt->importedScripts;
}
if (ctxt->imports) {
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/importScope.1.js b/tests/auto/declarative/qdeclarativeecmascript/data/importScope.1.js
new file mode 100644
index 0000000000..4c556f9e96
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/importScope.1.js
@@ -0,0 +1 @@
+var value = 240
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/importScope.2.js b/tests/auto/declarative/qdeclarativeecmascript/data/importScope.2.js
new file mode 100644
index 0000000000..291fb9d2cc
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/importScope.2.js
@@ -0,0 +1,3 @@
+function getValue() {
+ return ImportScope1.value
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/importScope.qml b/tests/auto/declarative/qdeclarativeecmascript/data/importScope.qml
new file mode 100644
index 0000000000..a72847f0d7
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeecmascript/data/importScope.qml
@@ -0,0 +1,7 @@
+import QtQuick 1.0
+import "importScope.1.js" as ImportScope1
+import "importScope.2.js" as ImportScope2
+
+QtObject {
+ property int test: ImportScope2.getValue()
+}
diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
index cabaddeeb7..3c4c336822 100644
--- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
+++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp
@@ -108,6 +108,7 @@ private slots:
void aliasPropertyAndBinding();
void nonExistentAttachedObject();
void scope();
+ void importScope();
void signalParameterTypes();
void objectsCompareAsEqual();
void dynamicCreation_data();
@@ -959,6 +960,19 @@ void tst_qdeclarativeecmascript::scope()
}
}
+// In 4.7, non-library javascript files that had no imports shared the imports of their
+// importing context
+void tst_qdeclarativeecmascript::importScope()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("importScope.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test").toInt(), 240);
+
+ delete o;
+}
+
/*
Tests that "any" type passes through a synthesized signal parameter. This
is essentially a test of QDeclarativeMetaType::copy()