ClangCodeModel: Fix potential crash

... when removing from the list of FollowSymbol operations. The done()
callback of ClangdFollowSymbol messes with the list, so call cancel()
after removing the corresponding iterator.

Change-Id: Ibb72ffa436598692e48119d93d430bb79bcb0f5e
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2024-06-03 13:59:46 +02:00
parent 173aed9b8e
commit 408e986f2b

View File

@@ -1011,9 +1011,10 @@ void ClangdClient::followSymbol(TextDocument *document,
: ClangdFollowSymbol::Origin::Code;
if (origin == ClangdFollowSymbol::Origin::User) {
for (auto it = d->followSymbolOps.begin(); it != d->followSymbolOps.end(); ) {
if ((*it)->isInteractive()) {
(*it)->cancel();
ClangdFollowSymbol * const followSymbol = *it;
if (followSymbol->isInteractive()) {
it = d->followSymbolOps.erase(it);
followSymbol->cancel();
} else {
++it;
}