ClassView: Move the GUI related code out of Parser

Don't create QStandardItem objects inside the non-gui thread,
as it was in case of requestCurrentState() which is always
called in parser's thread. As a result of parsing send a root's
ParserTreeItem::ConstPtr now instead. Store the generated
root inside Manager instead of inside Parser. Remove rootItemLocker
as it's not needed now anymore. Move the implementation of
canFetchMore(), fetchMore() and hasChildren() into Manager class.

Now all the API of Parser class is used only in parser's thread
(with the exception of constructor and destructor).

Task-number: QTCREATORBUG-25317
Change-Id: I2b3c49918bf58266e6bea8acf65c975e19f7d9cb
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Jarek Kobus
2021-02-16 14:01:16 +01:00
parent ab7560bec4
commit a513f25c39
5 changed files with 61 additions and 107 deletions

View File

@@ -52,11 +52,6 @@ public:
explicit Parser(QObject *parent = nullptr);
~Parser() override;
// TODO: below three methods are called directly from different thread
bool canFetchMore(QStandardItem *item, bool skipRoot = false) const;
void fetchMore(QStandardItem *item, bool skipRoot = false) const;
bool hasChildren(QStandardItem *item) const;
void requestCurrentState();
void removeFiles(const QStringList &fileList);
void resetDataToCurrentState();
@@ -65,7 +60,7 @@ public:
void aboutToShutdown();
signals:
void treeDataUpdate(QSharedPointer<QStandardItem> result);
void treeRegenerated(const ParserTreeItem::ConstPtr &root);
private:
void setFileList(const QStringList &fileList);
@@ -77,7 +72,6 @@ private:
ParserTreeItem::Ptr getCachedOrParseProjectTree(const QStringList &fileList,
const QString &projectId);
ParserTreeItem::ConstPtr parse();
ParserTreeItem::ConstPtr findItemByRoot(const QStandardItem *item, bool skipRoot = false) const;
QStringList getAllFiles(const ProjectExplorer::Project *project);
ParserTreeItem::Ptr addFlatTree(const ProjectExplorer::Project *project);