summaryrefslogtreecommitdiffstats
path: root/src/corelib/itemmodels/qabstractitemmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/itemmodels/qabstractitemmodel.cpp')
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp
index f893cf06e3..7e1ab851d7 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.cpp
+++ b/src/corelib/itemmodels/qabstractitemmodel.cpp
@@ -482,12 +482,12 @@ class QEmptyItemModel : public QAbstractItemModel
{
public:
explicit QEmptyItemModel(QObject *parent = 0) : QAbstractItemModel(parent) {}
- QModelIndex index(int, int, const QModelIndex &) const Q_DECL_OVERRIDE { return QModelIndex(); }
- QModelIndex parent(const QModelIndex &) const Q_DECL_OVERRIDE { return QModelIndex(); }
- int rowCount(const QModelIndex &) const Q_DECL_OVERRIDE { return 0; }
- int columnCount(const QModelIndex &) const Q_DECL_OVERRIDE { return 0; }
- bool hasChildren(const QModelIndex &) const Q_DECL_OVERRIDE { return false; }
- QVariant data(const QModelIndex &, int) const Q_DECL_OVERRIDE { return QVariant(); }
+ QModelIndex index(int, int, const QModelIndex &) const override { return QModelIndex(); }
+ QModelIndex parent(const QModelIndex &) const override { return QModelIndex(); }
+ int rowCount(const QModelIndex &) const override { return 0; }
+ int columnCount(const QModelIndex &) const override { return 0; }
+ bool hasChildren(const QModelIndex &) const override { return false; }
+ QVariant data(const QModelIndex &, int) const override { return QVariant(); }
};
Q_GLOBAL_STATIC(QEmptyItemModel, qEmptyModel)
@@ -2686,6 +2686,7 @@ bool QAbstractItemModel::decodeData(int row, int column, const QModelIndex &pare
void QAbstractItemModel::beginInsertRows(const QModelIndex &parent, int first, int last)
{
Q_ASSERT(first >= 0);
+ Q_ASSERT(first <= rowCount(parent)); // == is allowed, to insert at the end
Q_ASSERT(last >= first);
Q_D(QAbstractItemModel);
d->changes.push(QAbstractItemModelPrivate::Change(parent, first, last));
@@ -2741,6 +2742,7 @@ void QAbstractItemModel::beginRemoveRows(const QModelIndex &parent, int first, i
{
Q_ASSERT(first >= 0);
Q_ASSERT(last >= first);
+ Q_ASSERT(last < rowCount(parent));
Q_D(QAbstractItemModel);
d->changes.push(QAbstractItemModelPrivate::Change(parent, first, last));
emit rowsAboutToBeRemoved(parent, first, last, QPrivateSignal());
@@ -2987,6 +2989,7 @@ void QAbstractItemModel::endMoveRows()
void QAbstractItemModel::beginInsertColumns(const QModelIndex &parent, int first, int last)
{
Q_ASSERT(first >= 0);
+ Q_ASSERT(first <= columnCount(parent)); // == is allowed, to insert at the end
Q_ASSERT(last >= first);
Q_D(QAbstractItemModel);
d->changes.push(QAbstractItemModelPrivate::Change(parent, first, last));
@@ -3043,6 +3046,7 @@ void QAbstractItemModel::beginRemoveColumns(const QModelIndex &parent, int first
{
Q_ASSERT(first >= 0);
Q_ASSERT(last >= first);
+ Q_ASSERT(last < columnCount(parent));
Q_D(QAbstractItemModel);
d->changes.push(QAbstractItemModelPrivate::Change(parent, first, last));
emit columnsAboutToBeRemoved(parent, first, last, QPrivateSignal());