App: Coverity fixes

This commit is contained in:
Chris Hennes
2025-03-02 23:21:30 -06:00
committed by Benjamin Nauck
parent eedb743959
commit 09cdcee1bb
11 changed files with 41 additions and 38 deletions

View File

@@ -75,14 +75,17 @@ QString ExpressionTokenizer::perform(const QString& prefix, int pos)
// Pop those trailing tokens depending on the given position, which may be
// in the middle of a token, and we shall include that token.
for (auto it = tokens.begin(); it != tokens.end(); ++it) {
if (std::get<1>(*it) >= pos) {
int tokenType = std::get<0>(*it);
int location = std::get<1>(*it);
int tokenLength = static_cast<int> (std::get<2>(*it).size());
if (location >= pos) {
// Include the immediately followed '.' or '#', because we'll be
// inserting these separators too, in ExpressionCompleteModel::pathFromIndex()
if (it != tokens.begin() && std::get<0>(*it) != '.' && std::get<0>(*it) != '#') {
if (it != tokens.begin() && tokenType != '.' && tokenType != '#') {
it = it - 1;
}
tokens.resize(it - tokens.begin() + 1);
prefixEnd = start + std::get<1>(*it) + (int)std::get<2>(*it).size();
tokens.resize(it - tokens.begin() + 1); // Invalidates it, but we already calculated tokenLength
prefixEnd = start + location + tokenLength;
break;
}
}