From 47bc004e32068a6a59ff32a43a1d1121ffe40a69 Mon Sep 17 00:00:00 2001 From: Andrei Golubev Date: Thu, 25 Feb 2021 16:56:49 +0100 Subject: Log errors in QQmlComponent Add logging to QQmlComponent::create(). For instance, this handles cases when errors (non-logged) occur before the QQmlObjectCreator. What would typically be written is "QQmlComponent: Component is not ready", which is, well, not helpful Change-Id: Ia7aabe68d8f42f64b00528a3559830f54a3821d8 Reviewed-by: Ulf Hermann --- src/qml/qml/qqmlcomponent.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index d1aa2a09db..7d9261604e 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -64,12 +64,15 @@ #include #include #include +#include #include namespace { QThreadStorage creationDepth; } +Q_LOGGING_CATEGORY(lcQmlComponentGeneral, "qt.qml.qmlcomponent") + QT_BEGIN_NAMESPACE class QQmlComponentExtension : public QV4::ExecutionEngine::Deletable @@ -890,6 +893,12 @@ QObject *QQmlComponent::beginCreate(QQmlContext *publicContext) QObject *QQmlComponentPrivate::beginCreate(QQmlRefPointer context) { Q_Q(QQmlComponent); + auto cleanup = qScopeGuard([this] { + if (!state.errors.isEmpty()) { + for (const auto &e : qAsConst(state.errors)) + qCDebug(lcQmlComponentGeneral) << "QQmlComponent: " << e.toString(); + } + }); if (!context) { qWarning("QQmlComponent: Cannot create a component in a null context"); return nullptr; -- cgit v1.2.3