From fba3abf881f3d3eaa72cc9f4e81793f64143fea8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Han=C3=A7erli?= <burak.hancerli@qt.io> Date: Mon, 3 Mar 2025 14:59:23 +0000 Subject: [PATCH] fix: warnings from the qml project are forwarded twice (QDS-14772) --- src/backend/logger.h | 21 ++++++++++++++++++++- src/backend/projectmanager.cpp | 9 --------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/backend/logger.h b/src/backend/logger.h index 844f2dc..4b86db7 100644 --- a/src/backend/logger.h +++ b/src/backend/logger.h @@ -7,6 +7,18 @@ #ifdef Q_OS_ANDROID #include <android/log.h> +#else +enum android_LogPriority { + ANDROID_LOG_UNKNOWN = 0, + ANDROID_LOG_DEFAULT, + ANDROID_LOG_VERBOSE, + ANDROID_LOG_DEBUG, + ANDROID_LOG_INFO, + ANDROID_LOG_WARN, + ANDROID_LOG_ERROR, + ANDROID_LOG_FATAL, + ANDROID_LOG_SILENT, +}; #endif class Logger : public QObject @@ -30,28 +42,35 @@ public: const char *file = context.file ? context.file : ""; const char *function = context.function ? context.function : ""; + enum android_LogPriority logPriority; + switch (type) { case QtDebugMsg: logPrefix = QStringLiteral("Debug: "); + logPriority = ANDROID_LOG_DEBUG; break; case QtInfoMsg: logPrefix = QStringLiteral("Info: "); + logPriority = ANDROID_LOG_INFO; break; case QtWarningMsg: logPrefix = QStringLiteral("Warning: "); + logPriority = ANDROID_LOG_WARN; break; case QtCriticalMsg: logPrefix = QStringLiteral("Critical: "); + logPriority = ANDROID_LOG_ERROR; break; case QtFatalMsg: logPrefix = QStringLiteral("Fatal: "); logSuffix = QStringLiteral(" (%1:%2, %3)").arg(file).arg(context.line).arg(function); + logPriority = ANDROID_LOG_FATAL; break; } newLog += logPrefix + localMsg + logSuffix + "\n"; #ifdef Q_OS_ANDROID - __android_log_print(ANDROID_LOG_DEBUG, "Qt_UI_Viewer", "%s", qPrintable(newLog)); + __android_log_print(logPriority, "Qt_UI_Viewer", "%s", qPrintable(newLog)); #else fprintf(stderr, "%s", qPrintable(newLog)); #endif diff --git a/src/backend/projectmanager.cpp b/src/backend/projectmanager.cpp index 90a1e04..44d6ea5 100644 --- a/src/backend/projectmanager.cpp +++ b/src/backend/projectmanager.cpp @@ -255,15 +255,6 @@ bool ProjectManager::runProjectInternal(const QByteArray &project) m_qmlEngine->addImportPath(importPath); } - QObject::connect(m_qmlEngine.data(), - &QQmlEngine::warnings, - this, - [&](const QList<QQmlError> &warnings) { - for (const auto &warning : warnings) { - qWarning() << warning.toString(); - } - }); - qDebug() << "Loading mainQmlUrl: " << mainQmlUrl.toString(); m_qmlComponent.reset(new QQmlComponent(m_qmlEngine.data())); -- GitLab