forked from qt-creator/qt-creator
CppTools: Do not block GUI thread for completions
The GUI was blocked while waiting for the parsed document. Now the blocking operation is executed in the completion thread. Task-number: QTCREATORBUG-11037 Task-number: QTCREATORBUG-11433 Change-Id: Ia7c1b1b7eea0ba75010ff667ba05273c62c18491 Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -28,10 +28,13 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "cppcompletionassist.h"
|
||||
|
||||
#include "cppdoxygen.h"
|
||||
#include "cppmodelmanager.h"
|
||||
#include "cppmodelmanagerinterface.h"
|
||||
#include "cppsnapshotupdater.h"
|
||||
#include "cpptoolsconstants.h"
|
||||
#include "cpptoolseditorsupport.h"
|
||||
#include "cppdoxygen.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <cppeditor/cppeditorconstants.h>
|
||||
@@ -422,24 +425,9 @@ TextEditor::IAssistInterface *InternalCompletionAssistProvider::createAssistInte
|
||||
int position, TextEditor::AssistReason reason) const
|
||||
{
|
||||
Q_UNUSED(project);
|
||||
|
||||
CppModelManagerInterface *modelManager = CppModelManagerInterface::instance();
|
||||
|
||||
if (CppEditorSupport *supp = modelManager->cppEditorSupport(editor)) {
|
||||
if (QSharedPointer<SnapshotUpdater> updater = supp->snapshotUpdater()) {
|
||||
updater->update(modelManager->workingCopy());
|
||||
return new CppTools::Internal::CppCompletionAssistInterface(
|
||||
document,
|
||||
position,
|
||||
editor->document()->filePath(),
|
||||
reason,
|
||||
updater->snapshot(),
|
||||
updater->includePaths(),
|
||||
updater->frameworkPaths());
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
QTC_ASSERT(editor, return 0);
|
||||
QTC_ASSERT(document, return 0);
|
||||
return new CppTools::Internal::CppCompletionAssistInterface(editor, document, position, reason);
|
||||
}
|
||||
|
||||
// -----------------
|
||||
@@ -1930,3 +1918,20 @@ bool CppCompletionAssistProcessor::completeConstructorOrFunction(const QList<CPl
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CppCompletionAssistInterface::getCppSpecifics() const
|
||||
{
|
||||
if (m_gotCppSpecifics)
|
||||
return;
|
||||
m_gotCppSpecifics = true;
|
||||
|
||||
CppModelManagerInterface *modelManager = CppModelManagerInterface::instance();
|
||||
if (CppEditorSupport *supp = modelManager->cppEditorSupport(m_editor)) {
|
||||
if (QSharedPointer<SnapshotUpdater> updater = supp->snapshotUpdater()) {
|
||||
updater->update(modelManager->workingCopy());
|
||||
m_snapshot = updater->snapshot();
|
||||
m_includePaths = updater->includePaths();
|
||||
m_frameworkPaths = updater->frameworkPaths();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
# include <cplusplus/Symbol.h>
|
||||
#endif
|
||||
|
||||
#include <texteditor/basetexteditor.h>
|
||||
#include <texteditor/codeassist/basicproposalitemlistmodel.h>
|
||||
#include <texteditor/codeassist/defaultassistinterface.h>
|
||||
#include <texteditor/codeassist/iassistprocessor.h>
|
||||
@@ -170,6 +171,16 @@ private:
|
||||
class CppCompletionAssistInterface : public TextEditor::DefaultAssistInterface
|
||||
{
|
||||
public:
|
||||
CppCompletionAssistInterface(TextEditor::BaseTextEditor *editor,
|
||||
QTextDocument *textDocument,
|
||||
int position,
|
||||
TextEditor::AssistReason reason)
|
||||
: TextEditor::DefaultAssistInterface(textDocument, position, editor->document()->filePath(),
|
||||
reason)
|
||||
, m_editor(editor)
|
||||
, m_gotCppSpecifics(false)
|
||||
{}
|
||||
|
||||
CppCompletionAssistInterface(QTextDocument *textDocument,
|
||||
int position,
|
||||
const QString &fileName,
|
||||
@@ -178,19 +189,25 @@ public:
|
||||
const QStringList &includePaths,
|
||||
const QStringList &frameworkPaths)
|
||||
: TextEditor::DefaultAssistInterface(textDocument, position, fileName, reason)
|
||||
, m_editor(0)
|
||||
, m_gotCppSpecifics(true)
|
||||
, m_snapshot(snapshot)
|
||||
, m_includePaths(includePaths)
|
||||
, m_frameworkPaths(frameworkPaths)
|
||||
{}
|
||||
|
||||
const CPlusPlus::Snapshot &snapshot() const { return m_snapshot; }
|
||||
const QStringList &includePaths() const { return m_includePaths; }
|
||||
const QStringList &frameworkPaths() const { return m_frameworkPaths; }
|
||||
const CPlusPlus::Snapshot &snapshot() const { getCppSpecifics(); return m_snapshot; }
|
||||
const QStringList &includePaths() const { getCppSpecifics(); return m_includePaths; }
|
||||
const QStringList &frameworkPaths() const { getCppSpecifics(); return m_frameworkPaths; }
|
||||
|
||||
private:
|
||||
CPlusPlus::Snapshot m_snapshot;
|
||||
QStringList m_includePaths;
|
||||
QStringList m_frameworkPaths;
|
||||
void getCppSpecifics() const;
|
||||
|
||||
TextEditor::BaseTextEditor *m_editor;
|
||||
mutable bool m_gotCppSpecifics;
|
||||
mutable CPlusPlus::Snapshot m_snapshot;
|
||||
mutable QStringList m_includePaths;
|
||||
mutable QStringList m_frameworkPaths;
|
||||
};
|
||||
|
||||
} // Internal
|
||||
|
||||
Reference in New Issue
Block a user