summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Ghinet <samuel.ghinet@qt.io>2023-05-05 15:09:20 +0300
committerThomas Hartmann <thomas.hartmann@qt.io>2023-05-05 13:48:20 +0000
commitb15c4e1f75bfadd76543bebc6368e72e4cb5cb38 (patch)
tree0b0a655e70cb95667ade98459d93427d4f2b895d
parenta2d22cc8591628fe9ec6251a41a2cb57453647ce (diff)
downloadqt-creator-b15c4e1f75bfadd76543bebc6368e72e4cb5cb38.tar.gz
QmlDesigner: Fix crash at filtering the Style Model in QDS new dialog
Task-number: QDS-9731 Change-Id: Iac64d109fa125f67ab3e713e07ebbc3e519d5ac5 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
-rw-r--r--src/plugins/studiowelcome/stylemodel.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/plugins/studiowelcome/stylemodel.cpp b/src/plugins/studiowelcome/stylemodel.cpp
index d93fc5fded..1d548c510d 100644
--- a/src/plugins/studiowelcome/stylemodel.cpp
+++ b/src/plugins/studiowelcome/stylemodel.cpp
@@ -63,6 +63,12 @@ int StyleModel::filteredIndex(int actualIndex)
if (actualIndex < 0)
return actualIndex;
+ if (actualIndex >= m_items.size()) {
+ qWarning() << "Invalid actual index: " << actualIndex << "; Maximum index number permitted: "
+ << m_items.size() - 1;
+ return -1;
+ }
+
QStandardItem *item = m_items.at(actualIndex);
// TODO: perhaps should add this kind of find to utils/algorithm.h
auto it = std::find(std::cbegin(m_filteredItems), std::cend(m_filteredItems), item);