forked from qt-creator/qt-creator
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 <hjk@qt.io>
This commit is contained in:
@@ -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();
|
||||
|
Reference in New Issue
Block a user