summaryrefslogtreecommitdiff
path: root/src/plugins/classview/classviewparser.cpp
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2021-02-16 14:01:16 +0100
committerJarek Kobus <jaroslaw.kobus@qt.io>2021-02-16 15:13:31 +0000
commita513f25c39df21930e823100563553db2a2b65a9 (patch)
treea6a54639f2421c5c7048bed2c2290b008a5138fb /src/plugins/classview/classviewparser.cpp
parentab7560bec47bd20e0bdc05018e09a6ac3070a1b5 (diff)
downloadqt-creator-a513f25c39df21930e823100563553db2a2b65a9.tar.gz
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>
Diffstat (limited to 'src/plugins/classview/classviewparser.cpp')
-rw-r--r--src/plugins/classview/classviewparser.cpp89
1 files changed, 1 insertions, 88 deletions
diff --git a/src/plugins/classview/classviewparser.cpp b/src/plugins/classview/classviewparser.cpp
index 49af9de876..b3c0442007 100644
--- a/src/plugins/classview/classviewparser.cpp
+++ b/src/plugins/classview/classviewparser.cpp
@@ -111,12 +111,6 @@ public:
//! List for files which has to be parsed
QSet<QString> fileList;
- //! Root item read write lock
- QReadWriteLock rootItemLocker;
-
- //! Parsed root item
- ParserTreeItem::ConstPtr rootItem;
-
//! Flat mode
bool flatMode = false;
};
@@ -152,39 +146,6 @@ Parser::~Parser()
}
/*!
- Checks \a item for lazy data population of a QStandardItemModel.
-*/
-
-bool Parser::canFetchMore(QStandardItem *item, bool skipRoot) const
-{
- ParserTreeItem::ConstPtr ptr = findItemByRoot(item, skipRoot);
- if (ptr.isNull())
- return false;
- return ptr->canFetchMore(item);
-}
-
-/*!
- Checks \a item for lazy data population of a QStandardItemModel.
- \a skipRoot skips the root item.
-*/
-
-void Parser::fetchMore(QStandardItem *item, bool skipRoot) const
-{
- ParserTreeItem::ConstPtr ptr = findItemByRoot(item, skipRoot);
- if (ptr.isNull())
- return;
- ptr->fetchMore(item);
-}
-
-bool Parser::hasChildren(QStandardItem *item) const
-{
- ParserTreeItem::ConstPtr ptr = findItemByRoot(item);
- if (ptr.isNull())
- return false;
- return ptr->childCount() != 0;
-}
-
-/*!
Switches to flat mode (without subprojects) if \a flat returns \c true.
*/
@@ -207,45 +168,6 @@ void Parser::aboutToShutdown()
}
/*!
- Returns the internal tree item for \a item. \a skipRoot skips the root
- item.
-*/
-
-ParserTreeItem::ConstPtr Parser::findItemByRoot(const QStandardItem *item, bool skipRoot) const
-{
- if (!item)
- return ParserTreeItem::ConstPtr();
-
- // go item by item to the root
- QList<const QStandardItem *> uiList;
- const QStandardItem *cur = item;
- while (cur) {
- uiList.append(cur);
- cur = cur->parent();
- }
-
- if (skipRoot && uiList.count() > 0)
- uiList.removeLast();
-
- ParserTreeItem::ConstPtr internal;
- {
- QReadLocker locker(&d->rootItemLocker);
- internal = d->rootItem;
- }
-
- while (uiList.count() > 0) {
- cur = uiList.last();
- uiList.removeLast();
- const SymbolInformation &inf = Internal::symbolInformationFromItem(cur);
- internal = internal->child(inf);
- if (internal.isNull())
- break;
- }
-
- return internal;
-}
-
-/*!
Parses the class and produces a new tree.
\sa addProject
@@ -486,16 +408,7 @@ void Parser::requestCurrentState()
d->timer.stop();
// TODO: we need to have a fresh SessionManager data here, which we could pass to parse()
- const ParserTreeItem::ConstPtr newRoot = parse();
- {
- QWriteLocker locker(&d->rootItemLocker);
- d->rootItem = newRoot;
- }
-
- QSharedPointer<QStandardItem> std(new QStandardItem());
- d->rootItem->convertTo(std.data());
-
- emit treeDataUpdate(std);
+ emit treeRegenerated(parse());
}
// TODO: don't use Project class in this thread