aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qmlcompiler/qqmljslogger.cpp2
-rw-r--r--src/qmlcompiler/qqmljslogger_p.h5
2 files changed, 4 insertions, 3 deletions
diff --git a/src/qmlcompiler/qqmljslogger.cpp b/src/qmlcompiler/qqmljslogger.cpp
index 976f706a9b..3f00265c62 100644
--- a/src/qmlcompiler/qqmljslogger.cpp
+++ b/src/qmlcompiler/qqmljslogger.cpp
@@ -274,7 +274,7 @@ void QQmlJSLogger::log(const QString &message, LoggerWarningId id,
default: break;
}
- if (srcLocation.isValid() && !m_code.isEmpty() && showContext)
+ if (srcLocation.length > 0 && !m_code.isEmpty() && showContext)
printContext(overrideFileName, srcLocation);
if (suggestion.has_value())
diff --git a/src/qmlcompiler/qqmljslogger_p.h b/src/qmlcompiler/qqmljslogger_p.h
index 34be098832..f5b089a86c 100644
--- a/src/qmlcompiler/qqmljslogger_p.h
+++ b/src/qmlcompiler/qqmljslogger_p.h
@@ -45,9 +45,10 @@ public:
\param location: The location where an error occurred.
*/
IssueLocationWithContext(QStringView code, const QQmlJS::SourceLocation &location) {
- int before = qMax(0,code.lastIndexOf(QLatin1Char('\n'), location.offset));
+ qsizetype before = qMax(0, code.lastIndexOf(QLatin1Char('\n'), location.offset));
- if (before != 0) before++;
+ if (before != 0 && before < location.offset)
+ before++;
m_beforeText = code.mid(before, location.offset - before);
m_issueText = code.mid(location.offset, location.length);