QQmlComponent: Do not load qrc file paths as file:// URLs
Otherwise we hit a strange code path that omits the AOT compiled functions. Pick-to: 6.5 Change-Id: I2ecc4387f8d5e8025aa8f8b32f1ee22e2edc66ed Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
parent
054f430232
commit
55e7bc2a70
|
@ -626,8 +626,12 @@ QQmlComponent::QQmlComponent(QQmlEngine *engine, const QString &fileName,
|
|||
: QQmlComponent(engine, parent)
|
||||
{
|
||||
Q_D(QQmlComponent);
|
||||
const QUrl url = QDir::isAbsolutePath(fileName) ? QUrl::fromLocalFile(fileName) : QUrl(fileName);
|
||||
d->loadUrl(url, mode);
|
||||
if (fileName.startsWith(u':'))
|
||||
d->loadUrl(QUrl(QLatin1String("qrc") + fileName), mode);
|
||||
else if (QDir::isAbsolutePath(fileName))
|
||||
d->loadUrl(QUrl::fromLocalFile(fileName), mode);
|
||||
else
|
||||
d->loadUrl(QUrl(fileName), mode);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
@ -43,6 +43,7 @@ qt_add_qml_module(
|
|||
AUTO_RESOURCE_PREFIX
|
||||
QML_FILES
|
||||
"data/TestComponentWithIC.qml"
|
||||
"data/withAot.qml"
|
||||
)
|
||||
|
||||
# Resources:
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
pragma Strict
|
||||
import QtQml
|
||||
|
||||
QtObject {
|
||||
objectName: "A" + " fine " + 93939 + " number"
|
||||
}
|
|
@ -13,10 +13,12 @@
|
|||
#include <QtQuick/private/qquickpalette_p.h>
|
||||
#include <QtQuickTestUtils/private/qmlutils_p.h>
|
||||
#include <QtQuickTestUtils/private/testhttpserver_p.h>
|
||||
#include <private/qqmlcomponent_p.h>
|
||||
#include <private/qqmlguardedcontextdata_p.h>
|
||||
#include <private/qv4qmlcontext_p.h>
|
||||
#include <private/qv4scopedvalue_p.h>
|
||||
#include <private/qv4qmlcontext_p.h>
|
||||
#include <private/qv4scopedvalue_p.h>
|
||||
#include <private/qv4executablecompilationunit_p.h>
|
||||
#include <qcolor.h>
|
||||
#include <qsignalspy.h>
|
||||
|
||||
|
@ -142,6 +144,7 @@ private slots:
|
|||
void loadFromModuleFailures_data();
|
||||
void loadFromModuleFailures();
|
||||
void loadFromModuleRequired();
|
||||
void loadFromQrc();
|
||||
|
||||
private:
|
||||
QQmlEngine engine;
|
||||
|
@ -1408,6 +1411,18 @@ void tst_qqmlcomponent::loadFromModuleRequired()
|
|||
QVERIFY(!root);
|
||||
}
|
||||
|
||||
void tst_qqmlcomponent::loadFromQrc()
|
||||
{
|
||||
QQmlEngine engine;
|
||||
QQmlComponent component(&engine, QStringLiteral(":/qt/qml/test/data/withAot.qml"));
|
||||
QVERIFY2(component.isReady(), qPrintable(component.errorString()));
|
||||
|
||||
QQmlComponentPrivate *p = QQmlComponentPrivate::get(&component);
|
||||
QVERIFY(p);
|
||||
QVERIFY(p->compilationUnit);
|
||||
QVERIFY(p->compilationUnit->aotCompiledFunctions);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_qqmlcomponent)
|
||||
|
||||
#include "tst_qqmlcomponent.moc"
|
||||
|
|
Loading…
Reference in New Issue