summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cppcodeformatter.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2020-09-15 15:27:32 +0200
committerEike Ziller <eike.ziller@qt.io>2020-09-15 13:57:32 +0000
commit242579099a3fd31499e03b945e866e7159f4a1fb (patch)
tree25a1962b6b5901767a339f0a8103d00400bbdcba /src/plugins/cpptools/cppcodeformatter.cpp
parent432247357edfcea96b2f6a66dd17f398e9e55575 (diff)
downloadqt-creator-242579099a3fd31499e03b945e866e7159f4a1fb.tar.gz
CppTools: Fix QStringRef and QSharedPointer related issues with Qt6
Task-number: QTCREATORBUG-24098 Change-Id: I97347ac3fb397fea8eee655e3cc4ee252c511885 Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins/cpptools/cppcodeformatter.cpp')
-rw-r--r--src/plugins/cpptools/cppcodeformatter.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/plugins/cpptools/cppcodeformatter.cpp b/src/plugins/cpptools/cppcodeformatter.cpp
index c8ba07fbe0..ddd1079c32 100644
--- a/src/plugins/cpptools/cppcodeformatter.cpp
+++ b/src/plugins/cpptools/cppcodeformatter.cpp
@@ -528,7 +528,7 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
}
}
- QStringRef tokenText = currentTokenText();
+ QStringView tokenText = currentTokenText();
if (tokenText == QLatin1String("ifdef")
|| tokenText == QLatin1String("if")
|| tokenText == QLatin1String("ifndef")) {
@@ -854,7 +854,7 @@ bool CodeFormatter::tryDeclaration()
return true;
case T_IDENTIFIER:
if (m_tokenIndex == 0) {
- const QStringRef tokenText = currentTokenText();
+ const QStringView tokenText = currentTokenText();
if (tokenText.startsWith(QLatin1String("Q_"))
|| tokenText.startsWith(QLatin1String("QT_"))
|| tokenText.startsWith(QLatin1String("QML_"))
@@ -1009,9 +1009,11 @@ int CodeFormatter::column(int index) const
return col;
}
-QStringRef CodeFormatter::currentTokenText() const
+QStringView CodeFormatter::currentTokenText() const
{
- return m_currentLine.midRef(m_currentToken.utf16charsBegin(), m_currentToken.utf16chars());
+ if (m_currentToken.utf16charsEnd() > m_currentLine.size())
+ return QStringView(m_currentLine).mid(m_currentToken.utf16charsBegin());
+ return QStringView(m_currentLine).mid(m_currentToken.utf16charsBegin(), m_currentToken.utf16chars());
}
void CodeFormatter::turnInto(int newState)