From a2f4a45a1e5027694e39ca7c22bd4594caf61536 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 17 Mar 2025 09:36:41 +0100 Subject: [PATCH] ProjectExplorer: Guard against misuse of Node API in QtC the only direct subclasses of Node are FileNode and FolderNode, so that ensures that we always either have asFileNode() or asFolderNode(), but custom subclasses could do that wrong. Warn instead of crash in the FlatModel in that case (though there is no guarantee that there are other places that make that assumption). Change-Id: I29bc02116c775bc1b1068e791e08b2a7fa767917 Reviewed-by: hjk --- src/plugins/projectexplorer/projectmodels.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/projectexplorer/projectmodels.cpp b/src/plugins/projectexplorer/projectmodels.cpp index 8fbd4a3afec..a29e79abba0 100644 --- a/src/plugins/projectexplorer/projectmodels.cpp +++ b/src/plugins/projectexplorer/projectmodels.cpp @@ -223,8 +223,9 @@ QVariant FlatModel::data(const QModelIndex &index, int role) const return tooltip; } case Qt::DecorationRole: { + QTC_ASSERT(fileNode || folderNode, return {}); if (!folderNode) - return node->asFileNode()->icon(); + return fileNode->icon(); if (!project) return folderNode->icon(); static QIcon warnIcon = Utils::Icons::WARNING.icon();