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 <fabian.kosmale@qt.io>
(cherry picked from commit d257a56c93e58028031c41daf90d3d4e8f317846)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Marc Mutz 2023-02-05 18:43:09 +01:00 committed by Qt Cherry-pick Bot
parent 0c50cf2691
commit 27422d5f4d

View File

@ -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;