Commit Graph

17415 Commits (bb10)

Author SHA1 Message Date
Thiago Macieira 167af1611f QTest: fix bug dereferencing nullptr in toString<std::nullptr_t>()
Amends commit 0756cc1eae.

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 ae02188233.

Conflict resolution for 6.8: regenerated the expected output for
tst_selftest.

Fixes: QTBUG-133330
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>
(cherry picked from commit 042e713cb7800f97c10d2d75a717ceb3e41ab29a)
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-05 21:13:47 +01:00
Ivan Solovev 5762b152f9 tst_selftest: do not use -[no]throwon{fail,skip}
This commit partially reverts fde57300ab.
The reason for the revert is that tst_selftest has some tests that are
expected to continue the execution after a failure (see the follow-up
commit for one example of such test).

This patch is 6.8-only, because in 6.9 and dev the same is done by
ad568b859a6f0a16dd243f1ca2cdc19571337da3, which could not be directly
cherry-picked to 6.8 because it also reverts the testlib support for
command-line arguments.

Change-Id: Ie3fd2f755e69d05d359cdc4d1c57267ca2edb339
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2025-02-05 21:13:46 +01:00
Marc Mutz eb10876c7d Unbreak QSet::intersect()
The selection of which set to iterate over and which one to remove
from based on their relative size violates the function's
documentation, which clearly states that items are removed from *this,
and not from `other`, so the result must never contain any elements
from `other`.

Amends 4f2c96eaa8. Instead of reverting
to the gruesome old code with the forced detach-just-to-remove copies,
distinguish four cases:

- if the two sets are shallow copies of each other, then their
  intersection is *this

- otherwise, if either set is empty, clear() *this. This is required
  for one of the tests that 29017f1395
  added to succeed.

- otherwise, if *this is detached, perform the operation in-place,
  using removeIf()

- otherwise, create a new set and move-assign to *this to avoid
  detaching just to remove something again. In this case, we can
  continue to iterate over the smaller set, but we need to keep
  picking elements from LHS into the result.

[ChangeLog][QtCore][QSet] Fixed a regression (introduced for Qt 5.2)
in intersect() that caused equivalent elements of `*this` to be
overwritten by elements of `other` if `other.size()` was larger than
`this->size()`.

Not picking to 5.15, as users will have likely adjusted their code to
the buggy behavior, and because removeIf() isn't available there.

Pick-to: 6.5
Fixes: QTBUG-132536
Task-number: QTBUG-106179
Change-Id: Idfa17c3b3589c4eacec27259fc01df6aeaa6c45f
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit 162015e9c6f469951d9212ef655cff16dcace071)
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit eb13efc4a606cdb0c6f785a6319c489ad53626f3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-02-05 15:57:55 +00:00
Marc Mutz 0e17856f63 Revert "Optimize QSet::unite"
This reverts commit 92acc94fa9.

The change broke QSet ordering guarantees: The documentation clearly
states that each item from `other` that isn't already in `*this` is
inserted ("STL insertion behavior"). Swapping *this and other breaks
this.

Independent of STL vs. Qt insertion behavior, making the picking of
elements from containers "random" in the sense that the size of the
container is now important, and not merely LHS vs. RHS, is a bad idea.

[ChangeLog][QtCore][QSet] Fixed a regression in unite() that caused
equivalent elements of `*this` to be overwritten by elements of
`other` if `other.size()` was larger than `this->size()`.

Fixes: QTBUG-132500
Change-Id: Ia636b62325139d618b5467a643ff710716324296
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 2d1b3028673493cb144060cbec49b1b95f4188d2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 3dff1a3f7b22bc623b3c326630bfd94d2bd35d08)
2025-02-05 15:57:49 +00:00
Marc Mutz 88d9371d2c QSet: check that unite() and intersect() prefer elements from *this
In Qt versions 5.0..6.7, at least, this used to be the implemented
behavior for unite(). For intersect(), it was implemented up to and
excl. 5.2. Even the documentation states as much:

intersect(): Removes all items from _this set_ that are not
             contained in the other set.

unite(): Each item in the other set that isn't already in this set
         is inserted into this set.

Add checks that the functions behave as documented (hint: they no
longer do, since 6.8 (unite()) and 5.2 (intersect()), resp.), this
being the only correct way to implement these functions (items in
sets may be equivalent, but not identical; it is important that the
set operations work in a manner consistent with insert(), to meet
user's expectation of how these functions work (unite() just
inserts() the rhs, intersect() removes if !rhs.contains). Note that
QSet, unlike other Qt associative containers, actually has STL-style
insertion behavior (insert() doesn't overwrite).

subtract() is the only one that's still true to its docs. A test for
this function will be added in a follow-up commit - eventually.

In anticipation of adding rvalue-other overloads of at least
unite(), add a test with that, too.

Pick-to: 6.5 6.2 5.15
Task-number: QTBUG-132500
Task-number: QTBUG-132536
Change-Id: Id309ab5192e6d1c9bbeef496cbd7116d306eaae8
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 0d4fd5c545b47966c56ed0b9eb9b5c0a8f75c02a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 12f39bb2ab0e2bbf70c538af7b36014024b5901a)
2025-02-05 15:57:41 +00:00
Giuseppe D'Angelo d25dbb9a7b tst_QGestureRecognizer: do not leak the point device
QTest::createTouchDevice() passes ownership of the device to the caller,
so make sure to delete it.

Change-Id: I100d3de9eab8ec9f88ed3e0850ada9d988bd962e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 28d0e658e297b5de52fb0cccaede08179c7f4b8c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 8ef6d4ede857691798465eafcb7571f6c42c0ba9)
2025-02-02 15:38:10 +00:00
Christian Ehrlicher 1fb685f918 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.

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>
(cherry picked from commit 7a9f724735670d7880a1221fdde6d992e3554dd6)
2025-02-02 15:09:28 +00:00
Marc Mutz c1825660aa 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.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>
(cherry picked from commit 9120bb9e0393bd10e73510d0103bc330f5b92696)
2025-01-31 20:36:33 +00:00
Liang Qi 70b10666c3 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
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>
(cherry picked from commit dd927a4f3c73ea98975457f547bf23830e1f100a)
2025-01-31 14:06:21 +00:00
Marc Mutz ca216b7bed 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 090c7e3262 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 090c7e3262.

Fixes: QTBUG-132945
Pick-to: 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>
(cherry picked from commit d2c4f6df21629495ce6fe32653037b35a989d6f4)
2025-01-31 14:06:20 +00:00
Marc Mutz 4299115fe6 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 62dad9be9e (for removeIf()) and
5b7c3e31b5 (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.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>
(cherry picked from commit 605a20b2624dac1bfc4a4cb683700db5026bdbe8)
2025-01-31 14:06:18 +00:00
Giuseppe D'Angelo a2ef00ee82 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
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 8f762b546fe6b2254029c4804a32d9ae6bbf4495)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit b50f026c5586bb31d0611ca570a40e77d5e4eb43)
2025-01-29 18:51:30 +00:00
Giuseppe D'Angelo 4f234b02b7 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.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>
(cherry picked from commit ad867197cf02043f9ec67363b020ac08405b0ab1)
2025-01-29 13:33:32 +00:00
Giuseppe D'Angelo 2097519b3e QDebug: do not trigger integer overflow when printing a QRect
QRect::width() and height() may overflow: they're only safe to call
when right-left+1 (or bottom-top+1) is representable by an `int`.
Therefore, avoiding calling them from QDebug, which is supposed to
"always work" (otherwise, it's not of great debugging help...).

QRectF does not have this issue as it stores the width directly.

Change-Id: I438dbacae42c17730afb92f05d16e3eebb161255
Pick-to: 6.5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 0f336500a0add3e3a8bb31c5cc605e5e13e23833)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 8232c837b02885b6e143e6982bda3ef19e4017fa)
2025-01-29 10:50:18 +00:00
Edward Welbourne 1f55a339d2 Include more pruned likely-equivalent entries in QLocale::uiLanguages
We were including, for each entry we got from CLDR or the system,
minimal and maximal additions from CLDR's likely-subtag rules, plus
versions with script omitted and possibly also territory added, when
likely-equivalent to the original. Include also the converse, with
territory omitted and possibly also script added when
likely-equivalent, so as to control order when these entries also show
up by truncation of others.

The pick to 6.8 was bound to get conflicts and is really a back-port
of reasonably future-compatible behavior to the 6.8 code-base. Results
from uiLanguages() itself are not the same as in 6.9 - truncations are
not included, because QTranslator takes care of those. It includes,
from commit cbf49f735e3cca85922a85d6548666816686db78 and earlier work
on 6.9, various test-cases adapted to this altered aim. It also fixes
some minor details that I'll now forward-port to dev and pick back to
6.9, that I worked out how to do while wrestling to make those
test-cases produce sensible results.

Task-number: QTBUG-131894
Change-Id: I363bfe31867be43807fe3b4942dafa186b8d2e94
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 7f9ee43de783105d8de0a0b614751eec639131f8)
(cherry picked from commit 45c9a35d359381419f529ba36a5381b1302bf0f4)
2025-01-28 15:49:49 +01:00
Bartlomiej Moskal 161621312f Android: Unblacklist testQuickSelectionWithMouse test from tst_QLineEdit
Test was failing on Android because of three issues:
  1. Mouse selection does not work well with Android, especially when
     predictive text is enabled. After changes in
     de5ae6917c commit, mouse selection on
     Android needs ImhNoPredictiveText to be set for correct handling.
  2. Test sends mouse press events on center position of the QLineEdit.
     On some devices, the text would sometimes end before this center
     position. To avoid this situation the width is set directly.
  3. Android expects the mouse click to be released before the next
     click. If it doesn't, the next selection won't work properly

This commit fixes all those issues and unblacklists
testQuickSelectionWithMouse test

Fixes: QTBUG-87417
Fixes: QTQAINFRA-6896
Change-Id: Id19850446954196a077047e250ea24a91ae7255e
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit 1b02900ffe02980cb3e69c60ca415fd694cd773a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit b579f48790c3a77e26618c511ab305fda3599531)
2025-01-25 15:26:51 +00:00
Fabian Kosmale 238868c518 _qt_internal_process_resource: Properly escape XML
XML requires escaping for certain characters, and we need to consider
this when writing out qrc files (which use XML).

This commit introduces a helper function,
_qt_internal_escape_xml_characters, to take care of the escaping.
It uses regular expressions to process the input strings. We take care
to start with '&', as '&' needs to be escaped, too.

We minimize the amount of escaping we're doing (the exact rules
differing between attributes and text), to avoid unnecessary work that
needs to be done when configuring a project. This is achieved by a
SUBSET option which can be passed to _qt_internal_escape_xml_characters.

Task-number: QTBUG-131916
Change-Id: Ic1bd0eedee0343c3d70b6954842e21b3c550b092
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit e4fbbdea05540723d4c4429d673d25efa3201d7a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 6e35353c83925d7c0d5f90db320ef9621f1ffb94)
2025-01-25 14:21:36 +00:00
David Redondo ca04f4fedf QOpenGlContext: Always unset current context in doneCurrent()
Otherwise when no other context is made current until thread exit, the
QGuiGLThreadContext destructor will try to call doneCurrent() on an
already deleted context.

Change-Id: If55dd69a72b8ab4012780a449f6a02729dd0ed43
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
(cherry picked from commit cd1686e55f706048286cbc962bbe02032c2396cd)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 10c195b86432eaa430c6991c0fcb74c411407cdf)
2025-01-25 14:21:31 +00:00
Marc Mutz 51abd703d6 tst_QUuid: fix -Wreturn-type in make_minimal(QUuid::Version)
The code relies on -Wswitch, but lacked the Q_UNREACHABLE_RETURN() at
the end that compiler and code readers need to understand that we don't
accept values other than those enumerated, even though an enum variable
could hold other values, too.

Since the function is constexpr, can't use that macro directly, but
need to copy the usual GCC 8 magic incantation.

Amends 171ff57be1b8fd1c1b33cffbffa389790f239b5c.

Change-Id: I6c9dd0e4178211f57da61aa6df70f8036370f158
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 420ca3463ee8adf2d986af5802d8da4bb24ce14d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 760688cc754f7f84c10596345e488055ed511cfc)
2025-01-25 14:21:25 +00:00
Timur Pocheptsov 931f45a6f1 QTestLib: Add helper function to check for keychain access issues
To be used in network-related tests where we potentially are
using private/public keys and (on macOS) end-up with keychain
access blocking a test with dialogs requesting a permission
to access the keychain.

Task-number: QTBUG-132645
Change-Id: Ide74633bf88b0453d5d8f8de56282c8cf8207380
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 13109ba350686cd8ce8e298db5d76d0e7c209bd1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 2d819c70272607e465a2478ab68592ea77c320f3)
2025-01-25 14:21:22 +00:00
Marc Mutz b086e31bbd Update public suffix list
Version 47264b57765919188b9f4144de8d95cf77e1b6dc, fetched on
2025-01-22.

[ChangeLog][Third-Party Code] Updated the public suffix list to upstream
SHA 47264b57765919188b9f4144de8d95cf77e1b6dc.

Pick-to: 6.5 6.2 5.15
Task-number: QTBUG-132851
Change-Id: Iba19f5006e8cb60505505c96a4e4649b075cae6e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 09fa335fb22122c42f057380e3d6f4d8944256d0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit faf10af206c7f35f658ee18db2a90915acf43861)
2025-01-23 14:26:31 +00:00
Marc Mutz 66456f9aa0 tst_QSet: check whether remove/removeIf detach if nothing is removed
They do.

Task-number: QTBUG-132831
Pick-to: 6.5 6.2 5.15
Change-Id: Ia4e9de7e443d11af9675924718c551a06bc4b447
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit b80679a90f39106052f1b53f4073e679d5077a5f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit cd99c6aad554925d31d2b73e9fe7067f565d19e5)
2025-01-23 14:26:31 +00:00
Jani Heikkinen 26dbd670d7 Bump version to 6.8.3
Change-Id: Ia3e12247064f4977aae2d666f742cca0b2d772ac
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-01-23 11:04:42 +00:00
Mitch Curtis 23cd9fc756 Make iconbrowser manual test directly openable in Creator
This avoids the need to run qt-cmake-standalone-test and then import
the test, as described in QTCREATORBUG-25389.

Change-Id: I010d6613debb2e34ef3809d2da78ca33ade4d602
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 742a0ed72f5264b0198d87df6c4e0657eaf48172)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 133838a7c72bb026a6b34c6d35390111cc5fbdcf)
2025-01-22 23:04:14 +00:00
Jøger Hansegård 599301270f Compare QUniqueHandles using comparesEqual and compareThreeWay
This fixes an issue where comparing pointers to object is only defined
if both pointers point into the same array.

Task-number: QTBUG-132507
Change-Id: Ib7ccb30001add38ad25b62c848a01cd53566d8bf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 5dcdeeebbc08be8845cdb5a0e586b7a864b7f16f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 99d401220c3b200e76f00cb7457a5a3935379572)
2025-01-22 19:31:26 +00:00
Edward Welbourne 2457a59435 Add a QDuplicateTracker<T>::contains()
When even some values I haven't seen may need to be left for later,
but values I have seen are definitely to be discarded, I need to know
if I've already processed them before doing the fiddly check for
whether to defer; but if I decide to defer, I haven't yet processed
and need the later check, to which I've deferred, to see the value as
still new, even though I did once ask about it before. So I need a way
to query without adding to the set.

Pick-to: 6.5
Change-Id: I712f1c400147210c149aeec6de1d15d2e095d6a9
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 09b77a8d07276e0b5e5fec596f957f8fc4a78869)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 007c0a1854e0bcf6bbe6965fbc24ff1ae6a43cc5)
2025-01-22 15:08:02 +00:00
Thiago Macieira c4106f3d5e tst_QProcess: remove duplicate DisableCrashLogger variable
Amends 90bc0ad41f.

Change-Id: I3faad81a5748ed0942d4fffd93c82124fc18b751
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 08cd38078e11988530251240096b3686e26dd783)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit c88a8c78bdcd8c763fb7d264af884cf91024415c)
2025-01-22 02:25:26 +00:00
Thiago Macieira c17da11f5f tst_Q*Application: add tests for unusual qApp creations and exits
This commit adds one unusual creation and three more unusual exits:
* creation of the Q*Application in a thread (QTBUG-130895)
* exits using ::exit() instead of returning from main():
  * from the main thread's event loop
  * from an auxiliary thread
  * from inside an auxiliary thread's event loop

All of these exercise the moment the QAdoptedThread & QThreadData for
the main thread is destroyed, which are, respectively:
* thread exit time, running thread-specific destructors
* inside exit(), running atexit()-like callbacks (qthread_*.cpp)
* [tst_static_q*application] inside exit(), running static destructors
  (added in commit 1da7558bfd7626bcc40a214a90ae5027f32f6c7f)

Unlike the tst_static_q*application tests, the calls to ::exit() cannot
be a regular QtTest because that would cause the log output to be
incomplete. The threaded Q*Application could be a test of its own, but
since I needed to add the helper anyway, I chose to add the test there.

For the majority of the tests, the failure mode is going to be a crash
on exit.

Task-number: QTBUG-12673
Task-number: QTBUG-132429
Change-Id: I1062ef500356bd97dd0cfffda4aeeda9afa138e8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit bfbd1a281dd00c47df315c06e895bf5d53cd8764)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit ea6d467c050c9e4ab58f970f6720b428ec43c8e2)
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-20 13:31:34 -08:00
Thiago Macieira f1b03014c4 De-duplicate the disabling of crash dialogs in our unit tests
The code was duplicated in multiple places.

Pick-to: 6.5
Change-Id: If2ab30b7afbf6d2f99c9fffd999218802b734d5e
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit b119fee87d5579dc1c4bfc2f508b0e3a75d69fa3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit f9bdb80ef1f0d56d9585df61f0e209fe0b718443)
2025-01-20 21:30:42 +00:00
David Faure 1467bdb4ea Fix wrong value for 'noon' in tst_bench_qdatetime
12 hours corresponds to 43,200 seconds, not 43,200 milliseconds.
Amends commit 3febcd6286

Pick-to: 6.5
Change-Id: I2eb3abcab18cd87d51ae70b5fbaeac71a8fcd0a8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 0e2656f9371f92db3bb95ee5ba52c44a91e5ce68)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 2a121a9506145943b0ce5296d673afb46199ecea)
Reviewed-by: David Faure <david.faure@kdab.com>
2025-01-20 09:11:02 +00:00
Ahmad Samir f4d2babaff tst_QUniqueHandle: silence GCC/Clang -Wself-move warnings
And remove NOLINT(clang-diagnostic-self-move), silencing the warning for
Clang seems to work for clang-tidy too (tested locally).

Amends 03bd9491491881529ad28cd6d672edfdda9a0065.

Change-Id: Ibdf982a728f2c6150f2911173dc3c9246f3662b8
Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 6f0f39673f5ae9debd9ab59be60c32f00f40c41a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 55f8c072a301c55eda37c2b39dbcb0d579b3f414)
2025-01-19 23:05:30 +00:00
Tor Arne Vestbø d629b9574b macOS: Ignore stderr in tst_QProcess::terminateInChildProcessModifier
As we produce crash reporting via Swift on macOS 15 now.

Change-Id: Iab4777b29bcaa66eff9d2f1de63072f5744d56df
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit dbfc3c9c381aa1cc0ab3cf5b758b38fb4499cb39)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit ee97f24ef47594c97aaabe034169df7f78a5c884)
2025-01-18 18:49:18 +00:00
Bartlomiej Moskal 70417e5c89 Android: Unblacklist textMargin test from tst_QLineEdit
Older devices may have lower screen resolution. In this case, the
hardcoded width may not work as expected. For example, all text may
not fit in QLineEdit.
This was the reason why the tst_qlineedit::textMargin test failed on
some Android devices (especially x86 emulator with Android API 29).
When the left and right margins were set to 20, all tested text did
not fit in QLineEdit. When we clicked at the beginning of QLineEdit,
we clicked on the second character of the text. The cursor was moved
to position 1, which caused the test to fail.

This commit updates textMargin test to make sure that tested text will
fit in to the QLineEdit.

Task-number: QTBUG-87417
Fixes: QTQAINFRA-6897
Change-Id: I35352ac1e6f975e72d5c9638f8520f8ddd1d56ae
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
(cherry picked from commit 0a017308cca154b6f906c6e143fb33fe109316bc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit fdf4738be3a941a14a955aa6931ddfee2145ae58)
2025-01-17 21:55:03 +00:00
Bartlomiej Moskal 7de701b1a3 Android: Unblacklist tst_QLineEdit selection tests
Using the left/right keyboard key will deselect the text but also
move the cursor. In this case, to be consistent with the test, the
cursor must return to the previous position. This allows to
unblacklist tests:
  - undo_keypressevents
  - leftKeyOnSelectedText

Task-number: QTBUG-87417
Fixes: QTQAINFRA-6890
Fixes: QTQAINFRA-6895
Change-Id: I8a6d7cca332fe365ca820a67c23d9cd3fc36fc43
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit 43f2fdc25cfd356292636ea1f8160cf62bab4018)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 4ae1b626efaac7b4ae7fba62aacd2838b21ca311)
2025-01-17 21:55:03 +00:00
Edward Welbourne ccffe9b8ca Add tests that zh-TW now correctly prefers zh-TW over zh translation
The bug, QTBUG-121418, was actually fixed earlier by commit
84afaafc9c6968dd76fcadc5392065d340543521 (or, for 6.8, commit
8c40e8cf12), but escaped our attention
at the time.

On picking to 6.8, where the issue is fixed in QTranslator rather than
QLocale::uiLanguages(), omit the truncated entries from tests of the
latter. Also add commit 84afaafc9c6968dd76fcadc5392065d340543521's new
tst_QTranslator::loadLocale_data() "System, mixed dialects" test-case,
which commit 8c40e8cf12 skipped, despite
actually making it work.

Fixes: QTBUG-121418
Change-Id: Ie24eb172674189079aede7a39584ea760aac1b0c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 12f8ebf5cbdc9089564a93001926d20908bd1785)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit ee65d651a4cda48a9ed9636aecd45306d0f737d0)
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2025-01-17 20:15:04 +01:00
Eskil Abrahamsen Blomfeldt 583a81cc1c Don't include bearing of mid-string characters in max width
When calculating the maximum width of a text layout, we
would add the text width of each substring *after* we had
added the negative right bearing of the last character to it.
But the bearing of the last character in a wrapped substring
does not actually add to the maximum width unless it is the
last character of the *whole* string.

Prior to 250117086ff15bba79df8f0e15ee66192edc9ea9 this was
not noticed, because the last glyph in the substring would
typically be a space and the space does not have any
bearings (when doing wrapping on individual characters it
could still happen). After the change, the previous glyph
for which we get the right bearing will be the last
non-whitespace glyph. If this happened to have a negative
right bearing, we would add this to the max width and
end up with a larger max width than we should.

This caused a test failure in tst_qquicktext.

This test prefers the text width without the bearing (i.e.
the *advance* of the substring) unless the line is manually
wrapped or it is the last line of the layout.

Change-Id: Iba1a5ad48d575683672400f0572dfa683a0f2d9c
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
(cherry picked from commit c08a92307d6d9fa9d9d9a1f301e3f2a65374e99a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 610ee0c5040cac4989a1f624e7678f83668e99a0)
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2025-01-16 11:57:47 +01:00
Mårten Nordheim 5d42d3b4e4 QHttp2Connection: Fix handling of MAX_HEADER_TABLE_SIZE setting
We need to, following the RFC, send a Dynamic Table Size Update using
HPack once we have acknowledged the setting as long as the new size is
smaller, or if we decide to use the new, larger size.

It's further complicated by the fact that we need to send this update on
the next 'field block' (anything with headers in it), and we may have
multiple SETTING frames come in, and we need to then acknowledge the
_smallest_ one as well as the _final_ one. This is so the decoder on the
peer's side can know that we have set the smallest size, and trimmed our
tables thusly, before going to the larger size.

This could, for example, be used to clear the table.

Task-number: QTBUG-132277
Change-Id: I2b886e125f2c197bc3d42aa0b2bbd308ed2a687c
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit 57f44d6d882e09f1560f86816fac6ca8d06264fc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 55dc2af21db3059600465b194daf08cacd925e05)
2025-01-15 21:53:47 +00:00
Christian Ehrlicher 78387c078d QStandardItem: correctly set model during insertRows()
When calling insertRows(), the model of the child items was not
correctly updated. insertRow() is behaving correctly.

Fixes: QTBUG-131372
Change-Id: I8b6aef7ab97887c6eb46eb21b992d76e4d59b3a0
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit 5bab8448feb2661f871e71d71a95afaffcb1656a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 3536eb32bf7e6b177fe600256dc9efd0ff653e36)
2025-01-15 00:10:00 +00:00
Morteza Jamshidi 4df1256cff Windows: Add Key_Backtab as possible key combination for Shift+Tab
In windows Backtab key event always comes as "Shift+Backtab".
So in order for Backtab key to be recognized as a shortcut sequence,
we also consider Backtab without shift modifier a possibility.

Fixes: QTBUG-94890
Change-Id: I20a7b404b57d8df5bea23765257a178f2e098ed0
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
(cherry picked from commit 4d9f99c4ea70cdae58c80e1bfdbabefe3abb455f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 6d8afaac84f995cfb008bd2d3eb59fe4fe10dd69)
2025-01-15 00:09:59 +00:00
Mate Barany 5fbe185931 Update CLDR to v46
New languages added with v46
- Kara-Kalpak
- Swampy Cree

Several new Chinese-language locales have been added, including one
using Latin script, which invalidated some prior QLocale tests, which
have been adjusted to fit.

Some obsolete time-zone identifiers are now treated as deprecated
aliases. These have lost their AnyTerritory association, implying
changes to QTimeZone tests.

Many redundant likely sub-tag rules for unspecified language have been
dropped, in favor of simpler rules.

[ChangeLog][Third-Party Code] Updated CLDR data, used by QLocale, to
v46.

Task-number: QTBUG-130877
Change-Id: I92cf210422c7759dd829a7ca2f845d20e263d25b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit e316276b76b9c3768ca4e19a04d03308ef21fe12)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 9413c19cc1f394bc39a9f46d7d12a71fb42c8d1a)
2025-01-14 11:15:42 +01:00
Jøger Hansegård 872ecc4e37 Implement QUniqueHandle move assignment using MOVE_AND_SWAP macro
This removes boilerplate and the extra complication of std::addressof.

Task-number: QTBUG-132507
Change-Id: I07091ec0ac526975cf55361a9811fad77eb152c2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 30ae70a110ee2460744e4fb78bae29b75effbf72)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 11abd8704650cf09d8259adc58fa7f7a2ccaa2ed)
2025-01-14 08:03:44 +00:00
Thiago Macieira 5acbda4b06 QThread/Unix: revert to pthread destruction instead of thread_local
Amends 65093a84c2b94b1543fd4593bc45d491951d28d4, which changed how we
destroyed the main thread's QThreadData. This merges the call to
destroy_current_thread_data() for both types of Unix systems: those with
broken thread_local destructors and those with working ones. It turns
out that the function got called too early for us in those working
systems (see updated comment).

The clean up of the QThreadData is split into two different mechanisms:
 * for any auxiliary thread, when it exits, PThread will call back to
   destroy_current_thread_data()
 * for the thread that called ::exit(), PThread won't, but ::exit() will
   invoke set_thread_data()::TlsKey's destructor

This is different from the situation that existed prior to commit
65093a84c2b94b1543fd4593bc45d491951d28d4: first, there's no code in
qcoreapplication.cpp for this (all in qthread_unix.cpp). Second one may
call ::exit() from any thread, whether that is the thread that called
main(), the thread Qt thinks is theMainThread, or any other.

This commit moves the tst_QCoreApplication check for no extant objects
to a new test. I've chosen to add a new test instead of running a helper
binary via QProcess because we do have a couple of !QT_CONFIG(process)
platforms in the CI, and this is too important.

Credit to OSS-Fuzz for finding this, though it is not itself a fuzzying
problem (all tests of a given structure were crashing on exit).

Fixes: QTBUG-132381
Task-number: QTBUG-130895
Task-number: QTBUG-129927
Task-number: QTBUG-129846
Task-number: QTBUG-130341
Task-number: QTBUG-117996
Change-Id: Ie294dce7263b4189f89ffffd9155ec71d31b89d9
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 1da7558bfd7626bcc40a214a90ae5027f32f6c7f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 6dc19b55fc6d6dd3198b744f713101cf3b77c0c8)
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2025-01-14 02:21:01 -03:00
Mårten Nordheim 42a62db6f9 tst_Http2: Test SETTINGS_HEADER_TABLE_SIZE handling
This somewhat duplicates some other tests, namely the QHttp2Connection
one, but tst_http2 is our only coverage of the HTTP/2 code prior to 6.8.

This change adds a test where the server sets the
SETTINGS_HEADER_TABLE_SIZE to 0, effectively disabling the dynamic
table. We, in an earlier patch, makes the HPack table error out if
a new header entry is about to be added if the table has not been
resized below a changed 'max'. So, we take advantage of that here and
set the new 'max' capacity without resizing the table, or updating
dynamic capacity causing it to fail if the client doesn't send the
expected Dynamic Table Size Update.

Task-number: QTBUG-132277
Pick-to: 6.5
Change-Id: I1ca8ca7828d5b83606e7adbcfc13c154fa1e3cab
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit f7c3acd27ff48b24f99086be206acbe7e00e3208)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 9a1edf52d4b5af35d29b4b2563d1cebafe889385)
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-01-13 17:44:13 +01:00
Mårten Nordheim fc4bb856d9 HPack: test and fix Dynamic Table Size Update
Expose some new API to make it easier to test too.
Will be used in follow-up patches for a http2 bugfix.

The setMaxDynamicTableSize() method no longer sets capacity or evicts
entries. This can then be used to set the new maximum size which we will
accept later when we receive a Dynamic Table Size Update.

This flow makes sense with both encoder and decoder. The decoder would
usually be set by us when we send our SETTINGS frame, and then the
Dynamic Table Size Update would be sent by the peer.
For the encoder we would set the maximum size when we receive the
SETTINGS frame, and then we must defer the actual resizing until we
can send the Dynamic Table Size Update ourselves, usually along with the
next HEADERS frame.

Pick-to: 6.5
Task-number: QTBUG-132277
Change-Id: I959f5006eb09427d130735efe136da8c04453fa2
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit be477819ac17850632bca6ce59ee2c8ef11191cd)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 2101e9146522efa3810b10312207f7700fdc4bc7)
Reviewed-by: Mate Barany <mate.barany@qt.io>
2025-01-13 17:44:10 +01:00
Volker Hilsheimer 0be9ebcc22 JNI: replace va_arg helper with variadic template
Android 15 (at least) seems to have changed how float arguments are
passed to native functions, breaking our (conceptually correct) code for
processing the va_arg list into a list of static argument types of the
function implementation.

To fix this, we have to move away from using a va_arg function, and
register a function with statically typed arguments instead.

Use a template function that we instantiate with variadic arguments
deduced from the actual function, using a factory-helper that generates
a JNINativeMethod struct with that template instantiation as the
function pointer. Move all of that into a struct where we can also
declare the signature string as compile-time constant without cluttering
the namespace with static objects.

We can now remove the helpers that took care of type promotion in va_arg
functions, and of the tuple-construction from a va_list.

As a drive-by, don't cast function pointers to void *; it's strictly
speaking undefined behavior in C and should have generated a compiler
warning, if not a hard error [1]. We must initialize the
JNINativeMethod::fnPtr member with the address of the function pointer
instead.

[1] https://port70.net/~nsz/c/c11/n1570.html#6.3.2.3p8

Also, declare the native method as the JNICALL calling convention. That
is only defined on Windows, so makes no difference in practice, but it's
the correct thing to do anyway.

Fixes: QTBUG-132410
Change-Id: I190b95fcbcd07cf99c6765fa426c3c351f91994a
Reviewed-by: Volker Krause <vkrause@kde.org>
(cherry picked from commit e91a17873ee4ae58d369b8eb70029cf895b31d03)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 103aa5afb2d95f883daea41715c97455550285b2)
2025-01-13 14:52:09 +01:00
Volker Krause 8814bb1e81 Expand tst_qjniobject to cover float arguments in JNI native methods
Demonstrates the problem described in the bug report on Android
15/x86_64. QEXPECT_FAIL the relevant test cases until the next
commit fixes the problem.

Task-number: QTBUG-132410
Change-Id: I065fd29282ef42ed75a2ed8177ded183c92aa6e3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 749367da8c3309c98b3285836c2bd8abcd7274b1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit e342a5261332c2ef2c3b0d4d14f22dbdbd4a99c3)
2025-01-13 14:51:49 +01:00
Marc Mutz e843e299a3 tst_QSaveFile: QVERIFY the commit() return value in symlink() test
It's kinda is important to verify that commit() worked; all the
follow-up tests assume it, so wrap the calls in QVERIFY().

Amends 7e5e7eeaa1.

Pick-to: 6.5 5.15
Change-Id: I01185d65a5ec06ed122e59c43d9cdcc3a7157259
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 97fe38ff0d1e60f92c0bfa6fb3571a0433e60352)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 3660ff9ff88a69ce9f1366e5870f6aa0323f1fda)
2025-01-13 13:50:28 +00:00
Marc Mutz 6f38ff4ba5 tst_QSaveFile: mark a QString const
To ensure we don't overwrite it in this quite long function.

Amends 7e5e7eeaa1.

Pick-to: 6.5 5.15
Change-Id: Ie5f81b50d2d66ba9e064810f8cbc1a7af298cc2b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 67a906b5564a1ccf03e547aa78fc6fd910d9cd15)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit b2dad9724d5c92582851e56ba73383644ea8b32b)
2025-01-13 13:50:22 +00:00
Ahmad Samir f3d2c6879d tst_Q{Chrono,}Timer: fix typo in CMakelists.txt
Spotted by Thiago in code review.

Amends bd764cc1ca and
9cf47946fc.

Change-Id: I01b04d2c80c62158917e6f190418053edc0a0fe5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 4073a75959e00722271b8784cb8cb2ee40756ff6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 69277b9ed921a0146ea1fe0082f93889d96e18b0)
2025-01-13 13:50:09 +00:00
Marc Mutz 85f77604e3 QTemporaryFile: fix incorrect info about duplicate placeholders
The docs said only the first placeholder would be considered; in fact,
it considers only the last.

Fix the docs and add a test (also for QTemporaryDir).

Amends b4bb4449aea7592afdb9b9134bb90c40fe29735a.

While 6.6 and earlier are unaffected by the incorrect documentation,
pick this to all active branches in order to verify the behavior is
the same everywhere.

Pick-to: 6.5 6.2 5.15
Fixes: QTBUG-132597
Change-Id: Ia7a37f714f834191b07420d31ca9024702b537cc
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit e7abbc7bf3ab06359b2847b1e1a46c38d8bc6581)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 58221c19559541d7da24fa68f05310aeee230e26)
2025-01-13 13:50:00 +00:00
Jøger Hansegård c803b1f534 Test that reset() and move assignment handles self-assignment
Calling reset() with the owned handle should maintain ownership and not
leak resources. Move assignment should also handle self-assignment
without leaks. The new tests verifies that this holds true.

Task-number: QTBUG-132507
Change-Id: Icdfa4d67b06b71a74e810593e57449b51982c98c
Reviewed-by: Tim Blechmann <tim.blechmann@qt.io>
(cherry picked from commit 03bd9491491881529ad28cd6d672edfdda9a0065)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 33f37ff6376835dc8add4e5d8273f3dc5e7b086d)
2025-01-06 17:09:41 +00:00
Ivan Solovev 60f945527a QtConcurrent: fix support for callables with deduced return type
Commit 6ebe3d0f08 introduced extra
SFINAE checks on the template conditions.
However, it broke the case of using callables with deduced return
type, because SFINAE does not work for such conditions and treated
as a hard error instead.

Fix by explicitly providing all template parameters, so that compiler
could figure a better overload on its own.

Only QtConcurrent::blockingMapped() seems to be affected, but add
unit-tests to check all other methods as well.

Fixes: QTBUG-130766
Pick-to: 6.5
Change-Id: I1ddbe712d8ce04ac96ba13841cb569d728cfb943
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
(cherry picked from commit f73765682e7c8f1e0e78b7464deec57c7f2669ba)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 7b356f0f31e3bbfaeed25dd338c9c9c6d3c3f2c4)
2025-01-06 17:09:37 +00:00
Jøger Hansegård afa9ae9b0c Add missing noexcept specifiers for QUniqueHandle handle traits
Handle traits should be simple, and not require exceptions. This patch
will allow us to improve the noexcept correctness of QUniqueHandle.

Change-Id: I84d92818a2fcea5b98e09c0b7dc08b251751396c
Reviewed-by: Tim Blechmann <tim.blechmann@qt.io>
(cherry picked from commit 3c57c7357422bdfda60f56901a7590b258915b6b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 8adfacca6184d439c5febd71a6c78db3edce87c6)
2025-01-06 12:16:31 +00:00
Jøger Hansegård c082c07791 Make QUniqueHandle::reset() default to invalid handle
Having a defaulted argument to QUniqueHandle::reset() gives a convenient
way of releasing ownership without assigning a new handle, and makes
the QUniqueHandle API more similar to std::unique_ptr.

Task-number: QTBUG-132507
Change-Id: I842d4545d7cc2da8fe2df08280d0d816ed4be7fd
Reviewed-by: Tim Blechmann <tim.blechmann@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 248ac4128fe86150532ff7146d0459abb5260946)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 5653829bf8503c38f705893ebbf6b11dd69b211b)
2025-01-03 19:28:04 +00:00
Shawn Rutledge f5000beeb6 Fix QTransform::quadToQuad() to work with QRectF
A typical usage for mapping a 4-point polygon to a rectangle might be

  QTransform transform;
  bool ok = QTransform::quadToQuad(polygon, polygon->boundingRect(),
                                   transform);

It works because the QPolygonF(QRectF) ctor is implicitly called on
the second argument; but that ctor turns it into a 5-point polygon.
So it should be legal for QTransform functions to work with 5-point
closed paths.

Fixes: QTBUG-21329
Change-Id: Iae249012e14b8a3e8d3b0dfa35da8f9759359832
Pick-to: 6.5 5.15
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
(cherry picked from commit 48b1af941c50ab28cc92f9ea65a8a74a32eaf2bc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 5ead2a3d63a905ed758390e1558dbac744756077)
2025-01-03 05:52:46 +00:00
Ivan Solovev 6355568cc0 Fix QtFuture::when{All,Any}() overload resolution
Both whenAll() and whenAny() have two overloads:
* an overload taking two input iterators, e.g.
  whenAll(IntpuIt begin, InputIt end)
* an overload taking an arbitrary number of future objects, e.g.
  whenAll(Futures &&... futures)

The public APIs are properly constrained, but internally they call
QtPrivate::when*Impl() template functions, that have the same two
overloads, but do not have any constraints.

As a result, passing exactly two QFuture<T>{} objects was leading to
the compiler picking the Impl overload that takes a pair of iterators.

Fix it by applying a subset of constraints from the public API to
the private implementation as well.

Amends 102f7d31c4 which was introduced
for Qt 6.3, so picking down to Qt 6.5.

Fixes: QTBUG-131959
Pick-to: 6.5
Change-Id: Ide29ac9a494d07870e92957c40c1f614e56825f8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 8aef5b0d8fd57684abe39c88af8c14d8882ef07b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 90fab1e4e98962ecaff5fd66d218d4f76cb7b8cd)
2025-01-02 19:19:36 +00:00
Marc Mutz fb5fb04fb7 tst_QImage: fix discarded QFile::open() results
Wrap them in QVERIFY(), as usual.

Found by QFile::open()-turned-nodiscard-come-6.10.

Amends e673e5a257 and
25c96d547b.

Change-Id: Id39e5d9e500b524af8443cb57916a12f98bd7c23
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit cf6ae9a90106a3557a8df1e0d2567b02a4ef6ded)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 11f485ea68cff32f550c3d99475bb859a7495f69)
2025-01-01 04:02:36 +00:00
Ahmad Samir 547e27caab moc: fix GCC -Wextra-semi colon after member function definitions
As pointed out by Thiago the QT_DECLARE_METATYPE calls are redundant, so
remove them.

Task-number: QTBUG-132101
Change-Id: I73800e70d3f270fb87941d4e053aa7ac5ed1841c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 3bb4c4949fed9ccf8653151c78d5130b8db00716)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 01edc916d210238a06a043c1f8f9f44d69113ce2)
2025-01-01 04:02:35 +00:00
Ahmad Samir c2aef659ba QCryptographicHash: hashInto(): check the buffer size earlier
We can use hashLengthInternal() to check if the buffer is big enough.
This matches what the QCH::hash() method does, it also has an assert
that `result.size() == ba.size()`, so we can assume this works with
OpenSSL's EVP_MD_get_size() in EVP::finalizeUnchecked().

Amends c70c81b371.

Change-Id: I64935f3d590ab243b361a0b764f011c388820e32
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit b83e825fab16f83f86149ead78efb6ec3d2fa16d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit cc369ad07f9d66fe7ff71170a1a3ddfd2245e8cb)
2025-01-01 04:02:35 +00:00
Thiago Macieira f3fc37146d QSaveFile: make it so flush() errors imply commit() failed
QSaveFile records past write errors in writeData(), but often the
QFileDevice::writeData() calls it places will succeed because the data
is only being buffered. Instead, the failures are noticed only by
flush(), whose actions do not affect QSaveFilePrivate::writeError.

[ChangeLog][QtCore][QSaveFile] Fixed a bug that caused commit() to
return true and overwrite its intended target file even though it failed
to flush buffered data to the storage, which could cause data loss. This
issue can be worked around by calling flush() first and only calling
commit() if that returns success.

[ChangeLog][QtCore][QSaveFile] Fixed a bug that caused commit() to
return true even after a cancelWriting() call had been placed, if
writing directly to the target file (that is, only with
setDirectWriteFallback() set to true). Note that the state of the file
does not change under those conditions, only the value returned by the
function.

Drive-by clarify a comment from 6bf1674f1e51fd8b08783035cda7493ecd63b44
(Qt 4.6 "Don't drop errors from flush on QFile::close") which had me
chasing the wrong lead.

Fixes: QTBUG-132332
Pick-to: 6.5 5.15
Change-Id: I427df6fd02132d02be91fffd175579c35b9c06cc
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
(cherry picked from commit 92373d353cf090faa03cbc8aca505d1784b10b54)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 09d44fdef3acf4146a26d6ae757eb2915b29f147)
2024-12-26 19:50:47 +00:00
Marc Mutz cad7935b6f tst_QSpan: check QList<int> -> QSpan<const int> doesn't detach the former
It does.

While std::span, does, too, and so users should be using
std::as_const(), it's quite simple to avoid for QSpan, so we'll fix it
in QSpan. This patch adds the reproducer.

Task-number: QTBUG-132133
Change-Id: I2e416fb7344830cd5e0d945cce61491cd6f4a7a5
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 05b9a4b2deefd586356e1f36d84372b06e74cfe3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit aff082764ae2dc6ca3c7e9c9ee6573bdd5b4a2de)
2024-12-25 07:37:44 +00:00
Mårten Nordheim 5e84d211d5 tst_QHttp2Connection: make settings exchange wait for acknowledgement
Is needed when sending more SETTINGS frames during the test later

Task-number: QTBUG-132277
Change-Id: I24b2a5d1b2e7aecd8687db5b24f37233df3b91dd
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit 6e7a15f5c50a94216bcf35241ec008e6c419ba18)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit b91edac40d4ca62c19038853f0e45d48b0957325)
2024-12-20 22:02:55 +00:00
Edward Welbourne 8a63c9b438 Fix assertion failure on parsing Feb 29 in a non-leap year
If there's no way to resolve an actual date with the data parsed, then
the date-text given is invalid, so don't try to fix it up.

Pick-to: 6.5
Fixes: QTBUG-132115
Change-Id: Ic6821bd01394d4dba1be1d25806c372800f8176b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 72519aeb237a4085aeb6290b0b4088c690fad106)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit e2a0ef30da08ed46ea90e2c7aa297c8f8faf0dbb)
2024-12-20 07:20:44 +00:00
Thiago Macieira d490a1ac09 QCommandLineParser: include the positional arguments' sizes in --help
We were mostly ignoring them because it looks like most people's options
were longer than their positional arguments. The rest must have just
accepted the enforced wrapping.

But if you have very short options like single-letter only ones or none
at all, the positional argument wrapping is unnecessarily short.

[ChangeLog][QtCore][QCommandLineParser] Made it so the positional
argument descriptions are taken into account in the aligning of text for
helpText().

Fixes: QTBUG-131716
Change-Id: Ib1eee62c7cf4462f6a26fffdec233ba849ebf158
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit 8928b0fbb9ca4caf9b63a32b3d2a73a6da096755)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 55a46ec005894394031efbee1b9c2269bb1d8eea)
2024-12-20 04:30:30 +00:00
Tor Arne Vestbø eaaab38c3a Extend blacklisting of tst_QWidget::showMinimizedKeepsFocus to macOS 15
It's flaky on all version.

Change-Id: I01b2f0877efc100578c55d69e9f9ed65c02b2aab
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 1ce019815ba62245fd8ae6e8fb5e47f77621c3be)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 5051e2b97b44e43ddbdc9ec2beddb162e2d61a0d)
2024-12-20 04:30:28 +00:00
Robert Löhning e25f93c151 QRadialGradient: Fix crash on huge x values
Credit to OSS-Fuzz

Fixes: QTBUG-130992
Change-Id: Iefaa6964966f6828bc23a603f085d283189f1a3b
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit 42bd879e2bc6e0d8370d320cca17df36ea68d570)
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit e63884c5933d0a5c63fbbe27af85afd6feb61e89)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-19 05:16:42 +00:00
Christian Ehrlicher f70803eefb QBoxLayout: don't crash on passing invalid index
Passing an invalid index gives an assertion in debug mode and crashes in
release mode due to an out-of-bounds access. Fix it by appending the
given widget (same as passing a negative index which is documented).

Pick-to: 6.5 6.2
Fixes: QTBUG-130275
Change-Id: Id0c245e185acc36e5d07cea1d22619bb0e9eee07
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit 0f9062ec71021c256dba7ee8498f036d7aac0821)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 3c0f08ab7064d2c4183844613f08b3630f180fef)
2024-12-19 05:16:38 +00:00
Christian Ehrlicher 52103b5499 QStyleSheetStyle: Fix resetting fonts for subwidgets
When a compound widget is styled with a font through a property and the
default styling has no font settings, the font was not reset to the
parent font but left it the styled state.
Fix it by not resolving the current font when the style rule has no font
settings - use the parent font directly instead.

Fixes: QTBUG-131685
Change-Id: I8e79423cfeff24143cd051b282503c4565125b4d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 5731fe051e48e7a256ef31ae93cfb89ce8d871cc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 0dd2561d54209666cf78d053caf9b2d94fb1d80e)
2024-12-17 23:57:37 +00:00
Marc Mutz fb91b0d307 Q{Any,Utf8}StringView: fix construction from arrays of unknown size
Like QStringView's, these classes' documentation promised
is_constructible<View,Char[]>, but failed to deliver, because neither
the (const Pointer&) nor the (const Container &) compile for arrays of
unkonwn bounds, and the (const Char*) one is just a QDoc fake.

Apply the same fix as for QStringView: Add a ctor specifically for
arrays of unknown bound, delegating to the (ptr) overload.

The GHS compiler doesn't like the CanConvert static_asserts, so
comment them out for it. The functionality itself is tested by
the from*ArrayWithUnknownSize tests.

[ChangeLog][QtCore][QUtf8StringView/QAnyStringView] Made construction
from arrays of unknown size compile. Such arrays will use the const
Char* constructor, determining the size of the array at runtime.

Pick-to: 6.5
Fixes: QTBUG-112746
Change-Id: I7acdcae3c5bdf80a0bed673e621d53ef34a92a1e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 734bd05d0a6d37d6488cf8d1b2b9f79b9329d966)
(cherry picked from commit 51bfc9da41faa41a3161d30879b394a0dac94dcf)
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-12-16 20:45:24 +00:00
Dheerendra Purohit 829c0e55cd QToolBar: Update implicit icon size if style changes
Add logic in QToolBar::changeEvent() to update icon size set via
stylesheet.

Fixes: QTBUG-45949
Change-Id: I7fce830a969af8774116f0229153668252b55598
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 18733355689fc3ea336631b9c5ff17e3e983fb28)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit a77b11c548c0a24a6a50654e4657593543bbfad8)
2024-12-16 15:07:19 +00:00
Marc Mutz 909c3fab5c tst_QByteArrayView: check conversion from various QSpans
This is supposed to work, so check it.

Conflict resolutions for 6.8:
- added missing qspan.h include

Change-Id: I201033656f123b09644e5de447cd5d7b038e5155
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 8a3ffe7044249bcfb5185bd87a9713685d48de7b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 9bcbeea2adeda6b23b030a18af04fce9bf7e5998)
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-12-15 13:41:43 +00:00
Marc Mutz 6eef35abce tst_QStringApiSymmetry: test QByteArray(weak)/QByteArrayView overloading
Adding it here since this test case already has all the infrastructure
for the overload test.

Pick-to: 6.5
Change-Id: I2d7fff9d2d82fed3db2446690a354f939c9a37fc
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 140dac92f2a8ee1f54843f69be4026900a049ee7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 29e269567610aff4e26738aff507e58e23900133)
2024-12-13 08:00:16 +00:00
Marc Mutz 34dfd7e862 tst_QAnyStringView: complete Char[] CanConvert sets
Other view tests test Char[N] and const Char[N] separately. Do the
same here.

For many Char types, the array CanConvert test was missing
completely. Add them.

Pick-to: 6.5
Change-Id: I1d0b6de394d548554a547f190e74cb8cead6ecd4
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 0bbbbfc78beb2393ceea0de0fa85942f71d0a2ed)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 443bdb96206a66159ccd07e0704015cf07321327)
2024-12-13 08:00:16 +00:00
Marc Mutz 738a84115f tst_QString: extend arg() tests with enums w/o explicit underlying_type
The QtDeclarative code causing QTBUG-131906 hits UB, because it tries
to store -666 in an enum {A, B}, which has a valid range of [0,1],
therefore its underlying_type is uint, yet, as per [conv.prom]/3¹,
integer-promotes to _int_ instead, so in Qt 6.8 would cause the
arg(int) overload to be called, outputting -666, while in Qt 6.9, it's
treated (correctly) as an unsigned value, outputting -666's two's
complement, a positive value.

Add a version of the scenario that does not cause UB.

¹ Thanks to Ahmad Samir for digging up the pertinent legalese.

Task-number: QTBUG-131906
Pick-to: 6.5
Change-Id: Iba1a04de523a0b4cd1c87deea40c643cf16df14f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit e64fd05fecae291c9d7358d2e47d7170995af256)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 06a209384aff389af1b73cc77266f9b392219845)
2024-12-13 08:00:16 +00:00
Marc Mutz 3aef5b9457 tst_QStringView: verify that char16_t[] args aren't ambiguous for QS/QSV overloads
They are not.

Task-number: QTBUG-112746
Change-Id: I2a20d68543f5914690acbcb4f214b1d98681de6a
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit 67990c16a6b631c1d809d1ad656fc941293b3f83)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 31e30122963796d454d0351da92b0a608f305e50)
2024-12-13 08:00:15 +00:00
Marc Mutz e11edced7e QStringView: fix construction from arrays of unknown size
The original idea (8b5aa7b6c4) of the
separation of array and pointer ctors was to determine string literal
sizes at compile-time in C++11's limited constexpr semantics.

But when the scanning for NUL characters was added to the array ctor
in 107ff4c1d6, the distinction between
the two ctors became meaningless, because we were able to assume
post-C++11 constexpr to make the Char(0) scan a compile-time action.

Finally, 9e1dc1e8a9 removed the array
ctor in favor of the generic Container ctor. I didn't check whether
the old code handled arrays of unknown size, as in

    extern const char16_t str[];
    QStringView sv = str;
    ~~~
    const char16_t str[] = "str";

but std::size() (and therefore if_compatible_container) surely bails
on such arrays, and if_compatible_pointer also SFINAEs out. As a
consequence, such arrays cannot be used to construct QStringViews atm.

Fix by adding a new constructor for arrays of unknown size, delegating
to the existing pointer overload.

The GHS compiler doesn't like the CanConvert static_asserts, so
comment them out for it. The functionality itself is tested by
the from*ArrayWithUnknownSize tests.

[ChangeLog][QtCore][QStringView] Made construction from arrays of
unknown size compile. Such arrays will use the const Char*
constructor, determining the size of the array at runtime.

Pick-to: 6.5
Task-number: QTBUG-112746
Change-Id: Ifdb217350d93d38f081c99f14661975491d32076
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 56faffd92bf0ac459a921ec043a6f3b3dba51acc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 2dfc0cb6f6f1e29a0a1318793b29b89390543be6)
2024-12-13 08:00:15 +00:00
Edward Welbourne 2fa5a525a3 Cope with IANA DB links that aren't in the CLDR alias mapping
As documented in the LMDL spec (see comment on unAliasedLinks in the
diff) not all links in the IANA DB are represented as CLDR
aliases. This didn't surface until a recent update to the IANA DB used
symlinks more aggressively.

Add a set of known cases of this to exclude from hasAlternativeName()
checks and let's hope it doesn't grow too often.

Pick to 6.8 required #include <set> that was transitively available on
dev but not on 6.8

Change-Id: Ia12d9fcad96485469ded6bdb7345a400bd34efae
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit ae6b6bf363d71184269104e4bfbb19a9abd27a24)
2024-12-11 12:23:10 +00:00
Marc Mutz 2a5d0dcf10 tst_QStringView: add missing CanConvert from char16_t/wchar_t arrays
QChar[N] and ushort[N] are being checked, it's unclear why char16_t[N]
and wchar_t[N] were missing.

Add them.

Pick-to: 6.5 5.15
Change-Id: I9a2df2a75886b950e8c2bdec843e3e693e536f86
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 89401858696d63b8a13c945d5db63856a3b6f5ba)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 67adc2227dc179828d01475c2b9e534bca3152b7)
2024-12-11 06:29:24 +00:00
Marc Mutz 24ff7e683d Confirm QLatin1StringView can be constructed over arrays of unknown bounds
It can (unlike the other views).

Pick-to: 6.5 5.15
Task-number: QTBUG-112746
Change-Id: Id976429611c53f1c707de1d989c454507b8f4773
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 01f0305dc6f751d3eb4d1681a2f8f9f3165b547c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 0c054f6844583136f19608526b0319735d66f0b8)
2024-12-11 06:29:18 +00:00
Edward Welbourne 15189742c8 QLocale: fix likely subtags to include und -> en_Latn_US
The lack of this was hidden by other rules (redundant with it) until
CLDR v45, but v46 prunes the redundant rules, breaking this. So
include the missing rule and tweak the code that assumed likely
sub-tag rules preserved language, since this one doesn't. Rework the
tail of withLikelySubtagsAdded() to correctly use this rule, now that
we have it. (The prior comment about there being no match-all was
wrong: CLDR did have it, but our data skipped it.) Amended one test
affected by it (when system locale wasn't en_US).

On picking to 6.8, uiLanguages() needed some coaxing to avoid
duplicate C locale entries in tests of qualified C locale.

Task-number: QTBUG-130877
Change-Id: I2a415b67af4bc8aa6a766bcc1e349ee5bda9f174
Reviewed-by: Mate Barany <mate.barany@qt.io>
(cherry picked from commit 303863170c3ea7d1ee1b7188f507ad432ed3f860)
2024-12-10 12:35:05 +01:00
Marc Mutz 8a270b35fe tst_QString: extend arg() tests with unscoped enums
Conflict resolution for 6.8:
- remove the QEXCEPT_FAIL - 6.8 was never affected

Task-number: QTBUG-131906
Pick-to: 6.5
Change-Id: Icdd647bf6a36ad11e6e19786121d25392b53236c
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 64daf773afff7dbe440621a57f015d985e41f84a)
2024-12-10 08:59:57 +00:00
Tatiana Borisova 948599e7b7 QDomDocument::toByteArray() crashed in case of high XML nesting level
The issue the combination of:
- 300+ XML nesting level
- Small stack size, by default on Windows (1 MB)
- Unexpected and unexplained large stack frames with MSVC (3.5 kB)

The described factors combination leads to the stack overflow on
Windows + MSVC.

To fix the problem, I got rid of the recursive call from
QDomElementPrivate::save() and removed QDomNodePrivate::save()
implementation.

Instead of those I added the method that iterates through the tree not
using recursion.

[ChangeLog][QtXml] QDomDocument::toByteArray() now iterates the
nodes of the document instead of recursing into subnodes. This avoids
a stack-overflow crash that used to arise with deeply-nested document
structures.

Fixes: QTBUG-131151
Change-Id: Ib74aaef1422716f2aafcb89dfc8c05ef334e2a54
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 387633a6069a5e0e9b976971691b1b82725b6132)
2024-12-06 11:53:53 +01:00
Edward Welbourne 9399ffd301 Fix TZ backend to include CLDR-known zones by territory
As previously noted, this backend uses the legacy zone.tab file, which
only gives one territory for each entry, where zone1970.tab gives
several. Until we switch to using the latter, we thus don't know all
the territories in which an IANA ID is used. However, we do have such
data from CLDR and deploy it in the default backend to filter the list
of all available IDs. As a result, the TZ backend lacks some results
of filtering by territory that the base-class would get for it,
because the CLDR data associates more territories with some IDs.

It implements the overload because its lookups in a hash are
potentially more efficient than generating its full list in order to
iterate it while intersecting with a CLDR-derived list of candidates.
Leverage that hash also to do efficient intersecting with the
CLDR-derived list, which lets us avoid duplicates almost for free, to
make the subsequent union with the directly-derived entries from
zone.tab efficient. This incidentally resolves a TODO about handling
of QLocale::AnyTerritory. In the process, add more notes to the
zone{1970,}.tab details.

Restructure the base-class implementations of filtered available IDs
to separate their generation of a CLDR-derived list of candidates from
the intersection of that with the available IDs. For the territory
overload, this lets the TZ backend share the CLDR-derived list; for
symmetry, do the same to the offset-filter, too. (This also makes each
function responsible for fewer things.) Similar treatment may also be
needed for the ICU and chrono::tzdb backends, since the former also
overloads the territory filter and both overload the offset filter.
However, leave those for now (with comments added on the possibility)
until we have evidence they actually do need this.

On picking to 6.8, the chrono::tzdb backend part is gone, as that's
new in 6.9. QTZP_p.h also had a trivially-resolved conflict due to
adjacent 6.9-new content sharing the new protected: block. The initial
pick's conflict in tst_qtimezone.cpp is resolved by picking onto the
correct parent.

Task-number: QTBUG-130877
Task-number: QTBUG-64941
Change-Id: Ibb347df88dd14b55f8f580bb4c9e37e5c56a533a
Reviewed-by: Mate Barany <mate.barany@qt.io>
(cherry picked from commit 54c2d6ded779c3b9843fa18535b79ababa0d1a74)
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-12-05 20:26:43 +01:00
Assam Boudjelthia a0897816f8 Android: fix tst_android::testFullScreenDimensions()
The test was reporting wrong app size values and then
expecting a wrong height after subtracting the system
bar heights. This was happening because an older API
was still being used, using newer APIs fixes that.

Fixes: QTBUG-131338
Pick-to: 6.5
Change-Id: I7306ce62d9c683f84069cc19086a6cd28abf5441
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 50603fddc535179ee02379a8807fe5cb104e0aae)
2024-12-04 15:34:32 +00:00
Assam Boudjelthia 8e2209f3b0 Android: refactor tst_Android::testFullScreenDimensions()
Pick-to: 6.5
Change-Id: Iea06638d1c8eebf36ae010dad23fbeab4b890597
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
(cherry picked from commit ebdc01c1861667116aa09914b46df1ac8504baf9)
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2024-12-04 15:34:27 +00:00
Ivan Solovev 528c78d3a2 tst_collections.cpp: fix RecursiveList comparison case
The RecursiveList structure was defined like this:

 struct RecursiveList : public QList<RecursiveList> {};

However, this definition does not make any sense when it comes to the
relational operators. QList<T> needs to have operator<() defined for
the contained type T.

The current implementation of QTypeTraits::compare_lt_result_container
simply enables operator<() if Container is a base type of the contained
type. This unblocks the compilation of checks like

 static_assert(QTypeTraits::has_operator_less_than_v<RecursiveList>);

However, this is useless in practice.

This commit updates the struct to have a meaningful definition of
operator<().

Amends 9f13842fe6.

Task-number: QTBUG-120305
Pick-to: 6.5
Change-Id: Iaee96385a33ff131bdceabe945265b3285a370c2
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 58c492a4dc9868faff7e9334758947cf0027eeac)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-04 15:14:25 +00:00
Ivan Solovev 09ddc1b893 Fix tst_collections.cpp
There was a copy-paste error in NoCmpRecursiveList definition.

Amends 9f13842fe6.

Pick-to: 6.5
Change-Id: I1487710e51a8b92c53b79b747c324654d9b9f334
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 65fede8fae459da86784b0757ca6c3179a8fb883)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-04 15:14:22 +00:00
Edward Welbourne 06f77ab19c Correct handling of World in mapping MS's zone IDs to IANA ones
The AnyTerritory entries in the zoneDataTable are derived from
territory="ZZ" entries in the upstream CLDR data; the World ones from
territory="001". The latter give the default IANA ID for each MS ID,
the former give an (often legacy) IANA ID for the MS ID, that is not
based on geography. Some of these are being removed at CLDR v46.

The documentation said the ZZ entries have "no known territorial
association", hinting that there may be some (unknown) territorial
association; however, CLDR's inclusion of them is as entries with a
known non-territorial association, so revise the phrasing to reflect
this.

Also document that windowsIdToDefaultIanaId() returns empty when
there is no territory-specific value, and callers can use the
territory-neutral call to get a suitable value in that case. (They
may, however, wish to distinguish this case, to treat it differently,
so I decided not to just return that in place of empty in any case.)

The upstream CLDR tables do have entries for territory 001, so we
should report these if asked for World as territory. Amend the
available zone ID lookup and mapping from MS to IANA functions that
take a territory to duly handle World via the default-data that was
derived from 001 data in CLDR, instead of from the territory-varying
table, from which those were effectively filtered out when generating
the two tables. Update docs to mention this handling of World, for
contrast with that of AnyTerritory.

In the process remove a spurious split-on-space from the MS to default
IANA lookup, asserting there is no space (in a field now stored in the
table for single IANA ID entries, instead of the one for space-joined
lists of them in which it used to be stored, before I noticed it's
always only one ID). There is a matching assertion in the cldr.py code
that extracts the data. Added an assertion to this last, that each
default IANA ID given by CLDR's MS data does in fact also appear as
one of the IANA IDs for at least one territory (potentially ZZ), and
comment in C++ code on why this means we don't need to scan the
windowsDataTable in a few places, where it would just produce
duplicate entries.

On picking to 6.8, removed the timezone_locale addition, only relevant
on 6.9 and later.

[ChangeLog][QtCore][QTimeZone] Corrected handling of QLocale::World
and clarified in docs how QLocale::AnyTerritory is handled when
QTimeZone selects zones by territory.

Task-number: QTBUG-130877
Change-Id: I861c777c68b0cb73a194138fe23fbff839df49e6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit e23dc7c420297fb62db9834a17c59bbf5992dad7)
Reviewed-by: Mate Barany <mate.barany@qt.io>
2024-12-04 11:50:36 +01:00
Thiago Macieira 47d584b281 selftests/silent_fatal: disable core dumps and MSVC debug dialogs
Otherwise the test may hang forever waiting for the user to click a
button or just too long waiting for the core dumper.

Change-Id: Id570aab34608aed86b86fffd8d196c84296e0389
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 898abae6adf0ab9ff75752df456aaedef71ae096)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-04 01:47:11 +00:00
Edward Welbourne e5ab6a6588 Shortcut QDateTime comparison when difference is large
We want to avoid caling toMSecsSinceEpoch() since it's expensive for
LocalTime (which is presumed to be the common case). We can do so when
both sides have the same offset from UTC (and this can cheaply be
determined) but that's no help for two local times months apart, one
in DST the other not. However, in this case, the difference in millis
is big enough that no plausible difference in offset can overcome it,
so we can again avoid toMSecsSinceEpoch() and simply compare millis.
This should make some previously-expensive comparisons cheap.

Add test-cases to the QDateTime ordering test that verify this doesn't
lead to mis-comparison at the biggest offset-difference known.

Fixes: QTBUG-131491
Change-Id: I1afd5d058c8663c908f898d4c50d0837549b87db
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
(cherry picked from commit ef540d77751e24fe0b345694f43cdafca3434c68)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-02 13:49:13 +00:00
Frédéric Lefebvre 8a874d5b31 Fix flakiness in tst_QWidget::saveRestoreGeometry()
Add setWindowFlags(Qt::X11BypassWindowManagerHint) to bypass the
creation of the frame. We are checking the geometry of the widget
itself, not of his frame in this test.

Remove the comments preventing that it can be flaky when debugging.

Remove unnecessary QApplication::processEvents().

Remove several unnecessary qWait().

Change-Id: I4a4bcf5cb9522a9a504925c1ae31f0677deae3b1
Pick-to: 6.7 6.5
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit cf45ae08bc90b5dbbd20a7e7842856805205bca4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-29 16:58:42 +00:00
Fabian Kosmale 1be6e99b55 moc: Do not get confused by constexpr token in functions
Surprisingly, moc had no awareness of constexpr at all. This would still
mostly work, as we were just skipping it, except for the case where
constexpr appears as the last keyword – in which case we'd pick it up as
the type name.

Fix this by adding constexpr as a known token, and add it to the list of things we ignore in testForFunctionModifiers.

Pick-to: 6.5
Fixes: QTBUG-122609
Change-Id: I0ae0c0477e611ff83fbb841233035bea52216be2
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit 984ad9019a62a9a130647dbd765e38ee2e6250c1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-29 14:47:56 +00:00
Even Oscar Andersen 0c60d2c066 wasm: Fix focus handling
We had input handling enabled as a precondition for setting focus.
This is wrong, we need to have the focus for toggle buttons
and other non-input things as well.
(Also toggle buttons act on spacebar).

Also selects a new active window if the window
that is active (i.e a dialog) is deleted.

Also shift + tab did not always work, fixed
to emit Key_Backtab

Fixes: QTBUG-130371
Change-Id: I3b36a3e200ba9d4b0791865e75235ddfb72bcaa5
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
(cherry picked from commit ef8bf4c2cf3d86a869ff8a555d4e390168864144)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-27 06:47:13 +00:00
Lars Schmertmann a1c74e054c Android: Fix logging of the category
87d8ee755b changed the logging behavior
on Android to use the category as tag. But it was missed that
`formatLogMessage` only fills the fields given in the messagePattern.
Our default messagePattern includes the category but on Android it
is never filled since this change.

So we change the default messagePattern on Android to omit the category
and only use the category as tag when the category is not given in the
messagePattern.

Pick-to: 6.5
Task-number: QTBUG-94708
Change-Id: I80f65d0f7f8c0ca9c2fff2dcd63d4599848b6e2b
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit 709bc29a1d2abf40bf3f1c067fe3b96b6e0c09d0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-26 20:37:15 +00:00
Jonas Karlsson d8892d8533 test: baseline: Call finalizeAndDisconnect
Change-Id: I4379b4b982b869ca8d502d2f102ddc3b3858b5c8
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
(cherry picked from commit ae9006b72d199e2b8112a3a8bbf54609b2968a6e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-22 20:18:50 +00:00
Jonas Karlsson 3ffc5ac2a7 BaselineProtocol: add FinalizeTesting command
Also adds a helper function QBaselineTest::finalizeAndDisconnect()
that calls the finalize command, prints the optional report URL
and disconnects to the server.

Change-Id: Iabdba77f9eebad3e3f3fa67ab8977d1e49c49fb4
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
(cherry picked from commit 62b349c5cf157479041969dc41e98597912de8d4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-21 20:12:33 +00:00
Eskil Abrahamsen Blomfeldt 93f32fd47a test: Fix test for oblique/italic equivalence
The tst_QFont::italicOblique() test is testing whether
a request for an "Oblique" font in the presence of an italic
one (or vice versa) may return the other as a second-best match.

However, it did not consider the fact that some fonts may not
be marked as italic even if the style name contains the word
"italic". One instance of this are variable fonts with oblique
instances. In this case we currently do not correctly recognize
the fonts as oblique.

But there is nothing preventing someone from creating a normal
font that has "italic" in the style name and not setting it as
italic in the OS/2 table (maybe the style name is "non-italic"),
so we can't really depend on this.

This makes the test a bit more robust by checking if the actual
font stored in the database is italic and verifying a match with
the requested oblique font. There are still cases that might
fail here, but we don't need to address those unless they
actually appear.

Pick-to: 6.5
Fixes: QTBUG-131108
Task-number: QTBUG-131262
Change-Id: I9ae0d37d378e8fec2be524db203dcea9a881f15a
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit 957e2be00a5c45223a5ef842a5f9f2f7b7be882b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-19 13:06:56 +00:00
Eskil Abrahamsen Blomfeldt c73cc95ba7 Don't count overflowing inline image height to previous line
In the line break algorithm, we try filling characters and
objects onto a text line until we see an overflow. We then
keep the state *before* the overflow as the current line and
move to the next.

However, for inline images we would store its height to the
current state before checking if it overflowed. So if the
inline image did cause an overflow it would be counted
towards the height of the preceding line in addition to the
line where it actually ended up.

[ChangeLog][Text] Fixed an issue which could cause the
height of a word-wrapped text line to grow if the immediate
line after it began with an inline image.

Pick-to: 6.5 5.15
Fixes: QTBUG-130980
Change-Id: I68494b49059e5e35349cbde77aefc64abeb69697
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
(cherry picked from commit 7b024cc1749494114fffc3c434b58846707a64af)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-19 07:02:49 +00:00
Edward Welbourne d5bb57060b Remove test for America/Hermosillo transition at the epoch
A recent update [0] to the IANA timezone database has improved the
historical accuracy of transitions in Mexico. It turns out that the
transition at the start of 1970 was not a real event. The only actual
change then was that Mazatlan has followed the main Mexico zone rules
since then, having ignored some transitions of the main zone in
earlier decades.

[0] 812aff32b3

Picking to 6.8 got a trivially-resolved conflict due to dev having one
more BackendKludges flag to take into account. Removed 6.5 from the
destinations for picking because the removed test was added since
then.

Pick-to: 6.8.1
Fixes: QTQAINFRA-6757
Change-Id: I65d8ea1dfa76ce635bf11ffcc1ded8c9ceaf9fec
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
(cherry picked from commit 8a27c310b1e4ebc74999e09551ca5eab4570a68e)
2024-11-18 15:55:46 +01:00
Thiago Macieira dce6ef8fac QThread/Unix: do clean up the QAdoptedThread for the main thread
Commit 1ed0dd88a3 ("QThread/Unix: make
QThreadPrivate::finish() be called much later") introduced this problem.
Commit 4fabde349f16b59f37568da2a4c050c6dd53a34e split the thread
termination in two phases, but did not fix this.

This re-applies commit 950b35cf97 ("Clear
the current thread data for the main thread"), which was reverted in
commit 7dc622290b ("Make sure QThreadData
and QAdoptedThread object is destroyed at app exit"), both from Qt 5.1.

Between Qt 5.1 and 6.7, the responsibility of clearing the
QAdoptedThread for the main thread was split: it could occur either in
~QCoreApplicationData if exit() was called in that thread or in
~QThreadData() if it wasn't (e.g., when the Qt "main thread" is not
main()'s thread):
  * frame #0: 0x0000000101db8a28 QtCore`QAdoptedThread::~QAdoptedThread(this=0x000060000176c070) at qthread.cpp:139:1
    frame #1: 0x0000000101db81eb QtCore`QThreadData::~QThreadData(this=0x0000600002468000) at qthread.cpp:82:5
    frame #2: 0x0000000101db8379 QtCore`QThreadData::~QThreadData(this=0x0000600002468000) at qthread.cpp:57:1
    frame #3: 0x0000000101db841c QtCore`QThreadData::deref(this=0x0000600002468000) at qthread.cpp:108:9
    frame #4: 0x0000000101f4ec79 QtCore`destroy_current_thread_data(p=0x0000600002468000) at qthread_unix.cpp:104:11

This commit centralizes and gives ~QThreadData() the exclusive
responsibility.  That requires not resetting QThreadData::threadId so
~QThreadData can know it is theMainThread.

Fixes: QTBUG-130895
Task-number: QTBUG-129927
Task-number: QTBUG-129846
Task-number: QTBUG-130341
Task-number: QTBUG-117996
Change-Id: Ie3f3cbdc5523837b505cfffd95fba5e6498b5069
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 65093a84c2b94b1543fd4593bc45d491951d28d4)
2024-11-15 03:17:29 -07:00