diff options
author | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2017-06-16 14:15:02 +0200 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2017-06-20 07:42:06 +0000 |
commit | e50ad1e09c67414bb993f06fe66c275c3fe4ffb7 (patch) | |
tree | bbd7e617daa8b6f1d9e36265832d9901a4a90f41 /src/plugins/cpptools/builtincursorinfo.cpp | |
parent | 17b197f3033ee3d88f52e380535335fe6db3d3a3 (diff) | |
download | qt-creator-e50ad1e09c67414bb993f06fe66c275c3fe4ffb7.tar.gz |
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>
Diffstat (limited to 'src/plugins/cpptools/builtincursorinfo.cpp')
-rw-r--r-- | src/plugins/cpptools/builtincursorinfo.cpp | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/plugins/cpptools/builtincursorinfo.cpp b/src/plugins/cpptools/builtincursorinfo.cpp index 90c871269f..cd46380e19 100644 --- a/src/plugins/cpptools/builtincursorinfo.cpp +++ b/src/plugins/cpptools/builtincursorinfo.cpp @@ -163,22 +163,23 @@ private: class FindUses { public: - static CursorInfo find(const QTextCursor &textCursor, - const Document::Ptr document, - const Snapshot &snapshot) + static CursorInfo find(const Document::Ptr document, const Snapshot &snapshot, + int line, int column, Scope *scope, const QString &expression) { - const FindUses findUses(textCursor, document, snapshot); + FindUses findUses(document, snapshot, line, column, scope, expression); return findUses.doFind(); } private: - FindUses(const QTextCursor &textCursor, const Document::Ptr document, const Snapshot &snapshot) - : m_document(document), m_snapshot(snapshot) + FindUses(const Document::Ptr document, const Snapshot &snapshot, int line, int column, + 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 @@ -353,7 +354,15 @@ QFuture<CursorInfo> BuiltinCursorInfo::run(const CursorInfoParams &cursorInfoPar 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 |