aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qtsupport/exampleslistmodel.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2022-04-05 12:07:33 +0200
committerEike Ziller <eike.ziller@qt.io>2022-04-06 06:28:58 +0000
commit73a78a70dad941546b2d2b4ab56cc6451c6ed15e (patch)
tree63bb9f577dfcf026400f496d53c635b649955202 /src/plugins/qtsupport/exampleslistmodel.cpp
parentc2c8b137c04de8dfd92d376a0fd2493a6336c0e6 (diff)
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>
Diffstat (limited to 'src/plugins/qtsupport/exampleslistmodel.cpp')
-rw-r--r--src/plugins/qtsupport/exampleslistmodel.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/plugins/qtsupport/exampleslistmodel.cpp b/src/plugins/qtsupport/exampleslistmodel.cpp
index 7f030d524f..ebe547176e 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);
}