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>
This commit is contained in:
Samuel Ghinet
2023-05-05 15:09:20 +03:00
committed by Thomas Hartmann
parent a2d22cc859
commit b15c4e1f75

View File

@@ -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);