forked from qt-creator/qt-creator
ClangCodeModel: fix crash on followSymbol
Big files are loaded in chunks inside a QEventLoop. If follow symbol is triggered via mouse and opens such a big file and the mouse is moved while loading that file ClangdFollowSymbol got deleted while opening the file in ClangdClient::followSymbol. Instead of the hard deletion just cancel that follow symbol operation and make sure done is emitted afterwards. The handling of that done signal takes care of the deletion of that follow symbol operation. Change-Id: Iba4ad6abb541186c2f26506f82fe1bc582818fca Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -90,6 +90,7 @@ public:
|
||||
void closeTempDocuments();
|
||||
bool addOpenFile(const FilePath &filePath);
|
||||
bool defLinkIsAmbiguous() const;
|
||||
void cancel();
|
||||
|
||||
ClangdFollowSymbol * const q;
|
||||
ClangdClient * const client;
|
||||
@@ -169,18 +170,17 @@ ClangdFollowSymbol::ClangdFollowSymbol(ClangdClient *client, const QTextCursor &
|
||||
|
||||
ClangdFollowSymbol::~ClangdFollowSymbol()
|
||||
{
|
||||
d->closeTempDocuments();
|
||||
if (d->virtualFuncAssistProcessor)
|
||||
d->virtualFuncAssistProcessor->resetData(false);
|
||||
for (const MessageId &id : std::as_const(d->pendingSymbolInfoRequests))
|
||||
d->client->cancelRequest(id);
|
||||
for (const MessageId &id : std::as_const(d->pendingGotoImplRequests))
|
||||
d->client->cancelRequest(id);
|
||||
for (const MessageId &id : std::as_const(d->pendingGotoDefRequests))
|
||||
d->client->cancelRequest(id);
|
||||
d->cancel();
|
||||
delete d;
|
||||
}
|
||||
|
||||
void ClangdFollowSymbol::cancel()
|
||||
{
|
||||
d->cancel();
|
||||
clear();
|
||||
emitDone();
|
||||
}
|
||||
|
||||
void ClangdFollowSymbol::clear()
|
||||
{
|
||||
d->openedFiles.clear();
|
||||
@@ -221,6 +221,19 @@ bool ClangdFollowSymbol::Private::defLinkIsAmbiguous() const
|
||||
return true;
|
||||
}
|
||||
|
||||
void ClangdFollowSymbol::Private::cancel()
|
||||
{
|
||||
closeTempDocuments();
|
||||
if (virtualFuncAssistProcessor)
|
||||
virtualFuncAssistProcessor->resetData(false);
|
||||
for (const MessageId &id : std::as_const(pendingSymbolInfoRequests))
|
||||
client->cancelRequest(id);
|
||||
for (const MessageId &id : std::as_const(pendingGotoImplRequests))
|
||||
client->cancelRequest(id);
|
||||
for (const MessageId &id : std::as_const(pendingGotoDefRequests))
|
||||
client->cancelRequest(id);
|
||||
}
|
||||
|
||||
bool ClangdFollowSymbol::Private::addOpenFile(const FilePath &filePath)
|
||||
{
|
||||
return openedFiles.insert(filePath).second;
|
||||
|
||||
Reference in New Issue
Block a user