aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-10-13 09:19:56 +0200
committerUlf Hermann <ulf.hermann@qt.io>2022-10-31 20:34:01 +0100
commit1a55fe5440b7a96d5d79349b816f25c44b99da87 (patch)
tree91e9eb56d322c23bb096a6e3733eb231c8cc51c0
parent60d31a301a19d11d5a4666b4ad76fbec658e4940 (diff)
QmlCompiler: Add a separate flag for the "pragma Strict" check
We want to trigger the qFatal() when running qmlcachegen or qmlsc, but we don't want to trigger it in qmllint, even if we are using the same QtMsgType for the severity of the messages. In turn, demote qmlCompiler messages to QtWarningMsg in qmlcachegen. Task-number: QTBUG-107168 Change-Id: Ib660df41742b2d426241eb29ac4c91f4933c5ba1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit bc528a0770150e3fde1fdab7b699379bc736b9e1)
-rw-r--r--src/qmlcompiler/qqmljscompiler.cpp5
-rw-r--r--src/qmlcompiler/qqmljslogger_p.h14
-rw-r--r--tools/qmlcachegen/qmlcachegen.cpp1
3 files changed, 17 insertions, 3 deletions
diff --git a/src/qmlcompiler/qqmljscompiler.cpp b/src/qmlcompiler/qqmljscompiler.cpp
index 76a7ed80e2..9e4c3a1cbb 100644
--- a/src/qmlcompiler/qqmljscompiler.cpp
+++ b/src/qmlcompiler/qqmljscompiler.cpp
@@ -648,9 +648,8 @@ QQmlJS::DiagnosticMessage QQmlJSAotCompiler::diagnose(
const QString &message, QtMsgType type, const QQmlJS::SourceLocation &location) const
{
if (isStrict(m_document)
- && (type == QtWarningMsg || type == QtCriticalMsg || type == QtFatalMsg)
- && !m_logger->isCategoryIgnored(Log_Compiler)
- && m_logger->categoryLevel(Log_Compiler) == QtCriticalMsg) {
+ && (type == QtWarningMsg || type == QtCriticalMsg || type == QtFatalMsg)
+ && m_logger->isCategoryFatal(Log_Compiler)) {
qFatal("%s:%d: (strict mode) %s",
qPrintable(QFileInfo(m_resourcePath).fileName()),
location.startLine, qPrintable(message));
diff --git a/src/qmlcompiler/qqmljslogger_p.h b/src/qmlcompiler/qqmljslogger_p.h
index 0302201eaf..9c89fd754a 100644
--- a/src/qmlcompiler/qqmljslogger_p.h
+++ b/src/qmlcompiler/qqmljslogger_p.h
@@ -201,6 +201,16 @@ public:
m_categoryChanged[category] = true;
}
+ bool isCategoryFatal(QQmlJSLoggerCategory category) const
+ {
+ return m_categoryFatal[category];
+ }
+ void setCategoryFatal(QQmlJSLoggerCategory category, bool error)
+ {
+ m_categoryFatal[category] = error;
+ m_categoryChanged[category] = true;
+ }
+
bool wasCategoryChanged(QQmlJSLoggerCategory category) const
{
return m_categoryChanged[category];
@@ -257,6 +267,10 @@ private:
bool m_categoryIgnored[QQmlJSLoggerCategory_Last + 1] = {};
bool m_categoryChanged[QQmlJSLoggerCategory_Last + 1] = {};
+ // If true, triggers qFatal on documents with "pragma Strict"
+ // TODO: Works only for qmlCompiler category so far.
+ bool m_categoryFatal[QQmlJSLoggerCategory_Last + 1] = {};
+
QList<Message> m_infos;
QList<Message> m_warnings;
QList<Message> m_errors;
diff --git a/tools/qmlcachegen/qmlcachegen.cpp b/tools/qmlcachegen/qmlcachegen.cpp
index 3a74f587e9..141c010272 100644
--- a/tools/qmlcachegen/qmlcachegen.cpp
+++ b/tools/qmlcachegen/qmlcachegen.cpp
@@ -246,6 +246,7 @@ int main(int argc, char **argv)
// Always trigger the qFatal() on "pragma Strict" violations.
logger.setCategoryLevel(Log_Compiler, QtCriticalMsg);
logger.setCategoryIgnored(Log_Compiler, false);
+ logger.setCategoryFatal(Log_Compiler, true);
// By default, we're completely silent,
// as the lcAotCompiler category default is QtFatalMsg