ClassView: Fix a crash when switching sessions

Move a code that operates on QIcon instances out from non-GUI
thread into GUI thread. Instead of storing the QIcon directly
inside ParserTreeItem, store the path to the project. Set the
real icon when we are back on the main thread side.

Rename some fields to start with m_ prefix.

Task-number: QTCREATORBUG-25317
Task-number: QTCREATORBUG-25312
Change-Id: Iaff89c0995045b70c5378a2ff72c5deb74abf89e
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Jarek Kobus
2021-02-16 15:48:08 +01:00
parent c87284356c
commit d4fe3fdb15
4 changed files with 65 additions and 84 deletions

View File

@@ -48,21 +48,19 @@ public:
public:
ParserTreeItem();
ParserTreeItem(const Utils::FilePath &projectFilePath);
ParserTreeItem(const QHash<SymbolInformation, Ptr> &children);
~ParserTreeItem();
static Ptr parseDocument(const CPlusPlus::Document::Ptr &doc);
static Ptr mergeTrees(const QList<ConstPtr> &docTrees);
static Ptr mergeTrees(const Utils::FilePath &projectFilePath, const QList<ConstPtr> &docTrees);
Utils::FilePath projectFilePath() const;
QSet<SymbolLocation> symbolLocations() const;
Ptr child(const SymbolInformation &inf) const;
int childCount() const;
// TODO: Remove icon from this API, we can't use QIcons in non-GUI thread
QIcon icon() const;
void setIcon(const QIcon &icon);
void convertTo(QStandardItem *item) const;
// Make sure that below two methods are called only from the GUI thread
bool canFetchMore(QStandardItem *item) const;
void fetchMore(QStandardItem *item) const;