PE: Fix ProjectTreeWidget::expandedCount not to use 0 for error cases

This would make ProjectTreeWidget::nodeForFile pick the wrong node due
to nodeExpandCount having a lower count.

In case of qml files there is the source file node and the resource file
node pointing to the same file name, but the resource name has an invalid
index (not visible in the project view) and shouldn't be preffered!

Fixes: QTCREATORBUG-30571
Change-Id: I2aff7da9dd6d83222e341b5cbcb78db5cd6a9224
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Cristian Adam
2024-05-08 13:49:13 +02:00
parent 668e824299
commit 1fb5b54221

View File

@@ -308,11 +308,11 @@ ProjectTreeWidget::~ProjectTreeWidget()
int ProjectTreeWidget::expandedCount(Node *node)
{
if (m_projectTreeWidgets.isEmpty())
return 0;
return INT_MAX;
FlatModel *model = m_projectTreeWidgets.first()->m_model;
QModelIndex index = model->indexForNode(node);
if (!index.isValid())
return 0;
return INT_MAX;
int count = 0;
for (ProjectTreeWidget *tree : std::as_const(m_projectTreeWidgets)) {