Commit Graph

14245 Commits

Author SHA1 Message Date
Thiago Macieira
74fac865cf QMetaType: add registerType() and qRegisterMetaType(QMetaType)
This also rewrites QMetaType::id() on top of the helper, with the benefit
of calling a member static function, so QMetaType doesn't need to be
spilled onto the stack. In some upcoming changes I need to ensure that
QMetaTypes are registered so they can be found by name and I'd like to
have a dedicated function name for that, instead of calling .id().

Since I needed to add docs for the new function, I've updated for the
old one too.

[ChangeLog][QMetaType] Added QMetaType::registerType() and an overload
of qRegisterMetaType() taking QMetaType (the two functions do the same
thing). These two functions ensure a given QMetaType is registered with
the Qt global registry, so they can be found by name later. Using
qRegisterMetaType<T>() also accomplishes the same thing, but is slightly
better for completely generic code because it will avoid emitting the
registration for built-in types.

Change-Id: I3859764fed084846bcb0fffd170351d606034c22
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-26 20:12:30 -07:00
Thiago Macieira
b1d9331c15 QMetaType: fix isRegistered()
It's not registered until an ID is assigned.

Pick-to: 6.4
Change-Id: I3859764fed084846bcb0fffd17034f5b369c5b4d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-26 14:33:21 -07:00
Thiago Macieira
51905f8e76 tst_QMetaType: suppress most warnings
It's not warning-free, but it's much better.

Pick-to: 6.3 6.4
Change-Id: I3859764fed084846bcb0fffd170323c9ed12dd23
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-26 14:33:21 -07:00
Thiago Macieira
aae882b02f tst_QMetaType: merge flags and flagsStaticless
And rewrite them with templates. QMetaType::typeFlags() simply calls
flags() anyway.

Pick-to: 6.3 6.4
Change-Id: I3859764fed084846bcb0fffd170323f9d8c80466
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-26 14:33:21 -07:00
Dimitrios Apostolou
57be602fde Fix test being flaky on Linux
The cause is that the first EXPOSE event comes with the window not
having focus yet. See QTBUG-105177.

Also remove processEvents() as events are always processed when doing
qWaitFor...().

Task-number: QTBUG-105177
Change-Id: I2260d1885388bbf7091c423bc9b4c16e2ed0090f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-26 16:33:41 +02:00
Dimitrios Apostolou
2f8127f526 Test fails always on Android, so skip it
Previously the failure was been ignored because of the very generic
"linux" entry in the BLACKLIST file

Task-number: QTBUG-105201
Change-Id: I6914fe350f78266fc18541eb8fcd881f5a4ac511
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-26 16:33:34 +02:00
Dimitrios Apostolou
b1891e86d7 Test is no longer flaky
+ I could not reproduce the flakiness on OpenSUSE Tumbleweed.
+ No significant flakiness can be seen for this test in our testresults
  statistics.
+ Ubuntu-16.04 is no longer part of our CI

Change-Id: I7a18fc3fe2e58af8533171ebae0457b08424e810
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-26 16:33:27 +02:00
Dimitrios Apostolou
83090e16cb Fix flakiness of test on OpenSUSE/KDE
The cause is that the first EXPOSE event comes with the window not
having focus. See QTBUG-105177.

Fixes: QTBUG-67254
Task-number: QTBUG-105177
Change-Id: I04789d0a173979d9a60893989f76566b617c6576
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-07-26 16:33:22 +02:00
Alexandru Croitor
84c9a79a69 CMake: Make tst_qdbusabstractadaptor depend on qmyserver
Pick-to: 6.2 6.3 6.4
Change-Id: I8a38c6e2de7639ac8cd07e36a4f6d79830d34dc8
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
2022-07-26 14:33:42 +02:00
Marc Mutz
d76bf64531 QByteArray: fix base64 round-trip w/more than 2GiB data
There was an explicit int cast in fromBase64Encoding() which was never
ported to qsizetype and therefore truncated the result.

Fix by removing the int cast.

Add a test, optimize it for as low memory usage as possible, given we
need to work in input and output data each in excess of 2GiB.

Fixes: QTBUG-104985
Pick-to: 6.4 6.3 6.2
Change-Id: I9c0924957e62e5cb3003132cd811b8b0315d8ac1
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-07-26 02:06:17 +02:00
Edward Welbourne
21e9c223b7 Test skip and fail in cleanup() as well as in cleanupTestCase()
The skipcleanup and failcleanup tests were actually testing skip and
fail in cleanupTestCase(), not in cleanup(). Add almost-duplicate
tests and clean up so that we now have {fail,skip}cleanup(,testcase}
tests to cover all four cases. Generated expected output. The new
tests (with old names) get their fail or skip - during cleanup() -
reported against the test instead of the cleanupTestCase function.
(Results for {init,cleanup}TestCase() are always reported, even when
these slots are not defined, as no-op passes.)

Pick-to: 6.4
Change-Id: I0988d1696b50c0e2f30c45ddc25e1bd0bfd2151a
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2022-07-25 19:29:07 +02:00
Thiago Macieira
df0085d3a2 QVariant: do allow non-default-constructible types
So long as you only ask us to copy it. Copying is mandatory, though.

I'll firm up the warning in a later commit, which may not get cherry-
picked as far back.

Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-105140
Change-Id: I3859764fed084846bcb0fffd170432abf65dc197
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-22 12:42:55 -07:00
Dimitrios Apostolou
45501f6ca6 Ensure list has elements before getting them
Before a recent fix it would happen occasionally that
lastNormalizedPositions.at(0) would segfault because the list was
empty. The cause of the flakiness was fixed, but make the test more
resilient anyway by checking first the list is correctly populated.

Furthermore on some platforms this check fails:

  qAbs(leftWidget.lastNormalizedPositions.at(1).x() - 0.8) < 0.05

So instead of QVERIFY use QCOMPARE_LT to print the values when it fails.

Task-number: QTBUG-104268
Change-Id: Id5430eb53c133cf5d23647cfd9749f01f266efce
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-07-22 19:19:59 +02:00
Dimitrios Apostolou
60f61198f2 Fix test flaky-crashing on OpenSUSE with KDE window manager
Sometimes XCB_EXPOSE event is being propagated twice, once before and
once after qWaitForWindowExposed(). But the window has focus only after
the second expose event. Changing it to qWaitForWindowActive() fixes the
issue.

Fixes: QTBUG-104268
Pick-to: 6.2 6.3 6.4
Change-Id: Ibc78dd4958ed1a4a8d0967b29d2a53457ab9ae8b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-07-22 19:19:58 +02:00
Ivan Solovev
4b9c738185 QAction: add QT_DEPRECATED_VERSION_6_0 to deprecated methods
And fix all the new warnings.

Task-number: QTBUG-104857
Pick-to: 6.4 6.3 6.2
Change-Id: I2a5791f495575d71d2344429aca3363f9922e31b
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-07-21 23:12:15 +02:00
Ivan Solovev
8b029ef142 Do not use QTextFormat::FontFamily when building with QT_DISABLE_DEPRECATED_BEFORE >= 0x060000
The QTextFormat::FontFamily enum is deprecated since Qt 6.0, however it
is still used in the code.

To retain backward compatibility with the old data stream formats, we
introduce a new internal QTextFormat::OldFontFamily enum value, which
has exactly the same value as QTextFormat::FontFamily, and use it
instead.

Task-number: QTBUG-104857
Pick-to: 6.4 6.3 6.2
Change-Id: Ibf5258b621c2b0aa507005dfe2c1e80c26ddb0d4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-07-21 19:59:08 +02:00
Ivan Solovev
68ea9c0227 QGuiApplication: do not emit deprecated signals
... when QT_DISABLE_DEPRECATED_BEFORE is past the deprecation version.

This commit actually stops using the deprecated signals when we build
Qt with QT_DISABLE_DEPRECATED_BEFORE >= 0x060000. Otherwise we will
get a compilation error because the signals will be removed.

Task-number: QTBUG-104857
Pick-to: 6.4 6.3 6.2
Change-Id: Ie513ecc9451bf2d88f80857cf19f3d2b4958d022
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-07-21 19:59:07 +02:00
Ivan Solovev
24de000a9c QCursor: add missing QT_DEPRECATED_VERSION_X_6_0 for deprecated methods
When the method is wrapped into
 if QT_DEPRECATED_SINCE(MAJ, MIN)
we also need to add QT_DEPRECATED_VERSION_[X_]_MAJ_MIN macro right in
front of the method declaraion, to actually trigger a deprecation
warning.

This patch does that for QCursor's deprecated methods, and fixes all
related compilation warnings in QtBase.

Task-number: QTBUG-104857
Pick-to: 6.4 6.3 6.2
Change-Id: Ic8d059e8c852d4b2dee55e7ea94f4fc7a402cdf4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-07-21 19:59:07 +02:00
Fabian Kosmale
6a0e59ed50 QVariant: Avoid crash when constructed from unsuitable metatype
If the metatype does not support copy and default construction, then it
it unsuitunsuitable for use in QMetaType. We cannot prevent users from
passing in such metatypes (as we have e.g. a ctor taking QMetaType), so
verify this in customConstruct, and make the variant invalid in that
case.

Pick-to: 6.2 6.3 6.4
Change-Id: Ib1f0149c8fb9a1cce0049fd0311980754cc85d1b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-07-21 08:37:34 -07:00
Alexandru Croitor
552605b0fc CMake: Rename test to tst_gui_variant_no_application
Coin test collector expects tests to start with the tst_ prefix.

Pick-to: 6.2 6.3 6.4
Change-Id: I5cd49bf75fddc121fdfbde80d8a24a6110098011
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-20 16:51:19 +02:00
Alexandru Croitor
5afb5fb8e0 CMake: Rename test to tst_qobjectrace
Coin test collector expects tests to start with the tst_ prefix.

Pick-to: 6.2 6.3 6.4
Change-Id: Idc991273bacc41b62dbbf70f2ae0f3e712d34ab6
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-20 13:15:59 +02:00
Marc Mutz
ccb2e4dbb1 QOpenGLBuffer: add move-SMFs and swap()s
- add move special member functions (docs copied from QHostInfo)

- add member swap

- use move-and-swap, not pure-swap, because these objects hold
  resources (handles) other than just memory

- Q_DECLARE_SHARED (it's not implicitly shared, but explicitly)
  - adds ADL swap and Q_DECLARE_TYPEINFO

[ChangeLog][QtOpenGL][QOpenGLBuffer] Added member-swap(), move
constructor, move assignment operator.

Change-Id: I22dc92108bdd393fff4361db23e94eaf3d7ea9cc
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-20 13:15:55 +02:00
Marc Mutz
cb9715557c tst_QByteArray: fix custom QCOMPARE for QBAs > 2GiB
The tst_QByteArray test redefines the QCOMPARE macro to check the LHS
to be NUL-terminated. Because the code was never ported from int to
qsizetype, it fails for QByteArrays of size > 2GiB.

Fix by porting to qsizetype.

Pick-to: 6.4 6.3 6.2
Task-number: QTBUG-104985
Change-Id: Ib3951b0efed5f734ae1324ea2d455bb7762fb9c4
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-07-20 12:56:18 +02:00
Volker Hilsheimer
4802eec2ff QMutex: limit moreStress test to idealThreadCount threads
Or the previous limit, 10.

The test has a flaky and failing history, esp on macOS. Trying to
provoke race conditions with more threads than we have cores has little
value.

Pick-to: 6.4
Change-Id: I99dd2b5a6f64faa83963c279c84fc547416f914f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-07-20 06:57:43 +02:00
Volker Hilsheimer
2738a80acd QWidget: extend timeouts in flaky enterLeaveOnWindowShowHide test
That test has a very flaky history on Windows 11, presumably because
there are even more fade-in/out effects. Wait longer for those to
finish.

Fixes: QTBUG-102239
Pick-to: 6.4 6.3 6.2
Change-Id: I1d59f4422469e60a8c4dc5a52c48f0344e954491
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-17 13:20:04 +02:00
Timur Pocheptsov
d8ff4d9f57 tst_qnetworkreply: replace server.pem/key pair
OpenSSL v3 fails to set server's certificate, complaining that
"md is too weak".

Pick-to: 6.4 6.3 6.2 5.15
Fixes: QTBUG-49205
Change-Id: Ib21b10ff13bc2621ae2aaaab962efaaf77a854bc
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-07-15 22:42:43 +02:00
Volker Hilsheimer
e6c7d049f4 QGraphicsProxyWidget: make tolerance in mapToGlobal test at least 4
a61bf508e3 reduced the tolerance from 4 to
3 in one case, making the test more rather than less flaky on systems
with a device-pixel-ratio of 1.

Pick-to: 6.4 6.3 6.2
Change-Id: I245443f0dcb1aa40176c127025501b63f12f161b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-15 14:44:32 +02:00
Volker Hilsheimer
37c829f511 QPalette: detach before modifying resolve mask when resolving
Amends 1d961491d8. We modify the resolve
mask after making a shared copy of 'other', so we must detach. Call the
setter designed for that purpose.

Pick-to: 6.4 6.3 6.2
Task-number: QTBUG-98762
Change-Id: I4f45223e74764a341378992172787fae73efb8b7
Reviewed-by: JiDe Zhang <zhangjide@uniontech.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-07-15 09:58:23 +02:00
Fabian Kosmale
2c81ba2df9 QThread: Clean up bindingStatusOrList if object gets deleted
Deal with the case that the object gets deleted between a call to
moveToThread and the start of the thread by removing the object from the
list in that case.

Fixes: QTBUG-104014
Pick-to: 6.4
Change-Id: Ib249b6e8e8dfbc4d1332bb99a57fa9d3cff16465
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-14 19:34:46 +02:00
Volker Hilsheimer
a2c7428e4d QGraphicsWidget: skip test if graphics view fails to show
We set Qt::X11BypassWindowManagerHint on the view, which regularly makes
the test fail on X11 systems in the

QVERIFY(QTest::qWaitForWindowActive(dummyView.data()))

check.

If the view fails to show, skip the test instead of failing, we are not
testing anything X11 specific here, running this test on other platforms
will be good enough.

Pick-to: 6.4 6.3 6.2
Fixes: QTBUG-98921
Change-Id: I46dbcddf51ee1e92eb3bbb29bb57fcc314266bea
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-14 15:55:30 +02:00
Volker Hilsheimer
a61bf508e3 QGraphicsProxyWidget: make tolerance for errors depend on DPI
The test already accepts an error margin for coordinate mapping. It is
still flaky, so make that margin larger if the DPI of the widget >1.

Pick-to: 6.4 6.3 6.2
Change-Id: I0a598e5e94ac82c551cbeb935e2fa08cad048f84
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-07-14 15:24:43 +02:00
Eskil Abrahamsen Blomfeldt
ade2df4c4b Relayout QStaticText when dpi changes
If the cached font has a different DPI than the one used in
QPainter, we need to treat this the same as if other font
properties have changed and redo the layout.

This happened when running the QStaticText test on Wayland,
because the default dpi was 100 and the QPixmap we ended up
drawing to was 96. This caused the pixel size of the font to
be calculated differently when doing drawText() (using 96 dpi)
and drawStaticText() (using the cached 100 dpi).

Pick-to: 6.4
Fixes: QTBUG-100982
Change-Id: Ie4270341bb8a64b6458eb67ba460a282c65dc26b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-07-14 14:09:33 +02:00
Eskil Abrahamsen Blomfeldt
9a45a01a2c Try re-enabling test on Wayland
Running this test on Wayland passes for me, so maybe something
has magically improved.

Change-Id: I161b697c5be96af48938228267cb405048c78852
Reviewed-by: Inho Lee <inho.lee@qt.io>
2022-07-14 07:35:33 +02:00
Morten Johan Sørvig
5548b940fb wasm: add echo_client_mainthread example
This example connects an echo server running behind
WebSockify, on localhost.

For example, start websockify with

    websockify 1515 localhost:1516

to accept a webscoket connection on 1515 and forward
to echo_server at 1516.

Pick-to: 6.4
Change-Id: Id71364e4ab8c46d3482b515fcd1b991b61d7404b
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2022-07-14 01:10:56 +02:00
Volker Hilsheimer
d609b20842 QCompleter: make filesystem test robust against slow I/O
Use a signal spy to watch for the relevant signal from the file system
model and wait for that before checking whether the completer responded
to that signal by showing (or not showing) the popup.

If the file system model doesn't fire within the default timeout of 5
seconds, skip the rest of the test.

Fixes: QTBUG-46113
Pick-to: 6.4 6.3 6.2
Change-Id: I9becfe19a220bdb178ed8275c327d55ea19aa342
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-07-13 22:41:43 +02:00
Volker Hilsheimer
826a98cff1 QProcess: skip processesInMultipleThreads test on emulators
The test has timed out when run on ARM in qemu. We start more threads
than the ideal count, which is likely too much for the emulator when not
running the native architecture.

Pick-to: 6.4
Change-Id: I42e11945070646551e77c10618df762a4bffc8ba
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-07-13 21:02:01 +02:00
Ivan Solovev
12262adeba Do not use QExposedEvent::region() in internal code
Task-number: QTBUG-104857
Pick-to: 6.4 6.3 6.2
Change-Id: I5ee41802ecc4d6291aaaa1f0efddd20027c1c1e4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-13 16:45:00 +02:00
Volker Hilsheimer
92e696b4ba Use debug stream in QTest::toString's default fallback if possible
For built-in types, this is a compile-time assert - we should not have
any types in Qt for which we have neither debug streaming nor a
QTest::toString specialization implemented. A build of most of Qt
submodules passes with this change, after minor modifications to some
tests. We cannot declare QSizeHint::Policy as a metatype after the
QMetaType has already been instantiated for it, and the QDebug stream
operator for QElaspedTimer needs to be correctly declared within the
namespace.

Add a self-test function for a custom type, and update reference files
of the self-test.

Task-number: QTBUG-104867
Pick-to: 6.4
Change-Id: I2936db5933f4589fce45f47cf2f3224ed614d8c9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-13 15:14:35 +02:00
Eskil Abrahamsen Blomfeldt
3fee97c4ab Skip test which depends on window activations on Wayland
Wayland does not support window activation, so rather than skipping
tests based on platform name, we can use the platform capability
(which will also cover future platforms with the same issue)

Pick-to: 6.4
Task-number: QTBUG-104241
Change-Id: Ibf5f8968f3979b789ef68f92768419bef4500fb3
Reviewed-by: Inho Lee <inho.lee@qt.io>
2022-07-13 14:35:03 +02:00
Shawn Rutledge
8d9301b413 Add QInputDevice::name() to output in device_information manual test
Pick-to: 6.4 6.3 6.2
Task-number: QTBUG-104878
Change-Id: I4299228c90777d71f01c3e2607f8ad4af6e081ed
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-13 14:35:02 +02:00
Fabian Kosmale
268ff00ef5 QThread: Initialize bindingStatus for adopted threads
If we create a QThread from QThread::current(), we want it to have a
correct value for its bindingStatus. Thus, initialize bindingStatus in
the ctor of QAdoptedThread.

Task-number: QTBUG-101177
Task-number: QTBUG-102403
Pick-to: 6.4 6.3
Change-Id: I3ef27ed62c5dc25eed05d551c72743a1b8528318
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-13 12:51:59 +02:00
Morten Johan Sørvig
7e0711e0c0 wasm: secondary thread blocking sockets example
Connects to echo_server via websockify, like the async version.

Pick-to: 6.4
Change-Id: I9ed560cd388cfddbd0d284d8d40fb7ddf964ba96
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2022-07-13 09:29:28 +02:00
Volker Hilsheimer
0dadb951b5 qobjectrace test: Don't hardcode the number of threads
Use QThread::idealThreadCount instead. This requires that we use
QVarLengthArray, as MSVC doesn't allow us to allocate arrays with a
non-constexpr size on the stack.

By using as many threads as the system has cores, we are more likely
to detect race conditions reliably. On systems with fewer cores (in
particular on qemu platforms like QNX, where this test has been
failing a lot), we'll less likely end up with false negatives due
to timeouts.

Pick-to: 6.4 6.3 6.2
Change-Id: Ie8631aef544ca7b53c06a0729d05459016745486
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-07-12 17:16:37 +02:00
Laszlo Agocs
7de0f3e9cc rhi: Clean up some inconsistencies
Some of the offsets are already quint32 in the API (vertex input
attributes, dynamic offsets, offsets in draw calls), matching the
reality of the underlying 3D APIs, but many buffer-related functions
use int as of now, simply because that used to be the default choice,
and the same goes for sizes (such as buffer or range sizes). This is
not quite consistent and should be cleaned up if for nothing else then
just to make the classes consistent, but also because no 3D API use a
signed type for offsets, sizes, and strides. (except OpenGL for some)

When it comes to strides (for vertex inputs and raw image texture
uploads), those are already all quint32s. This is straightforward
because most of the 3D APIs use 32-bit uints for these regardless of
the architecture.

Sizes and offsets are often architecture-dependent (Vulkan, Metal),
but there is at least one API where they are always 32-bit even on
64-bit Windows (UINT == unsigned int, D3D11). In addition, we do not
really care about buffer or texture data larger than 4 GB, at least
not without realistic use cases and real world testing, which are
quite unlikely to materialize for now (esp. since we still have the
width/height of 2D textures limited to 16 or 32K in many cases even on
desktops, whereas 2GB+ buffers are not guaranteed in practice even
when an API seemingly allows it).

In any case, the important change here is the signed->unsigned
switch. A number of casts can now be removed here and there in the
backends, because the offsets and sizes are now unsigned as well,
matching the underlying API reality. The size can be potentially
increased later on with minimal effort, if that becomes necessary for
some reason.

Change-Id: I404dbc365ac397eaeeb3bd2da9ce7eb98916da5f
Reviewed-by: Inho Lee <inho.lee@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-07-12 17:16:37 +02:00
Volker Hilsheimer
7b6350fa77 QJniObject: Add template overloads for get/setStaticField
Allow specifying the Java class on which to set/get the field via its
corresponding C++ type, removing the need to explicitly provide the
Java type string.

Those were missing from a085a14d76, which
was noticed when porting QtConnectivity over to the new template APIs.

Pick-to: 6.4
Change-Id: I8f324c9fcc486b4c6c2f2b9051f7eca0cbec0e91
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-07-12 13:25:04 +02:00
Øystein Heskestad
1c563035c7 Disable unit testing setting up QTcpServer on special Apple interfaces
The iBridge interface is used for the keyboard touch bar, and the Apple
Wireless Direct Link interfaces are used by Apple for various purposes.
Setting up a server on these interfaces does not work.
Only the tst_QTcpServer::linkLocal unit test on macOS is affected by
this change.

Fixes: QTBUG-103892
Change-Id: I29701ce51d5e40dff6c59547a8639c1fba330d36
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-07-12 13:24:57 +02:00
Mikolaj Boc
fd45278eaa Specialize MetaObjectForType for non-pointer QObject-derived types
QMetaTypeInterfaceWrapper tries to find the metaObjectFunction using
the MetaObjectForType template. Using SFINAE, for a QObject, it should
resolve to a suitable specialization.

Such a specialization doesn't yet exist. It had to be created.

The following path returns nullptr for registered meta types:

  auto metatype = QMetaType(typeId);
  requestedTestType.metaObject() -> returns nullptr since a bad template
  argument is fed to MetaObjectForType<T> in
  QMetaTypeInterfaceWrapper<IneritingFromQObject>::metaType's static initializer.

Change-Id: I8b31c51e12cb19c333e00480b0177354b910ce1e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-07-12 13:24:57 +02:00
Sona Kurazyan
5e8cc498a1 QDomDocument: add a missing full-stop to a warning message
Change-Id: I3c44afa466cbcb12fc0b44ad8bd1b52ded5f4ddd
Pick-to: 6.4 6.3 6.2
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-07-12 13:24:57 +02:00
Sona Kurazyan
6bc227a06a Port QXmlStremReader to QAnyStringView
Port the constructor and addData() method to QAnyStringView, but keep
the overloads taking a QByteArray to avoid extra copies when actual
QByteArray is passed. These overlaods need to be Q_WEAK_OVERLOADs, to
avoid ambiguities (e.g. for const char * arguments).

Additionally, add a test to make sure the patch doesn't break parsing
from a QLatin1StringView input.

[ChangeLog][QtCore][QXmlStremReader] Added constructor and addData()
overloads taking QAnyStringView.

Change-Id: I0efaab82a2123271c88407e380f3c67d1099a4a6
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-07-12 13:24:56 +02:00
David Skoland
281d915ba4 Add wasm exception for tst_qchar
Since wasm doesn't like filesystems that well, we omit this test in
tst_qchar for wasm, this allows us to still run the test without the
case where it needs to read the normalization file.

Change-Id: I37e54d97e119f94e1a9ca53917d0b93183321899
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-07-11 17:21:27 +02:00
Shawn Rutledge
092ef06e00 Fix directory listing in manual filetest; add recursive find
- QFileInfo::fileName() is not the name of a directory, so we need
  absoluteFilePath() to construct a QDir
- QDir::entryList() returns only the name suffix, not the whole path
- stop at any arbitrary depth, and add a find command which does full
  recursion

Amends 04a5a74685

Change-Id: I9870db092125a797e8b654e98954ac611dde1ab2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-11 14:42:27 +02:00
Giuseppe D'Angelo
6f852935e0 QString: fix lifetime issues with QRegularExpression APIs
QString has several functions taking a QRegularExpression: indexOf(),
contains(), and so on. Some of those have an out-argument of type
QRegularExpressionMatch, to report the details of the match (if any).
For instance:

  QRegularExpression re(...);
  QRegularExpressionMatch match;

  if (string.contains(re, &match))
    use(match);

The code used to route the implementation of these functions through
QStringView (which has the very same functions). This however opens
up a lifetime problem with temporary strings:

  if (getString().contains(re, &match))
    use(match); // match is dangling

Here `match` is dangling because it is referencing data into the
destroyed temporary -- nothing is keeping the string alive. This is
against the rules we've decided for Qt, and it's also asymmetric with
the corresponding code that uses QRegularExpression directly instead:

  match = re.match(getString());
  if (match.hasMatch())
    use(match); // not dangling

... although we've documented not to do this. (In light of the decision
we've made w.r.t. temporaries, the documentation is wrong anyways.)
Here QRE takes a copy of the string and stores it in the match object,
thus keeping it alive.

Hence, extend the implementation of the QString functions to keep a
(shallow) copy of the string. To keep the code shared as much as
possible with QStringView, in theory one could have a function taking a
std::variant<QString, QStringView> and that uses the currently active
member. However I've found that std::variant here creates some abysmal
codegen, so instead I went for a simpler approach -- pass a QStringView
and an optional pointer to a QString. Use the latter if it's loaded.

QStringView has some inline code that calls into exported functions, so
I can't change the signature of them without breaking BC; I'm instead
adding new unexported functions and a Qt 7 note to unify them.

Change-Id: I7c65885a84069d0fbb902dcc96ddff543ca84562
Fixes: QTBUG-103940
Pick-to: 6.2 6.3 6.4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-07-10 23:40:24 +02:00
Volker Hilsheimer
54b276be0b testlib: Don't print QCOMPARE values if they lack string representation
Before 0681a2dd5a, QCOMPARE'ing types
for which no QTest::toString specialization exists did not output
Actual and Expected lines on failure, as that would only print <null>
for both values (which then look like the same value, confusingly).

Commit 0681a2dd5a changed that behavior,
and started printing the confusing <null> values.

Take care of the logic in the formatFailMessage function: if both values
are nullptr, then print only the variable names, but not the confusing
<null> text representation of the values.

Remove dead and duplicated code related to the formatting logic, add a
self-test function, and update the expected_cmptest files.

Fixes: QTBUG-104867
Pick-to: 6.4
Change-Id: I4be98e79f91196b14690a2cc0a68ffd50b431a45
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-07-10 03:08:32 +00:00
Laszlo Papp
1ea0d399b3 QKeySequenceEdit: Add a finishing key combinations property
Different shortcut editors seem to have different preferences. By
default, QWidget seems to utilise Tab, Backtab, Return and Enter for
navigation purposes. However, some shortcut editors would like to be
able to record these keys as part of combinations to use in the
application.

Therefore, leave it with the application developers to decide what key
combinations they would like to use for finishing the key sequence edit.
This should provide enough flexibility for application developers to
customize their shortcut editor behavior.

[ChangeLog][QtWidgets][QKeySequenceEdit] Added a property to allow
defining the finishing key combinations.

Fixes: QTBUG-103844
Fixes: QTBUG-103843
Change-Id: Id84644086ca7a4f11618d510e59698a43735b99b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-09 11:23:49 +00:00
Marc Mutz
2cfabed1ff Long live QDebug op<< QMetaType!
It's needed in QtHttpServer.

[ChangeLog][QtCore][QDebug] Can now stream QMetaType.

[ChangeLog][QtCore][QMetaType] Can now be streamed through QDebug.

Change-Id: I974d77d678137715472a3907ab1e50ba2dbaa087
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-07-09 06:40:08 +02:00
JiDe Zhang
1d961491d8 Always update QPalette resolve mask, regardless of QBrush change
56bd1b76d2 changed the update
resolve mask behavior in QPalette to avoid detaching brush data
when modifying the resolve mask if the brush value is not changed.

But this behavior broke compatibility, it introduced unknown risks, and
we cannot ensure that other code in Qt does not depend on the old
behavior.

We both need to ensure that we don't detach when the value is not
changed, and ensure that the resolveMask is always updated regardless
of whether the value changes, so we need to split them up and
independently share the brush data.

QFont will update its corresponding resolveMask even if the value has
not changed, so it is better to correct this behavior so that QPalette
and QFont are consistent.

[ChangeLog][QtGui][QPalette] Always update resolve mask in
QPalette::setBrush, even if the value of brush has not changed.

Fixes: QTBUG-98762
Pick-to: 6.4 6.3 6.2
Change-Id: Ib845361b30f21c3d78c16ced923c1678b12e05ac
Reviewed-by: JiDe Zhang <zhangjide@uniontech.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-08 17:09:04 +00:00
Richard Moe Gustavsen
e44edaac2c QWidget: use WA_InputMethodEnabled when ImEnabled is not implemented
In Qt 6.3, a check for WA_InputMethodEnabled was removed
in QWidget, to support IM queries also for read-only
widgets (7c6e4af48). This caused a regression on iOS, which
made the input panel open for widgets that didn't support
IM at all.

A patch was merged that solved the regression (3b12305575),
but it didn't take the widget attribute into account.
Since not doing so has the potential to cause regressions,
this patch will modify the affected code once more, so that
we instead fall back to test WA_InputMethodEnabled when
ImEnabled is not implemented. This will match closely
to the way ImEnabled was implemented in Qt 6.2.

Since we, with this change, now require that either ImEnabled
or WA_InputMethodEnabled is set, our own input widgets will
fail to support IM text selection when they're read-only, since
they actually don't implement ImEnabled.
This patch will therefore also make sure that we do so.

Task-number: QTBUG-104527
Pick-to: 6.4 6.3
Change-Id: I70ad910aec38d0a74f4dd7d3115d3c45c16d2b3b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-08 09:41:29 +02:00
Ulf Hermann
66a30b9a33 moc: Allow writing properties through bindables
BINDABLE should generally behave the same as MEMBER if "WRITE default",
except where it cannot. In particular we cannot know if any NOTIFY
signal should be sent from the synthetic WRITE accessor.

[ChangeLog][QtCore] moc will now synthesize WRITE accessors for
properties with BINDABLE if you specify "WRITE default".

Task-number: QTBUG-97249
Change-Id: I883c40ba0dda7989c840971860addaeaa75a8c83
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-08 09:38:27 +02:00
hjk
6619c94087 rcc: Suppress clang's -Wexit-time-destructors
It's an opt-in warning that some people like to use. It was introduced
to clang 3.0.0 in 2011 by

   98766db785

However, the feature is intentionally used here and the generated code is legit.

Make both sides happy.

Change-Id: I79335cd3a6a6cc128fa65f77d201a12f67424260
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-07-07 17:53:23 +02:00
Laszlo Agocs
c9d1d4c33c rhi: Fix a manual test
...that uses the old name after a recent change in the
name of a function.

Change-Id: Ife36fbb0c5d28b350cb1cfc48625528a205af8f9
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2022-07-07 16:07:18 +02:00
Morten Sørvig
4cc84dc31c Revert "Apply ScaleFactorRoundingPolicy to QT_SCREEN_SCALE_FACTORS"
Unblock the qtdeclarative dependency update.

This behavior change is causing a regression for QQmlPreviewHandler's
zoom feature. Back out of the change for now, until we can find a way
to make both use cases work.

This reverts commit 1c0a56a2f3.

Change-Id: I1b3d84504bbcb4f2b2250a20194fdaf4ab4fd97f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-07 14:47:14 +02:00
Juha Vuolle
c5caab1f15 Add support for scoped JNI callbacks
This commit adds macros for declaring scoped native callbacks which are
in namespace or for example defined as static class member variables.

The existing macros don't allow this as they use QtJniMethods namespace
and the introduced callbacks' namespaces are not enclosed in that
namespace, yielding a compilation error.

Pick-to: 6.4
Change-Id: I754560bea7e9a1b57c2661d1ee7236e78db39ba1
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-07 13:35:08 +03:00
Mate Barany
cc70757964 qdbusxml2cpp: allow choosing <> over ""
qdbusxml2cpp's -i option uses "" for the includes.
However, an option to include with <> would be also
desirable, since some compilers may use a different
search strategy for <> than for "".

Add a new command line option -I/--global-include
to include the given argument using <>.

The new option will be used in qtconnectivity.

[ChangeLog][qdbusxml2cpp] Added command line option
-I/--global-include to include header files with <> in
the generated files.

Fixes: QTBUG-103362
Change-Id: If8e7f8b86440bdec53f2517db1ad460912664b20
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-07-07 07:44:16 +00:00
Mikolaj Boc
fb8832de9c Make the promises js-less using a newly introduced thunk pool
Since we cannot rely on the clients specifying a suitable CSP that will
not forbid execution of js injections, we have to refrain from using
any explicit <script> elements. To keep the promise system working, a
thunk pool was introduced which keeps track of a limited pool of promise
callback exports. In case the resources are busy, pending calls are
enqueued. This works since the JS Promise.then/catch/finally always fire,
even on ready/failed promises.
As the situation of full thunk pool allocation is unlikely to happen
en masse IRL, the solution should not adversely affect the performance.
Heavy unit tests were created to confirm the solution works as expected.

Task-number: QTBUG-99611
Change-Id: I0e6982d4ee76a4263b59e72b004b3ff2f167e4df
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-07-07 06:28:13 +02:00
Sona Kurazyan
6ad481c31f Revert "QFutureCallOutEvent: de-export again"
QFutureCallOutEvent is used externally, so it needs to be exported.

This reverts commit 3141a13b2a.

Fixes: QTBUG-104732
Pick-to: 6.4
Change-Id: I82c9e7414192ee948f78259bd74a404691a7805a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-07-06 18:41:31 +02:00
Morten Sørvig
1c0a56a2f3 Apply ScaleFactorRoundingPolicy to QT_SCREEN_SCALE_FACTORS
QT_SCREEN_SCALE_FACTORS in many cases set on behalf of the user,
instead of by the user, so we should make it less sharp and more
in line with standard high-dpi configuration.

Specifically, make it subject to the rounding policy set by
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(). This
means that applications which support integer scale factors
only will see integers only, also when QT_SCREEN_SCALE_FACTORS
specifies a fractional factor.

Users who want to override can set

  QT_SCALE_FACTOR_ROUNDING_POLICY=PassThrough

to restore the default Qt rounding behavior.

[ChangeLog][QtGui] The high-DPI scale factor rounding policy (settable with
QGuiApplication::setHighDpiScaleFactorRoundingPolicy() or
QT_SCALE_FACTOR_ROUNDING_POLICY) now applies to scale factors set
with QT_SCREEN_SCALE_FACTORS.

Pick-to: 6.4
Fixes: QTBUG-95930
Fixes: QTBUG-99546
Change-Id: Ibb0aa5cb9d3a356d33429d0efe69d984b2530728
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-07-06 15:56:58 +00:00
Morten Sørvig
bc6dea891e High-dpi: Add test for setting the scale factor rounding policy
Test setting both via QGuiApplication property and environment.

Change-Id: Iaccc920adb6294d610b02d4c844aa5b15eb7eecd
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-07-06 17:56:58 +02:00
Morten Sørvig
9be0f2945d wasm: begin work on accessibility backend
Implement a11y support by adding html elements of the
appropriate type and/or with the appropriate ARIA attribute
behind the canvas.

Also add a simple manual-test.

Change-Id: I2898fb038c1d326135a1341cdee323bc964420bb
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2022-07-06 17:56:58 +02:00
Marc Mutz
0587d4752d Remove uses of Q_ATOMIC_INT{8,16,32}_IS_SUPPORTED
It's always true these days, assert so in qatomic.cpp and
tst_QAtomicInteger.

Update the docs.

Pick-to: 6.4
Change-Id: I3684cff96c1d2e05677314e29514cc279bd6b1a1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-07-06 17:56:58 +02:00
Marc Mutz
0231971b3e tst_QGraphicsScene: fix -Wsuggest-override
Add the override keyword.

Amends 2e12479e06.

Pick-to: 6.4 6.3 6.2
Change-Id: Ic62dd33b1ee52983481e39e862b9bd87695f5044
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-06 17:56:57 +02:00
Mikolaj Boc
3c07f12415 Port promise tests to qtwasmtestlib
The promise tests have been ported to qtwasmtestlib so that they do not
have to use asyncify anymore.

Task-number: QTBUG-99611
Change-Id: Id1b5742c90e36a89540e7a2387cb4110c21ace9b
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-07-06 17:56:57 +02:00
Mikolaj Boc
a50590370f Create the Qt File Filter => showOpen/SaveFilePicker options mapper
As a preparatory measure for using showXFilePicker, the Qt file
filter has to be transformed to the format used by the showXFilePicker
(sXFP) options. A class structure reflecting the options was created. Based on
an input in the form of a qt file filter, it will parse the filter to
the sXFP options format. Unit tests were added and the code is not yet
used in non-test env, next change will use it.

Task-number: QTBUG-99611
Change-Id: I277286467a7b5ce6f323c19bdd31740a41b6a6be
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-07-05 22:22:54 +02:00
Mikolaj Boc
3ca167a30e Enhance the qtwasmtestlib with comparison functions and status reporting
Added the functionality to report text statuses from tests, reporting
file and line of assertion failures. Refactored the qtwasmtestlib.js
for improved stability.

Task-number: QTBUG-99611
Change-Id: I717e0cc38ac7f155fe870710f6b5e4bfb81b9317
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-07-05 21:18:30 +02:00
Timur Pocheptsov
7949dab8ab tst_QSslKey: prepare for the migration to OpenSSL v3
Many algorithms (ciphers etc.) had become 'legacy' in OpenSSL v3,
meaning they are not available by default. Since we don't mess with
loading providers and don't load the 'legacy' one, we have to
skip tests involving such algorithms.

Pick-to: 6.4 6.3 6.2 5.15
Fixes: QTBUG-104232
Change-Id: Ieceabeb080e531aeb24f733cb8c83ad08a25049c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-07-05 17:36:03 +02:00
Tang Haixiang
551127209e QListview: PageDown/Up infinite loop
When item.height > viewport.height, the next item is not found
correctly, resulting in an infinite loop.

In this case, move directly to the next item.

Pick-to: 6.4 6.3 6.2
Change-Id: I67a40a079ca9dd9189bf84ae550758c685b83d75
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-05 11:55:19 +00:00
Tang Haixiang
c2a63b4014 tst_qwindow: modify some abnormal touch tests
Under normal circumstances, when the second point is touched, the
first point has not been released, and the message at this time
should contain two touch points. We are simulating the case where
the message is lost when the popup is closed by touch. Amends
efc02f9cc3

Pick-to: 6.4 6.3 6.2
Change-Id: Ic722e3dbd615c46076ede26611d0107501c5e274
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-07-05 13:55:19 +02:00
Laszlo Agocs
6ec339c484 rhi: Keep track of pipeline creation times
Make our QRhiMemAllocStats struct a bit more generic, drop the memory
allocation part in the naming, and use the same getter and struct for
reporting some important timings. (we are free to rename for now, there
are no users in other modules yet)

The time spent in graphics (or compute) pipeline creation has a special
relevance in particular with the modern APIs (as it is the single
biggest potentially time consuming blocking operation), but also highly
interesting with others like D3D11 simply because that's where we do the
expensive source-to-intermediate compilation is HLSL source is provided.
In order to see the effects of the various caching mechanisms (of which
there can be confusingly many, on multiple levels), the ability to see
how much time we spent on pipeline creation e.g. until we render the
first view of an application can be pretty essential.

Task-number: QTBUG-103802
Change-Id: I85dd056a39db7e6b25fb1f9d02e4c94298d22b41
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-07-05 13:04:09 +02:00
Laszlo Agocs
a09e518f65 rhi: Make it possible to query the backend name beforehand
The goal is to make it possible to implement QSGRhiSupport::backendName()
in Qt Quick with just a single line:

return QString::fromUtf8(QRhi::backendName(m_rhiBackend));

instead of duplicating the strings and the logic.

Similarly, QBackingStoreRhiSupport can now drop its apiName() helper
entirely.

Change-Id: Ia8cbb1f1243539ed4d7a98e71dcc2ed56b017e40
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-07-05 13:04:09 +02:00
Juha Vuolle
58fd12a487 Add support for naming JNI functions with the unstringify macro
The manually defined native JNI function tables allow defining a name
that may be different from the actual function name; this name is then
used from the Java-side.

This can be useful to provide also as an option with the new
"unstringifying" macros which can help for example in porting code
to these new macros.

Pick-to: 6.4
Change-Id: Icfebfb351cb8dfb122795d20b37e2eac167a41bf
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-05 11:50:25 +03:00
Laszlo Agocs
dab0ef3670 Harden drag and drop handling in widget window
User code in an event handler can do arbitrary things, including
operations that lead to destroying the QWidgetWindow. An example is
what the autotest does: reparenting the top-level widget to under
another top-level upon the drop. Internally this leads to destroying
the drop target's QWidgetWindow as the widget is now a child, not a
top-level.

In fact some of the existing drag and drop handling code seems to be
prepared to handle the case of having the drag target widget destroyed
in the user's event handler during a drag-move. But none of it is
prepared for having the QWidgetWindow destroyed upon returning from
forwardEvent().

The associated bug report has the same root cause, it is just popping up
now via the new 6.4 behavior: adding a QOpenGLWidget to a widget
hierarchy upon a drop leads to getting a new QWidgetWindow (if the
window only had regular raster widgets before).

To solve this, avoid touching members on 'this' after the
forwardEvent(). It looks like the handlers for mouse events follow
this pattern already, no member data is touched after forwarding events
(not sure if that is intentional or just incidental but it is the safe
solution, even if this is not feasible everywhere, but ideally input
events should take this into account).

Fixes: QTBUG-104596
Pick-to: 6.4 6.3 6.2
Change-Id: I96c704cadcd799fc5619b776e939dfdf313a27dd
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-01 22:38:45 +00:00
Ahmad Samir
60c69b4da5 QLayout: add className() to a warning message
Since objectName() isn't always set, the className() makes it slightly
easier to find and fix the issue.

Also unify some wording "produce a warning", which is generic enough to
fit:
print warning in terminal
print warning in logviewer (if you're unlucky and have to use Windows?)
print warning in system journal (if you're unlucky have to use binary
systemd journal logs)

Pick-to: 6.4
Change-Id: I7522d65666cb5829c33c45039b8646dd535e21ea
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-01 18:19:46 +00:00
Richard Moe Gustavsen
3b12305575 IM: Don't let all widgets support IM by default
A new property Qt::ImEnabled was added in Qt 5.3.
Since the already existing widgets with IM support
(3rd party included) didn't implement this property,
QWidget got the fall back logic that if a widget
was queried for Qt::ImEnabled, and the returned QVariant
was invalid (the widget didn't implement it), we
would, for backwards compatibility with Qt 4, return "true"
(meaning that the widget supports IM).

But a side effect from this fallback logic, is that now
any widget that doesn't implement ImEnabled (or input
methods at all) report that they support IM. This will
confuse platforms like iOS, which uses ImEnabled to decide
if the input panel should show, and if text selection tools
should be enabled. The result is therefore that if you click
on a QPushButton, the input panel will open.

This patch will implement a more careful strategy to check if
a widget implements IM, if ImEnabled is missing. Rather than
saying that all widgets that don't implement ImEnabled supports
IM, we now require that the widget also returns a valid QVariant
for Qt::ImSurroundingText. We assume then, that a widget that
doesn't do so will anyway not be in need of input method support
from the platform.

Fixes: QTBUG-104527
Pick-to: 6.4 6.3 6.2
Change-Id: Ib391fd1daae92c4325e9ccb59730fbdd7c9328fc
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-07-01 10:47:17 +02:00
Mikolaj Boc
d0eba2449a Create a promise wrapper for C++ and port existing uses
Currently, to use a promise from C++ we either have to use an ASM block
(which does not work well with dynamic linking) or declare exports in
the EMSCRIPTEN_BINDINGS block, which is cumbersome and cannot be chained.
This solution makes it easy to use js promises by introducing the
WebPromiseManager which dispatches callbacks to appropriate callers when
available.
This is a preliminary patch for FileSystem support, which will heavily
use async APIs.

Task-number: QTBUG-99611
Change-Id: I368a8f173027eaa883a9ca18d0ea6a3e99b86071
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-06-30 01:20:28 +02:00
Morten Johan Sørvig
122aa530d6 wasm: add qtwasmtestlib
qtwasmtestlib supports writing asynchronous tests for
the web platform.

Asynchronous test functions differ from normal test
functions in that they allow returning from the test
function before the test has completed:

void TestObject::testTimer()
{
    QTimer::singleShot(100, [](){
        completeTestFunction(); // Test pass if we get here
    });
}

Currently one logging backend is supported which
writes the results to an html element. See the README
file for further documentation.

Change-Id: Ia633ad3f41a653e40d6bf35dd09d62a97c608f84
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-06-29 15:09:02 +02:00
Dimitrios Apostolou
d23dcc0542 qtestlib: exit with error if a test is invoked with unknown data tag
Previously trying to execute a test function with an unknown data tag
would print an error message but exit with 0.

This patch stores a test failure, and continues trying to execute the
rest of the command line arguments, if any. In the end the process exits
with the usual exit code (number of failed tests) which is now !=0.

Pick-to: 6.4 6.3 6.2
Fixes: QTBUG-24240
Change-Id: Id4d422035f173e01e77ca88028dfd94dc0f9085c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-06-28 18:06:33 +02:00
Alexey Edelev
d4b27d9b52 Avoid including qopenglfunctions header files if Qt is built with GLES2
Change-Id: I3a7a69f5eef604408713934811efb984e78d68dd
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-06-28 10:52:23 +02:00
Laszlo Agocs
f814cc6a79 rhi: metal: Switch back to presentDrawable
This convenience should be, according to the Apple docs, equivalent to
calling present from a scheduled handler. (which on its own makes it
unclear why we switched in the first place)

In practice it seems the two approaches are not identical. It looks
like that once a frame is submitted earlier than the next display link
callback, the throttling behavior we implement in beginFrame()
(waiting on the semaphore for the completion of the appropriate
command list etc.) starts exhibiting unexpected behavior, not
correctly throttling the thread to the refresh rate. Changing back to
presentDrawable does not exhibit this at all.

The suspicion is that presentDrawable is probably doing more than what
the docs suggest, and so is not fully equivalent to calling present
manually from a scheduled handler.

Therefore, switch to presentDrawable now, which restores the expected
cross-platform behavior, but make a note of the oddity, and also
prepare the hellominimalcrossgfxtriangle manual test to provide an
easy, self-contained application to allow experimenting in the future,
if needed.

This allows Qt Quick render thread animations to advance at the
expected speed (because the render thread is correctly throttled to
the refresh rate), even if the render thread decides to generate a new
frame right away, without waiting for the next display link update.

Without this patch, attempting to get updates not via requestUpdate(),
but by other means (timer etc.) leads to incorrect throttling, and so
the triangle in the test app is rotating faster than expected - but
only with Metal. Running with OpenGL on macOS or with any API on any
other platform the behavior will be correct. Even if scheduling
updates without display link is not efficient, and should be
discouraged, not doing so cannot break the core contract of vsync
throttling, i.e. the thread cannot run faster just because it renders
a frame not in response to an UpdateRequest.

Amends 98b60450f7 (effectively reverts
but keeps the code and the notes because we might want to clear this
up some day)

Pick-to: 6.4 6.3 6.2
Fixes: QTBUG-103415
Change-Id: Id3bd43e94785384142337564ce4b2644bf257100
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-06-28 10:47:41 +02:00
Thiago Macieira
5e67e7efaa FatalSignalHandler: print some more information from siginfo_t
The siginfo_t parameter allows us to show what process sent a signal or
the crashing address. Additionally, it allows us to determine if the
crashing signal was indeed sent due to a crash.

The selftest tst_crashes produces now:

$ QTEST_DISABLE_STACK_DUMP=1 ./crashes
********* Start testing of tst_Crashes *********
Config: Using QtTest library 6.4.0, Qt 6.4.0 (x86_64-little_endian-lp64 shared (dynamic) debug build; by GCC 11.2.1 20220420 [revision 691af15031e00227ba6d5935c1d737026cda4129]), opensuse-tumbleweed 20220428
PASS   : tst_Crashes::initTestCase()
Received signal 11 (SIGSEGV), code 1, for address 0x0000000000000004
         Function time: 0ms, total time: 0ms
[1]    201995 segmentation fault (core dumped)  QTEST_DISABLE_STACK_DUMP=1 ./crashes

The last line comes from the shell. The code isn't decoded, but on Linux
it's a SEGV_MAPERR. macOS prints exactly the same thing.

I've updated one of the expected_crashes_*.txt output that doesn't seem
possible (the "Received a fatal error" message does not appear in Qt
anywhere).

Pick-to: 6.4
Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16ebc8391234f0e2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-06-28 00:39:35 +00:00
Laszlo Papp
9521a07af2 QKeySequenceEdit: add a maximumSquenceLength property
At the very least, it would be important to have a single combination
key sequence. This is commonly seen in keyboard shortcut editors where
QKeySequenceEdit is very much applicable.

[ChangeLog][QtWidgets][QKeySequenceEdit] Added a maximumSquenceLength
property.

Done-with: Marc Mutz <marc.mutz@qt.io>
Change-Id: Id7fa5a8593eb150fa67d7e89308492c0a200ac36
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-06-27 12:02:47 +00:00
Mårten Nordheim
4d60ba61dc Fix QDBusInterface crashing with empty path on construction
On some machines having an empty path passed to QDBusInterface
would cause a crash.

This happened because the code created a QDBusMessage and manually
marked it as validated when it was not. The validation would not
pass for this object.

Change-Id: I496dd922fa64353399655a1e84996b99990f5879
Pick-to: 6.4 6.3 6.2 5.15
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-27 14:02:47 +02:00
Lars Schmertmann
e3ea1d02e6 QHttpHeaderParser: Allow larger fields but restrict total size
Our limit of 8k for a single header field was too small for certain
services which returned Location values or WWW-Authenticate challenges
longer than 8k.

Instead, taking inspiration from Chromium, we have a limit of 250k for
the full header itself. And increasing our field limit to 100k, which
would occupy almost half of what the total header allows.

Also took the opportunity to make it adjustable from the outside so we
can set more strict limits in other components.

Fixes: QTBUG-104132
Pick-to: 6.3 6.4
Change-Id: Ibbe139445e79baaef30829cfbc9a59f884e96293
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2022-06-27 14:02:47 +02:00
Thiago Macieira
f5697d2b2a tst_moc: fix build with GCC 12
You can't mismatch the export macros. The QT_MOC_EXPORT_PLUGIN_V2 macro
defines these functions as Q_DECL_EXPORT so they can be found by
QPluginLoader. We must match the macro here, otherwise GCC 12 complains
(tst_moc.cpp is compiled with -fvisibility=hidden):

tst_moc.cpp.o: non-canonical reference to canonical protected function `qt_plugin_instance' in moc_plugin_metadata.cpp.o

Pick-to: 6.4
Change-Id: Id0fb9ab0089845ee8843fffd16f99893d5730da5
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-24 19:05:53 -07:00
Shawn Rutledge
846b314aaf Emit autolinks in QTextMarkdownWriter
When a markdown document contains a "naked" URL, or an angle-bracketed
<URL>, md4c recognizes it, and we set the AnchorHref charfmt property.
There's no need to expand it into the [text](url) form if the text is
the same as the url, there is no tooltip, and the url is valid.
QTextMarkdownWriter now writes a CommonMark "autolink" in that case:
https://spec.commonmark.org/0.30/#autolinks

[ChangeLog][QtGui][Text] QTextMarkdownWriter now writes an autolink
whenever a hyperlink has no custom text and no tooltip, including
when the document was parsed from Markdown containing a naked URL.

Pick-to: 6.4
Fixes: QTBUG-94713
Change-Id: I432db8499c62e1e0b1e913bfd8ef2147e3c2bb2a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-06-24 22:42:43 +02:00
Shawn Rutledge
56f0ebfe86 Support markdown in QTextEditMimeData; fix pasting trailing newlines
- Since 4edcea762d the dropsite example
  shows markdown if available; and now it shows that when we do DnD
  of a selection from the richtext example, text/markdown is available.
- If we artificially make html unavailable, copying and pasting between
  widget-based rich text editors uses markdown.

In case markdown writer output contains unnecessary backticks due to
monospace fonts getting used, the workaround from
1ad456c908 is applied.

Pick-to: 6.4
Task-number: QTBUG-76105
Task-number: QTBUG-103484
Change-Id: Ie6ca4dbb450dbc36b3d09fd0df1ae5909aaebca7
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-06-24 22:42:28 +02:00
Toni Saario
ec0ecedf2a Blacklist qtcpsocket bind on arm macOS
This was unblacklisted in b885820c39
however it is still very flaky.

Change-Id: If9796231c584c894387106dfeb262c9eb4ce73f5
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-06-24 17:20:02 +00:00
Mårten Nordheim
6cbe8f74ce Network: Update expired cert
Pick-to: 6.4 6.3 6.2 5.15
Change-Id: I233ffee5b720c0554071c1d49d4fb861736b2e2a
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-06-24 17:20:00 +00:00
Anna Wojciechowska
b885820c39 unblacklist passing tests 2022
Change-Id: Ifb09a997d39fc2c92503e77cf372d443c13c4c2b
Reviewed-by: Daniel Smith <Daniel.Smith@qt.io>
2022-06-23 01:36:01 +02:00
Thiago Macieira
dda9c9e2bc moc: fix use of escape sequence of more than one character
We had the code to calculate the length, but were improperly using it
only for the offset, not the length of the string or its containing
array. That resulted in the generated moc output containing:

 QT_MOC_LITERAL(111, 5), // "\xffz"
 QT_MOC_LITERAL(114, 5), // "\0012"
 QT_MOC_LITERAL(117, 23), // "slotWithAReallyLongName"

The two strings are described as occupying 5 bytes (length 4 + null
terminator), which is incorrect. The offset was correct: 114 - 111 = 3
and 117 - 114 = 3. The new output is:

        QT_MOC_LITERAL(111, 2),  // "\xffz"
        QT_MOC_LITERAL(114, 2),  // "\0012"
        QT_MOC_LITERAL(117, 23),  // "slotWithAReallyLongName"

The effect of the array size calculation would only be felt if moc
decided it needed a second string array (for strings over 65535 bytes),
which would cause the offsets in the second array to be all wrong. There
was no such test until now.

Drive-by fixing of the newline, indentation, and the stale comment
referring to QByteArrayData (Qt 5).

Pick-to: 6.2 6.3 6.4
Change-Id: Id0fb9ab0089845ee8843fffd16f9cd01b3e0709a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-22 13:03:17 -07:00
Ye ShanShan
c3b959733a Add QDom internalSubset implementation
QDom's internalSubset() always returned empty because nothing
actually set the internal data member it returns. When parsing
the DECLTYPE, extract the internal subset and save it to the
doctype()'s member when present.

Pick-to: 5.15 6.2 6.3 6.4
Fixes: QTBUG-53661
Change-Id: I6e41ff8b914381168246073b3289d82205b1c255
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-06-23 02:18:39 +08:00
Ulf Hermann
2c0518eb62 moc: Allow reading property values through bindables
The behavior is similar to MEMBER: If the READ accessor is "default",
synthesize it using the bindable.

[ChangeLog][QtCore] You can now specify "READ default" in a Q_PROPERTY
if you also specify a BINDABLE. moc will synthesize a READ accessor in
that case.

Task-number: QTBUG-97249
Change-Id: I4a275adabaed12df95dac505095f847c4be65dfe
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-22 16:05:07 +02:00
Thiago Macieira
e114fec62a QJsonValue: fix incorrect to{Array,Object} when the value is empty
This is a repeat of commit de6ced6692
"QCborValue: fix incorrect to{Array,Map} when the value is empty" (6.4),
which fixed the same thing for QCborValue. I've just copied the exact
same implementation onto the QJsonValue functions.

Pick-to: 6.2 6.3 6.4 5.15
Fixes: QTBUG-104085
Change-Id: I175efddd75f24ae59057fffd16f6b257bf7ed36d
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-06-21 22:25:32 -07:00
Marc Mutz
32925d0a85 tst_tostring: add benchmarks for QCOMPARE vs. QCOMPARE_EQ
There's currently no statistically-significant difference between the
two, due to a huge pessimistion in QTestLib where every QCOMPARE* and
QVERIFY writes 1KiB of data onto the stack before doing anything else,
so I'm not reporting numbers in this commit message.

Pick-to: 6.4
Task-number: QTBUG-98873
Task-number: QTBUG-98874
Change-Id: I233878596f0a8fe6b96360adb839fecd72c398a2
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-06-22 01:38:12 +00:00
Marc Mutz
882fc48b9e tst_bench_shared_ptr: fix build with BOOST_NO_EXCEPTIONS
If, for whatever reason, BOOST_NO_EXCEPTIONS is defined, the user of
the Boost libraries is supposed to provide a definition of
boost::throw_exception, which we didn't.

We used to run into this only on ubsan builds, but it seems we now
have the problem on a regular Ubuntu 22.04 build, too (cf. bugreport).

Fix by adding the necessary definitions.

Fixes: QTBUG-104083
Pick-to: 6.4 6.3
Change-Id: I9b061a158a5b77e8d286bd7b40312e5bc63ee8de
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-06-22 03:09:24 +02:00
Sona Kurazyan
bf3fc5c95c QPromise: run continuation(s) on destruction
If the QFuture is canceled because the associated QPromise has been
destroyed, we still need to run its continuations (i.e. onCanceled
handler, if it's attached), so replaced the cleanContinuation() call
inside ~QPromise() with runContinuation(), which will also take care of
cleaning the continuation.

[ChangeLog][QtCore][Important Behavior Changes] QFuture now runs its
continuations when its associated QPromise has been destroyed.
Previously, if a QFuture was canceled because the associated QPromise
has been destroyed, its continuations were skipped.

Fixes: QTBUG-103992
Pick-to: 6.4 6.3 6.2
Change-Id: Ie05bc760c96c349aade8adb8d2fe5263aff8efac
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-22 03:09:24 +02:00
Shawn Rutledge
579f0a4cf2 Remove unused variable in tst_QTextEdit::setDocumentPreservesPalette()
Change-Id: I96c0f39c2ee1bd03cf0d7939624652ee008c9726
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-06-21 21:42:18 +02:00
Lars Knoll
9c1f3b6d4d Add QStringDecoder::decoderForHtml()
Now that QStringConverter can handle non UTF encodings through ICU,
add a way to get a decoder for arbitrary HTML code.

Opposed to QStringConverter::encodingForHtml(), this method will
try to create a valid string decoder also for non unicode codecs.

Pick-to: 6.4
Change-Id: I343584da1b114396c744f482d9b433c9cedcc511
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-21 01:04:12 +02:00
Sona Kurazyan
da0d7f61c8 QDom: Stop treating non-BMP characters as invalid
According to https://www.w3.org/TR/REC-xml/#NT-Char unicode characters
within the range of [#x10000-#x10FFFF] are considered to be valid, so
fix the check for valid characters accordingly. This requires changing
the loop over the input QString to iterate over code points (instead of
code units).

Fixes: QTBUG-104362
Pick-to: 6.4 6.3 6.2 5.15
Change-Id: I7dcf5cad05265a54882807a50522d28b647e06ee
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-20 21:29:04 +00:00
Mårten Nordheim
3d73aa660b function_ref test: Don't take reference of temporaries
When assigning the lambdas directly to a function_ref their lifetime is
limited to that of the expression. Store them on the stack first to
avoid the UB.

Fixes: QTBUG-104419
Pick-to: 6.4
Change-Id: I3c85ac683b0bd7768b646dc9d0a1ed4dd173e6f3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-20 19:52:01 +00:00
Volker Hilsheimer
2e12479e06 QGraphicsScene: respect that items can override selection changes
QGraphicsItems may override itemChange to prevent certain attribute
changes. Overriding ItemSelectedChange this way is explicitly documented
to be allowed.

However QGraphicsScene::clearSelection did not test whether items were
in fact deselected after the call to setSelection, and always cleared
the stored set of selected items.

Fix this by checking the actual selected state of the item as we iterate
over them, and store those items that are still selected in a set that
becomes the new selectedItems set (which will be empty if no item
overrides, which is the default).

Add a test that also checks that clearing the selection emits the
selectionChanged signal correctly (and does not if all selected items
block being deselected).

Fixes: QTBUG-85474
Pick-to: 6.4 6.3 6.2
Change-Id: I665afc132876e02e6e1061b7be37f4f6e4be418f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-06-20 20:44:23 +02:00
Heikki Halmet
bb674adb25 BLACKLIST tst_qfont for Ubuntu 22.04
Pick-to: 6.4 6.3 6.2 5.15
Task-number: QTBUG-84248
Change-Id: I2978cd2a6ed07bb6fc5769b174d0a897dfa3566d
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
2022-06-20 17:06:20 +00:00
Allan Sandfeld Jensen
0bd2876275 Avoid misleading bindingStatus
Set it to nullptr on clear, and deal with possibly null bindingStatus.

Task-number: QTBUG-101177
Task-number: QTBUG-102403
Pick-to: 6.4
Change-Id: I66cb4d505a4f7b377dc90b45ac13834fca19d399
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-06-20 19:06:20 +02:00
Heikki Halmet
903bde19a4 BLACKLIST: tst_QGlyphRun::mixedScripts for Ubuntu 22.04
Pick-to: 6.4 6.3 6.2 5.15
Task-number: QTBUG-68860
Change-Id: I79c085c7321e0bee78e8cb31daa8c7992d3a3ec6
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
2022-06-20 20:06:20 +03:00
Heikki Halmet
a3c43394bb BLACKLIST tst_QApplication::sendEventsOnProcessEvents for Ubuntu 22.04
Pick-to: 6.4 6.3 6.2 5.15
Task-number: QTBUG-87137
Change-Id: Ib09382af7504f5ee078d23cc021c1b0faf051e23
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
2022-06-20 20:06:20 +03:00
Heikki Halmet
5aca1fe1d0 BLACKLIST tst_QMenuBar::check_menuPosition for Ubuntu 22.04
Pick-to: 6.4 6.3 6.2 5.15
Task-number: QTBUG-68865
Change-Id: I1eda9789a30737104c6e97de583a9f3022ae0bf6
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
2022-06-20 20:06:20 +03:00
Fabian Kosmale
c15714191c tst_qthread: Fix compilation under ubsan
We missed the terminating ";" in the QSKIP lines.
Amends ea4d6b987a

Pick-to: 6.3 6.4
Change-Id: Ibda43b8a84230c243dbcc74e157f4c3f8ef3891d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-06-20 12:12:07 +02:00
Volker Hilsheimer
ea4d6b987a Skip tests that terminate threads under ASAN
Thread termination might prevent stack unwinding, which then
generates ASAN errors such as

ERROR: AddressSanitizer: stack-buffer-underflow on address
0x7f3c1d7858b0 at pc 0x7f3c243d8918 bp 0x7f3c1d7857f0 sp 0x7f3c1d7857e8

Skip such tests so that we can enable blocking CI runs under ASAN.

Fixes: QTBUG-104421
Pick-to: 6.4 6.3
Change-Id: I169235a12190e3f72525cddfe1a44a4bee19eca1
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2022-06-19 12:16:00 +02:00
Fabian Kosmale
122270d6be Long live the ICU-based QStringConverter interface!
This adds support for additional codecs to QStringConverter when ICU is
available.

We store the converter in the state (d[0]), and its canonical name in
d[1]. We need the name there, as in the clear function we close the
UConverter, and set the pointer to null. Consequently, the actual
conversion functions might need to re-open the converter again. The
advantage of this approach is that clear is used in the destructor of
State, and with this approach we properly clean up the state.
There is however a disadvantage: The clear function was so far also used
for resetting the state when QStringConverter::resetState . Discarding
the whole Uconverter for that is however rather costly. For that reason
we modify resetState to call a new function, State::reset. For existing
converters, it behaves the same as clear; for the ICU based converter,
we call the more efficient ucnv_reset. Code compiled against Qt 6.4 can
benefit from this more efficient version; code compiled against older Qt
versions will continue to work, as the conversion functions can just
recretate the converter from the name.
We can distinguish between ICU and non-ICU converters by checking if the
UsesIcu flag is set.

QStringConverter::name is changed to return the name stored in d[1]. The
interface of the ICU converter has a dummy name, so code using the old
name function from QT < 6.4 still returns something, namely a message
asking the user to recompile.
The function is moved out of line, as we need to check for the private
ICU feature, and want to avoid having that check in the public header.

As the QStringConverter ctor taking a name now can allocate memory, it
can no longer be noexcept. Removing the noexceptness is safe, as it was
only added after Qt 6.3.

Note that we cannot extend the API consuming or returning Encoding, as
we use Encoding values to index into an array of converter interfaces in
inline API.

Further API to support getting an ICU converter for HTML will be added
in a future commit.

Currently, the code depending on ICU is enabled at compile time if ICU
is found. However, in the future it could be moved into a plugin to
avoid a hard dependency on ICU in Core.

[ChangeLog][Corelib][Text] QStringConverter and API using it now
supports more text codecs if Qt is compiled with ICU support.

Fixes: QTBUG-103375
Change-Id: I7afb92fc68ef994179ebc7a3aa73beebb1386204
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-19 00:41:12 +02:00
Axel Spoerl
99c8ffb9f2 Update window state in QWindowsWindow and QXcbWindow geometry setters
When QWidget::resize() is called on a maximized or minimized QWidget,
the window state of the widget and the corresponding QWindow is not
updated (i.e. remains maximized or minimized).

This patch updates the window state to Qt:WindowNoState when
setGeometry() is called in QWindowsWindow or QXcbWindow.

A test is added in tst_QWidget.

Fixes: QTBUG-104201
Pick-to: 6.4
Change-Id: I07491fb9293d13509573fc403750da0a50f6a785
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-06-17 18:59:22 +00:00
Ivan Solovev
2ed54dedf3 QMainWindow: fix restoreState() for toolbars
Restoring the toolbar state of a QMainWindow could not update
QWidgetPrivate::widgetItem for the QToolBar, because at that point it
was still holding the pointer to the widgetItem of the previous state.
Later on, when the new state was successfully applied, the previous
state was deleted, and the corresponding widgetItem was reset to
nullptr.

This patch explicitly resets the QToolBar's widgetItem while updating
the state, so that it is later correctly updated while creating a
new QWidgetItemV2.

Fixes: QTBUG-102395
Pick-to: 6.4 6.3 6.2 5.15
Change-Id: I17613d62423edcc0faf85ecb0a714865a50d87e8
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-06-17 20:59:21 +02:00
Edward Welbourne
cfcbf38f76 Teach qmake about digit-grouping apostrophes in numeric literals
It was previously understanding them as character literal delimiters,
with unfortunate consequences if a numeric literal contained an odd
number of them. Recognize that an apostrophe with a digit on each side
of it isn't the opening quote of a character literal (unless the digit
before it is preceded by a u). Extend the findMocs test to trigger the
bug, prior to the fix; verified it passes with the fix.

Fixes: QTBUG-98845
Change-Id: I5db3ac59aaeade7c2d6c1fb680ba97261ec0e8a9
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-06-17 00:05:53 +02:00
Ivan Solovev
662184ac68 QComboBox: emit currentIndexChanged() and currentTextChanged() when the model is cleared
QComboBox uses QPersistentModelIndex to store the current index of the
underlying model. When the model is cleared, that index is automatically
invalidated, so calling QComboBoxPrivate::setCurrentIndex(QModelIndex())
does not result in signals being emitted, because we do not detect the
index change.

This patch uses indexBeforeChange to detect such situation and emit all
necessary signals.

Fixes: QTBUG-103007
Pick-to: 6.4 6.3 6.2
Change-Id: I29326830a30a17900839e8d1737a08bd940081ea
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-06-16 19:29:36 +02:00
Laszlo Agocs
e4961afed2 Work around lavapipe bug in tst_qvulkan
Work around https://gitlab.freedesktop.org/mesa/mesa/-/issues/5875 by
treating the driver as broken when both the driver and device UUIDs
are all zeroes.

Fixes: QTBUG-104231
Pick-to: 6.4 6.3 6.2
Change-Id: Ibf7973361d472ebb1cb433bc61b50b2828f75c6b
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-06-16 17:29:36 +00:00
Volker Hilsheimer
79a11470f3 Accessibility: don't emit focus change when reason is window activation
If a window becomes active, then the accessibility system gets informed
about that already. Qt puts focus on the focus child of the activated
window afterwards, and if this emits another accessibility event, then
accessibility clients like Windows Narrator will stop reading the
activated window, and instead read about the focused widget.

This makes dialogs like message boxes poorly accessible.

Accessibility clients already know that a window became active, and can
query Qt about the focused child within that window.

Amend test case.

Fixes: QTBUG-101585
Pick-to: 6.4 6.3 6.2
Change-Id: I2d6bff7c415a6f29c4a4f7f4e4be38079fb976ca
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2022-06-16 19:29:36 +02:00
Volker Hilsheimer
56d6a36020 Implement a dedicated QAccessibleInterface for QMessageBox
QMessageBox has text values that an accessible client should be able to
read directly without having to navigate through the text labels.

Add test coverage.

Windows Narrator is inconsistent in reading the contents of a message
box. It might skip them completely, even though the text property is
read through the interface.

Task-number: QTBUG-101585
Change-Id: I639c2210a627733c093743790c6a6b83f4bb80d0
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2022-06-16 19:29:36 +02:00
Ulf Hermann
4912903e37 Endian: Remove old special integer bitfields
The only way to use them was to put them in a union and then write all
the members of the union to set the various bit ranges. As only one
member of a union can be active at any time, the compiler is free to
optimize those writes away, though. This has started happening in the
wild now.

As we have a replacement, we can remove the old and broken code now.

Task-number: QTBUG-99545
Change-Id: I90718ec06662258d1c15220f54da9eed2186c5a5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-16 06:12:27 +00:00
Thiago Macieira
2a1122f465 QStringConverter: fix use-after-free in the stack in the test
Detected by ASan. Introduced by aef27c5aa2

Pick-to: 6.3 6.4
Fixes: QTBUG-104261
Change-Id: Id0fb9ab0089845ee8843fffd16f88bdeb4f42c7c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-06-15 15:43:32 -07:00
Dimitrios Apostolou
96001cb812 Increase timeout of slow test for ASAN-enabled build
Change-Id: I47b6e7e1462c1af7d41677bfe7bb0f78430f72d1
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-15 23:58:16 +02:00
Dimitrios Apostolou
f0c0ec59df Fix memory leaks
This renders these simple tests ASAN and LSAN (Address Sanitizer
and Leak Sanitizer) clean.

Change-Id: Ibe5b7054a20c1575a1a7939b0bed4101afeeee56
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-06-15 23:58:16 +02:00
Dimitrios Apostolou
741fc8b752 Increase timeout of slow test for ASAN-enabled build
Change-Id: Iea0802220701501f18822a5eb1f1b0c22f62e705
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-15 23:58:16 +02:00
Kai Köhne
9d2cc4dd76 Fix typos in docs and comments
Found by codespell

Pick-to: 6.4
Change-Id: Ie3e301a23830c773a2e9aff487c702a223d246eb
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-06-15 21:31:02 +02:00
Edward Welbourne
12eac545b6 Make two QDT benchmarks data-driven and add more rows
The QDateTime benchmark's toMSecsSinceEpoch() and
toMSecsSinceEpochTz() each iterated the 2010s and had 1950 and 2050
variants for two other decades. I want to also test some earlier
decades and do similar for create(), so combine the existing triplets
as three rows of a data-driven test for each triplet, add the new rows
and apply the same to create().

In the process, turn an enum used for qint64 constants into a set of
constexpr qint64 declarations.

Pick-to: 6.4 6.3 6.2 5.15
Task-number: QTBUG-104012
Change-Id: I2657346b65d96a7ef7503cd33c870b688ea5dbff
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-06-15 08:57:20 +02:00
Morten Sørvig
79bead6c3b Add support for painting at integer DPR with downscale
Enable by setting QT_WIDGETS_HIGHDPI_DOWNSCALE=1 and QT_WIDGETS_RHI=1.

This will make the backing store and painter operate at the next
highest integer DPR in cases where QWindow::devicePixelRatio() returns
a fractional value. The backing store image will then be downscaled
to the target DPR at flush time, using the RHI flush pipeline.

[ChangeLog][QWidgets] Added experimental support for always
painting at an integer device pixel ratio (rounding the DPR up if
necessary), followed by a downscale to the target DPR.Enable by setting
QT_WIDGETS_HIGHDPI_DOWNSCALE=1 and QT_WIDGETS_RHI=1.

Pick-to: 6.4
Task-number: QTBUG-86344
Change-Id: Id5b834a0e3499818b0b656161f5e0c38a6caa340
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-06-14 19:16:35 +00:00
Laszlo Agocs
9dced35b41 Use consistent ordering in QShader
Fixes: QTBUG-101923
Change-Id: I62df3eba773350e47ed650acb00bc42b3ce6a899
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-06-14 14:58:09 +02:00
Marc Mutz
fa4d18b86c Revert "qxp::function_ref: drop use of q23::invoke_r"
This reverts commit b9cce12e76, which
broke

    function_ref<void(int)> f = [](int i) { return i; };

ie. swallowing of return types.

We could maybe implement the same without invoke_r, with the same
manual if-constexpr that invoke_r has, but it would be a pointless
duplication across the two thunks we have, so just use invoke_r.

Add tests.

Pick-to: 6.4
Task-number: QTBUG-103739
Change-Id: I6034f05d813c06a25e8058ded5b6b62f3ca858b4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-14 01:30:48 +00:00
Marc Mutz
6345929115 tst_QResourceManager: extend the test to cover open files
... when unregistering.

Task-number: QTBUG-86088
Change-Id: I11112142ef1d8c4b269089a0a82ca06a5e434f7e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2022-06-14 03:30:48 +02:00
Marc Mutz
1b8b802455 tst_QAnyStringView: explicitly check the spaceship operator
We implicitly checked it, because, in C++20 builds, the non-equality
relational operators are synthesized from it by the compiler, and we
test those, but we didn't check that <=> returns strong_ordering.

We now do.

Pick-to: 6.4 6.3 6.2
Task-number: QTBUG-104108
Change-Id: Ieb19a2d4cb2d600d884f4e2e89e98c6187e23872
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-06-14 01:30:48 +00:00
Volker Hilsheimer
ac80cee846 Don't crash when removing the last visible tab
The code incorrectly tried to ensure that the firstVisible tab was a
valid index, even though there might not be any visible tab left after
removing the last visible tab.

The same logic didn't exist of the lastVisible tab, so we tripped the
assert in qBound, as max (being -1) ended up smaller than min (0).

Fix this by removing the wrong correcting of firstVisible to be always
valid. Make sure we emit currentChanged with -1 when no visible tab is
left after removing the current tab.

Add a test.

Fixes: QTBUG-104003
Pick-to: 6.3 6.2
Change-Id: I27e6438a02d0a0f1ac4d0e0160cee4f33b3f3766
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-06-13 14:04:31 +02:00
Jan Arve Sæther
e7477e8934 Update window geometry when QWindow::m{in|ax}imumSize is updated
More specifically, if either minimum or maximum size are updated, make
sure that the current window geometry is updated so that it is within
the minimum and maximum sizes.

Previously, these constraints was only respected by the window manager
when the user resized the window.

For widgets this already worked, because a top-level widget will take
care of respecting these constraints if they are changed.

Since QWindow::setMinimumSize and QWindow::setMaximumSize started to
share so many common things, a new function (setMinOrMaxSize_helper())
is added.

Task-number: QTBUG-102771
Change-Id: Ia4b2680dcf865f84a3cf6424187f9a6036b76386
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-06-13 09:19:17 +02:00
Shawn Rutledge
eee9d25202 Use CSS classes on html list items for checkbox support
If we replace the bullet character with a UC checkbox character, it
looks ok in a browser, and the HTML parser can recover the BlockMarker
attribute from the css class.

[ChangeLog][QtGui][Text] Checkbox list items can now be read and written
in both HTML and Markdown, including conversions.

Task-number: QTBUG-103714
Change-Id: Ic6b74512075cd4ac16d6f80fdf55b221447491a9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-06-11 14:18:35 +00:00
Laszlo Papp
0a78cb7fab QNetworkReply: Fix the test compilation
It would not compile on my Linux box due to using QVariantMap, but not
actually including QMap itself. Using gcc 9.3.1 on CentOS 7.

Pick-to: 6.3 6.4
Change-Id: I808a270c814a906030cb34b197d3a2a85ba384e1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
2022-06-10 20:57:19 +00:00
Vladimir Belyavsky
865212057b Windows: fix DeferredDelete events processing on QThread::terminate()
On finishing/terminating a thread, when processing posted events,
we need to consider QThread's own data instead of caller thread's data.
Otherwise we can get into unexpected situations such as double
destruction of an object, premature destruction, etc.

Fixes: QTBUG-103922
Pick-to: 6.4 6.3 6.3.1 6.2 5.15
Change-Id: Idf77221ebbaa0b150ee2d0c296b51829ae8dc30e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-10 19:40:32 +00:00
Thiago Macieira
17454bf9c6 FatalSignalHandler: print the signal name on crash
It's easier to remember what "SIGSEGV" means instead of "11".

GNU libc has offered sigabbrev_np() (non-portable) since 2.32; for older
libcs, we'll be happy with a hardcoded list.

Selftest updated to match... though it didn't seem to be necessary.

Pick-to: 6.4
Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16ebc66ecf6e9465
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-06-08 20:39:18 +00:00
Marc Mutz
a7dcdf063d Update Catch2 to v2.13.9
Two patches applied to upstream release.

Pick-to: 6.4 6.3 6.2
Fixes: QTBUG-103732
Change-Id: Id64b65c4567433806047a2a34fa85ab5f260e6cc
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-06-08 19:43:34 +02:00
Mårten Nordheim
4dfc582644 tst_QTcpServer: Make test-helper a dependency
For convenience.

Change-Id: I91017e4b05b3c64f8628f23a0a3cf7abd4b4d686
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-06-07 15:09:48 +02:00
Janne Juntunen
c58e97245d tst_qfile: skip trash bin test on webOS
Skipping moveToTrash() test is needed because WebOS
does not implement a trash bin directory.

Fixes: QTBUG-104053
Pick-to: 6.4
Change-Id: Id1d1595eb401d8ef3a403c915d95be1cd75368d2
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-06-07 13:37:34 +03:00
Jani Heikkinen
0cbb471b1b Bump version to 6.5.0
Change-Id: I83a4f915a914bdc18f6706bb902f3e3b13da074f
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2022-06-06 13:23:59 +03:00
Eirik Aavitsland
f67d89ebde Support cosmetic brush patterns in the pdf and opengl paint engines
This implements the recent functionality extension of painting
cosmetic (untransformed) brush patterns, and the corresponding
NonCosmeticBrushPatterns render hint, in the pdf and opengl paint
engines.

As part of the implementation it also fixes a couple of pre-existing
bugs in the opengl engine, relating to updating the brush after
changes in transformation or brush origin.

As a driveby, it also includes a minor fix for the lance testing tool:
request stencil buffer, as that is needed and not always provided by
default. This echoes a recent fix done to tst_baseline_painting.

Change-Id: Ia8811477e015eebeb40ed138bca96643ce1ab0dc
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-06-04 21:15:42 +02:00
Giuseppe D'Angelo
f8c5f4b7b5 QTest::toString benchmark: do not pass a template type parameter
Let it to be deduced, otherwise it may force instantiations which
are ill-formed.

Change-Id: I3ce674128d96a48ad6883e265734ff330645dd75
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-04 12:40:05 +02:00
Øystein Heskestad
d631e581c0 Unify QSslServer from QtWebSockets and QtHttpServer into QtNetwork
Both QtWeSockets and QtHttpServer has a QSslServer class that is useful
elsewhere. They are different though, so the new class has features
from both versions.

[ChangeLog][QtNetwork] Unify QSslServer from QtWebSockets and QtHttpServer into QtNetwork

Task-number: QTBUG-100823
Change-Id: I523f04db39297ceb9b258f673eb12deecfc6886c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-06-04 02:22:56 +02:00
Øystein Heskestad
782fbe0f63 The new signal pendingConnectionAvailable is added to QTcpServer
The new signal pendingConnnectionAvailable is emitted after a new
connection has been added to the pending connections queue. Connect
to this signal and call nextPendingConnection to handle incoming
connections.

The existing unchanged newConnection signal is emitted after the
overridable function incomingConnection is called, regardless of whether
a new connection is added to the pending connections queue in the
incomingConnection function or not.

If a subclass that overrides incomingConnection either decides to not
add all incoming connections to the pending connections queue, or to
postpone adding the connection until a handshake is successfully
completed, the pendingConnectionAvailable signal should be to used,
because this signal directly corresponds to insertions to the pending
connections queue.

[ChangeLog][QtNetwork][QTcpServer] New signal pendingConnectionAvailable
is emitted when a new connection is added

Task-number: QTBUG-100823
Change-Id: I00c76761389065f68271553e69e6c45c393a2fa8
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-06-04 00:22:55 +00:00
Ivan Solovev
0681a2dd5a QTestLib: rework QTest::compare_helper()
[ChangeLog][QTestLib] QCOMPARE now evaluates toString() on its
arguments lazily, speeding up the general case where the comparison
doesn't fail. This is true for the QCOMPARE functionality provided
by Qt. If you specialized qCompare() for your own types, then you
need to change its implementation in line with Qt's own qCompare()
specializations in order to enable this feature.

[ChangeLog][QTestLib] QCOMPARE calls with nullptr argument(s) will
now print the actual and expected values upon failure.

Previously it was not like that because of the compareHelper()
overload in qtestresult.cpp that treated the presence of
nullptr-arguments as a reason to ignore formatFailMessage() call.
New implementation does not have this check, and correctly
executes formatFailMessage() for all arguments.

Note that the qCompare() overloads that call QTestResult::compare()
internally were not affected by this patch, because they already
defer toString() invocation until the comparison fails.

Some numbers, collected against shared release developer build.
I checked how this change affects the test execution. The idea was
to pick some tests for types that do not have a specific
QTestResult::compare overload, so I picked a couple of QByteArray
tests.
The comparison is done by running a test 10 times and taking the
average execution duration, as reported in the log.

tst_qbytearrayapisymmetry:
 Before: 15.6 ms
 After:  14.2 ms

tst_qbytearray:
 Before: 41 ms
 After:  36 ms

The benefit is around 9% and 12% respectively.

Fixes: QTBUG-98874
Change-Id: I7d59ddc760168b15974e7720930f629fb34efa13
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-03 20:37:51 +00:00
Ivan Solovev
1e36eedb7f tst_QStringApiSymmetry: use QCOMPARE_EQ instead of QCOMPARE
This allows to defer the toString() invocation until it is really
needed, and so allows to speed-up the test execution.

I was testing a release shared developer build, running
tst_QStringApiSymmetry 10 times before the change, and 10 times after
the change, and then taking the average execution duration, as
reported in the log.

Before the change (using QCOMPARE): 51ms
After the change (using QCOMPARE_EQ): 45ms

As we see from the results, the benefit is around 10%.

Task-number: QTBUG-98873
Task-number: QTBUG-98874
Change-Id: Ifcfbcca1f2c1eaf82c7f1a9098fa1512a269cbf8
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-03 20:37:51 +00:00
Ivan Solovev
cc6d984390 Add QTRY_COMPARE_{EQ,NE,LT,LE,GT,GE}_WITH_TIMEOUT()
[ChangeLog][QTestLib] Add QTRY_COMPARE_{EQ,NE,LT,LE,GT,GE}_WITH_TIMEOUT
macros that repeatedly execute QCOMPARE_{EQ,NE,LT,LE,GT,GE} until either
the comparison returns true or the timeout expires. Also add
QTRY_COMPARE_{EQ,NE,LT,LE,GT,GE} macros that simply invoke the
*_WITH_TIMEOUT versions with the usual timeout of five seconds.

Task-number: QTBUG-98873
Change-Id: Ib0d7d1c8c997f442b46acd85da738a8f512cc875
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-03 22:37:50 +02:00
Ivan Solovev
343e0ff485 Add QCOMPARE_{EQ,NE,LT,LE,GT,GE}()
[ChangeLog][QTestLib] Add QCOMPARE_{EQ,NE,LT,LE,GT,GE}()
macros. These new macros behave similarly to QVERIFY(a op b),
where 'op' is ==, !=, <, <=, >, >= respectively, but print
a formatted error message with argument values in case of failure.
The formatting is done lazily, which means that the strings will
be generated only when the comparison fails.

Also add a new test for tst_selftest and generate expected output
for it.

Fixes: QTBUG-98873
Task-number: QTBUG-98874
Change-Id: Ic8074798901d7a469b1f58d5cd28bbf49a3da1db
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-06-03 22:37:50 +02:00
Edward Welbourne
3dcf1779be tst_QUrlQuery: improve formatting of lists of pairs of strings
The compare() implementation made its actual and expected seem to have
different types (using a typedef name for one, when the other was of
the type that expands to) and the formatter it used was needlessly
clunky. Use modern string literals and package a repeated
null-or-quoted representation as a lambda, inline the resulting
simplified prettyElement() into prettyPair(), which can now just take
a pair rather than an iterator. Short-cut the empty list so that the
comma-joined accumulation could initialize with the first entry and
loop over the rest, always joining with a comma.

Undo commit f776595cc10aaafc7162f382a8fa11afffb0e708's mistaken update
to the copyright header and update correctly.

Change-Id: I99258dafa01e79f9ec384d9b375a59376eb7fb53
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-03 21:53:14 +02:00
Ulf Hermann
a248d8daf5 Endian: Allow special bitfield union fields to cover the whole storage
This requires a different computation of the mask since we can't shift
out of the storage type.

Change-Id: Ife85ca3e0c5ca47f06988a397cc2f8a7e28ad0fe
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-02 14:02:44 +02:00
Marc Mutz
29b65c98e7 Short live qxp::function_ref!
This is an implementation of function_ref, which has been proposed for
inclusion into C++23, but has not been accepted, yet, which is why we
place it in namespace qxp (for eXPerimental) instead of q23.

The implementation is based on wg21.link/P0792r9, which, at the time
of writing, is the latest revision of the paper. It will be used in
both QTestLib and qmldom.

Fixes: QTBUG-103739
Change-Id: I52723eca28f7ac02ce7ce51928361d81ae5c92b1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-06-02 12:54:55 +02:00
Allan Sandfeld Jensen
f9df8512c2 Do metadata detach simpler than full detach
Avoid a full data detach when only metadata changes. This paradigm was
already used one place, and made generic.

Fixes: QTBUG-81674
Change-Id: I605253babc6ad9fc130e19e8cef3812690933ac5
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-06-01 15:54:50 +02:00
Allan Sandfeld Jensen
567ffafe7f Add new map methods for QColorTransform
Change-Id: I520fc4f4bd958472c6d6359bf671835796c677fe
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-05-31 22:23:40 +02:00
Allan Sandfeld Jensen
5ea6da55e0 Test prepared qcolortransform
Add test of explicitly prepared qcolortransform, this is a state
a transform can get into if used for an image transform.

Also cleans up the test code.

Change-Id: I9445ed114bed0edc790e14024aaae6a42989220b
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-05-31 22:23:40 +02:00
Eirik Aavitsland
5adaa8d868 Add painter render hint for brush pattern transformation
[ChangeLog][QtGui][QPainter] In Qt 5, the predefined brush patterns
would always be transformed along with the object being painted. In Qt
6.0 onwards, they would or would not, depending on the
SmoothPixmapTransformation render hint. Instead of this somewhat
surprising behavior, make the default be untransformed
(i.e. cosmetic), which makes sense when it comes to dpr scaling. For
the cases where one wants scaling, a new render hint is introduced to
enable that: NonCosmeticPatternBrushes.

Change-Id: I2208c7a28af9056d7ab97a529b66bf2d502c3c4f
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-05-31 21:20:41 +02:00
Marc Mutz
5e48a51608 Long live QAtomicScopedValueRollback (private API)!
QScopedValueRollback has a few users that apply it on QAtomicInt,
which happens to work as QAtomicInt is copy-constructible and its
ctors are implicit.

But that's of course nonsense. We don't need to store the oldValue in
an atomic, nor do we need to pass the new value into the ctor as an
atomic.

So, add a QAtomicScopedValueRollback which works on std::atomic as
well as the Qt atomics, but distinguishes between the reference (which
is atomic) and the value (which isn't), and use it in one of the
users, tst_QList.

Keep it private until we know whether there's an actual need for this.

The test is a copy of tst_qscopedvaluefallback, so the occasional
oddity (like atomic op*=) should be ignored.

Task-number: QTBUG-103835
Change-Id: I3c05b3e51f465698657a02ca5521ed465386e9a6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-05-31 19:25:52 +02:00
Thiago Macieira
23184fb6cd qglobal.h: use the GCC attribute for nothrow in C mode
There's exactly one use in Qt: the qVersion() function.

Change-Id: Ieb9a2aa1ea914b1b956bfffd16eff4b3b9e2119a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-05-27 14:12:07 -07:00
Volker Hilsheimer
31f98957cf Add compile-time generation of JNI class names
As with method signatures, register class names using template function
specialization in the QtJniTypes namespace, and then declare C++ types
as JNI classes with a class name string. Such classes implicitly get
registered as JNI types as well.

Add a QJniObject construct method (since C++ constructors that are
templates cannot be explicitly instantiated with a type), and a
QJniEnvironment::findClass overload.

Add test coverage, also for the recently added macros for native
methods.

As a drive-by, change the name of the Q_JNI_DECLARE_NATIVE_METHOD
macro to Q_DECLARE_JNI_NATIVE_METHOD for consistency.

Change-Id: Ic19562d78da726f202b3bdf4e9354e8ad24d8bd9
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-05-27 22:27:13 +02:00
David Faure
09c7457f4a QTextDocument: add setLayoutEnabled()
This allows to set up everything first - without paying for the layout
calculation at every step - and only then trigger the layout once.

Results:
 0.065 msecs to create a QGraphicsTextItem with some text (layouted)
 0.036 msecs to set everything up in a QGraphicsTextItem with 0 width

Change-Id: I138bd1d58941d029bc0a36d2730216778f1fbd97
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-05-26 16:58:42 +02:00
Allan Sandfeld Jensen
734c9f2df2 Expand QColorTransform
Add comparison operators and an isIdentity() method to detect (1-1)
transforms.

[ChangeLog][QtGui] Added QColorTransform::isIdentity() method. Added QImage::colorTransformed() transitive method.

Change-Id: I5fbcd14e75f2179e43e94e8c5f42cd0a5600790b
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-05-26 09:06:45 +02:00
Allan Sandfeld Jensen
f4b7401cdb Add test of QColorTransform
Before it was only tested indirectly as part of the qcolorspace
tests. This also fixes a rounding for maximum RGB64 values.

Pick-to: 6.3
Change-Id: I6106e662c0f9d00c0b3a0c13213cb051ea39e14e
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-05-26 02:08:38 +02:00
Fabian Kosmale
c46ee7df57 QStringConverter: Do not crash if invalid
Attempting to use an invalid QStringConverter would so far have resulted
in a crash, as we would dereference the null iface pointer.
Fix this by inserting adequate checks, and ensure that hasError returns
true if we attempt to en/decode with an invalid converter.

Pick-to: 6.2 6.3
Change-Id: Icf74bb88cd8c95685481cc0bd512da99b62f33e6
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-05-25 16:38:35 +02:00
Laszlo Papp
d83441340c QKeySequence: Add missing modifier names
The issue is that when someone is trying to use the following code:

QKeySequence keySequence(Qt::Key_Shift);
qDebug() << keySequence.toString();

This will print seemingly gibberish output. It is unicode in practice. For
Qt::Key_Shift, this would be: "�_@\uDC20"

The reason why this is happening is because we have platform-specific ways to
handle this due to Mac glyphs which are not available on Linux or Windows. This
works fine on Mac.

But for the Linux and Windows codepaths, there is not really any mapping like
for other keys. It seems that modifiers were left out.

The solution is to simply amend the list of mapping from these modifier key
codes to raw strings for Linux and Windows like it is done for other key codes.
So, now, modifiers will also be included in the list.

So, the expected output will be generated for the above code, as: "Shift".

[ChangeLog][QtGui][QKeySequence] Added missing modifier names

Fixes: QTBUG-69715
Fixes: QTBUG-40030
Change-Id: I460d54bc8e593b350ff95894f23c5b4a7c819a44
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-05-25 13:00:02 +00:00
Thiago Macieira
121ddac2ed tst_qpainter: change the FP exception block-list to a pass-list
We should prefer to test this unless we know it won't work, but this is
very hardware and implementation-dependent anyway. So I declare that
we'll only guarantee FP exception cleanliness on a best-effort basis for
a few platforms.

The notable difference in this commit is the removal of QNX. I don't
know why it began producing an FP exception with one of my changes, but
since the toolchain isn't public, I can't debug and will not devote any
time to figuring it out. If users of QNX require this, then someone with
interest in that OS will need to spend time after my changes integrate.

Change-Id: Ibcde9b9795ad42ac9978fffd16f1cb9c03a0ff66
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-05-24 23:42:53 -07:00
Ievgenii Meshcheriakov
0e64d97cc1 tst_qtextboundaryfinder: Remove full copies of data files
There are no commented out test cases remaining, so the normal
test vectors are identical to full test vectors.

Fixes: QTBUG-97537
Pick-to: 6.3
Change-Id: I987f178f192e1c8e2d998d36499fdce84f237e77
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-05-24 23:07:43 +02:00
Ievgenii Meshcheriakov
4d4d8dac94 QUnicodeTools: Fix line breaking before open parentheses
UAX #14, revision 45 (Unicode 13) has changed rule LB30 to only
trigger if the open parentheses is non-wide:

    (AL | HL | NU) × [OP-[\p{ea=F}\p{ea=W}\p{ea=H}]]

This fixes the remaining 24 line break tests.

Task-number: QTBUG-97537
Pick-to: 6.3
Change-Id: I9870588c04bf0f6ae0a98289739bef8490f67f69
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-05-24 23:07:43 +02:00
Ievgenii Meshcheriakov
40b4ad1866 QUnicodeTools: Fix line breaking for potential emojis
Implement part of LB30b introduced by UAX #14, revision 47
(Unicode 14.0.0):

    [\p{Extended_Pictographic}&\p{Cn}] × EM

This fixes one line breaking test.

Task-number: QTBUG-97537
Pick-to: 6.3
Change-Id: I3fd2372a057b7391d8846e9c146f69a54686ea61
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-05-24 23:07:42 +02:00
Ievgenii Meshcheriakov
08d2ae411f QUnicodeTools: Fix interactions of WB3d and WB4 rules
Word breaking rule WB3d should not be affected by WB4.

This fixes the remaining word break test.

Task-number: QTBUG-97537
Pick-to: 6.2 6.3
Change-Id: I99aee831d7c54fafcd2a9d526a3e078b12c5bfad
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-05-24 23:07:42 +02:00
Ievgenii Meshcheriakov
c63cdbdc43 QUnicodeTools: Handle WB3c word break rule
Adjust handling of WB3c rule to UAX #29, revision 33 (Unicode 11.0.0).

The rule reads:

    ZWJ × \p{Extended_Pictographic}

This fixes 9 word break tests.

Task-number: QTBUG-97537
Pick-to: 6.2 6.3
Change-Id: I818d4048828e6663d5c090aa372d83f5099fdffe
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-05-24 23:07:42 +02:00
Ievgenii Meshcheriakov
79d26ef3ae QUnicodeTools: Adjust properties of WSegSpace word break class
Disable break between sequences of WSegSpace characters (rule WB3d,
introduced in UAX #29, version 33, Unicode 11.0.0). Also disable breaks
between WSegSpace and (Extend | Format | ZWJ) due to rule WB4.

Adjust "words4" test to take the above changes into account (space
character belongs to WSegSpace).

Mention the full class name in a comment inside the word break table.

This fixes 34 word break tests.

Task-number: QTBUG-97537
Pick-to: 6.2 6.3
Change-Id: I7dfe8367e45c86913bb7d7fe2adb053711978487
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-05-24 23:07:42 +02:00
Ievgenii Meshcheriakov
9a831bdf54 QUnicodeTools: Fix handling of LB22 line break rule
This rule was simplified in version UTS #14 version 45 (Unicode 13.0.0)
to read:

    × IN

Re-enabled 28 fixed line break tests.

Task-number: QTBUG-97537
Pick-to: 6.2 6.3
Change-Id: I1c5565a8c1633428c22379917215d4e424ff0055
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-05-24 23:07:42 +02:00
Ievgenii Meshcheriakov
92d340ed1c QUnicodeTools: Fix handling of ZWJ for line breaks
Adjust implementation of rule LB8a of UAX #14. The rule was changed
in version 41 (corresponding to Unicode 11.0.0):

     ZWJ × (ID | EB | EM) ⇒ ZWJ ×

Fixing this rule fixes 9 line break tests. Those are re-enabled.

Task-number: QTBUG-97537
Pick-to: 6.2 6.3
Change-Id: I1570719590a46ae28c98ed7d5053e72b12915db7
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-05-24 23:07:41 +02:00
Morten Sørvig
e3b3c77d0e wasm: Improve wheel event handling
Always invert scroll deltas. This is what the code did
before, expect for on non-Safari macOS. There is no
need any "smart" code here: correct deltas are provided
by the native API regardless of macOS scroll direction
setting.

Reading webkitDirectionInvertedFromDevice is still useful
for certain use cases, such as 3D scene zooming or spinbox
value change, where upwards motion on the trackpad should
always correspond to "increment" regardless of scroll direction.
Propagate this to Qt using one of the handleWheelEvent()
overloads

Finally, we were sending pixel deltas as angle deltas;
fix by sending pixel deltas as well, but keep existing
angle delta behavior for compatibility.

Change-Id: I7a7104c30da057fefc0377816e551a9e7e2fa0e7
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Reviewed-by: David Skoland <david.skoland@qt.io>
2022-05-24 03:10:10 +02:00
Thiago Macieira
f569acd6ae tst_QStringConverter: roll up independent tests to rows in others
Simplifies the test a little.

Pick-to: 6.3
Change-Id: I77c8221eb2824c369feffffd16f0a7fc44215aaf
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-05-23 14:53:18 -07:00
Thiago Macieira
30721c3d03 tst_QStringConverter: implement the TODO of testing with flags
Pick-to: 6.3
Change-Id: I77c8221eb2824c369feffffd16f0a7e428b23fb6
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-05-23 14:53:18 -07:00
Thiago Macieira
aef27c5aa2 tst_QStringConverter: improve the char-by-char UTF-8 testing
The utf8.txt file was only 21 bytes and contained exactly two non-ASCII
characters. It wasn't very good.

This commit brings back the UTF-8 test rows that existed before commit
18ec53156e deleted tst_Utf8. There's a lot
of overlap with some of the other rows in this test, though.

Pick-to: 6.2 6.3
Change-Id: I77c8221eb2824c369feffffd16f094619b69faef
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-05-23 14:53:18 -07:00
Thiago Macieira
9bad4be214 QStringConverter: use the QUtf8 codec when Windows is using UTF-8
The QLocal8Bit implementation assumes that there's at most one
continuation byte -- that is, that all codecs are either Single or
Double Byte Character Sets (SBCS or DBCS). It appears to be the case for
all Windows default codepages, except for CP_UTF8, which is an opt-in
anyway.

Instead of fixing our codec, let's just use the optimized UTF-8
implementation.

[ChangeLog][Windows] Fixed support for using Qt applications with UTF-8
as the system codepage or by enabling that in the application's
manifest.

Discussed-on: https://lists.qt-project.org/pipermail/interest/2022-May/038241.html
Pick-to: 6.2 6.3
Change-Id: I77c8221eb2824c369feffffd16f0912550a98049
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-05-23 14:53:18 -07:00
Ivan Solovev
e2e0420028 Network: update Public Suffix List
using the description from qtbase/src/network/kernel/qurltlds_p.h.INFO

Task-number: QTBUG-103663
Change-Id: I543fa96d2538f5eb63b114fe6467fb5b0e891e3b
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-05-23 22:28:49 +02:00
Allan Sandfeld Jensen
0d97723ee2 Fix separate delete of window and windowcontainer
The documentation says we can change window parent to avoid the widget
deleting the window. That didn't work as the widget didn't get the
child-removed event as it wasn't the parent.

This patch instead uses an event filter on the set parent.

Pick-to: 6.3 6.2
Change-Id: I1f61d1832fcf3257722f305beeefd8f1abf1f656
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-05-23 21:25:46 +02:00
Volker Hilsheimer
6b02c85f87 Android: Enable building of the QLocale test case
Amends 2a893db480, which changed the
#ifdef'ery but didn't actually enable the building of the test on
Android.

Task-number: QTBUG-87414
Pick-to: 6.3 6.2
Change-Id: Id944dd3023da40ecbf4b8a324784409a63f94aec
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-05-23 19:12:06 +00:00
Volker Hilsheimer
dd8da7ebd9 Compile-time generate a JNINativeMethod from a C function
Add a template function that allows us to get the method signature
string from a free function, which are used as native callbacks methods
from Java.

Provide a macro that defines a signature object, and a JNINativeMethod
object based on it, in an internal namespace so that we don't pollute
the namespace with generated names.

Add another macro to get the generated JNINativeMethod object based on
the free function name.

Lastly, add overloads to QJniEnvironment::registerNativeMethods that
take a std::initializer_list of JNINativeMethods.

We can now declare a free function to be a JNI native method:

static bool callbackFromJava(JNIEnv *e, jobject /*thiz*/, jstring p1)
{
   // ...
}
Q_JNI_DECLARE_NATIVE_METHOD(callbackFromJava);

and register it with the JNI environment like this:

QJniEnvironment jni;
jni.registerNativeMethods(clazz, {
    Q_JNI_NATIVE_METHOD(callbackFromJava)
});

removing a significant amount of boiler plate code.

Change-Id: Ie4007b24125879fed3dae1f4d232b4aa95999b44
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-05-23 21:12:06 +02:00
Volker Hilsheimer
fb56a0f2ce Don't hide a widget that is swapped into a hidden splitter
When replacing a widget in a hidden splitter, then we only need to keep
the new widget hidden if the previous widget was hidden.

If the new widget is not explicitly hidden, and the splitter is already
visible, then we need to explicitly show the new widget.

Augment test case; the existing test cases already cover swapping out a
collapsed or hidden widget.

Fixes: QTBUG-102134
Pick-to: 6.3 6.2
Change-Id: I9b60711a5c1cab79777ce4183783114a16ac3394
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-05-23 21:12:05 +02:00
Giuseppe D'Angelo
c613dd4765 QMetaType: disable conversion from smart pointer<const QObject>
QMetaType can register a converter from a smart pointer class to
QObject *. The code tries to do so even if the smart pointer is
actually holding a pointer to a _const_ QObject
(e.g. shared_ptr<const QObject>), causing a compile error:

  ../src/qt5/qtbase/build/include/QtCore/../../../src/corelib/kernel/qmetatype.h:1208:32: error: invalid conversion from ‘const QObject*’ to ‘QObject*’ [-fpermissive]
   1208 |             return p.operator->();
        |                    ~~~~~~~~~~~~^~
        |                                |
        |                                const QObject*

Disable the conversion if indeed the source is const qualified.

Change-Id: I9e9bc5992f74131e5cfd6ece9b83d4f26d370e92
Fixes: QTBUG-103741
Pick-to: 6.2 6.3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-05-21 11:43:59 +02:00
Sona Kurazyan
bd1023a824 QtConcurrent: prevent conversion of ReduceOption to initial value
QtConcurrent map- and filter-reduce functions take an initial value,
which can be of any type that is convertable to the result type. The
side-effect of this is that the enum values passed as ReduceOptions can
be treated as an initial value (if they are convertable to the result
type) which will result into a wrong overload call. To avoid this, added
additional check to make sure that the initial value type doesn't match
with ReduceOption enum.

Note that this required including the qtconcurrentreducekernel.h header
in qtconcurrentfunctionwrappers.h (which contains compiler checks for
QtConcurrent) for accessing ReduceOption enum, so I had to get rid of
qtconcurrentfunctionwrappers.h include from qtconcurrentreducekernel.h
to avoid circular header includes. This, in turn, required moving the
QtPrivate::SequenceHolder helper type to qtconcurrentreducekernel.h,
which didn't belong to qtconcurrentfunctionwrappers.h anyway.

Pick-to: 6.3 6.2
Fixes: QTBUG-102999
Change-Id: Ieaa8ef2e4bd82ce2ada2e0af9a47b87b51d59e87
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-05-20 17:11:15 +02:00
Eskil Abrahamsen Blomfeldt
4fe9374589 Fix crash in tst_qquicktext::implicitSize
This reverts commit 1e938c348b
and bb2f4d08d9.

bb2f4d08d9 causes the crash, but 1e938c348b amends it, so
this reverts both. When the cause of the crash has been determined
and mitigated, the patches can be recreated.

Fixes: QTBUG-103719
Change-Id: Ifc36b3771a96f6c85387a5306a0402d4c508d006
Reviewed-by: David Faure <david.faure@kdab.com>
2022-05-20 13:14:01 +02:00
Tang Haixiang
efc02f9cc3 xcb: Delete touch points without target windows
When XCB_INPUT_TOUCH_BEGIN closes a popup, we then receive
XCB_INPUT_TOUCH_END, and cannot find a target window (because it's
destroyed). If we don't deliver it, we need to at least clear the
stored point from QPointingDevicePrivate::activePoints. Then when
we deliver the next touch press, m_fakeMouseSourcePointId also
needs to be reset.

It's now even more paramount that autotests (and real-world
touchscreens) must never omit any active touchpoint from a touch event.
If a point doesn't move, it must be included in the QTouchEvent, with
Stationary state. If not, QGuiApp::processTouchEvent() could generate
multiple TouchBegin events in a row, which gets other bits of logic
confused, here and there.

Fixes: QTBUG-94557
Fixes: QTBUG-98519
Fixes: QTBUG-102751
Fixes: QTBUG-103706
Pick-to: 6.2 6.3 5.15
Change-Id: Ia95e410a2bb8bc7784aa5d296fac2b89e53a9f55
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-05-20 10:26:18 +02:00
Shawn Rutledge
ff153d9874 Avoid ending Markdown fenced code blocks with gratuitous blank lines
This caused unnecessary empty <pre> blocks when converting markdown to
HTML, made code blocks too large using QSyntaxHighlighter to highlight
the whole block, and caused assymmetry when rewriting markdown.

Pick-to: 6.3
Fixes: QTBUG-101031
Change-Id: I08016577ccb92edb4afae31d7df3259cb011d5c8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-05-20 00:49:18 +02:00
Shawn Rutledge
04a60bb033 Convert <pre> to Markdown ``` and vice-versa with nonBreakableLines
The HTML parser calls QTextBlockFormat::setNonBreakableLines(true) when
it sees a <pre> tag; so for symmetry, the markdown reader now does the
same when it sees a fenced code block, and the markdown writer honors
the nonBreakableLines property by writing a fenced code block. This
preserves the meaning better when reading HTML and writing markdown or
vice-versa, without modifying HTML reading or writing code.

Added a test tst_QTextMarkdownImporter::fencedCodeBlocks() which
unfortunately also highlights a known bug in the markdown reader: each
fenced code block ends with an extra empty block. That can be fixed
separately.

tst_QTextMarkdownWriter::fromHtml(preformats with embedded backticks)
that we re-enabled in 1abaf9d5d6 was not a
very useful test: ``` with a space and some words but no newline is not
a fence: it's just like a `monospace` span. We have had trouble with
those in CI because of missing monospace fonts, or inconsistency when
a supposedly mono font's QFontInfo::fixedPitch() returns false.
So just test proper <pre>/fence conversion for now.

Pick-to: 6.3
Fixes: QTBUG-100515
Fixes: QTBUG-100981
Task-number: QTBUG-101031
Change-Id: I88f0ede0810d8a9480b30eb0cd780e1af67cc5f2
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-05-19 14:43:39 +02:00
David Faure
1e938c348b QTextDocument: add setLayoutEnabled()
This allows to set up everything first - without paying for layouting
at every step - and only then trigger layouting.

Same performance behavior as setTextWidth(0), but this is a more
explicit/readable API.

Change-Id: I044dbd8b1301b1c97a92f9a29ccde2baf27a7665
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-05-19 12:26:57 +00:00
Anna Wojciechowska
2a34d4bc66 unblacklist passing tests 2022
Pick-to: 6.2 6.3
Change-Id: I7d37dd58eaede1bd0d1b53fe264b45be83cbca57
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-05-18 23:59:19 +02:00
Thiago Macieira
56dcb3b496 qglobal.h: #include <stdbool.h> in C mode
It's C99 and we require C11.

Change-Id: Ieb9a2aa1ea914b1b956bfffd16eff4556b99f976
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-05-18 09:14:18 -07:00
Marc Mutz
042bab072a Fix return value of qGlobalPostedEventsCount()
The unsigned return value was very un-Qt-ish, and, indeed,
tst_QCoreApplication just stored the result in ints.

Port to qsizetype, being the type of the expression that the function
calculates.

Task-number: QTBUG-103532
Change-Id: I95a81a686439b0686faad7a430adeaab66dc9e8d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-05-18 17:54:15 +02:00
Marc Mutz
7b736e1faf Make qGlobalPostedEventsCount() auto-test-exported-only
The only in-tree user outside QtCore is tst_QCoreApplication, guard
the (single) test function there with QT_BUILD_INTERNAL.

Change-Id: Ibc87ba76f2135cd8283acd75318f80a95e4b5c45
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-05-18 17:54:15 +02:00
Marc Mutz
f2fea2325d Remove manual declarations of qGlobalPostedEventsCount()
... in favor of including qabstracteventdispatcher_p.h, where needed.

Keeps the code DRY.

Change-Id: I5bee2e653cb29ffac2601ff03c952a4b3adbdb9c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-05-18 17:54:15 +02:00
Shawn Rutledge
1ad456c908 Un-blacklist markdown tests: QSKIP when fonts are scrambled
On QNX in CI we see
system fonts: fixed: monospace 9; general: Sans Serif 9
and "monospace" isn't really a fixed pitch font.
On B2Qt arm7 in CI we see
system fonts: fixed: monospace 9; general Sans Serif 9
and Sans Serif is actually fixed pitch.

So these tests can go wrong both ways; we need to skip them whenever
the fonts would lead QTextMarkdownWriter astray.

Pick-to: 6.3 6.2
Task-number: QTBUG-89819
Task-number: QTBUG-99676
Task-number: QTBUG-100515
Task-number: QTBUG-103484
Change-Id: I7b9adca967eaf9b8d33d1e03ef2627f70f375196
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-05-18 14:30:07 +02:00
Volker Hilsheimer
9d41bd4312 Stylesheet: Another positioning fix for the menu indicator
Draw tool button menu indicator relative to frame, not content, so that
padding added in the stylesheet creates room between text and indicator.

Also, prevent another double-arrow by ignoring menu indicator rendering
when a menu button subcontrol is used, as the two are mutually
exclusive. This amends 1c338e6d07.

Add problematic case to stylesheet baseline test.

Fixes: QTBUG-102866
Pick-to: 6.3 6.2
Change-Id: I5d79e65b33a2e41ac07c8efe0c15697c5be65201
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-05-18 13:15:00 +02:00
Andreas Buhr
2f35653a30 Use QAbstractItemModelTester or QFileSystemModel
This patch enables usage of QAbstractItemModelTester on
QFileSystemModel. QAbstractItemModelTester called fetchMore()
on all items. QFileSystemModel represents the whole file system.
This led to very long test runs. To avoid this, this patch
introduces a new feature in QAbstractItemModelTester, namely
to disable calling of fetchMore().

Change-Id: Ie5d2e22fa4c143be7c080d9f79632cd2cbe07aac
Reviewed-by: David Faure <david.faure@kdab.com>
2022-05-18 12:58:06 +02:00
Andreas Buhr
ec7989aa66 Fix memory leak in tst_qtreewidget
Invalid inserts of items are tested. However, on an invalid insert
of QTreeWidgetItem into QTreeWidget, the QTreeWidget does not take
ownership of the to-be-inserted items. These items were leaked in
the past.
This patch introduces a scope-guard, so the items are not leaked.

Change-Id: Ib53ac02605c3a3c0bd1ae69bbd0876f860d08093
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-05-18 10:58:05 +00:00
Volker Hilsheimer
76e441c9ee Make uic generate correct C++ comments
Revert the change to uic of 05fc3aef53.

Task-number: QTBUG-67283
Change-Id: Icfd83bb6d80b91d4e58f1be460f6772ba49a6921
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-05-18 11:53:26 +02:00
Giuseppe D'Angelo
07d80deeab QtWidgets: restore Qt 5 compatibility for save/restore state
Several classes in QWidget use QDataStream internally in order
to save and restore state. These QDataStream usages were not
versioned, meaning that if Qt changes the serialization for some
datatype, then the data saved between different Qt versions becomes
incompatible. Note that the save/restore API in question just produce
opaque blobs as QByteArrays -- the user has no control over the
QDataStream objects and thus versions.

Fix by version the usages.

In QHeaderView this has caused a regression because QBitArray *did*
change version between Qt 5 and 6. In general, using QDataStream without
explicit versioning is a mistake, so deploy the same fix elsewhere as
well.

Fixes: QTBUG-99487
Pick-to: 5.15 6.2 6.3
Change-Id: I82bb5c266f4e5dedc0887cbef855dccab1015e29
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: <doctor.whom@gmail.com>
2022-05-18 02:21:31 +02:00
David Faure
bb2f4d08d9 QTextDocument/QGraphicsTextItem: skip layout in setTextWidth(0)
In a QGraphicsTextItem without a width yet, there's no need to do any
layouting. The use case is obviously items with an app-defined size,
not the default where text items adapt to their contents.

Results:
 0.065 msecs to create a QGraphicsTextItem with some text (layouted)
 0.036 msecs to set everything up in a QGraphicsTextItem with 0 width

QTextEdit was abusing the width 0 to mean "no wrap, width comes from
contents", but since the value -1 means that already in QTextDocument,
QTextEdit now uses a width of -1 for that meaning.

Change-Id: I67ad59c305e5dd34830886e4e6c56dde03c93668
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-05-17 22:37:40 +02:00
Alexey Edelev
b576d7f6d1 Guard the use of QWinEventNotifier in tests
Add the Q_OS_WIN32 guard for the include of QWinEventNotifier.

Change-Id: I7824b2ee236a370c83fd85a2f594a39cf36b36e6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-05-17 02:51:22 +02:00
David Faure
546e11f1dc QDBusArgument: ensure std::vector isn't seen as an associative container
This broke compilation of qDBusRegisterMetaType<std::vector<MyStruct>>
because std::vector<T> is in fact std::vector<T, std::allocator<T>>.

Pick-to: 6.2
Change-Id: I6a13f5f0476a3faa3a43da54d90d652b4bdd8186
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-05-17 01:27:33 +02:00
Volker Hilsheimer
367092d7e0 Return specific types for frequently used Java objects
This allows us to specialize JNI type signature templates for e.g. the
context object, which in Java signatures is "android/content/Context".

Introduce a Q_DECLARE_JNI_TYPE macro that takes care of the plumbing.
The types declared this way live in the QtJniTypes namespace, and
transparently convert from and to jobject. Since jobject is a typedef
to _jobject* we cannot create a subclass. Use a "Object" superclass
that we can provide a QJniObject constructor for so that we don't
require the QJniObject declaration to be able to use the macro.

The APIs in the QNativeInterface namespace doesn't provide source or
binary compatibility guarantees, so we can change the return types.

Change-Id: I4cf9fa734ec9a5550b6fddeb14ef0ffd72663f29
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-05-17 00:34:06 +02:00
Volker Hilsheimer
f6e89e901b Fold methods for object return type into generic methods
Since we know at compile time whether the return type is an object type,
we can use 'if constexpr' and auto return type in the call(Static)Method
and get(Static)Field functions to call the object-type methods.

This makes the object-methods conceptually obsolete, but don't declare
them as deprecated as long as they are still used in submodules to avoid
warning floods and build failures in -Werror configurations.

Change-Id: Ic3019ed990a9252eefcb02cdb355f8a6ed6bc2ff
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-05-17 00:34:06 +02:00
Volker Hilsheimer
1c338e6d07 Stylesheet: fix toolbutton menu indicator rendering
Turn off native indicators if we have custom rules, and if we drew
natively, don't draw custom indicators. This amends
ea0e0a8652 which turned off custom drawing
too aggressively, removing custom indicators also if no custom drop
down arrow (which is only relevant for drop down menu buttons) was set.

When then drawing the custom indicator, respect positioning rules in the
style sheet.

Extend baseline test.

Fixes: QTBUG-102866
Pick-to: 6.3 6.2
Change-Id: I5ca353f42e704ec3f6e57677c35118a9cb358b0b
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-05-16 20:32:27 +02:00
Lucie Gérard
05fc3aef53 Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
Files that have to be modified by hand are modified.
License files are organized under LICENSES directory.

Task-number: QTBUG-67283
Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-05-16 16:37:38 +02:00
Shawn Rutledge
7c76064604 Add QTextDocFragment::to/fromMarkdown() & QTextCursor::insertMarkdown()
Also add the beginnings of an autotest for QTextCursor::insertHtml(),
for comparison purposes.

We can see that the block to be inserted is merged with an existing
block by default rather than being inserted as a new one, with both HTML and
Markdown insertions.  So now we test for leading and trailing newlines
in the markdown to be inserted, to determine whether we need a new block
into which to insert, and to "hit enter" at the end of the insertion.

QSKIP the toMarkdown() comparisons if GeneralFont is mono. This happens
on Boot2Qt systems in CI.

Task-number: QTBUG-76105
Task-number: QTBUG-94462
Task-number: QTBUG-100515
Task-number: QTBUG-103484
Change-Id: I51a05c6a7cd0be4f2817f4a922f45fa663982293
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-05-14 21:32:05 +02:00
Allan Sandfeld Jensen
e69ebf93ca Add floating point color space conversions
This allows color space conversions that produces values outside the
0.0->1.0 range, which is one of the intended functions of the floating
point image formats.

Change-Id: I63b37b0f6934d4382edafb4709486c785a637c67
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-05-14 01:00:05 +02:00
Oliver Eftevaag
e33a449271 Add override keyword to avoid warning from compiler
A class that reimplements a virtual function isn't using the override
keyword, which generates a warning during compilation.

Pick-to: 6.3
Change-Id: Ic39ea24993e031f95ac9e61c3285d3be05fe6c34
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-05-13 18:49:05 +00:00
Volker Hilsheimer
601dbd6499 Add variadic template overloads for QJniObject/Environment methods
This allows the compiler to deduce the template arguments based on the
provided method parameters, which we can then pass to the methodSignature
and fieldSignature helpers to generate the signature string completely at
compile time.

Since we can't partially specialize template member functions, replace
the specializations for void methods with compile-time-if branches in
the general templates.

This variadic template now prevents implicit conversion from the
LiteralStorage types to const char* signatures, so catch the case where
such a type ends up in the parameter list.

Due to overload resolution rules for constructors, we need to explicitly
disable the constructor if any of the arguments is a string literal type,
as we have to keep the old C-style variadic function working for such
calls.

Add variations that use the variadic templates to the unit tests.

Change-Id: I8734664b38bae932369462330a9a03302254c33c
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-05-13 18:13:49 +02:00
David Skoland
8e07d5095b Only configure one test for wasm
Since we still don't support dynamic linking in wasm, we can't
use it for tests, which forces us to use static linking, which is
very slow (up to 30 seconds in some cases). The idea is to at least
have one test run for wasm before expanding it later.

Note that even with this change,
QT_BUILD_MINIMAL_STATIC_TESTS=ON needs to be defined to skip
the baseline test directory.

Change-Id: I39aea22087211fb39f03dfb0b39c55f63a26d2a7
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-05-12 18:55:04 +02:00
Ville Voutilainen
0c0a784c6f Add BiC data for the new way to do BiC testing
Change-Id: Id85fc21d4758eecc73b48f64370cc1479b618d81
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-05-12 13:33:41 +03:00
Fabian Kosmale
4e7f92bf0d QMetaType: Fix normalization on MSVC if name contains enum
During type normalization, we remove the struct, class and enum
keywords (see the skipStructClassOrEnum function). However, we only want
to do that for actual keywords, not for a name that happens to start
with e.g. "enum", as in "enumerationNameSpacce".
Adjust the MSVC check to still require no identifier character after the
keyword, while still allowing for some remaining characters.

Fixes: QTBUG-97813
Pick-to: 6.3 6.2
Change-Id: I82b873d02ff454cce4b75f2814a52a66f2268208
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-05-12 08:17:54 +02:00
Thiago Macieira
20104bb237 Remove remnants of the old Intel C++ compiler
We don't support it any more. I don't think it has ever properly
compiled Qt 6 (and it's no longer working for me against GCC 12's
libstdc++ headers). If you report a bug against it, Intel support's
first question is if you can try instead the new Clang/LLVM-based oneAPI
C++ compiler.

So we support only that one, which identifies itself as Q_CC_CLANG.

Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16eb57a092c8439e
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-05-11 12:50:08 -07:00
David Skoland
0c44dd3a33 Exclude network tests based on feature
Both tests in the conditional depend on the
qnetworkinterface feature, and will fail to build
if qt is configured without the networkinterface feature.

Additionally, a missing system header in a test was added.

Change-Id: Ife5989ee57675ebe117de2c92a4f96c7125cbab1
Pick-to: 6.3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-05-11 20:14:39 +02:00
Liang Qi
4872392925 Update shared-mime-info to the 2.2 release
This also includes the fix for x-objc++src mimetype.

Fixes: QTBUG-70739
Pick-to: 6.3 6.2 5.15
Change-Id: I24f70fa5cea2e5b1a7877569be98d36878fcfe72
Reviewed-by: David Faure <david.faure@kdab.com>
2022-05-11 11:36:49 +02:00
Marc Mutz
a1903eb941 QPolygon: add toPolygonF()
This was forgotten when implementing QTBUG-73160, but suggested in
passing in QTBUG-64.

[ChangeLog][QtGui][QPolygon] Added toPolygonF().

Task-number: QTBUG-73160
Task-number: QTBUG-64
Change-Id: I9b33cf47a0d432aa842ab0f8337001c66e4ca41c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-05-10 15:51:04 +02:00
David Faure
3bc80195df QWidgetTextControl: port to new-style connects (faster)
This speeds up creating a QGraphicsTextItem by 14% in an optimized build
Before: 0.070 msecs per iteration
After: 0.060 msecs per iteration

Those connects were showing up when profiling, because of the string
parsing that is necessary when using SIGNAL/SLOT macros.
The stacktrace was connect() => decodeMethodSignature() => argumentTypesFromString()
=> QArgumentType constructor => qMetaTypeInternal(const char*).

Pick-to: 6.3 6.2 5.15
Change-Id: I3cf5655c5450f121005140bdb587fafa083cce6a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-05-10 15:20:57 +02:00
Lorn Potter
d490501641 wasm: add support for drag into browser window
Drag and drop into the browser will work.
Drag and drop out of the browser will not.

Fixes: QTBUG-102242
Change-Id: Id9981ab6f9514535e1409bec18068790833a67a6
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-05-10 01:20:45 +00:00
Marc Mutz
277c23956c tst_qobjectrace: fix potential UB (something with pointers and new)
The current [basic.life] wording seems to cover the existing code, but
IIRC, older versions of [basic.life] were not so relaxed. In
particular, while not completely pertinent, the second placement new
is awfully similar to http://eel.is/c++draft/ptr.launder#example-1

Just make all of this SEP and use std::optional. That way, the code
gets simpler, too, plus we get rid of the last use of C++23-deprecated
std::aligned_storage.

The reset() before the 2nd emplace() isn't necessary, but, in a test,
it doesn't hurt, either, and keeps code readers from guessing whether
the first-emplaced object's dtor is actually properly run (it is).

Pick-to: 6.3 6.2
Fixes: QTBUG-99122
Change-Id: If31a46f8be3a74499f1176133029d097faf7dfe9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-05-07 18:47:48 +00:00
Ulf Hermann
38002df206 Endian: Provide special integer bitfield unions
Our previous approach of creating a union from individual special
integer bitfields leads to undefined values because only one member of a
union can be active at any given time. Compilers have finally caught up
with us on that and have started removing "no-op" writes to members.

The primary user of the special integer bitfield unions is
qv4compileddata_p.h in qtdeclarative. We want our on-disk format of
QML compilation units to be platform agnostic and space efficient.

Pick-to: 5.15 6.2 6.3
Task-number: QTBUG-99545
Change-Id: I24847bda2c364eb8ba75f074cde2a9bec25ced06
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-05-07 08:37:42 +02:00
Volker Hilsheimer
2b99a71b22 Stylesheet: Don't ignore item check indicator styling
Amends cf52d725156811754cd4e094b0984864795d1d58, after which most
indicator styling was no longer taken into account unless some other
item aspects were styled. Calling the baseStyle to draw the entire item
doesn't call back into the style sheet style for the indicator itself.

The QCommonStyle code that breaks the item up into individual sub
elements cannot be called for each element. E.g. turning off the check
indicator feature changes the layout of the item.

So if the indicator is styled, then we have to draw an otherwise empty
item with the style sheet style, and then clip the already painted rect
before calling the base style to draw text and highlighting with the
correct palette.

Add baseline test for QTreeView with different style sheets.

Fixes: QTBUG-102820
Pick-to: 6.3 6.2
Change-Id: I1da5676cc63556230eac525bc550457ebd495a58
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-05-06 03:48:09 +02:00
Volker Hilsheimer
4222d117d2 Baseline tests: slow down cursor blinking
Override the default cursor blink time so that we don't get mismatches
from line edits. We need to set the time to > 0 so that QStyleHints does
not fall back to the platform integration.

Pick-to: 6.3
Change-Id: Ib1d04f7450c01c352c13098886aee032dcb14c72
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-05-05 16:50:31 +02:00
Volker Hilsheimer
dc96d812ec Baseline testing of widget: wait before taking snapshot
Widgets and styles might use fade effects or other asynchronous mechanisms
as part of hovering. This results in mismatches when the snapshot is
taken before those effects are completed.

Since we can't control all such animations from the outside, process
events for some milliseconds before taking the snapshot.

Pick-to: 6.3
Change-Id: I771658300628238552bddcd14a6751c3f6c0c63d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-05-05 16:50:31 +02:00
Volker Hilsheimer
a085a14d76 Generate JNI signature strings at compile time
Introduce an internal QtJniTypes namespace with types that allow us to
concatenate string literals at compile time. This makes it possible to
generate arbitrary strings based on types, which we can then use as
signatures to JNI method calls.

Move some of the private members of QJniObject into the QtJniTypes
namespace for consistency, and to allow further template specialization
by user code to make other types and their JNI signature string known.
Remove the "Jni" prefix from names.

Use the compile-time generated string in QJniObject methods that created
the signature string at runtime, which involved a temporary memory
allocation.

Treat 'void' as a primitive type (with signature string 'V'), and
remove redundant template specializations.

Add a test case to verify the the strings are constructed correctly
at compile time.

Change-Id: I5e3895a97f7dc1b86961f7a7855b899d9203037d
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-05-05 07:29:25 +02:00
Mårten Nordheim
953512ec84 Add test-helper as dependency to tst_qdbusinterface
Then the test-helper is (re)built as part of `ninja tst_qdbusinterface`
or `ninja tst_qdbusinterface_check`

Pick-to: 6.3 6.2
Change-Id: Id129c2fdc5980ea268ef1383f0747589876e2a9f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-05-04 12:14:49 +00:00
Marc Mutz
9b3885248b QTextStream: complete char16_t support
... by providing also op>> for char16_t.

[ChangeLog][QtCore][QTextStream] Added op>>(char16_t&).

Change-Id: I2f6cc2b2cdacd5190d364f94c1830f6de62d3b7e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-05-04 07:09:22 +02:00
CI Insignificant Platforms Monitor Bot
72a3172ea5 Blacklist: test cases blacklisted in tst_QTcpServer:
- serverAddress on qnx

Pick-to: 6.2
Pick-to: 6.3
Task-number: QTBUG-103056
Change-Id: I21b858fabc9d0ec49ded99c921ea399a0dc193a8
Reviewed-by: CI Insignificant Platforms Monitor Bot <ci_insignificant_platforms_monitor_bot@qt.io>
2022-05-04 05:08:37 +00:00
CI Insignificant Platforms Monitor Bot
80a8d9553f Blacklist: test cases blacklisted in tst_QDockWidget:
- floatingTabs on qnx

Pick-to: 6.2
Pick-to: 6.3
Task-number: QTBUG-103091
Change-Id: Ia8b4a60847ba27dd2e9e50148bbe1e37febe1498
Reviewed-by: CI Insignificant Platforms Monitor Bot <ci_insignificant_platforms_monitor_bot@qt.io>
2022-05-04 05:08:34 +00:00
CI Insignificant Platforms Monitor Bot
d106caeac8 Blacklist: test cases blacklisted in tst_QNetworkReply:
- ioGetFromHttpWithProxyAuth on qnx

Pick-to: 6.2
Pick-to: 6.3
Task-number: QTBUG-103055
Change-Id: I45bf4c2df7fa977ffa525bf80108a74f1e8f4eef
Reviewed-by: CI Insignificant Platforms Monitor Bot <ci_insignificant_platforms_monitor_bot@qt.io>
2022-05-04 05:08:32 +00:00
Marc Mutz
7905b624fd QTextStream: fix streaming of char16_t's
Clazy complains about all uses of QLatin1Char these days, but if one
actually applies the fixit to turn

   out << QLatin1Char(' ');

into

   out << u' ';

the space is now streamed as an int (20), not as a space.

Fix by providing an explicit char16_t overload.

[ChangeLog][QtCore][QTextStream] Added op<<(char16_t).

[ChangeLog][Important Behavior Changes] QTextStream streams char16_t's
as QChars now instead of outputting the numeric value. If you want to
preserve the old behavior, cast the char16_t to a numeric type, such
as ushort or int, and stream that. This is backwards-compatible.

Pick-to: 6.3
Change-Id: I42d422cdebb27d38ac1714b22ef186642ec407e7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-05-03 11:44:56 +02:00
Sona Kurazyan
34242f843e Deprecate _qs and _qba literal operators in favor of _s and _ba
[ChangeLog][QtCore] Deprecated _qs and _qba literal operators
for QString and QByteArray in favor of _s and _ba in the
Qt::Literals::StringLiterals namespace.

Task-number: QTBUG-101408
Change-Id: I26aee0055e3b4c1860de6eda8e0eb857c5b3e11a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-05-02 12:23:56 +02:00
Sona Kurazyan
17e06afdc3 Replace remaining uses of deprecated _qs with _s
Task-number: QTBUG-101408
Change-Id: I1fda67c07e948af5017f0b99b67f8c20d7052033
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-05-02 12:23:44 +02:00
Mårten Nordheim
b322984b49 tst_QNetworkReply try stabilize autoDeleteReplies tests
The http test data hasn't always been stable but for some reason
it fails far more than usual.

Originally the domain was a non-existing one, because it would then work
on any machine (even if not in CI) and would finish() (with error)
after failing to look up the domain in DNS. However, some machines in CI,
for some reason, take too long to do this and end up failing the test.

So, we change the URL to point to the network server in CI. This should,
at the very least, finish quickly when running in CI.

Pick-to: 6.3 6.2 5.15
Fixes: QTBUG-102952
Change-Id: I3b3f6fa23acf78fefdb69ff9ae7722f15e5f1736
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-04-29 04:28:56 +00:00
Marc Mutz
e48b4d2b7c Implement support for '0b' prefix in toInt() etc
[ChangeLog][QtCore][QByteArray/QByteArrayView/QLatin1String/QString/QStringView]
The string-to-integer conversion functions (toInt() etc) now support
the 0b prefix for binary literals. That means that base = 0 will
recognize 0b to mean base = 2 and an explicit base = 2 argument will
make toInt() (etc) skip an optional 0b.

[ChangeLog][QtCore][Important Behavior Changes] Due to the
newly-introduced support for 0b (binary) prefixes in integer parsing,
some strings that were previously rejected as invalid now parse as
valid. E.g., Qt 6.3 with autodetected bases would have tried to parse
"0b1" as an octal value and fail, whereas 6.4 will parse it as the
binary literal and return 1.

Fixes: QTBUG-85002
Change-Id: Id4eff72d63619080e5afece4d059b6ffd52f28c8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-04-28 08:40:19 +00:00
JiDe Zhang
7a5d7e8440 Optimize the QPalette::resolve from the other palette
If all the palette's colors are resolved, nothing needs to be done in
QPalette::resolve(const QPalette &other).

Change-Id: I1573cfa5b5cd1e7eb15f3242aff6ab92e9f8c84b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-04-28 09:24:39 +02:00
Mårten Nordheim
41d217829c QHttp: Fix handling of redirect loaded from cache
In some situations when loading a redirect from cache which would lead
to a real request we would not emit the finished() signal because the
replyFinished function has a pre-condition that the response did
not originate from the cache.
However, after the initial redirect was loaded from the cache we never
unset the 'loadingFromCache' boolean, so it was still true after the
request had been made to the real target.

Pick-to: 6.2 6.3 5.15
Change-Id: I015a2ebae4af4bd17392182c3951e875a7b353c4
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-04-27 18:31:01 +02:00
Mårten Nordheim
d642c16fe7 QNetworkReply: update decompress error message and handling
The error message was quite vague since it would then not require
any additional translations. However, in hindsight this was a mistake
since now developers just thought their downloads were being corrupted.

Pick-to: 6.2 6.3
Fixes: QTBUG-101942
Change-Id: Ie9af42510ca027d15248e5bcf21e836e709898d9
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-04-27 18:31:01 +02:00
Giuseppe D'Angelo
45b09215e5 tst_qitemdelegate: make it more robust
Remove a processEvents() call followed by a QCOMPARE and turn it
into a QTRY_COMPARE. Otherwise it seems to be randomly failing on Ubuntu
22.04.

Change-Id: I3c1b9d55c857c79ffd36aeb98971db60267adace
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-04-27 17:54:19 +02:00
Edward Welbourne
0b5b98c4ae Fix qlocale_unix's handling of uiLanguages to take script into account
Some languages have, in the same territory, locales for more than one
script. In such cases, since we ignored the script, we got the one
that is used by default, instead of the one actually asked for. Take
the script into account.

Added TODO comment in test listing the known examples of this;
manually tested before and after the fix to verify the prior code was
indeed getting it wrong and now does do it right.

Change-Id: Iaf9201d6992bc39e6e9346ef8b7c69d418db7253
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-04-27 17:03:54 +02:00
Edward Welbourne
7a7f2547f3 Return more specific entries before less in QLocale::uiLanguages()
The documentation overtly listed entries in this order but the code
gave less specific entries before more specific (and the tests
verified the same). This is now reversed.

[ChangeLog][QtCore][QLocale] uiLanguages() now prefers more specific
locale names over less specific ones, matching its own documentation,
except where the system backend supplies them in some other order.
This means a translation with the expected script and/or territory as
well as language will be used in preference to a generic one for just
the language, rather than only as a fall-back when the more generic
one is missing.

Fixes: QTBUG-102796
Change-Id: I3c7b3627afb51246df5a6ad0230e23b60af78071
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-04-27 17:03:54 +02:00
Alexandru Croitor
bf96f0eea0 tests: Blacklist tst_QLocalSocket::threadedConnection on Windows
As well as processConnection.

These tests cause flaky failures on Windows.

Pick-to: 6.3
Task-number: QTBUG-102880
Change-Id: Ie4bfe2ef40ad44efcfd0d83711ce257d1244ecdc
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-04-27 17:03:54 +02:00
Tor Arne Vestbø
aa0a53fc19 Don't declare type 'id' in the global namespace in a public header
It's not necessary, and it breaks the qttools build (where we have a
global variable named 'id'), and thus will most certainly build a lot
of existing user code.

Amends e47c22480f.

Change-Id: I97a91c2cb23fdae65143cf14c81570cf88d529d5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-04-27 00:16:26 +02:00