Examples: Make sure to select some example set if available

In the case of the bug report, there is no previously selected index,
and no valid Qt version, so setting the index to the highest Qt version
doesn't result in anything. Make sure to select something in the
dropdown, if we have any item there at all, even if our heuristics don't
come up with an optimal selection.

Fixes: QTCREATORBUG-26791
Change-Id: I2327594f0fd36e312aa71d1990e8ccab4a488367
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Eike Ziller
2022-04-05 12:07:33 +02:00
parent c2c8b137c0
commit 73a78a70da

View File

@@ -555,6 +555,9 @@ void ExampleSetModel::updateQtVersionList()
newQtVersion = findHighestQtVersion(versions); newQtVersion = findHighestQtVersion(versions);
currentIndex = indexForQtVersion(newQtVersion); currentIndex = indexForQtVersion(newQtVersion);
} // nothing to do for extra example sets } // nothing to do for extra example sets
// Make sure to select something even if the above failed
if (currentIndex < 0 && rowCount() > 0)
currentIndex = 0; // simply select first
selectExampleSet(currentIndex); selectExampleSet(currentIndex);
emit selectedExampleSetChanged(currentIndex); emit selectedExampleSetChanged(currentIndex);
} }