Immediately complete component upon creation failure
We do not want to wait until reaching the Component destructor (at which point e.g. the engine might be gone). Pick-to: 6.2 6.3 Change-Id: Ic0e4383ec4e3759d9f02847413a25191a01286cb Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
parent
ed7dd5ad01
commit
759090f591
|
@ -862,8 +862,16 @@ QObject *QQmlComponent::create(QQmlContext *context)
|
|||
Q_D(QQmlComponent);
|
||||
|
||||
QObject *rv = d->doBeginCreate(this, context);
|
||||
if (rv)
|
||||
if (rv) {
|
||||
completeCreate();
|
||||
} else if (d->state.completePending) {
|
||||
// overridden completCreate might assume that
|
||||
// the object has actually been created
|
||||
++creationDepth;
|
||||
QQmlEnginePrivate *ep = QQmlEnginePrivate::get(d->engine);
|
||||
d->complete(ep, &d->state);
|
||||
--creationDepth;
|
||||
}
|
||||
if (rv && !d->requiredProperties().empty()) {
|
||||
delete rv;
|
||||
return nullptr;
|
||||
|
|
|
@ -4427,9 +4427,6 @@ void tst_qqmllanguage::deepProperty()
|
|||
void tst_qqmllanguage::groupAssignmentFailure()
|
||||
{
|
||||
auto ep = std::make_unique<QQmlEngine>();
|
||||
QTest::ignoreMessage(QtMsgType::QtWarningMsg, "QQmlComponent: Component destroyed while completion pending");
|
||||
QTest::ignoreMessage(QtMsgType::QtWarningMsg, "This may have been caused by one of the following errors:");
|
||||
QTest::ignoreMessage(QtMsgType::QtWarningMsg, QRegularExpression(".*Cannot set properties on b as it is null.*"));
|
||||
QTest::ignoreMessage(QtMsgType::QtWarningMsg, QRegularExpression(".*Invalid property assignment: url expected - Assigning null to incompatible properties in QML is deprecated. This will become a compile error in future versions of Qt..*"));
|
||||
QQmlComponent component(ep.get(), testFileUrl("groupFailure.qml"));
|
||||
QScopedPointer<QObject> o(component.create());
|
||||
|
|
Loading…
Reference in New Issue