70857 Commits

Author SHA1 Message Date
Thiago Macieira
ae2502b4ad QLibraryInfo: speed up checking if ":/qt/etc/qt.conf" resource exists
Go straight for QResource, because this is run very early in Qt's
initialization, usually as a result of some debug message, via
QLoggingRegistry::initializeRules(). This bypasses the need to create
QResourceFileEnginePrivate, QResourceFileEngine, QFileInfoPrivate, and
QFileInfo, all of which would end up in this .isValid() call.

Additionally, I'm making it query in the C locale, which will also avoid
initializing the system & default QLocales. If a resource exists in any
language, the C locale query will find it.

Pick-to: 6.8
Task-number: QTBUG-133206
Change-Id: I434b498903d793c12d35fffd3e297bfdbdc1b6fe
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit d59e640c868f3db2d661970f3d34a22013d49053)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-02-04 03:01:59 +00:00
Ahmad Samir
0ca8024da2 QDirListing: clarify the ExcludeSpecial flag API docs
Amends e583c3d5163a5512abac85e32359652e28a053f7.

Pick-to: 6.8
Change-Id: I2ed231990778d03384045bc417efc58a6019fc14
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit e5fbe88708103781ee8d60f5280ea1ad4bed21f5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-02-04 02:47:39 +00:00
Christian Ehrlicher
c7f914c68c Widgets/styles: don't create a QPen when not needed
Use QPainter::setPen(QColor) overload instead creating a temporary QPen
to gain advantaged of the newly introduced QPen operator=(QColor)
function from ab53500cfa11b988e7e4234583fa6eb5027b4c08

Change-Id: Ib29a932a183b629f2c5f3ce32f4e00bd7ab24a03
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 678564291d8faa7689b4a65376b2c60118fc9936)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-02-03 05:13:25 +00:00
Eskil Abrahamsen Blomfeldt
b6557e4be8 Fix compilation with unofficial DirectWrite headers
Reportedly, some unofficial DirectWrite ports are missing the
default values to the arguments for IDWritePaintReader's
MoveToFirstChild() and MoveToNextSibling(), so we make this
explicit to work around the problem.

Fixes: QTBUG-133336
Change-Id: Ia9a01e371e7424508db0d5ad3c75037caaf16854
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit cbce69ebd643bb4841de20f34c5b23bddbcde0c6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-02-01 09:53:16 +00:00
Alexandru Croitor
9ffc3b0705 CMake: Wrap path in quotes to avoid issues with spaces in paths
Otherwise running the deployment script fails on macOS with something
like

CMake Error at
 .qt/deploy_qml_app_texteditorexample_32987d3e6e.cmake:1 (include):
  include called with invalid argument:
   2/build/.qt/QtDeploySupport.cmake

due to the following generated content:
  include(build/texteditor space 2/build/.qt/QtDeploySupport.cmake)

Pick-to: 6.8
Task-number: QTBUG-126827
Change-Id: I8f9923db8dc670a6efbd6f75c48da5dfd1af687d
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 65f08c09713b6d167638c4e19ebafcac045fc1c5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-02-01 09:53:05 +00:00
Robert Löhning
01b90c38e7 libinput: Fix developer build without xkbcommon
Before this fix, the build failed with:
error: unused variable 'REPEAT_DELAY' [-Werror,-Wunused-const-variable]
error: unused variable 'REPEAT_RATE' [-Werror,-Wunused-const-variable]

Pick-to: 6.8
Change-Id: I44a76e2270c1f5d8af6bd018869db5e30e40ecbb
Reviewed-by: Liang Qi <liang.qi@qt.io>
(cherry picked from commit 42ea8c31fe459ac252144f89986891b241c3e9d0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-02-01 09:52:51 +00:00
Cristian Le
9601b5fa5b Check for misspelled FEATURE_* variable
The feature names are normalized using `qt_feature_normalize_name`, but
a user might read `qt_feature` usage and not realize that they should
normalize the name in the `FEATURE_*` variable.

This change emits an error if it detects such invalid names.

Fixes: QTBUG-132464
Pick-to: 6.8
Change-Id: I33c7ab9f589c92e11e16d376660e8b6152339d12
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit b71647d06970b2cc3b63b93c020eca8caf0a519f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-02-01 09:52:36 +00:00
Ivan Solovev
7e80af2bc2 QSharedPointer: document rvalue overloads of various cast methods
The patch provides two documentation snippets: for an arbitrary arg
and for \c {*this}. That is because qdoc does not support passing
a command (e.g. \c) as a part of the snippet's parameter.

Amends e95fb04202b3f786037c10942fd4e912644fd7d2.

Found in Qt 6.9 API review.

Change-Id: I4eed234d18e39f2fc0c30a647a423f3240e31d40
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 8511149d886e5aef2a065efffc336c7b25e6540e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-02-01 09:52:27 +00:00
Andreas Eliasson
c965151d4d Doc: Fix typo in in scope resolution operator
Fixes: QTBUG-132911
Pick-to: 6.8 6.7 6.5
Change-Id: Iaa7c4830abd273ccfe558e089da5072a83607f26
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
(cherry picked from commit bc733ea787ad6993e945146a9d297d14cb6175ac)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-02-01 09:51:43 +00:00
Liang Qi
98065efdfa Fix dangling references - GCC 15
This amends 8a6750475410629741de0417c28f574c25c65338 and
18def77d27f88ce26b6af29fe56a80429fed555d.

Pick-to: 6.8
Change-Id: I31068527458da3d25211743fb64e2624039bd78b
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 9379b95b533216593d4d37c0cbf70f91d1ce037a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-02-01 09:26:07 +00:00
Marc Mutz
0ce4cdddb4 util/update_public_suffix_list.sh: use commit date, not wall clock
This is both more accurate and also more stable: The suffix-list
update usually takes several days to go through all branches; using
the commit date avoids using newer fetch dates in older branches.

Pick-to: 6.8 6.5 6.2 5.15
Change-Id: Ifefd7158e4104c7bbdfe6a2d8a505d8acf7275b4
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit cbea57f80b43a969d2e15d53b759abb9924d52c1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-02-01 00:09:42 +00:00
Christian Ehrlicher
7a9f724735 QMenu: Ignore disabled hotkey during hotkey search
When two actions in one menu have the same hotkey and the first action
is not enabled, the action search was selecting the first, disabled
action despite the fact that it could not be selected later on.

Pick-to: 6.8
Fixes: QTBUG-56952
Change-Id: I894ee09d9ccc7154ca506ef907924cd150ac6ed2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 13636f848da6932f9864bf9335d19b439b8387cd)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-31 23:06:46 +00:00
Assam Boudjelthia
44b706457e Android:CMake: add \cmakepropertysince to packaging type properties
QT_ANDROID_SYSTEM_LIBS_PREFIX and QT_ANDROID_NO_DEPLOY_QT_LIBS were
added in Qt 6.4, but they were missing \cmakepropertysince 6.4.

Pick-to: 6.8
Change-Id: Ife0f68e79d331f4923d1015431f5af65d80dca36
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit 51474d795a4c801933f9444b73d536fb1c407e72)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-31 22:03:12 +00:00
Assam Boudjelthia
6f6c291beb Android:CMake: remove \preliminarycmakeproperty for non-preliminary cases
Those Android CMake properties have been carrying the documentation tag
of \preliminarycmakeproperty by mistake.

Pick-to: 6.8
Change-Id: I739fee2f078300427557a29b25e1898d57cf04d7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit 2abc4594791823f1e56d692df38ede69f83e45cf)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-31 22:03:05 +00:00
Marc Mutz
7dca077bb6 QObjectData: Return const QMetaObject* from dynamicMetaObject() already now
It's semi-private API (ie. undocumented) and for most platforms¹, the
change is a no-op, which is why the approach here is a bit different
than your usual REMOVED_SINCE:

Normally, when only the return value changes, we mark the new overload
as QT6_*_NEW_OVERLOAD to allow the two function to coexist and the old
function to call the new one.

But the extra argument backing QT6_*_NEW_OVERLOAD would change the
mangling of the function even on platforms that don't mangle the
return type (the majority), and we'd have to decorate all calls that
could possibly be seen by QtCore's removed_api.cpp TU with
QT6_CALL_NEW_OVERLOAD. The main user of the API is moc-generated code,
though, and so I didn't want to have to change moc's output, even
though, currently, nothing in removed_api.cpp includes moc-generated
code. But it may, at some point in time.

This means I needed to grasp the nettle and duplicate the (granted,
trivial) implementation. Even a private helper function would mean
(maintenance and runtime) overhead for "normal"¹ platforms, so I opted
not to go there, either.

¹ those that (rightfully) don't mangle the return type, ie. all except
  ... MSVC.

As a benefit, we catch the mistake of modifying the dynamic
QMetaObject under the object's radar already now.

[ChangeLog][Potentially Source-Incompatible Changes][QtCore][QObjectData] This
(undocumented) class' dynamicMetaObject() function now returns a const
QMetaObject* (was: non-const). The backwards-compatible fix is to
receive the result in a const QMetaObject* variable (or to use auto),
and applying a manual const_cast, if a non-const object pointer was
actually required. Modifying the meta object that was returned by this
function was never supported and may lead to problems elsewhere.

Amends 0b044e8b055f9c1d93b278ed69aba76f7c886cb1.

Change-Id: I4ebc43018a2a87433ab7a97554196842b97cf1ba
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 2c212e15f8b9dc2578d93ac69a0f5826ea9de18f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-31 10:16:43 +00:00
Marc Mutz
d2c4f6df21 QDuplicateTracker: shed memory_resource on clear()
The pmr::monotonic_buffer_resource ("pmr::mbr") strategy can only
allocate buffers; deallocation is a no-op. I chose it for
QDuplicateTracker because the tool was only used one-off: build it,
then destroy it. There were no other operations.

That changed when 090c7e3262dce93df83c73a4a822761e5d9b4650 added
clear().

Calling pmr::unordered_set::clear() will deallocate the nodes (but not
the bucket array), but due to pmr::mbr, nothing is actually
deallocated, so memory that was freed by the container isn't actually
reused by it, later. IOW: repeated grow-clear-grow-clear cycles would
forever grow the monotonic_muffer_resource, using more and more memory
and thus appear to be leaking it.

This isn't exactly optimal behavior, so try to shed the pmr::mbr's
extra memory with a call to mbr::release().

Unfortunately, C++17 originally failed to nail down the semantics of
pmr::mbr::release(), prompting LWG 3120 in response to observed
implementation divergence. In particular, MSSTL, at the time of LWG
3120 filing, didn't appear to allow to allocate() after release(). In
our tests, it does allow it, it just never falls back to the original
(stack) buffer, and, looking at the implementation, it doesn't look
like it can do so anytime soon (it doesn't remember the buffer, and
everything is inline, so they would seem to need a BC break to fix it.

We tried to work-around the problem by hard-resetting 'res' by going
through a destroy-recreate cycle. pmr::mbr is neither copy- nor
move-constructible, so that blunt instrument is, unfortunately,
necessary (std::optional would be an alternative, but has overhead
that affects all platforms). This crashed, though, so just call
release() and handle MSSTL's failure to reuse the initial buffer as a
QoI issue.

For all platforms, before release(), we also need to make sure that
`set` no longer holds any references into it, and, since clear()
doesn't shed capacity, we need to use the C++11 version of the
swap-trick (swap is actually UB here, because the allocators differ):
move-assign a default-constructed set.

Amends 090c7e3262dce93df83c73a4a822761e5d9b4650.

Fixes: QTBUG-132945
Pick-to: 6.8 6.5 6.2
Change-Id: I4796806e427602255439dcb1518aa9b661c7933e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 9f4325e67354ce6c4c98e7a206f17729b378dc04)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-31 10:16:43 +00:00
Marc Mutz
605a20b262 QSet: don't detach in remove()/removeIf() if nothing is being removed
QSet::remove() calls QHash::remove(), which unconditionally detaches,
so fixing the detach there, by pulling the isUnused() check to before
detach(), fixes it for both.

For removeIf(), the old code used begin()/end() for iteration,
detaching unconditionally, even if nothing was removed in the end.

In this case, fix by using cbegin()/cend(). That delays the detach()
until the first erase(), where it belongs. The end() iterator of QHash
(and therefore QSet) are stateless sentinels in all but name, so we can
continue to cache end(). Add a code comment to that effect.

Amends 62dad9be9e172597c56a970202299563aa04918e (for removeIf()) and
5b7c3e31b538376f2b4733bd868b5875b504cdb3 (for remove()).

[ChangeLog][QtCore][QSet] remove() and removeIf() no longer
unconditionally detach, but only if something is actually being
removed.

[ChangeLog][QtCore][QHash] remove() no longer unconditionally
detaches, but only if something is actually being removed.

Pick-to: 6.8 6.5
Task-number: QTBUG-106179
Fixes: QTBUG-132831
Change-Id: I807577eafa1be478b0a2da45cf8c44936d5e48ed
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit 3a284dc19d1c77692f2faddedc674cc293d51a00)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-31 10:16:43 +00:00
Liang Qi
dd927a4f3c tests: Skip tst_QClipboard for Ubuntu 24.04 GNOME/X11
Sometimes test causes kernel crash. Test is skipped until
gnome-shell 46.1 or newer is backported to Ubuntu 24.04 LTS.

See also https://bugs.launchpad.net/ubuntu/+source/gnome-shell/+bug/2095396

Task-number: QTBUG-132070
Pick-to: 6.8
Change-Id: Ia1c7f1737e225189b86cb2b2d2ff68a7cc1e838c
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 1c0406ee17d5747f8e5b107db81949055aaa7f9e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-31 10:16:43 +00:00
Marc Mutz
aefd124efa q17::uninitialized_value_construct: use C++17/20 semantics of voidify
While LWG 3870 changed the const/static_cast'ing for C++23, this is
q17, so use the C++17/20 semantics of casting away const- and
volatile-ness.

Found in API-review.

Amends 364ac13a79a8fff0447a62e9af5588db397c0bfd.

Change-Id: Ie11589cbc96b8c3c36deaa6101a897f527d92a46
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit c05982fda39bbfa9fa3641c7e5938f204a8b1bf5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-31 07:12:16 +00:00
Marc Mutz
398c576037 QPen/QBrush: de-inline compare helper functions
These functions expose implementation details of their respective
class, so, seeing as the classes are pimpl'ed and their op==s are
out-of-line, too, these functions ought to be out-of-line, too.

De-inline them, by calling a private out-of-line helper function. This
way, they can remain unexported and "real" hidden friends (= with an
inline definition).

As drive-by:

- in QBrush/QColor: check the properties in the order of cheapness
  (style(), color(), transform()), and don't copy QTransform just to
  check isIdentity() (access the member directly).

- in QPen/QColor: avoid the QBrush copy (access the member
  directly). This also retroactively endorses the noexcept on this
  function.

- in QPen/PenStyle: amend the comment that says it's allocating with a
  `// ### optimize`

Amends f0186862e16128343705abd0de5994e8ca05a909.

Found in API-review.

Change-Id: Ibfd43b1f2200ef030d6739dad1bf026cc190606b
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit d769ca41fc11e1af81e4cdf7cacb3884f98b108c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-31 07:12:15 +00:00
Thiago Macieira
042e713cb7 QTest: fix bug dereferencing nullptr in toString<std::nullptr_t>()
Amends commit 0756cc1eae5fd8981983319fef1d084762a67b8d.

The generic instantiation of this function had a std::nullptr_t *
parameter, but callers had special code to pass a nullptr there because
we never needed a value of a nullptr (it's always a null pointer). For
example, in compare_ptr_helper():

        auto lhsFormatter = Internal::pointerToString<QObject>;
        auto rhsFormatter = Internal::genericToString<std::nullptr_t>;
        return compare_helper(t1 == nullptr, "Compared QObject pointers are not the same",
                              const_cast<const QObject *>(t1), nullptr,
                              lhsFormatter, rhsFormatter, actual, expected, file, line);

But in debug mode, some compilers did emit a load from this memory
location, causing a crash. So we just specialize this function to avoid
such.

We had a test for this... except it was never reached because the
earlier QCOMPARE() had already failed. For the test, this amends
commit ae021882330abc5f6fbaadca290e6e5670c89028.

Fixes: QTBUG-133330
Pick-to: 6.8
Change-Id: I2cd3bb475788431c6a0dfffd28e730e8b613e033
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit e19b633c468123526660b40ae110f46090682c76)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-30 23:57:18 +00:00
Assam Boudjelthia
f3c839ecc4 Android: add note about using qt_add_android_permission()
Change-Id: Ie8d48ce1460b6f7fe4023f204be8fd2511cabe4d
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 91d86e4f7a58cc2f3071234e42848928a4aea45c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-30 23:14:53 +00:00
Assam Boudjelthia
e48aac4ec6 Android: add note on using custom AndroidManifest.xml for permissions
Setting permissions manually require the user to point to the manually
managed AndroidManifest.xml file.

Pick-to: 6.8
Change-Id: Iae289ad32a12f869a5a0ec0261bc3e771d94a15d
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 40e18c7c7e3afd8dacf22879ec1bc442ecbd9877)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-30 23:14:46 +00:00
Alexandru Croitor
3f2698ce36 coin: Enable git cloning
Cloning the git sources will:
- allow embedding the git sha1 into the SBOM generated by the build
system
- ease development process in CI VMs when investigating issues.

This will slightly slow down the CI build phase by a minute or two.

Pick-to: 6.8
Task-number: QTBUG-122899
Task-number: QTQAINFRA-6520
Change-Id: If554ed0fedca26ff77d04752288ee8497bc4b9ce
Reviewed-by: Toni Saario <toni.saario@qt.io>
(cherry picked from commit 5717a4fd4a3fd2ba530a7eb4812ce2a5c34515cb)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-30 21:32:52 +00:00
Edward Welbourne
8c93587612 Rework QLocale::uiLanguages()'s order
On back-porting commit 7f9ee43de783105d8de0a0b614751eec639131f8 to
6.8, I worked out how to move the maximal version of each locale ID to
the front, while keeping it after a shorter ID that can't be derived
from it. Forward-port a refactored (and more systematic) version of
those changes now to dev (and thus 6.9) so that we get reasonable
compatibility between versions (albeit with 6.8 still lacking
truncated forms, since its QTranslator takes care of those).

This, however, brought to light a problem in the subsequent addition
and insertion of truncations. Since non-equivalent truncations of the
maximal version may (and often do) use the same script, they match
equivalents that are now later than the maximal one, which caused all
truncations to be appended, where some should be inserted just after
the equivalents. Furthermore, had the truncations of the maximal one
been inserted, they'd have appeared just after it, before some of its
equivalents, where it should be after. Reworked the handling of
truncations to take account of the fact that entries come in blocks of
equivalent forms; any truncations inserted instead of appended should
be inserted after this block, not between its members.

Adapt tests to match. As a "drive-by", shuffle some Punjabi tests so
that the comment that applies to two of them is followed by those two.

Task-number: QTBUG-131894
Change-Id: I67ea21cf279e8a3b2e8413c27ac0fa5dfabdaca7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit b6122866962880251fa8a82856d1fb9db43900d6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-30 21:23:48 +00:00
Marc Mutz
6067b27071 QPainterStateGuard: also check for nullptr painter in save(), restore()
The ctor refuses to be called with a nullptr painter, but a moved-from
QPainterStateGuard object _will_ have a nullptr painter. An assert
gives a slightly nicer error message than "nullptr deref".

Extract Method verifyPainter() to not litter the executable with
string literals for every one of the these functions (some compilers
don't use the leeway extended to them by the standard to fold duplicate
string literals).

Found in API-review.

Amends ec3a5f4994a2bafc65fa8e01fb0861219580f622.

Change-Id: I562e6a0ff5a4c8ce86418b998ed78c501441b61a
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
(cherry picked from commit 5c20f9aa5c31d30a2dccfc617e93c6d6ac0fc96c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-30 21:23:47 +00:00
Marc Mutz
a546662cd8 QtGuiTest: remove Q_NAMESPACE
There are no Q_ENUM/Q_FLAG/Q_INVOKABLEs defined in it, so drop
Q_NAMESPACE. We can always add it back in when something is added to
it that does require a meta object.

Found in API-review.

Amends 5ac4f04325a56d47812f528fe31ceb0d4932f664.

Change-Id: I8b197f2cd835d1fe4893f2e9608dcaf0ffd14cd9
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 530b2e1fc7d289c12507696137996a02bdbeb439)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-30 21:18:57 +00:00
Marc Mutz
9120bb9e03 tst_QSet: check whether QSet::removeIf() can modify elements
It can't, pfew. Was wondering for a moment, but of course, even the
QSet::iterator is really a const_iterator.

Pick-to: 6.8 6.5 6.2
Change-Id: I85caa64c1caca6d77569aa2ceb868a4aa0e5578d
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Magdalena Stojek <magdalena.stojek@qt.io>
Reviewed-by: Lena Biliaieva <lena.biliaieva@qt.io>
(cherry picked from commit a4fd95c51a4347482d6d0a815657d0b5bdaf06db)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-30 21:18:54 +00:00
Marc Mutz
ad014ed702 qpen_p.h: include what you need
In QtCreator, the file lit up like a Christmas tree from all the
undefined types :)

Amends the start of the public history.

Pick-to: 6.8 6.5 6.2 5.15
Change-Id: I558ad493a4848e6a28bd37a38f2432c5605e0f43
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 768ab2051765f3825903c449a2f0e2c07e665152)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-30 21:18:51 +00:00
Alexandru Croitor
004c87ced5 configure.bat: Use call when calling the helper cmake scripts
If an executable has a .bat or .cmd extension, and is executed without
a prepended 'call' command within a batch script, the parent batch
script execution will not continue once the child process has
finished.

Prepending call to the command ensures that the parent batch script
continues execution.

This changes ensures that configuration succeeds for the use case when
cmake is actually a batch script called cmake.bat or cmake.cmd.

We already use 'call' in qt-configure-module, so do it also in
configure.

Pick-to: 6.8
Change-Id: Ia42cb71787e88c850f1cbd1fcef5b6decbdeaabf
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 062a7dc4248904bed51dc87466ec29b407945950)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-30 21:18:49 +00:00
David Redondo
fb6b0e5c94 QDesktopUnixServices: Fix #endif comment
So it doesn't confuse me or anyone else again

Change-Id: I8ad5d4cb1b00e0edaffa90ed67e30246211e1a97
Reviewed-by: Liang Qi <liang.qi@qt.io>
(cherry picked from commit 7fcfc3790512b6d467732119330ea886de2a72fb)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-30 19:47:38 +00:00
Marc Mutz
6143ae4012 Don't export ~QESDP<QFontVariableAxisPrivate>
It's not needed, cf. QTBUG-128656 and
qtgraphs/6ae7164a5432bc49d7e9688dfd79c20515dd9333.

Found in API-review.

Amends cc128d802c6d9c87a1e00a8a88d5e6590a7195f4.

Change-Id: I3860ea5ac3d17590b1134af40927387f19dea640
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit ac5ab8ce32c6bd4122ecc690d30eade5c4f4bf2a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-30 01:00:37 +00:00
Giuseppe D'Angelo
e4502f3dc1 QProgressBar: prevent integer overflow
If `value` is INT_MAX and `lastPaintedValue` is -1 (the default), the
subtraction will overflow. Extend the arguments to 64 bits. The result
is only used for a double comparison anyhow.

Change-Id: Id4a5396c61da81932ac626b3102e583a74264df4
Pick-to: 6.8
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit 8e843ddba8de6b9dbe9851856fd4524af5d3c584)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-30 01:00:36 +00:00
Christian Ehrlicher
b5ff268a3b QMenu: Simplify check for SH_Menu_AllowActiveAndDisabled
The check for SH_Menu_AllowActiveAndDisabled is done in eight places.
Simplify it by added a helper function which checks if an action should
be considered (i.e. is not a separator, is enabled or
SH_Menu_AllowActiveAndDisabled is enabled).

Pick-to: 6.8
Task-number: QTBUG-56952
Change-Id: I65c6dc67b804dd4c5cf463767a525ec6f785bf1a
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit e0a44cd32ed3884fd665c112a9dfc2bc45a6597d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-30 01:00:36 +00:00
Giuseppe D'Angelo
df0d74dca4 QDateTime: prevent signed integer overflow
While the code checks for the possibility that leftMillis-rightMillis
may overflow, it fails to take into account that the result may be
minimal ("INT64_MIN", so to speak) and passes it to qAbs, triggering UB
in there. Since it's just a range check and we don't need the result to
be signed, use qUnsignedAbs.

Change-Id: I7f1a4bbc521fdc164ca20fedf0e995359a67ea4d
Pick-to: 6.8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 45e90b73c75b2c7997a0f8d750f9927f64e05a0e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-30 01:00:36 +00:00
Marc Mutz
6ba8e9875a QDuplicateTracker: don't value-initialize the stack buffer
The typical usage of a QDuplicateTracker should be to pass the
guesstimate for the number of entries as a constructor argument, or,
failing that, default-construct the object. In those cases, everything
is peachy:

   QDuplicateTracker<int> seen(n);
   QDuplicateTracker<int> seen;

But for users that subscribe to a AAA view and use

   auto seen = QDuplicateTracker<int>{};

or that emplace() a QDuplicateTracker in e.g. std::optional, we need
to make sure that value-initializing QDuplicateTracker doesn't
value-initialize the internal buffer (which can be several KiB in
size).

So don't = default the default ctor, but implement it as empty.

Amends f21a6d409ea0504c64cd72861fc16b6f3e080086.

Pick-to: 6.8 6.5 6.2 5.15
Change-Id: I930f40d2bb85b74d2216378d8b8ca854a53a49e4
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 15154fa4c5d216b1c943a3b37be24f5fb2e4fa73)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-29 18:51:22 +00:00
Edward Welbourne
9df9412335 Update testlib's copy of Linux's perf_event_p.h header
This isn't strictly necessary, as it doesn't affect anything we use
the header for, but it brings us back in sync so future updates don't
involve as many changes to review. Document why we amend the upstream
SPDX identifier (to a non-deprecated equivalent).

[ChangeLog][Third-Party Code][QtTest] The perf_event_p.h from Linux is
updated to match Linux kernel 6.13.

Pick-to: 6.8
Task-number: QTBUG-132871
Change-Id: I101734b743f6689ca64054008455b98e4f6b827c
Reviewed-by: Lucie Gerard <lucie.gerard@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 019d2e5974326cac1803bb860f280c1b8fd104c3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-29 18:51:22 +00:00
Edward Welbourne
8146816342 Skip zone naming with no CLDR data
In the git version of CLDR v46.1, Acre's metazone inherits a generic
long name. However, root provides no metazone data for it to inherit.
So we ended up with an empty entry for Acre in the QlocaleXML file.
Harmless, but easy to avoid, so avoid it.

Pick-to: 6.8
Task-number: QTBUG-132851
Change-Id: I392d0922bebff731632e729a4931caa02dc3a404
Reviewed-by: Mate Barany <mate.barany@qt.io>
(cherry picked from commit b60be8c14d9f39358d00ef06a8ea5562fba17d98)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-29 18:51:22 +00:00
Joni Poikelin
54ed658919 android: Fix file dialog name filter matching for extensions with numbers
Pick-to: 6.8 6.5
Task-number: QTBUG-114957
Change-Id: I8e9ff3b9c7ad3fe8442caa49f6ad0bb6449bb9e9
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit e445067507d8002b51d85e7c51a600525fead8b3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-29 18:51:21 +00:00
Tinja Paavoseppä
e0529535ca Android: Update Activity reference to C++ when set
There already exists a method to do this, but seems at some point
calling it has been dropped. Add a call to update the native
reference whenever the reference in Java gets updated.

Task-number: QTBUG-130614
Change-Id: If9654b504c88340feff2432973f8f9f2eaffa272
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit acd331cd15785dda444b1a34f343a42c6b3c89fe)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-29 18:51:21 +00:00
Morten Sørvig
55148eb94d wasm: don't give native focus to non-focus windows
isActive() may return true if a (transient) parent window
is active (has focus).

Compare against QGuiApplication::focusWindow() instead.

Fixes: QTBUG-129233
Pick-to: 6.8
Change-Id: I834a5814a5db161bdea2ba3524d1010e0c0e3e6e
Reviewed-by: Even Oscar Andersen <even.oscar.andersen@qt.io>
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@qt.io>
(cherry picked from commit 31762e2e704673057a292ac59977b501919f2450)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-29 14:04:33 +00:00
Giuseppe D'Angelo
b50f026c55 QTextStream: fix UB calls to qAbs() with minimal arguments
QTextStream's operator<<(number) uses qAbs to extract the "absolute
value" of number, and passes that and the number's sign to an internal
formatting function. However qAbs is unsuitable for the task, because it
will fail if `number` is minimal, as it returns the same type of
its input.

Since we can afford to change the type of the result, call the private
qUnsignedAbs() function instead.

Change-Id: Ib813a199503f2d07c78bb76862ab2e15d68d0ec2
Pick-to: 6.8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 8f762b546fe6b2254029c4804a32d9ae6bbf4495)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-29 12:59:21 +00:00
Joni Poikelin
0479ef1c1c Fix crash cases where window container tries to touch destroyed window
Fixes: QTBUG-133289
Pick-to: 6.8 6.5
Change-Id: I4b5a6ab12c32133d633e1bf11567119d52c1cb5a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 9940f3f280473856858afafc6a4a4feab48c653f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-29 11:30:03 +00:00
Jøger Hansegård
9f1893855b QTest: Reset repeat counter for each call to QTest::qRun()
This fix ensures that each call to QTest::qRun() runs all tests the
requested number of repetitions.

This fixes an issue where QTEST_QUICKCONTROLS_MAIN would only test the
first style, and skip remaining styles. The cause was that the repeat
counter was not reset between QTest::qRun() calls. Subsequent calls to
QTest::qRun() would therefore not run any tests.

Amends: 80a14c86b2739492d7f7fbdb1cbde1da85d1341d

Fixes: QTBUG-133207
Pick-to: 6.8 6.7
Change-Id: Idb164fd01ac0b8e04e5dd74c3625f2c343f742c5
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
(cherry picked from commit 07318c81a700b4d4a46c81ae2e4f17c6b1e501c0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-29 11:30:03 +00:00
Christian Ehrlicher
1a6b177ec7 SQL/PSQL: use a QByteArray for preparedStmtId
... instead a QString as it gets converted to an utf-8 string anyway to
avoid this conversion.

Task-number: QTBUG-132303
Change-Id: I3fcf721f9fd0d1dd181af262663fddd532262ee3
Reviewed-by: Thierry Bastian <thierryb@filewave.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 892a020cc3ad7e3d5cdcb38d26091343e78695da)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-29 08:17:04 +00:00
Thiago Macieira
d5c5f9f352 QSystemLocale: bail out if accessed post-destruction
There's little we can do, but a lot of content ends up in QLocale very
late in the execution. Let's at least not crash.

Task-number: QTBUG-133206
Pick-to: 6.8
Change-Id: I77d41141cb115147f9befffdd5e69dac19c96044
Reviewed-by: Albert Astals Cid <aacid@kde.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit e32f28034ad2383393645777bcd96eab3f696076)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-29 08:17:02 +00:00
Giuseppe D'Angelo
ad867197cf QNumeric: add a private qUnsignedAbs
Checking qAbs preconditions reveals that several places into Qt are
calling it with minimal values, causing UB. Those places do not actually
need that the absolute value is of the same type as the parameter.
Therefore, introduce qUnsignedAbs, which is like qAbs() but whose return
type is always unsigned, and therefore can accept everything.

This function is private; I don't want to encourage users to rely on our
extension.

Aggressively cherry picking because this will be needed in subsequent
bugfixes.

Change-Id: I2047768a5fd35f12bf898ca8c2008813434edd8d
Pick-to: 6.8 6.5 6.2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 83c812e1322a2b004bc604be3e6f61fb83246eb0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-29 05:36:59 +00:00
Marc Mutz
176f9f6ce2 Give LegacyUncomparable::Unordered's value a symbolic name
We'll need it higher up in the file, but we don't want to/can't move
code around, so make -127 a symbolic constant.

Amends 39c7bf4631b401c681c24bb5a732a0359c8a6d7c, which, however,
merely moved the code around.

Pick-to: 6.8
Change-Id: Id6f2d51e5678b3bad7ae658cc3e38fd3909861d7
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 57aabff91eed41fb7ba0cf67df4fe7767c6e0e43)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-29 05:21:26 +00:00
Marc Mutz
36f091f65d QBasicMutex::destroyInternal(): avoid clazy warning about returning void
Says Clazy:

   removed_api.cpp:1291:5: Returning a void expression [clazy-returning-void-expression]

Just drop the return keyword.

Amends bc080a909b8bb67c1fb23afca69682ba86cdf526.

Change-Id: Iccbc343f2dd72a7c75da5e703e8e0722a0c50f31
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 875aaa39a28dfe9c26f1416f3e16758540b17a27)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-29 02:00:35 +00:00
Michael Weghorn
bd1cb1547f a11y atspi: Report app parent
While the application's a11y object doesn't have a parent
within Qt's a11y hierarchy, the AT-SPI registry/desktop is the
parent of all application objects.

Therefore, report that one instead of using a null path.

With that in place, querying the application parent
via Accerciser's IPython console now gives the expected
result:

    In [16]: acc.role
    Out[16]: <enum ATSPI_ROLE_APPLICATION of type Atspi.Role>
    In [17]: acc.parent
    Out[17]: <Atspi.Accessible object at 0x7fbebc3fc1c0 (AtspiAccessible at 0x139d6410)>
    In [18]: acc.parent.role
    Out[18]: <enum ATSPI_ROLE_DESKTOP_FRAME of type Atspi.Role>

While at it, also add a "m_" prefix for the
AtspiAdaptor::accessibilityRegistry member.

Fixes: QTBUG-132935
Change-Id: I0e174f73c837b233fe4d5788d1c375b404000025
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
(cherry picked from commit befce757faa0b0abd2c1f4ec408c1a0932794b0c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-28 22:47:27 +00:00