71508 Commits

Author SHA1 Message Date
Joerg Bornemann
13871ee86b Fix linker errors when building bootstrap lib on macOS
The bootstrap lib doesn't build qfilesystemengine_mac.mm, and that's
where QFileSystemEngine::supportsMoveFileToTrash and
QFileSystemEngine::moveFileToTrash are implemented.

Make sure that the preprocessor picks up the QT_BOOTSTRAPPED condition
first to define implementations for the two methods.

Fixes: QTBUG-135650
Change-Id: Icf7995abfae368b9f5bd5c4ccfcf4c3c6664d519
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit fc277e3ff655780622bcbc0b664efc69fbc33537)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-10 19:08:11 +00:00
Joerg Bornemann
b3b836e703 CMake: Prevent creation of empty InputSupportPrivate module
The combination of
    -no-feature-evdev
    -no-feature-tslib
    -no-feature-libinput
led to the creation of the InputSupportPrivate module without source
files.

This triggered CMake upstream issue 23464 when using CMake < 3.25.

Fix this by adjusting the inexact condition that decides whether to
build InputSupportPrivate.

Pick-to: 6.8
Fixes: QTBUG-99957
Change-Id: If23d029f21811b6ff7c92ac9ecd2882aedb309d6
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit cf2efa90fa92898f71861fca8100d7ac72244dae)
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-04-10 21:08:02 +02:00
Axel Spoerl
c33044f500 Blacklist tst_QGestureRecognizer::touchReplay() on Linux
Deeper research into recent failure necessary.
Blacklist to unblock CI.

Task-number: QTBUG-129754
Pick-to: 6.8 6.5
Change-Id: I1f543e35acdac7d91d48215a2130a03b77fd2ac5
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
(cherry picked from commit 4392e5f4c5b4806051f5d4c70de423133dfd2d86)
2025-04-10 18:36:42 +00:00
Eskil Abrahamsen Blomfeldt
a1b4480c53 Upgrade Harfbuzz to 11.0.0
[ChangeLog][Third-Party Code] Upgraded Harfbuzz to version
11.0.0.

Pick-to: 6.8 6.5 5.15
Fixes: QTBUG-135373
Change-Id: If4a530ec43f5992141945d7ad86268e838cc0230
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
(cherry picked from commit 98e0a7e0a067c6aacf9d61295bd36d290b150d51)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-10 18:22:52 +00:00
Eskil Abrahamsen Blomfeldt
53a687e5c3 Make sure Harfbuzz build picks up Qt atomics
We have our own implementation of the atomics API in Harfbuzz
for broader platform support. This is done through the mechanism
in Harfbuzz where you make a file called config.h with the
implementation and then define HAVE_CONFIG_H.

In Qt, we have this in src/3rdparty/harfbuzz-ng/config.h,
next to the CMakeLists.txt.

However, on some platforms, a different config.h has been found
earlier in the include paths and included instead, causing us to
use the default atomic implementation instead on these platforms.

This causes problems with the upgrade to Harfbuzz 11, where the
atomics have been written to depend on some template syntax which
is not properly supported on the Integrity OS compilers yet.

This was also a random inconsistency, so rather than try to work
around the compile issue on Integrity, we add the CMakeLists.txt
directory as the first include path, to make sure the correct
config.h is picked up on all platforms.

Pick-to: 6.8 6.5
Change-Id: I5fc2d57e740ea0a59700ebe319213fe716f8490e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 66fae045cd289e2f1525c7c4e4ce7a3069ec97ee)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-10 18:22:46 +00:00
Thiago Macieira
0c3fa7cd30 QXcbWindow: fix build: getpid() is <unistd.h>
Change-Id: I3494ac2ce660faa49b72fffdc3b9fbb13df0372d
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
(cherry picked from commit ecfa7406f1de34bacca57be2068423206f9c3707)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-10 18:21:45 +00:00
Tor Arne Vestbø
227dc87ab1 Account for Qt::AA_MacDontSwapCtrlAndMeta when mapping Latin ⌘-shortcuts
To follow the system we map key events that include ⌘ as if they had
been made using a Latin/Roman keyboard layout. However when looking
for the ⌘-keymap, we were not taking Qt::AA_MacDontSwapCtrlAndMeta
into account, and since the keymap differs whether the attribute is
set or not we ended up pulling the Meta-keymap instead.

Fixes: QTBUG-133963
Pick-to: 6.8
Change-Id: I32dd06025e1e1d93f3792952e6ad842efc6245a6
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit 2e5a881d347b2b20cfe19f0a9d9cb89f2c441408)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-09 23:49:44 +00:00
Tor Arne Vestbø
8dac03db35 iOS: Replace variable length array in event dispatcher with QVarLengthArray
This does mean that if a custom stack size has been requested which
is larger than the default size, we'll end up with a custom stack
on the heap instead of on the existing stack.

I don't remember exactly why we opted for our custom stack to live
on the stack in the fist place. The commit message for the change
that introduced it (59601e06d96edb5661a3dd91341d74e16dc6b229) does
mention garbage collection as once use-case, but iOS hasn't used
GC itself, and a GC's mark-and-sweep would have to include the heap
in any case.

However, for compatibility we keep the custom stack on the stack
if we can, as we pass the default stack size to QVarLengthArray,
which covers 99,9999% of apps use anyways (GitHub shows no hits
for the QtRunLoopIntegrationStackSize override that would trigger
a heap-allocated custom stack).

In testing on both simulator and device a custom stack size that
results in a heap-allocated custom stack does work, so we should
be good in either case.

Fixes: QTBUG-135609
Pick-to: 6.8
Change-Id: I86251da005ebca8a1cad5cabd2835e83486b3f8e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit be93c06758260b1e0738ab17a2ecc4ee8f90e87e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-09 23:49:39 +00:00
Tor Arne Vestbø
d18756589a iOS: Replace variable length array in QIOScreen with QVarLengthArray
Fixes: QTBUG-135609
Pick-to: 6.8
Change-Id: I3db252a4893ef298f6878fe2f3fac7c93fcf6c3a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit 5dd41d5e3035bc2335ab12015a0d633d4b249874)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-09 23:49:32 +00:00
Christian Ehrlicher
c46fdbad79 Windows11Style: Fix size hint for RadioButton/Checkbox
When the radiobutton/checkbox has no text, the size is to small as the
check rect is enlarged by 2px due to the rounded borders. This is only
visible when they have no text as otherwise there is enough space
between the checkbox and the text.
Therefore add 2px in width when no text is available.

Pick-to: 6.8
Fixes: QTBUG-135628
Task-number: QTBUG-133117
Change-Id: I8e3342fdc980485ab1494ef7f6df044f42883619
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
(cherry picked from commit 696f9adaa4b7a293ff1bfe3fa47dca62b4fdc710)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-09 19:58:17 +00:00
Safiyyah Moosa
f7ad71f39c Doc: Add Alt-text to the Qt SQL examples
QDoc generates warnings for images that do not have alt-text associated
with them. Alt-text is used to add context to images for users who use
screen-readers.

This patch applies alt-text to images in the Qt SQL module that do not
have any alt-text associated with them.

Fixes: QTBUG-135114
Pick-to: 6.8
Change-Id: Iead375852d30219db7dfed12bb1f383eb55713e6
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
(cherry picked from commit 7b66c906bf7a8c32650157fdd13221822ec1558e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-09 15:43:59 +00:00
Nodir Temirkhodjaev
541d53f28d QMainWindowLayout: Fix build with -no-feature-dockwidget
Make deletion of unused tab bars conditional to dockwidget and tabwidget
features.

Task-number: QTBUG-135468
Pick-to: 6.8 6.5
Change-Id: I0ecb55ab20737f401796cdd4ebbc6040e54b5afe
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit b37f84ba414f36d941d42f7addb2f8ca1516d3d6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-08 06:53:25 +00:00
Eike Ziller
08a65966af CMake: Add .js files to Source Files source group
In addition to .qml files

Change-Id: I8df7fd9bc997b888213b14c9de8b8d29ea536c1e
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 9302945ce35c836f97f50ac78bfb74b45824ca59)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-08 05:39:28 +00:00
Eike Ziller
1432788a12 CMake: Do not limit source_group creation to Xcode and VS
source_group is used by various IDEs, including Qt Creator,
so it makes sense to do that for other generators too.

Amends 06ea3e3994b38e5fe9ac4f33044b0efa1f1be294

Change-Id: I32334d658ea5a74a9e5f2a7fab2c1f531c099901
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit f302a312dcf1005e147193e12fbfc4677aa7af30)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-08 05:39:21 +00:00
Christian Ehrlicher
969fbfb89b Windows11Style: Disable shadow for QComboBox inside QGraphicsProxyWidget
A QGraphicsEffect is not rendered inside a QGraphicsView so we must not
set it on a QComboBoxPrivateContainer. We have to do some checks for it
when a stylesheet is set as polish() is then called before the proxy
widget is set on the QComboBoxPrivateContainer. But luckily QComboBox
has the proxy widget already set so do the check there.

Pick-to: 6.8
Fixes: QTBUG-135340
Task-number: QTBUG-128916
Task-number: QTBUG-128329
Change-Id: I2426701f3aa44a2eb14b66846628dbb9cd16dc9f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 847c0bf07695942271f9a0cf2b3eb63fa19c7d72)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-08 05:38:08 +00:00
Joerg Bornemann
40fa39ba83 Doc: Fix the example for qt_generate_deploy_script
The EXECUTABLE argument must point to the full path of the created
executable, not just the file name. Otherwise,
qt_deploy_runtime_dependencies won't file the file.

Pick-to: 6.8
Change-Id: I18b6214b9f46c0ad4b99ca57468fe272efb9d718
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit e07b4d4394be2885cb35ed2c08a3eaedb6fd26e4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-07 17:05:51 +00:00
Alexandru Croitor
84841f3bb0 CMake: Fix DESTDIR handling for plugin rpath adjustment on Linux
_qt_internal_set_rpath was using CMAKE_INSTALL_PREFIX instead of
QT_DEPLOY_PREFIX for the destination path, which ends up trying to
adjust the rpath of plugins in the regular install destination, rather
than in DESTDIR.

Change the code to use QT_DEPLOY_PREFIX where appropriate.

Amends 5430fb22439db9fc1ad1df4cbf0319b63346b0a5

Pick-to: 6.8
Fixes: QTBUG-135620
Task-number: QTBUG-109553
Change-Id: Iea1c0b69ba93fa5e81c463df57f8c2e19703a66a
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit ae4f9fe0cf6acded39020b8fbefd35df20ffff7d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-07 17:05:45 +00:00
Albert Astals Cid
1f354786f1 Improve macos tabs accessbility support
Map PageTabList controls (i.e. QTabBar) to the TabGroup role, and
report the list of PageTabs as the tabs. Add a predicate-argument
to the unignoredChildren() function so that we can re-use that
logic to return the list of tabs, while also ignoring otherwise
accessible children, such as the scroll buttons.

Change-Id: I57472e9213dd178e018449e542de276051097073
Fixes: QTBUG-134807
Pick-to: 6.8
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 0475bc57d699ac3bc82e2970b97ff267922bd15e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-06 22:29:00 +00:00
Christian Ehrlicher
7d04246b95 Windows11Style: replace QObject::inherits() with qobject_cast<>
Use qobject_cast<QComboBoxPrivateContainer *> instead
QObject::inherits() as this should be slightly faster and we have access
to the type so no need to use error-prone string comparison.

Pick-to: 6.8
Task-number: QTBUG-135340
Change-Id: I90ebb2323f21c2f5f9dd65bd7b1beeb32f1a91cc
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
(cherry picked from commit 7fdf7ad7e578675b32deb399b51ec6392c66cb2d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-06 22:29:00 +00:00
Volker Hilsheimer
56218773ce macOS a11y: clean up ignore-logic
Replace an if-chain with a switch statement, and remove the duplicate
test for QAccessible::Client - we already ignore all such elements,
no matter their special role name.

Compare an object's className as a QByteArrayView, no need to expand to
a UTF16 QString just to compare with a Latin1 literal.

Pick-to: 6.8
Change-Id: I79f52277e4177f2a688216b7f5ef7469cfe0534c
Reviewed-by: Albert Astals Cid <aacid@kde.org>
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
(cherry picked from commit e88940941f8ffe8236d281d5e0e46205f5c405ee)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-06 22:29:00 +00:00
Thiago Macieira
65768082fe QUrl::adjusted: remove unnecessary temporary variable
We don't need to QUrlPrivate::appendPath() to a temporary variable under
QUrl::FullyEncoded mode and then setPath(). We can simply ask
appendPath() to write to the destination variable once and for all, so
long as we take care to ask it to use the encoding form that setPath()
uses (QUrl::PrettyDecoded, which is 0x0). That avoids the side trip
through FullyEncoded mode.

Pick-to: 6.8
Change-Id: I7908b9cf75742db07145fffd9499ce3b79492fdb
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit 7ed94ef2b510a51d81dbe8aa4700dc8a283b21aa)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-06 19:49:26 +00:00
Thiago Macieira
01ff6e19f7 QUrl: expand the square brackets encoding to decoded setPath() calls
Amends (reverts) commit 5e936b60fc921e21b8153a83113886a1de333b57, which
forced the encoding of the square brackets ("[]") into their percent-
encoded forms only in QUrl::fromLocalFile(). This commit expands the
functionality to all uses of decoded paths by applying the change
directly to recodeFromUser().

[ChangeLog][QtCore][QUrl] Square brackets ("[]") are now transformed to
their percent-encoded forms ("%5B" and "%5D") when present as inputs to
setPath(), setQuery(), and setFragment() if the parsing mode is
QUrl::DecodedMode (the default).

Pick-to: 6.8
Fixes: QTBUG-135433
Task-number: QTBUG-134073
See: https://bugs.kde.org/show_bug.cgi?id=502280
Change-Id: Id2b41559af08b5f228e4fffdb9c6f23120f856b5
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit f3da9d3c858e8dc28a5dc91047b592ed5becbd62)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-06 19:49:25 +00:00
Thiago Macieira
bbe0b18b38 Add support for C23 standard attributes using __has_c_attribute()
The __has_cpp_attribute() refers to the attributes supported by the C++
language. GCC returns its knowledge of the C++ attribute in C, even when
the C code doesn't support it.

N2335[1] added the C++ attribute syntax to the C language and N2553[2] added
the __has_c_attribute() query syntax.

Known attributes:
From https://en.cppreference.com/w/c/language/attributes#Standard_attributes:
* [[deprecated]] (from N2334)
* [[fallthrough]] (from N2408)
* [[nodiscard]] (from N2267, with message in N2448)
* [[maybe_unused]] (from N2662)
* [[noreturn]] (from N2764, which also deprecates _Noreturn)

Drive-by remove C++11 & 14 support from [[nodiscard]]

[1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2335.pdf
[2] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2553.pdf

Change-Id: Ifd32b2557683218e0d26fffd5b58dedf7911f77a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 4cd66686e4fcf31ca1c8038c11125f90dc0b4782)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-06 00:46:16 +00:00
Alexey Edelev
61369b37e1 Dealias the target implicitly in _qt_internal_add_transitive_property
Ensure the target is not an ALIAS target when adding the
transitive properties.

Pick-to: 6.8
Change-Id: Ic9cb4f1a6e110596e430176cfa9b7f742d2c3446
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit d9ce5184c28b7d00330939f9907be5d0a069e68d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-05 18:09:09 +00:00
Laszlo Agocs
93933c5761 rhi: d3d11: Avoid 1 sec timeout when skipping present
endFrame(SkipPresent) followed by beginFrame() would sometimes end
up waiting up to a second. We should not wait at all in this case.

D3D12 patch will follow separately.

Pick-to: 6.8
Change-Id: I3a5605c3fb672f9d68f2afb69645c5c47a5214b3
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
(cherry picked from commit f2437c9d8ca0d4b4af7e917ff18cd0bc6ca83bcc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-05 18:08:56 +00:00
Laszlo Agocs
8121b39921 rhi: d3d11: Add activeAdapter null check
...to match 6.8 that has this added as part of a backport.

The D3D12 backend has this already. Still, move the
resetting of the variable to the outer scope in that one
too, to cover both code paths.

Change-Id: Ie4ba22ff9f2a2f6882dd2d5e3063c4e6701fa95c
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
(cherry picked from commit 35dd681f2ba00e7196e59309d76f920ad8807205)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-05 18:08:30 +00:00
Axel Spoerl
e6a294a69b Rename QDockWidgetGroupWindow::reparent() to reparentToMainWindow()
Naming the private API "reparent()" was unfortunate. It is ambigous, as
it suggests that the QDockWidget argument may be parented to the group
window. In fact the opposite is the case: It is removed from the group
window and re-parented to the QMainWindow.

Rename the API into reparentToMainWindow(), which is what it does.

Amends e6d85cf28bc4f750b69c33b72c006b067ae1190f.

Task-number: QTBUG-135442
Pick-to: 6.8 6.5
Change-Id: I6f9f37c190f3550348b1e4e14a8612d8880170dd
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit a0e0425a107aebf8727673505ea2376400b54b07)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-05 10:29:08 +00:00
Sebastian Beckmann
c0cee227de QComboBox: Ignore wheel event when not reacting to it
With the SH_ComboBox_AllowWheelScrolling style hint introduced in [1],
it's possible for combo boxes to not react to wheel scrolling. However,
since the event isn't explicitly ignored, it gets "eaten" by the combo
box instead of propagating up. This leads to upper level scroll areas
not receiving the event (and thus not scrolling).
By ignoring the event, the scroll area now scrolls if the hint is set
to false instead of nothing happening. This feels more intuitive and
mimics system behavior on both macOS (where the hint is set to false by
default) and Windows 11.

[1]: 5e9e4ccdc363297f70d4ebfbbb3e279670eca553

Pick-to: 6.8
Change-Id: I2207af8aad81fb76f3b1bbe074c3c4fbf22e3eca
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit 9c966d837fe33b1e32f5e95f29a380dd3063055b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-05 09:55:29 +00:00
Alexandru Croitor
fe1863228c CMake: Fix CMP0177 warnings by adjusting qt_join_path
INSTALL_DATADIR and INSTALL_ARCHDATADIR have the value "." by default.

CMP0177 in CMake 3.31 now warns when paths that have "." as a
component are passed to install().

To avoid the warning, change the implementation of qt_path_join, to
filter out "." components.

That way all install() calls that build up their paths via
qt_path_join() will avoid the warning.

Pick-to: 6.8
Change-Id: Ib82aa9fe6b5d32e374e8b1acf05402312b6dbe1a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit a20f28121264bfe18af13bfe14be7fd29d33a2fe)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-04 09:07:29 +00:00
Ivan Solovev
0d2fd73c29 QXmlStreamReader: check appending data with unexpected encoding
If we add the first part of the XML document using a QBA overload of
the constructor or addData() method, the encoding of the document will
be extracted from the "encoding" attribute of the XML prolog.

This way, if the encoding is different from UTF-8, appending the data
with the QASV overload of addData() will always result in reading the
data incorrectly, because the implementation converts the input data
to UTF-8.

This test explicitly highlights this behavior.
In some cases the current behavior is probably fine. However, cases
like appending Latin1 to Latin1-encoded document or appending UTF-16
to UTF-16-encoded document should just work instead of doing the
unwanted conversion to UTF-8 and failing.

Task-number: QTBUG-124636
Task-number: QTBUG-135129
Pick-to: 6.8 6.5
Change-Id: Idf0571083e56032145478631538f09d251cb1022
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 046b8523f20bdc86373eff7dfc2a1c0f7bb297d4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-04 08:51:48 +00:00
Ivan Solovev
a0ed54cb0b QXmlStreamReader: fix parsing of non-wellformed inputs
The tst_QXmlStream::runTestSuite() had two issues which resulted
in non-wellformed files not being checked in the incremental
parsing mode.

The first issue is that the TestSuiteHandler::endElement()
function calls isWellformed() twice with two different modes,
passing a pointer to a previously opened QFile to both calls.
As a result, the first call uses ParseSinglePass mode, which reads
the entire file at once. After that, the second call with
ParseIncrementally mode already uses a file which has
atEnd() == true. So, the call to readAll() simply returns an empty
QByteArray. So, the ParseIncrementally test was effectively a no-op.

This commit fixes it by explicitly calling seek(0) at the beginning
of the isWellformed() function and also changing the type of the
input parameter to be a QFile pointer instead of QIODevice pointer,
to make sure that seek(0) actually makes sense.

After that issue was solved, I noticed that in the incremental mode
the algorithm that was feeding the data to QXmlStreamReader
byte-by-byte was always skipping the first character (and also
reading past the end of the buffer). As a result, all the XML files
parsed in this mode were malformed.

This was fixed by moving the increment of the index after the
addData() call.

Finally, after these two things were fixed, six test cases from the
XML test suite started to fail, because the non-wellformed files
were incorrectly reported as well-formed.

Fix it by using StreamEOF instead of 0 in
QXmlStreamReaderPrivate::fastScanContentCharList().

The test case fixes amend the beginning of the public history.

The parser fix amends 817800ad39df10ca78e2c965a61d4d2025df622b
which introduced StreamEOF instead of 0.

Fixes: QTBUG-135471
Pick-to: 6.8 6.5 5.15
Change-Id: I885166252d40819a4460ec246db10bf448e4a8e2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 633278fe1c9991237e02233b32f825b2506187c3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-04 08:51:45 +00:00
Edward Welbourne
ecae579d03 Add a reproducer tests for an assertion failure
The fix [*] means this already passes on dev; and the belated pick to
6.8 should get there before this does (it landed before 6.9, so did
not need picked there).

[*] commit 5d656e5085303bd427a4e8564818c65ec1d0ac26

On 6.8, without the fix, the ISODate test passes (that's handled by a
sui generis parser) but all three of the fromStringFormat tests of
QDate, and the QDatetime exact reproducer from the bug report, provoke
assertion failures.

Task-number: QTBUG-135382
Pick-to: 6.8
Change-Id: I303df9215873e37a9f2cbf5a78aab8ffa48f67aa
Reviewed-by: Albert Astals Cid <aacid@kde.org>
(cherry picked from commit 79a1986e86243e94e8558ab5805a75b424916c89)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-03 15:25:26 +00:00
Axel Spoerl
ab6f1ad778 QMainWindowLayout: Fix leaking of unused tab bars
QMainWindowLayout::unusedTabBars contains unparented tab bars.
They are leaked when QMainWindow and its layout get destroyed.
They still are in QApplication::allWidgets(), which attempts to delete
them eventually. When that happens, they try to remove themselves from
an already deleted QMainWindowLayout::unusedTabBars.

Delete all unused tab bars in the d'tor of QMainWindowLayout.

Task-number: QTBUG-135468
Pick-to: 6.8 6.5
Change-Id: I5ac7748ef738955522567db585e9505e3ba435ad
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 23357e59bb4dc54e76a237b290aa64a620db2ea1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-03 12:47:02 +00:00
Volker Hilsheimer
19c4db4201 QDockWidget: don't access a QMainWindow that's under destruction
Amends b6b489db6968fbc3b4aab3755d0166ee09712ff0, which introduced UB
(invalid downcast):

By the time the
QMainWindowTabBars are destroyed, and they want to unregister
themselves from the QMainWindow, the ex-QMainWindow has already been
demoted to a QWidget. Says UBSan:

  qmainwindow.cpp:63:47: runtime error: member call on address 0x6040000267d0 which does not point to an object of type 'QMainWindow'
  0x6040000267d0: note: object is of type 'QWidget'
   00 00 00 00  28 c1 e6 f3 c7 7f 00 00  80 24 00 00 60 61 00 00  d8 c2 e6 f3 c7 7f 00 00  00 00 be be
                ^~~~~~~~~~~~~~~~~~~~~~~
                vptr for 'QWidget'
    #0 0x7fc7f06da8c5 in QMainWindowPrivate::mainWindowLayout(QMainWindow const*) qmainwindow.cpp:63
    #1 0x7fc7f06da8c5 in qt_mainwindow_layout(QMainWindow const*) qmainwindow.cpp:69
    #2 0x7fc7f07bb4ed in QMainWindowTabBar::~QMainWindowTabBar() qmainwindowlayout.cpp:2042
    #3 0x7fc7f07bf4e5 in QMainWindowTabBar::~QMainWindowTabBar() qmainwindowlayout.cpp:2047
    #4 0x7fc7c69f9c2a in QObjectPrivate::deleteChildren() qobject.cpp:2226
    #5 0x7fc7ef0b7f3d in QWidget::~QWidget() qwidget.cpp:1557
    #6 0x7fc7f082c7c7 in QDockWidgetGroupWindow::~QDockWidgetGroupWindow() qmainwindowlayout_p.h:343
    #7 0x7fc7f082c7c7 in QDockWidgetGroupWindow::~QDockWidgetGroupWindow() qmainwindowlayout_p.h:343
    #8 0x7fc7c69f9c2a in QObjectPrivate::deleteChildren() qobject.cpp:2226
    #9 0x7fc7ef0b7f3d in QWidget::~QWidget() qwidget.cpp:1557
    #10 0x7fc7f06ce495 in QMainWindow::~QMainWindow() qmainwindow.cpp:338
    #12 0x556a6180a84c in std::default_delete<QMainWindow>::operator()(QMainWindow*) const unique_ptr.h:85
    #13 0x556a6180a84c in std::unique_ptr<QMainWindow, std::default_delete<QMainWindow> >::~unique_ptr() unique_ptr.h:361
    #14 0x556a6180a84c in tst_QDockWidget::setFloatingReparenting() tst_qdockwidget.cpp:492

Use qobject_cast to verify that the mainWindow is not pointing to a
QMainWindow that is being destroyed (and has passed the ~QMainWindow
destructor). If the main window is destroyed, then removing the tab bar
from the list of unused tab bars is unnecessary.

Pick-to: 6.8 6.5
Change-Id: I25e12d79198137b75cd2576ff1440b6c94277eba
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 1bbbacbecb0bd03a58fea889215850dfffebeb3b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-03 12:46:56 +00:00
Tor Arne Vestbø
793a8d9d14 Replace variable length array in qt_mac_draw_pattern with QVarLengthArray
Pick-to: 6.8
Change-Id: I1869ba14cdddb23cd903013fb6d160e24ac72967
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit 10851432080df38668a07ff22f1da1c3cbfbfe51)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-03 12:46:54 +00:00
Marc Mutz
435da40cc0 QGraphicsView: remove (last remaining?) user of QEvent::op=
Instead of aggregating a QMutableSinglePointEvent by value, which
depends on the QEvent copy assignment operator, and casting it to a
QMouseEvent that it isn't, introduce QEventStorage which is a bit like
std::optional, but, by each event subclass befriending it, can store
event copies by-value, unlike clone(), which is restricted to the
heap. We could have befriended std::optional<QMouseEvent>, too, but by
adding our own type in _p.h, we can better control which code uses
this dangerous construct.

Added a guard to avoid clobbering lastMouseEvent with a copy of itself
in storeMouseEvent(). Before, we'd self-assign to lastMouseEvent,
which didn't invalidate the reference. Now, a store() is the
equivalent of a dtor + copy constructor, so we need to be a bit more
careful.

Fixes UBSan reports when running tst_qgraphicsview:

  qgraphicsview/qgraphicsview.cpp:612:27: runtime error: downcast of address 0x61a000035e90 which does not point to an object of type 'QMouseEvent'
   0x61a000035e90: note: object is of type 'QMutableSinglePointEvent'
    00 00 00 00  30 47 ef 8b 99 7f 00 00  02 00 00 00 00 00 00 e0  d0 91 00 00 20 60 00 00  00 00 00 00
                 ^~~~~~~~~~~~~~~~~~~~~~~
                 vptr for 'QMutableSinglePointEvent'
       #0 0x7f99a27c7a47 in QGraphicsViewPrivate::replayLastMouseEvent() qgraphicsview.cpp:612

  qgraphicsview.cpp:653:39: runtime error: member call on address 0x61a0000fe290 which does not point to an object of type 'QMouseEvent'
   0x61a0000fe290: note: object is of type 'QMutableSinglePointEvent'
    00 00 00 00  30 47 ef 8b 99 7f 00 00  05 00 00 00 00 00 00 e0  d0 91 00 00 20 60 00 00  00 00 00 00
                 ^~~~~~~~~~~~~~~~~~~~~~~
                 vptr for 'QMutableSinglePointEvent'
       #0 0x7f99a27c3609 in QGraphicsViewPrivate::mouseMoveEventHandler(QMouseEvent*) qgraphicsview.cpp:653
       #1 0x7f99a27c7832 in QGraphicsViewPrivate::replayLastMouseEvent() qgraphicsview.cpp:612

  qgraphicsview.cpp:654:37: runtime error: member call on address 0x61a0000fe290 which does not point to an object of type 'QMouseEvent'
   0x61a0000fe290: note: object is of type 'QMutableSinglePointEvent'
    00 00 00 00  30 47 ef 8b 99 7f 00 00  05 00 00 00 00 00 00 e0  d0 91 00 00 20 60 00 00  00 00 00 00
                 ^~~~~~~~~~~~~~~~~~~~~~~
                 vptr for 'QMutableSinglePointEvent'
       #0 0x7f99a27c358b in QGraphicsViewPrivate::mouseMoveEventHandler(QMouseEvent*) qgraphicsview.cpp:654
       #1 0x7f99a27c7832 in QGraphicsViewPrivate::replayLastMouseEvent() qgraphicsview.cpp:612

Task-number: QTBUG-99563
Change-Id: Ib642d416b8aef98c7fd8b1fa164ec2449189992a
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
(cherry picked from commit dd264cc9c00e09eb995f1c6f9b1fd651f1d4b2f4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-03 05:35:08 +00:00
Marc Mutz
34e7253d05 tst_QComboBox: fix popupPositionAfterStyleChange() FAIL on Kubuntu 20.04
On my machine, the window manager opened the QComboBox always at y = 0
(top edge of the screen), where the popup, being confined to the
screen geometry, had no chance of "open[ing] up centered on top of the
current index".

Fix by centering the widget on screen.

Amends 8393922e7071221a9c6c0811eb714f20bf4ed02b.

Pick-to: 6.8 6.5
Change-Id: I7b4d066aa1e555f3d5cc1d5e0c88b1d835bf2b26
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit e2790a6758be18add2bcab42cc7dfebdd74daae1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-03 05:34:34 +00:00
Marc Mutz
09d266af99 QAbstractItemView: disconnect from the correct delegate
Purely from a symmetry argument, we should be disconnecting the old
item delegate, not the new one.

I didn't find a case where this actually causes test failures, nor did
I take the time to implement a test where it does.

Amends a126d3627cc347500c1a6bd82027efa6d451ccbd. That patch landed in
Qt 6.7, but that branch is "closed" at this point in time, so not
picking there now.

Pick-to: 6.8
Change-Id: I06b704e699616d61c65ad676ffe45dfbd9f8a870
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit e5f11eebc89ec041995cbbbc9b3db9eb3c6968c2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-03 05:34:25 +00:00
Marc Mutz
76918c1f28 tst_QComboBox: ignore two warnings from setCompleter() in getSetCheck()
Tidies up the test output by removing expected warnings from the log
(and alerting us if they're missing).

Amends 64f6169f61ce8c982a1b92b20f930518a5f0d477, which introduced the
warning.

Pick-to: 6.8 6.5 5.15
Change-Id: Idcef99d556b11035307e6e207cf31fc2f13ed291
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit e55479ea4a2dca266b73a2a17ff77ec44e1c2135)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-03 05:34:16 +00:00
Marc Mutz
2efeaab1c6 QComboBox: fix UB (signed overflow) in Private::recomputeSizeHint()
The minimumContentsLength() is user-settable, and tst_QComboBox
actually sets it to INT_MAX as some point. As such, the implementation
needs to defend itself from UB, either by limiting what values it
accepts as minimumContentsLength() or by making sure it doesn't cause
signed overflow in calculations involving this user-controlled
variable.

The former doesn't really work as long as the test checks that INT_MAX
is accepted as-is, so we need to do the latter.

Do the calculation in qint64, and use the result only when it doesn't
exceeed good old QWIDGETSIZE_MAX.

Amends the start of the public history.

Pick-to: 6.8 6.5 5.15
Change-Id: I8aac7bda593095638c9c09db3b70b4c84e698419
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 00fdf9e432c78e7d7f1a491f7bc1f375fcbde8da)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-03 05:34:05 +00:00
Marc Mutz
f261357c1a tst_QComboBox: fix memleak in task_QTBUG_56693_itemFontFromModel()
QProxyStyle's ctor arguments are not QObject parents, but the proxied
style, which becomes the proxy's QObject ... get this ... _child_.

What a broken concept... It means that this test function took
ownership of QApplication::style(), and the only way it wasn't going
to wreak havoc on the rest of the test functions was to leak it after
use.

To fix, create the style on the stack, so it gets automatically freed
by the compiler on all exists from the function. As a drive-by, use {}
instead of () to call the ctor (not to prevent C++' Most Vexing Parse,
just because it's easier on the eye).

The meat of the change, however, is in making the helper proxy-style
defend against QProxyStyle's grabbing of the baseStyle() as its child,
and managing baseStyle()->d->proxyStyle so we properly dissociate from
qApp->style() after we're done. Needed to use ctor delegation to
extract original parent and proxy model from the incoming style before
QProxyStyle, our first subobject, gets first picking on the style,
destroying the very state we're trying to preserve.

This should be become some QTest::LocalProxyStyle, if we find more
users of this pattern.

Amends 5cff7d2b679d48a247b4630cb9e3d5b04fab0b55.

Pick-to: 6.8 6.5 5.15
Change-Id: I2abf4a0bf54158254fd8d526de55ad486ca4e296
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit d88459139119b898e81c1a104e6fd3e28c8f01cf)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-03 05:33:56 +00:00
Marc Mutz
fee3a39fdc tst_QComboBox: fix memleaks in task_QTBUG_52027_mapCompleterIndex()
Both the QCompleter and the QSortFilterProxy objects are not owned by
the QComboBox merely by setting them as completer and model. Having no
other QObject parents, and having being allocated on the heap, they
were leaked.

To fix, give them the combo-box as QObject parent.

Amends 8b6d6d4832ea8ed5f9857d5ddf06408ee9d0b4e0.

Pick-to: 6.8 6.5 5.15
Change-Id: I5c3594272a5283a3fbaeb9885d315047b04f30de
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 27279e01d2794bba8c69db4b987c3351a2daa619)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-03 05:33:45 +00:00
Marc Mutz
73d2a7d29b tst_QComboBox: fix memleak in task190205_setModelAdjustToContents()
A QComboBox does not own the model set on it, because models can be in
many views at once. So the QStringListModel, allocated on the heap
without a QObject parent was leaked.

Fix by giving the model the combo-box as QObject parent.

Amends the start of the public history.

Pick-to: 6.8 6.5 5.15
Change-Id: Idd9057c8f796937d9d3c5c4ef99b329124d2192d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit c41592c900257177849758ef31212a83fc813be5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-03 05:33:32 +00:00
Marc Mutz
c818392a59 tst_QComboBox: fix memleaks in setItemDelegate()/task253944_itemDelegateIsReset()
QItemDelegates are owned by neither the QComboBox directly, nor the
QComboBox::view(), upon a mere setItemDelegate() (the docs of this
function is pretty clear about that). Since the objects didn't have a
QObject parent, either, they were leaked.

To fix, give it the comboBox as a parent.

Amends the start of the public history.

Pick-to: 6.8 6.5 5.15
Change-Id: Ic8bc2603072070b458bd79a6129af6c76811f8ec
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit fda3526f9c6c34f509ebaba67a27e5c32235d7e9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-03 05:33:22 +00:00
Marc Mutz
5e3db40ba3 tst_QComboBox: fix memleak in getSetCheck()
Contrary to what the code comment suggested, a QComboBox does not own
the object passed in by setItemDelegate(). After a nullptr check, the
function merely forwards to QComboBox::view()->setItemDelegate() and
QAbstractItemView::setItemDelegate() documents very clearly that the
item delegate ownership does not change. Consequently, the test
function leaked the object.

To fix, hold it in a unique_ptr and reset() at the end of the code
block.

I opted to not merely comment in the delete there, because that would
still leak in case one of the QCOMPARE()s in-between failed. While it
is not the purpose of the current work to make tests leak-free even on
failure, it likewise makes little sense to not reap this small benefit
now, albeit at the cost of a bit of git history mess-up, itself
mediated by the fact that we're picking this all the way back, since
this...

Amends the start of the public history.

Pick-to: 6.8 6.5 5.15
Change-Id: I1e604b795f5a12dc8829bf5913b88bc7c7110352
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 0de7cafabc6d71cf3c129e7a67792d2a3ff1c864)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-03 05:33:15 +00:00
Marc Mutz
82cf1c0c16 QLineEdit: fix UB (invalid downcast) in Private::removeAction()
QLineEdit remembers whether a QWidget size-widget came from a
QWidgetAction or is just one of its own QLineEditIconButtons. On
removal of the action, if QWidgetAction, it will ask the action to
deal with its widget, calling QWidgetAction::releaseWidget(),
otherwise it just deletes the QLineEditIconButton itself.

This is fine if the action is being removed from the line edit, but
not immediately deleted. But if the action is being deleted while its
widget is still in a QLineEdit, then the QLineEdit is informed of this
only by ~QAction(), at which point the QWidgetAction has ceased to
exist and the cast, in QLineEditPrivate::removeAction(), to
QWidgetAction is UB.

Says UBSan:

  qlineedit_p.cpp:656:10: runtime error: downcast of address 0x6020000c3950 which does not point to an object of type 'QWidgetAction'
   0x6020000c3950: note: object is of type 'QAction'
    00 00 00 00  70 57 49 81 3d 7f 00 00  80 bc 0c 00 50 61 00 00  03 02 00 00 10 00 00 00  a6 01 00 71
                 ^~~~~~~~~~~~~~~~~~~~~~~
                 vptr for 'QAction'
    #0 0x7f3d93910686 in QLineEditPrivate::removeAction(QAction*) qlineedit_p.cpp:656
    #1 0x7f3d938b44bc in QLineEdit::event(QEvent*) qlineedit.cpp:1469
    #2 0x7f3d91c50211 in QApplicationPrivate::notify_helper(QObject*, QEvent*) qapplication.cpp:3309
    #3 0x7f3d91cd160a in QApplication::notify(QObject*, QEvent*) qapplication.cpp:3259
    #4 0x7f3d697f6ada in QCoreApplication::notifyInternal2(QObject*, QEvent*) qcoreapplication.cpp:1111
    #5 0x7f3d697f94e3 in QCoreApplication::sendEvent(QObject*, QEvent*) qcoreapplication.cpp:1551
    #6 0x7f3d92345199 in QWidget::removeAction(QAction*) qwidget.cpp:3215
    #7 0x7f3d92e47202 in QtWidgetsActionPrivate::destroy() qaction_widgets.cpp:35
    #8 0x7f3d7f75d5fb in QAction::~QAction() qaction.cpp:451
    #9 0x7f3d92e4cc76 in QWidgetAction::~QWidgetAction() qwidgetaction.cpp:94
    #10 0x7f3d92e4e965 in QWidgetAction::~QWidgetAction() qwidgetaction.cpp:94
    #11 0x558c993da3b0 in tst_QLineEdit::sideWidgets() tst_qlineedit.cpp:4693

To fix, check the dynamic type of the action (using qobject_cast)
before calling QWidgetAction::releaseWidget(). If the cast fails, the
QWidgetAction will have dealt with the widget itself, in its own dtor,
so QLineEdit needn't do anything.

Unfortunately, fixing this centrally by just dragging destroy() down
from ~QAction() to ~QWidgetAction() causes use-after-free in other
test functions of tst_QLineEdit, so I deciced to fix this at the
QLineEdit level only.

Amends 9ce12cc8de940cdd450a28f4bd079acfc3621aa3.

Pick-to: 6.8 6.5 5.15
Change-Id: I3c514dbd1f1a4e1510df3dd9ac67b4bab50e63e9
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit bf62a9762b04689094d1411168ad785b2152cba4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-03 05:33:06 +00:00
Marc Mutz
799237eaae tst_QTextEdit: fix UB (invalid downcast) in various functions
The test uses the old-but-invalid trick of inheriting from a class X
to gain access to its private or protected parts, but then just
casting an object of dynamic type X to the newly derived class. This
is invalid, because the object is not actually of the newly-derived
type.

Says UBSan (excerpt):

  tst_qtextedit.cpp:2273:5: runtime error: downcast of address 0x60400013c190 which does not point to an object of type 'PublicTextEdit'
  0x60400013c190: note: object is of type 'QTextEdit'
   00 00 00 00  70 bc 57 df b1 7f 00 00  80 66 30 00 90 61 00 00  70 be 57 df b1 7f 00 00  00 00 be be
                ^~~~~~~~~~~~~~~~~~~~~~~
                vptr for 'QTextEdit'

To fix, make QTextEdit befriend tst_QTextEdit. This is how we do it
elsewhere, too. Then remove the now-unused PublicTextEdit helper.

Amends the start of the public history, and, in one function,
56f0ebfe860e440dcbba8997f44836debc901119 (which is only in Qt 6.4+, so
the cherry-pick to 5.15 will have to drop the part in pasteFromMarkdown().

Pick-to: 6.8 6.5 5.15
Change-Id: I967238d84cae0f6dd8f05d0afb7a318292d96415
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 73fc32af1410b54fc38d7450fad04bb9dabec077)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-03 05:32:55 +00:00
Marc Mutz
a8f7a100ae tst_QTextEdit: fix memleak in the MyPaintDevice helper
The constructor new'ed up a MyPaintEngine, but there was no destructor
to delete the object again. Neither is ownership of the engine
transferred out of the class, so the object was leaked.

Fix by holding it in a unique_ptr.

Amends 391e3aeef45efc937979b44c32147206e389a60b.

Pick-to: 6.8 6.5 5.15
Change-Id: I0c4da10d5a1659eceac0deba32cac757579e46c5
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit de2de7e12cb82064e32197f88c8772ceeeead8ae)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-03 05:32:46 +00:00
Marc Mutz
414ca19a3f tst_QMetaType: fix UB (nullptr passed to memcmp()) in selfCompare()
QMetaType::Void is not constructible, so create() will return nullptr,
and even though sizeOf() returns 0, calling memcmp() is still UB in
that case.

Fix by guarding the memcmp() from QMetaType::Void.

Amends a59e7361714d50687d82a2d9abae9e95825a23b6.

Pick-to: 6.8 6.5
Change-Id: I55896826e6c0cad5d77e9d0ab861efa9a32f780f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit c6c2a0bf3799c9851551bc9e1bd0919dbc64924c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-02 14:48:23 +00:00
Tim Blechmann
21b219f6b7 QLinuxFbIntegration: silence -Wunused-private-field
when configured without `evdev`, clang emits -Wunused-private-field

Pick-to: 6.8
Change-Id: Ia4ff59c002c1a00ef1b445520c28db0d932ee564
Reviewed-by: Liang Qi <liang.qi@qt.io>
(cherry picked from commit eb6042f915c27a9988392eb3ea4bf4b5830cc7d7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-04-02 02:21:05 +00:00