From: Aaron Kennedy Date: Thu, 23 Jun 2011 01:20:00 +0000 (+1000) Subject: Fix regression against 4.7 X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=b35d6b475333fc2fabd0e91f1bfcf2f65aa4d4f4;p=konrad%2Fqtdeclarative.git Fix regression against 4.7 Task-number: QTBUG-19136 --- diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp index a9b303c..8959f17 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 0000000..4c556f9 --- /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 0000000..291fb9d --- /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 0000000..a72847f --- /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 cabadde..3c4c336 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()