forked from qt-creator/qt-creator
QmlDesigner: Fix potential crash
Change-Id: I85e5b7d8f03e270540294a20ccc24658943a2c9b Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -207,10 +207,11 @@ void ItemLibraryCategoriesModel::clearSelectedCategory(int categoryIndex)
|
||||
|
||||
QPointer<ItemLibraryCategory> ItemLibraryCategoriesModel::selectCategory(int categoryIndex)
|
||||
{
|
||||
if (categoryIndex == -1 || m_categoryList.isEmpty())
|
||||
if (m_categoryList.isEmpty() || categoryIndex < 0 || categoryIndex >= m_categoryList.size())
|
||||
return nullptr;
|
||||
|
||||
const QPointer<ItemLibraryCategory> category = m_categoryList.at(categoryIndex);
|
||||
|
||||
if (!category->categorySelected()) {
|
||||
category->setCategorySelected(true);
|
||||
emit dataChanged(index(categoryIndex),index(categoryIndex), {m_roleNames.key("categorySelected")});
|
||||
|
Reference in New Issue
Block a user