diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-05-17 10:13:55 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-05-19 11:10:39 +0200 |
commit | a887891271a52b2546265c13c6dc70fdd08507e3 (patch) | |
tree | b5e8a04c4a8800461f3f2393d353fdc55889dcff /src/corelib/kernel/qcoreapplication.cpp | |
parent | 13d1a6095d0b02621a9f4e1b4a0f9929aaa1058d (diff) |
QCoreApplication: port some indexed to ranged for loops
... fixing the int/qsizetype mismatches in the old code.
These loops trivially don't modify the container under iteration, so
using a ranged for loop is safe.
Pick-to: 6.3 6.2
Task-number: QTBUG-103532
Change-Id: I1c9e1bffceea0ada54007d313aebe2e688fa9122
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qcoreapplication.cpp')
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 0dafc40381..71e1b88cd8 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -289,8 +289,8 @@ static void qt_call_pre_routines() // the function to be executed every time QCoreApplication is created. list = *preRList; } - for (int i = 0; i < list.count(); ++i) - list.at(i)(); + for (QtCleanUpFunction f : std::as_const(list)) + f(); } void Q_CORE_EXPORT qt_call_post_routines() @@ -472,8 +472,7 @@ void QCoreApplicationPrivate::cleanupThreadData() // need to clear the state of the mainData, just in case a new QCoreApplication comes along. const auto locker = qt_scoped_lock(thisThreadData->postEventList.mutex); - for (int i = 0; i < thisThreadData->postEventList.size(); ++i) { - const QPostEvent &pe = thisThreadData->postEventList.at(i); + for (const QPostEvent &pe : std::as_const(thisThreadData->postEventList)) { if (pe.event) { --pe.receiver->d_func()->postedEvents; pe.event->m_posted = false; @@ -1607,8 +1606,7 @@ bool QCoreApplication::compressEvent(QEvent *event, QObject *receiver, QPostEven // compress posted timers to this object. if (event->type() == QEvent::Timer && receiver->d_func()->postedEvents > 0) { int timerId = ((QTimerEvent *) event)->timerId(); - for (int i=0; i<postedEvents->size(); ++i) { - const QPostEvent &e = postedEvents->at(i); + for (const QPostEvent &e : std::as_const(*postedEvents)) { if (e.receiver == receiver && e.event && e.event->type() == QEvent::Timer && ((QTimerEvent *) e.event)->timerId() == timerId) { delete event; @@ -1631,8 +1629,7 @@ bool QCoreApplication::compressEvent(QEvent *event, QObject *receiver, QPostEven } if (event->type() == QEvent::Quit && receiver->d_func()->postedEvents > 0) { - for (int i = 0; i < postedEvents->size(); ++i) { - const QPostEvent &cur = postedEvents->at(i); + for (const QPostEvent &cur : std::as_const(*postedEvents)) { if (cur.receiver != receiver || cur.event == nullptr || cur.event->type() != event->type()) @@ -1916,8 +1913,7 @@ void QCoreApplicationPrivate::removePostedEvent(QEvent * event) #endif } - for (int i = 0; i < data->postEventList.size(); ++i) { - const QPostEvent & pe = data->postEventList.at(i); + for (const QPostEvent &pe : std::as_const(data->postEventList)) { if (pe.event == event) { #ifndef QT_NO_DEBUG qWarning("QCoreApplication::removePostedEvent: Event of type %d deleted while posted to %s %s", |