From 73a78a70dad941546b2d2b4ab56cc6451c6ed15e Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 5 Apr 2022 12:07:33 +0200 Subject: [PATCH] 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: Reviewed-by: Qt CI Bot Reviewed-by: Christian Stenger --- src/plugins/qtsupport/exampleslistmodel.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/qtsupport/exampleslistmodel.cpp b/src/plugins/qtsupport/exampleslistmodel.cpp index 7f030d524f5..ebe547176e2 100644 --- a/src/plugins/qtsupport/exampleslistmodel.cpp +++ b/src/plugins/qtsupport/exampleslistmodel.cpp @@ -555,6 +555,9 @@ void ExampleSetModel::updateQtVersionList() newQtVersion = findHighestQtVersion(versions); currentIndex = indexForQtVersion(newQtVersion); } // 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); emit selectedExampleSetChanged(currentIndex); }