diff options
author | Andrei Golubev <andrei.golubev@qt.io> | 2021-02-25 16:56:49 +0100 |
---|---|---|
committer | Andrei Golubev <andrei.golubev@qt.io> | 2021-03-05 09:46:04 +0100 |
commit | 47bc004e32068a6a59ff32a43a1d1121ffe40a69 (patch) | |
tree | 170f37eaa0cf3ec42094459706655cb5fbb606b5 | |
parent | 79cde77f23358adbe57ab8ce08730d2de5bb1288 (diff) |
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 <ulf.hermann@qt.io>
-rw-r--r-- | src/qml/qml/qqmlcomponent.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
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 <QStringList> #include <QThreadStorage> #include <QtCore/qdebug.h> +#include <QtCore/qloggingcategory.h> #include <qqmlinfo.h> namespace { QThreadStorage<int> 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<QQmlContextData> 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; |