forked from qt-creator/qt-creator
CppTools: Avoid unnecessary blocking of main thread
Among others, BaseEditorDocumentParser::projectPart() was a blocking operation in case the parser was running. This led to noticeable GUI freezes for the ClangCodeModel since the function was called from the main thread. Rework *EditorDocumentParser to clearly separate the configuration data (input) from the actual object state. Querying/setting configuration or (last) state does not block anymore. update() is supposed to get the necessary configuration and the last state at the beginning and to set the new state at end. Change-Id: Ib4b534fa6ff373c3059826726b3f10ece95acc21 Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
This commit is contained in:
@@ -37,7 +37,6 @@
|
||||
|
||||
#include <cplusplus/CppDocument.h>
|
||||
|
||||
#include <QMutex>
|
||||
#include <QString>
|
||||
|
||||
namespace CppTools {
|
||||
@@ -49,14 +48,16 @@ class CPPTOOLS_EXPORT BuiltinEditorDocumentParser : public BaseEditorDocumentPar
|
||||
public:
|
||||
BuiltinEditorDocumentParser(const QString &filePath);
|
||||
|
||||
bool releaseSourceAndAST() const;
|
||||
void setReleaseSourceAndAST(bool release);
|
||||
|
||||
void update(WorkingCopy workingCopy) override;
|
||||
void releaseResources();
|
||||
|
||||
CPlusPlus::Document::Ptr document() const;
|
||||
CPlusPlus::Snapshot snapshot() const;
|
||||
ProjectPart::HeaderPaths headerPaths() const;
|
||||
|
||||
void setReleaseSourceAndAST(bool onoff);
|
||||
void releaseResources();
|
||||
|
||||
signals:
|
||||
void finished(CPlusPlus::Document::Ptr document, CPlusPlus::Snapshot snapshot);
|
||||
@@ -65,18 +66,26 @@ public:
|
||||
static BuiltinEditorDocumentParser *get(const QString &filePath);
|
||||
|
||||
private:
|
||||
void addFileAndDependencies(QSet<Utils::FileName> *toRemove, const Utils::FileName &fileName) const;
|
||||
void addFileAndDependencies(CPlusPlus::Snapshot *snapshot,
|
||||
QSet<Utils::FileName> *toRemove,
|
||||
const Utils::FileName &fileName) const;
|
||||
|
||||
private:
|
||||
QByteArray m_configFile;
|
||||
struct ExtraState {
|
||||
QByteArray configFile;
|
||||
|
||||
ProjectPart::HeaderPaths m_headerPaths;
|
||||
QString m_projectConfigFile;
|
||||
QStringList m_precompiledHeaders;
|
||||
ProjectPart::HeaderPaths headerPaths;
|
||||
QString projectConfigFile;
|
||||
QStringList precompiledHeaders;
|
||||
|
||||
CPlusPlus::Snapshot m_snapshot;
|
||||
bool m_forceSnapshotInvalidation;
|
||||
bool m_releaseSourceAndAST;
|
||||
CPlusPlus::Snapshot snapshot;
|
||||
bool forceSnapshotInvalidation = false;
|
||||
};
|
||||
|
||||
ExtraState extraState() const;
|
||||
void setExtraState(const ExtraState &extraState);
|
||||
|
||||
bool m_releaseSourceAndAST = true;
|
||||
ExtraState m_extraState;
|
||||
};
|
||||
|
||||
} // namespace CppTools
|
||||
|
||||
Reference in New Issue
Block a user