Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Factory:Rebuild
qt6-base
0001-QAbstractItemModelPrivate-add-resetting-me...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-QAbstractItemModelPrivate-add-resetting-member.patch of Package qt6-base
From 9785bc77eb4967c4a791eef1745c0c4f2b0db95a Mon Sep 17 00:00:00 2001 From: Mitch Curtis <mitch.curtis@qt.io> Date: Tue, 24 Sep 2024 10:40:37 +0800 Subject: [PATCH] QAbstractItemModelPrivate: add resetting member This allows QQmlDelegateModel to know if a QAbstractItemModel subclass is in the process of a reset, which it can't know if beginResetModel was called in the model's constructor. As an added bonus, it also allows us to warn the user if they call endResetModel with a previous call to beginResetModel. Task-number: QTBUG-125053 Task-number: QTBUG-127340 Pick-to: 6.5 Change-Id: I7d1fb983e9bf868c48472624ad945ae158115943 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> (cherry picked from commit 9d8663c18e88cb0b5a65f86cfd7726f3d31e04d6) (cherry picked from commit 2ea3abed0125d81ca4f3bacb9650db7314657332) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> --- src/corelib/itemmodels/qabstractitemmodel.cpp | 13 +++++++++++++ src/corelib/itemmodels/qabstractitemmodel_p.h | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index 5b9b215..3d4d566 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -3400,6 +3400,13 @@ void QAbstractItemModel::endMoveColumns() */ void QAbstractItemModel::beginResetModel() { + Q_D(QAbstractItemModel); + if (d->resetting) { + qWarning() << "beginResetModel called on" << this << "without calling endResetModel first"; + // Warn, but don't return early in case user code relies on the incorrect behavior. + } + + d->resetting = true; emit modelAboutToBeReset(QPrivateSignal()); } @@ -3417,8 +3424,14 @@ void QAbstractItemModel::beginResetModel() void QAbstractItemModel::endResetModel() { Q_D(QAbstractItemModel); + if (!d->resetting) { + qWarning() << "endResetModel called on" << this << "without calling beginResetModel first"; + // Warn, but don't return early in case user code relies on the incorrect behavior. + } + d->invalidatePersistentIndexes(); resetInternalData(); + d->resetting = false; emit modelReset(QPrivateSignal()); } diff --git a/src/corelib/itemmodels/qabstractitemmodel_p.h b/src/corelib/itemmodels/qabstractitemmodel_p.h index e34dc32..c2113fd 100644 --- a/src/corelib/itemmodels/qabstractitemmodel_p.h +++ b/src/corelib/itemmodels/qabstractitemmodel_p.h @@ -45,6 +45,8 @@ public: QAbstractItemModelPrivate(); ~QAbstractItemModelPrivate(); + static const QAbstractItemModelPrivate *get(const QAbstractItemModel *model) { return model->d_func(); } + void removePersistentIndexData(QPersistentModelIndexData *data); void movePersistentIndexes(const QList<QPersistentModelIndexData *> &indexes, int change, const QModelIndex &parent, Qt::Orientation orientation); @@ -115,6 +117,8 @@ public: void insertMultiAtEnd(const QModelIndex& key, QPersistentModelIndexData *data); } persistent; + bool resetting = false; + static const QHash<int,QByteArray> &defaultRoleNames(); static bool isVariantLessThan(const QVariant &left, const QVariant &right, Qt::CaseSensitivity cs = Qt::CaseSensitive, bool isLocaleAware = false); -- 2.46.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor