diff --git a/components/contentselector/model/contentmodel.cpp b/components/contentselector/model/contentmodel.cpp index 39e91d5a39..7a4558d57a 100644 --- a/components/contentselector/model/contentmodel.cpp +++ b/components/contentselector/model/contentmodel.cpp @@ -474,9 +474,13 @@ void ContentSelectorModel::ContentModel::addFiles(const QString &path) void ContentSelectorModel::ContentModel::clearFiles() { - beginRemoveRows(QModelIndex(), 0, mFiles.count()-1); - mFiles.clear(); - endRemoveRows(); + const int filesCount = mFiles.count(); + + if (filesCount > 0) { + beginRemoveRows(QModelIndex(), 0, filesCount - 1); + mFiles.clear(); + endRemoveRows(); + } } QStringList ContentSelectorModel::ContentModel::gameFiles() const