forked from qt-creator/qt-creator
CppTools: Avoid concurrent access to QTextDocument
Do not pass QTextCursor to another thread, but determine what we need from it in the main thread. Change-Id: I86900cfc5a28849efc1bd1dacb9b1452a5db252e Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -163,22 +163,23 @@ private:
|
|||||||
class FindUses
|
class FindUses
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static CursorInfo find(const QTextCursor &textCursor,
|
static CursorInfo find(const Document::Ptr document, const Snapshot &snapshot,
|
||||||
const Document::Ptr document,
|
int line, int column, Scope *scope, const QString &expression)
|
||||||
const Snapshot &snapshot)
|
|
||||||
{
|
{
|
||||||
const FindUses findUses(textCursor, document, snapshot);
|
FindUses findUses(document, snapshot, line, column, scope, expression);
|
||||||
return findUses.doFind();
|
return findUses.doFind();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FindUses(const QTextCursor &textCursor, const Document::Ptr document, const Snapshot &snapshot)
|
FindUses(const Document::Ptr document, const Snapshot &snapshot, int line, int column,
|
||||||
: m_document(document), m_snapshot(snapshot)
|
Scope *scope, const QString &expression)
|
||||||
|
: m_document(document)
|
||||||
|
, m_line(line)
|
||||||
|
, m_column(column)
|
||||||
|
, m_scope(scope)
|
||||||
|
, m_expression(expression)
|
||||||
|
, m_snapshot(snapshot)
|
||||||
{
|
{
|
||||||
TextEditor::Convenience::convertPosition(textCursor.document(), textCursor.position(),
|
|
||||||
&m_line, &m_column);
|
|
||||||
CanonicalSymbol canonicalSymbol(document, snapshot);
|
|
||||||
m_scope = canonicalSymbol.getScopeAndExpression(textCursor, &m_expression);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CursorInfo doFind() const
|
CursorInfo doFind() const
|
||||||
@@ -353,7 +354,15 @@ QFuture<CursorInfo> BuiltinCursorInfo::run(const CursorInfoParams &cursorInfoPar
|
|||||||
return fi.future();
|
return fi.future();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Utils::runAsync(&FindUses::find, cursorInfoParams.textCursor, document, snapshot);
|
const QTextCursor &textCursor = cursorInfoParams.textCursor;
|
||||||
|
int line, column;
|
||||||
|
TextEditor::Convenience::convertPosition(textCursor.document(), textCursor.position(),
|
||||||
|
&line, &column);
|
||||||
|
CanonicalSymbol canonicalSymbol(document, snapshot);
|
||||||
|
QString expression;
|
||||||
|
Scope *scope = canonicalSymbol.getScopeAndExpression(textCursor, &expression);
|
||||||
|
|
||||||
|
return Utils::runAsync(&FindUses::find, document, snapshot, line, column, scope, expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user