result = i->result();
} else {
+ QScopedPointer<QV4::Script> script;
- QFile f(localFile);
+ if (const QQmlPrivate::CachedQmlUnit *cachedUnit = QQmlMetaType::findCachedCompilationUnit(url)) {
+ QV4::CompiledData::CompilationUnit *jsUnit = cachedUnit->createCompilationUnit();
+ script.reset(new QV4::Script(v4, qmlcontextobject, jsUnit));
+ } else {
+ QFile f(localFile);
- if (f.open(QIODevice::ReadOnly)) {
- QByteArray data = f.readAll();
- QString code = QString::fromUtf8(data);
- QmlIR::Document::removeScriptPragmas(code);
+ if (f.open(QIODevice::ReadOnly)) {
+ QByteArray data = f.readAll();
+ QString code = QString::fromUtf8(data);
+ QmlIR::Document::removeScriptPragmas(code);
- QV4::Script script(v4, qmlcontextobject, code, url.toString());
+ script.reset(new QV4::Script(v4, qmlcontextobject, code, url.toString()));
+ }
+ }
+ if (!script.isNull()) {
QV4::ExecutionContext *ctx = v4->currentContext();
- script.parse();
+ script->parse();
if (!v4->hasException)
- script.run();
+ script->run();
if (v4->hasException) {
QV4::ScopedValue ex(scope, ctx->catchException());
result = resultValue(v4, Exception);
--- /dev/null
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+<file>data/include.qml</file>
+<file>data/include.js</file>
+<file>data/js/include2.js</file>
+<file>data/js/include3.js</file>
+</qresource>
+</RCC>
delete o;
}
+
+ // include from resources
+ {
+ QQmlComponent component(&engine, QUrl("qrc:///data/include.qml"));
+ QObject *o = component.create();
+ QVERIFY(o != 0);
+
+ QCOMPARE(o->property("test0").toInt(), 99);
+ QCOMPARE(o->property("test1").toBool(), true);
+ QCOMPARE(o->property("test2").toBool(), true);
+ QCOMPARE(o->property("test2_1").toBool(), true);
+ QCOMPARE(o->property("test3").toBool(), true);
+ QCOMPARE(o->property("test3_1").toBool(), true);
+
+ delete o;
+ }
+
}
void tst_qqmlecmascript::includeRemoteSuccess()