From: Shawn Rutledge Date: Wed, 13 Feb 2013 13:08:19 +0000 (+0100) Subject: FolderListModel: prevent assertion failure when filter selects 0 files X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=af8c15951886ffb10e1ea8a0631e3ea7e29da483;p=konrad%2Fqtdeclarative.git FolderListModel: prevent assertion failure when filter selects 0 files If you do nameFilters = "*.foo" and there are no matching files, there was an assertion failure due to inserting rows from 0 to -1: ASSERT: "last >= first" in file itemmodels/qabstractitemmodel.cpp Change-Id: I4a3642906a4588bebc699b8d99438726676fb4ca Reviewed-by: Shawn Rutledge --- diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp index 3e3a824..421e215 100644 --- a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp +++ b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp @@ -159,8 +159,10 @@ void QQuickFolderListModelPrivate::_q_directoryUpdated(const QString &directory, data = list; q->beginRemoveRows(parent, fromIndex, toIndex); q->endRemoveRows(); - q->beginInsertRows(parent, fromIndex, list.size()-1); - q->endInsertRows(); + if (list.size() > 0) { + q->beginInsertRows(parent, fromIndex, list.size()-1); + q->endInsertRows(); + } emit q->rowCountChanged(); } else if (data.size() < list.size()) { //qDebug() << "File added. FromIndex: " << fromIndex << " toIndex: " << toIndex << " list size: " << list.size();