From 27422d5f4d5f03f478a5f867b4be23a13509a0b5 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 5 Feb 2023 18:43:09 +0100 Subject: [PATCH] Fix narrowing in Qt::endPropertyUpdateGroup() decltype(QPropertyDelayedNotifications::used) is qsizetype, not int, so don't use int to count from 0...used. The notify() and evaluateBinding() functions use their int argument only for pointer arithmetic, so this is completely self-contained. Amends fdedcb6ec650236bef4a8c8f005b5dd24ef7d77a. Task-number: QTBUG-103532 Task-number: QTBUG-110710 Change-Id: I765a06628d330fbb57a2fbecc96d66690bb62f13 Reviewed-by: Fabian Kosmale (cherry picked from commit d257a56c93e58028031c41daf90d3d4e8f317846) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/kernel/qproperty.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp index 742d2c5f409..273f788add2 100644 --- a/src/corelib/kernel/qproperty.cpp +++ b/src/corelib/kernel/qproperty.cpp @@ -121,7 +121,7 @@ struct QPropertyDelayedNotifications Change notifications are sent later with notify (following the logic of separating binding updates and notifications used in non-deferred updates). */ - [[nodiscard]] PendingBindingObserverList evaluateBindings(int index, QBindingStatus *status) { + [[nodiscard]] PendingBindingObserverList evaluateBindings(qsizetype index, QBindingStatus *status) { PendingBindingObserverList bindingObservers; auto *delayed = delayedProperties + index; auto *bindingData = delayed->originalBindingData; @@ -151,7 +151,7 @@ struct QPropertyDelayedNotifications \li sends any pending notifications. \endlist */ - void notify(int index) { + void notify(qsizetype index) { auto *delayed = delayedProperties + index; auto *bindingData = delayed->originalBindingData; if (!bindingData) @@ -221,7 +221,7 @@ void Qt::endPropertyUpdateGroup() // update all delayed properties auto start = data; while (data) { - for (int i = 0; i < data->used; ++i) { + for (qsizetype i = 0; i < data->used; ++i) { PendingBindingObserverList bindingObserves = data->evaluateBindings(i, status); Q_UNUSED(bindingObserves); // ### TODO: Use bindingObservers for notify @@ -231,7 +231,7 @@ void Qt::endPropertyUpdateGroup() // notify all delayed properties data = start; while (data) { - for (int i = 0; i < data->used; ++i) + for (qsizetype i = 0; i < data->used; ++i) data->notify(i); auto *next = data->next; delete data;