Clang: Do not call built-in follow symbol with no document

CppEditor tests (the part which works with ClangCodeModel) showed
that it's possible that QTextCursor might get document reset
to the moment we try to call built-in follow symbol. That means
that the editor widget is closed already.

Check for the document to prevent such behavior.

Change-Id: I2463f4688dc6fca7f701fba243ffc6e43a573b33
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
Ivan Donchevskii
2018-11-06 14:50:35 +01:00
parent ea0837377b
commit d47cb48909

View File

@@ -491,10 +491,13 @@ void FollowSymbolUnderCursor::findLink(
{
Link link;
int line = 0;
int column = 0;
QTextCursor cursor = data.cursor();
QTextDocument *document = cursor.document();
if (!document)
return processLinkCallback(link);
int line = 0;
int column = 0;
Utils::Text::convertPosition(document, cursor.position(), &line, &column);
const int positionInBlock = column - 1;