Skip to content
Snippets Groups Projects
Verified Commit 8011714a authored by Burak Hançerli's avatar Burak Hançerli :headphones:
Browse files

fix: warnings from the qml project are forwarded twice

parent 41c3790a
No related branches found
No related tags found
1 merge request!81fix: warnings from the qml project are forwarded twice (QDS-14772)
Pipeline #79900 passed
...@@ -7,6 +7,18 @@ ...@@ -7,6 +7,18 @@
#ifdef Q_OS_ANDROID #ifdef Q_OS_ANDROID
#include <android/log.h> #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 #endif
class Logger : public QObject class Logger : public QObject
...@@ -30,28 +42,35 @@ public: ...@@ -30,28 +42,35 @@ public:
const char *file = context.file ? context.file : ""; const char *file = context.file ? context.file : "";
const char *function = context.function ? context.function : ""; const char *function = context.function ? context.function : "";
enum android_LogPriority logPriority;
switch (type) { switch (type) {
case QtDebugMsg: case QtDebugMsg:
logPrefix = QStringLiteral("Debug: "); logPrefix = QStringLiteral("Debug: ");
logPriority = ANDROID_LOG_DEBUG;
break; break;
case QtInfoMsg: case QtInfoMsg:
logPrefix = QStringLiteral("Info: "); logPrefix = QStringLiteral("Info: ");
logPriority = ANDROID_LOG_INFO;
break; break;
case QtWarningMsg: case QtWarningMsg:
logPrefix = QStringLiteral("Warning: "); logPrefix = QStringLiteral("Warning: ");
logPriority = ANDROID_LOG_WARN;
break; break;
case QtCriticalMsg: case QtCriticalMsg:
logPrefix = QStringLiteral("Critical: "); logPrefix = QStringLiteral("Critical: ");
logPriority = ANDROID_LOG_ERROR;
break; break;
case QtFatalMsg: case QtFatalMsg:
logPrefix = QStringLiteral("Fatal: "); logPrefix = QStringLiteral("Fatal: ");
logSuffix = QStringLiteral(" (%1:%2, %3)").arg(file).arg(context.line).arg(function); logSuffix = QStringLiteral(" (%1:%2, %3)").arg(file).arg(context.line).arg(function);
logPriority = ANDROID_LOG_FATAL;
break; break;
} }
newLog += logPrefix + localMsg + logSuffix + "\n"; newLog += logPrefix + localMsg + logSuffix + "\n";
#ifdef Q_OS_ANDROID #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 #else
fprintf(stderr, "%s", qPrintable(newLog)); fprintf(stderr, "%s", qPrintable(newLog));
#endif #endif
......
...@@ -255,15 +255,6 @@ bool ProjectManager::runProjectInternal(const QByteArray &project) ...@@ -255,15 +255,6 @@ bool ProjectManager::runProjectInternal(const QByteArray &project)
m_qmlEngine->addImportPath(importPath); 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(); qDebug() << "Loading mainQmlUrl: " << mainQmlUrl.toString();
m_qmlComponent.reset(new QQmlComponent(m_qmlEngine.data())); m_qmlComponent.reset(new QQmlComponent(m_qmlEngine.data()));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment