StackView: improve the component creation errors

Previously it just dumped the error from the component, without telling
that it was anyhow related to StackView. Now it uses the standard QML
warning syntax and includes the name of the operation (push/replace).

Task-number: QTBUG-59634
Change-Id: Iea8df51f587c243ca065627e59bb0e5b5b526664
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
This commit is contained in:
J-P Nurmi 2017-03-23 11:35:18 +01:00
parent 7c7b58c732
commit 9ccdc189c7
2 changed files with 6 additions and 4 deletions

View File

@ -152,7 +152,7 @@ bool QQuickStackElement::load(QQuickStackView *parent)
if (status == QQmlComponent::Ready)
load(view);
else if (status == QQmlComponent::Error)
qWarning() << qPrintable(component->errorString().trimmed());
QQuickStackViewPrivate::get(view)->warn(component->errorString().trimmed());
});
return true;
}
@ -166,7 +166,7 @@ bool QQuickStackElement::load(QQuickStackView *parent)
QQuickStackIncubator incubator(this);
component->create(incubator, context);
if (component->isError())
qWarning() << qPrintable(component->errorString().trimmed());
QQuickStackViewPrivate::get(parent)->warn(component->errorString().trimmed());
} else {
initialize();
}

View File

@ -907,12 +907,14 @@ TestCase {
var control = createTemporaryObject(stackView, testCase, {initialItem: component})
verify(control)
var error = Qt.resolvedUrl("non-existent.qml") + ":-1 No such file or directory"
ignoreWarning("QQmlComponent: Component is not ready")
ignoreWarning(Qt.resolvedUrl("non-existent.qml") + ":-1 No such file or directory")
ignoreWarning(Qt.resolvedUrl("tst_stackview.qml") + ":69:9: QML StackView: push: " + error)
control.push(Qt.resolvedUrl("non-existent.qml"))
ignoreWarning("QQmlComponent: Component is not ready")
ignoreWarning(Qt.resolvedUrl("non-existent.qml") + ":-1 No such file or directory")
ignoreWarning(Qt.resolvedUrl("tst_stackview.qml") + ":69:9: QML StackView: replace: " + error)
control.replace(Qt.resolvedUrl("non-existent.qml"))
control.pop()