diff options
| author | Méven Car <[email protected]> | 2026-06-13 16:11:44 +0000 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2026-06-14 06:56:21 +0000 |
| commit | 451ae420c8454c3f6a157019646781fa97af3b2e (patch) | |
| tree | b291fcbee9dd05dcab8da3123047f73c1b81c54e /src/kitemviews/kfileitemmodelrolesupdater.h | |
| parent | 655ded169bf5f3c7a925d01a15738333dc64a5df (diff) | |
Replace the itemsChanged disconnect/connect dance with a guard
The updater must not react to its own setData() changes, or it would
resolve the roles again. Instead of disconnecting slotItemsChanged()
around every setData() and reconnecting (a dozen times), add a
setModelData() helper that sets a guard while calling setData(), and
make slotItemsChanged() return early while it is set. The view still
gets itemsChanged and repaints.
This also drops a stray disconnect of itemsMoved (never reconnected)
that a hover-sequence block did while duplicating the itemsChanged
connection.
Diffstat (limited to 'src/kitemviews/kfileitemmodelrolesupdater.h')
| -rw-r--r-- | src/kitemviews/kfileitemmodelrolesupdater.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/kitemviews/kfileitemmodelrolesupdater.h b/src/kitemviews/kfileitemmodelrolesupdater.h index fc6e78295..61e85188e 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.h +++ b/src/kitemviews/kfileitemmodelrolesupdater.h @@ -318,6 +318,13 @@ private: QHash<QByteArray, QVariant> rolesData(const KFileItem &item, int index); /** + * Sets \a data on the model item at \a index without re-entering + * slotItemsChanged() for this self-induced change (other listeners, e.g. the + * view, still get the change). Replaces a manual disconnect/setData/connect. + */ + void setModelData(int index, const QHash<QByteArray, QVariant> &data); + + /** * Must be invoked if a property has been changed that affects * the look of the preview. Takes care to update all previews. */ @@ -361,6 +368,10 @@ private: // during the roles-updater has been paused by setPaused(). bool m_clearPreviews; + // True while setModelData() applies a self-induced change, so that + // slotItemsChanged() ignores it instead of resolving roles again. + bool m_applyingChangesToModel = false; + // Remembers which items have been handled already, to prevent that // previews and other expensive roles are determined again. QSet<KFileItem> m_finishedItems; |
