From 1c359e6ea1a55d954239f11dfa90aa1beecc4501 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Sat, 14 Oct 2023 23:12:51 +0300 Subject: [PATCH] QCoreApplication: use the correct typedef of `preRList` `QVFuncList` and `QStartUpFuncList` are identical typdefs (`QtCleanUpFunction` and `QtStartUpFunction` are identical typedefs): typedef QList QVFuncList; typedef QList QStartUpFuncList; So from the compiler's POV QVFuncList and QStartUpFuncList can be used interchangeably, but from a code reader's POV, this is confusing. Use IILE to make the local variable const. This amends commits 942922652481347659a0dae78758c334778a58d2 and a887891271a52b2546265c13c6dc70fdd08507e3. Pick-to: 6.5 6.2 5.15 Fixes: QTBUG-117242 Change-Id: I67f6af89027fe36a1915e815acd3c9446f7dcd5d Reviewed-by: Marc Mutz (cherry picked from commit 408799de65aaa4adcc6660c444f98bfb1a326dfe) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/kernel/qcoreapplication.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 344830efda1..5ee430222fe 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -294,15 +294,15 @@ static void qt_call_pre_routines() if (!preRList.exists()) return; - QVFuncList list; - { + const QStartUpFuncList list = [] { const auto locker = qt_scoped_lock(globalRoutinesMutex); // Unlike qt_call_post_routines, we don't empty the list, because // Q_COREAPP_STARTUP_FUNCTION is a macro, so the user expects // the function to be executed every time QCoreApplication is created. - list = *preRList; - } - for (QtCleanUpFunction f : std::as_const(list)) + return *preRList; + }(); + + for (QtStartUpFunction f : list) f(); }