Commit Graph

40343 Commits

Author SHA1 Message Date
Marc Mutz
8224fd45d0 QtCore: includemocs
This leaves moc_qnamespace.cpp in mocs_compilation.cpp.

Including moc files directly into their classes' TU tends to improve
codegen and enables extended compiler warnings, e.g. about unused
private functions or fields.

Pick-to: 6.3 6.2 5.15
Change-Id: Ifdff378c74828e12ec770cb2f453dab3a880e2a5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-27 01:36:04 +01:00
Marc Mutz
97b465455b QCalendar: move memory allocation out of critical section
By Amdahl's Law, provides for more scalability.

This is just for backporting. The registry should really be able to
perform lookups without allocating memory...

Pick-to: 6.3 6.2
Change-Id: Ifbb832a06991b9ee9a1fd6a43db567bb572fca4f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-27 01:36:04 +01:00
Alexey Edelev
4ecbebebf7 Check if 'aab' target exists when adding <target>_make_aab as dependency
The global 'aab' target has its own switch QT_NO_GLOBAL_AAB_TARGET
that prevents it from being created. We need to check if 'aab' target
exists before adding <target>_make_aab as a dependency.

Pick-to: 6.3 6.2
Change-Id: Iea569e3b6c7dfb6d0efa60dd2001fb9de161f725
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-01-26 23:57:00 +00:00
Joerg Bornemann
7015eafa5c qt6_standard_project_setup: Don't enable AUTORCC
We discourage using AUTORCC, so don't make it the default for our
"standard project setup".

Pick-to: 6.3
Task-number: QTBUG-87643
Task-number: QTBUG-100209
Change-Id: I2715ec561266bfed5ea4ac7722ab1f1c8b982788
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-01-26 23:57:43 +01:00
Volker Hilsheimer
8359e44324 Offscreen: Fix implementation of QScreen::grabWindow
If id == 0, then we should grab the specified rect from the screen.

To do that, find all windows intersecting with the screen geometry, and
compose their backing store images into a screen-size pixmap.

Otherwise, find the respective backing store and grab only that.

Remove the old code respecting the desktop widget, which is no longer a
thing in Qt 6. The code was also wrongly grabbing only the first
containing - not intersecting - window's backing store into the screen
pixmap.

Enable the QScreen::grabImage test for the offscreen platform, where it
now passes.

Task-number: QTBUG-99962
Change-Id: I16eca7b082d65095a62c73624f86a4423e997a7a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-01-26 17:18:18 +01:00
Volker Hilsheimer
5d1bb2ed57 Offscreen: Implement QPlatformBackingStore::toImage
Re-applies 77895514d5419b77535de093b544aee30686cd22, which was
reverted after tests started to XPASS-fail in qtdeclarative. Those
tests are now get consistently QSKIP'ed, so reapply the change.

This makes testing of actually produced output easy in unit tests,
and makes a number of previously failing QtDeclarative tests pass.

Task-number: QTBUG-99962
Change-Id: I167b46b954dee18bdbf90c09c5e42a8c179a1fac
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-01-26 17:18:18 +01:00
Jungi Byun
574b625914 evdev: Prevent race condition in touch events processing
Unlike other input devices, touch devices are managed by corresponding
handler threads which are not the main thread. InputEvent that is
inherited by TouchEvent has a constant pointer member for device, but in
touch events case, handler threads may destroy the device which is
pointed by events while processing these events in main thread,
and this may cause critical potential issues such as crash. In order to
prevent this race condition, move device of QEvdevTouchScreenHandler
into main thread and delete this device later if QGuiApplication
instance exists when handler thread quits, and check event's device is
valid when processing touch events.

Change-Id: I02583238d97d768abcc544ee882160eda3178282
Reviewed-by: Elvis Lee <kwangwoong.lee@lge.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-01-26 01:01:31 +00:00
Eskil Abrahamsen Blomfeldt
2e29a427ca Windows: Change default hinting preference for high-dpi
When high-dpi is enabled, we would previously default to
QFont::PreferVerticalHinting which maps to the asymmetric
antialiasing strategy, where only horizontal antialiasing is
enabled.

The idea behind this is that it provides crisper text,
especially for smaller font sizes, but for larger font sizes
the aliasing artifacts outweigh the added sharpness.

Inspecting native Windows applications, such as the system
settings, it looks like asymmetric antialiasing is used
up to a certain font size threshold. The documentation uses
a font size of 16 as the suggested threshold.

In accordance with the documentation, we use PreferNoHinting
for font sizes above this threshold.

[ChangeLog][Windows] When high-dpi scaling is active, the
default text antialiasing has been set to symmetric for
larger fonts (pixel size higher than 16 px). The old default
can be selected manually as QFont::PreferVerticalHinting.

Fixes: QTBUG-99066
Change-Id: Ibf53556f6e2cbbe1dc5d30c6c1743a499a99a90b
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-01-25 17:20:26 +01:00
Edward Welbourne
78eac57f3d Check for null driver() before trying to exec()
QSqlQuery::exec() took for granted that it can dereference driver(),
which should be true for all sane usage; however, it should not crash
if used misguidedly. Added regression test, based on bug report's
reproducer, which crashes without the fix.

Fixes: QTBUG-100037
Pick-to: 6.3 6.2 5.15 5.12
Change-Id: I94600bc60f89e82a1121b418144006a683921a38
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2022-01-25 16:18:35 +01:00
Giuseppe D'Angelo
2d95b75345 QByteArray: fix isUpper/isLower
577d698b8e changed QString::isUpper /
isLower behaviors to match Unicode semantics: a string is uppercase
if it's identical to its own toLower/toUpper folding. These semantics
come from Unicode so they're not up for debate.

That commit however left QByteArray untouched. Generally speaking, we
want to move away from QByteArray as "text storage" -- this has
partially happened between Qt 5 and Qt 6, where QByteArray went from
Latin-1 semantics to ASCII semantics. Still, QByteArray offers
toUpper/toLower and isUpper/isLower and all this family of functions
should be consistent in behavior.

Apply the same fix that was applied to QString.

[ChangeLog][Important Behavior Changes] The semantics of
QByteArray::isLower() and QByteArray::isUpper() have been changed. Now
lowercase (resp. uppercase) byte arrays are allowed to contain any
character; a byte array is considered lowercase (resp. uppercase) if
it's equal to its own toLower() (resp. toUpper()) folding. For instance,
the "abc123" byte array is now considered to be lowercase.
Previously, the isLower() (resp. isUpper()) functions checked whether
the byte array only contained ASCII lowercase (resp. uppercase)
characters, and was at least 1 character long. This had the side effect
that byte array containing ASCII non-letters (e.g. numbers, symbols,
etc.) were not lowercase nor uppercase.

[ChangeLog][QtCore][QByteArray] QByteArray::isLower() and
QByteArray::isUpper() now work correctly with empty byte arrays. The
semantics of these functions have been changed.

Pick-to: 6.3 6.2
Fixes: QTBUG-100107
Change-Id: Id56a42f01b2d1af5387bf0e6ccff0f824f757155
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-25 15:29:20 +01:00
Oliver Wolff
32caaacee3 windows arm64: Use correct Q_PROCESSOR_ARM_64 define check
Inclusion of qt_windows.h is needed to avoid  "No Target Architecture"
in winnt.h.

Change-Id: Ic67ce8a306ef52c4ce3e6eaad0b7864632610737
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-25 14:22:27 +01:00
Marc Mutz
1f118a54f8 Revert "QLatin1String: Add overloads taking QLatin1Char"
This reverts commit 1c164ec7f2,
except for the test additions.

Reason for revert: We need to optimize the implementation, not
complicate the API.

Found during the 6.3 API review.

Pick-to: 6.3
Change-Id: I91c3f65ed6d1fc438deb0e028d578a07c0005362
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-25 11:59:02 +00:00
Yuhang Zhao
c532a57670 Fix build with clang-cl
1. Clang-CL can't recognize "/d2FH4" and it's causing
lots of warnings when compiling. So don't apply it
when building with clang-cl.
2. The definition of "FS_INFORMATION_CLASS" need to
be visible to clang as well. Don't know why it was
excluded originally.

Pick-to: 6.3
Change-Id: I7b6e14999eea0ba1f0d73962ff03a35548f88a5a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-25 14:09:31 +08:00
Thiago Macieira
5e2ce03510 QEventDispatcherWin32: use SetCoalescableTimer for (Very)Coarse timers
The tolerance can be set per timer, unlike on Linux.

Fixes: QTBUG-98316
Change-Id: I5e52dc5b093c43a3b678fffd16b788a30bcb9574
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-24 19:28:48 -08:00
Tatiana Borisova
b5124d9719 Fix run time failure for UI autotests (INTEGRITY)
- Add WFD resources release:
  It provides possibility to re-create native window on run time.
  It allows to run several Qt UI applications (one by one) without device reboot.

- Fix crash that found during window re-creation: ~QOpenGLCompositorBacking() calls
  QOpenGLCompositor::instance(). But compositor is deleted for that moment.

Task-number: QTBUG-99123
Pick-to: 6.2 6.3
Change-Id: I1e6dc9a012a166d1fd6cd1c24f9d2e9a8995fc00
Reviewed-by: Kimmo Ollila <kimmo.ollila@qt.io>
Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-01-25 02:59:36 +02:00
Laszlo Agocs
406bb6ae20 rhi: Make sure pixelSize() to a texture rt is always up to date
This is an issue for QQuickWindow in practice, although it is not hit
by our current tests.

Pick-to: 6.3
Change-Id: Ia73704c1af6a82b2689ce7b844d3b0eb9a17ec18
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2022-01-25 01:04:07 +01:00
Mårten Nordheim
4b6064aef4 QOperatingSystemVersion: fix #if check for macos version check
It would check the version regardless of OS, but this macro doesn't exist
on non-darwin platforms.

Amends 3446313c7a

Pick-to: 6.3
Change-Id: I7bdc302c85626d410e77bea1eb7aac7fbf1cb679
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-25 00:31:10 +01:00
Mårten Nordheim
c781d5ed08 Move private QOperatingSystemVersion::compare to removed_api
From the API review.

Pick-to: 6.3
Change-Id: I9877990f75189b99a372ea6342d07a7031228ac7
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-25 00:31:10 +01:00
Sona Kurazyan
4cd8eeaf8c Fix memory leak in QtConcurrent::run when called with a NULL QThreadPool
QThreadPool automatically deletes the runnable after it finishes running
the task. In case QThreadPool is nullptr, we should delete the runnable
manually. This amends 87b93c29be.

Pick-to: 6.3 6.2 5.15
Change-Id: Id7e4ed3d4d6de05990edf62e4099852983debc64
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-24 22:40:35 +01:00
Marc Mutz
df0f8e036c Replace cxx17_bm_searcher config check with feature test macro
This enables the code also for boostrap.

Amends b24e689cb5.

Pick-to: 6.3
Change-Id: I8efc76c20690282a2428f360d6b93896966b97ee
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-24 20:11:23 +00:00
Marc Mutz
af2d9bc3c4 Optimize finding UTF-16 needles in L1 haystacks
We were converting the full L1 haystack to UTF-16. But, even so, we
won't be able to find non-L1 UTF-16 needles in L1 haystacks!

Optimize by converting the needle (not the haystack) to L1, after
checking it's actually L1.

Pick-to: 6.3
Change-Id: I413d7a602d44ecb2d3149dc4fa87c690c40e6aaa
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-24 21:11:22 +01:00
Sona Kurazyan
d1639da0d5 Mark ResultStoreBase as final
The class is not intended for inheriting from it (see also
e502906305), so we can mark it as final
to explicitly forbid this. The tests were still using it as a base
class to clean the results during destruction, so fix them accordingly.

Task-number: QTBUG-99883
Pick-to: 6.3
Change-Id: I4a7ee3e2b462bd704e4b5a95ed733144805d6e5b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-24 20:54:36 +01:00
Alessandro Portale
edf1c3b001 Unify indentation in help information of androiddeployqt
Some of the parameters in the help information were indented by 3
characters instead of by 4.

Pick-to: 6.3
Change-Id: Id11cda79d61c4eab82ee09e33034db55730123c5
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-01-24 12:57:23 +00:00
Sona Kurazyan
1daaf613dc QFuture: add a missing include for qpromise.h
QPromise is now used in qfuture_impl.h, so we need to include it. Remove
qfuture.h include from qpromise.h, to avoid circular dependency.

As a drive-by, simplify a type-trait: is_convertible_v<T, S> is true
whenever is_same_v<T, S> is, so we don't need to instantiate both.

Fixes: QTBUG-100144
Pick-to: 6.3 6.2
Change-Id: Ic6df43d96d9d168cc44c2949e41c5e490f4c50ce
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-24 09:37:54 +00:00
Fabian Kosmale
0842b01f02 QProperty: Work around constexpr issues on MSVC
MSVC complains about illegal uses of void, even though the code should
be guarded by an if constexpr statement.
 qproperty.h(85): error C2182: 'val': illegal use of type 'void'
 qproperty.h(92): error C2182: 'abstract declarator': illegal use of type 'void'

Avoid the issue by using a dedicated dummy type instead of void.

Fixes: QTBUG-100072
Task-number: QTQAINFRA-4242
Pick-to: 6.3 6.2
Change-Id: Idc4886c26c3794e709eb762ba836139f720f8133
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-23 23:11:50 +01:00
Marc Mutz
228b5dd074 QStaticByteArrayMatcherBase: make dtor protected
Base class dtors should either be public and virtual or else protected
and non-virtual.

We don't want to model polymorphy, so protected and non-virtual it is.

Pick-to: 6.3
Change-Id: I3c545b01c3ec831ee8b4a0c522501222a69923e9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-23 09:48:34 +01:00
Marc Mutz
cce7e35253 Q(Static)ByteArrayMatcher: manage indexIn() overloads
Unlike QString and QStringView, QByteArrayView and QByteArray don't
overload well.

Solve the overload issue the usual way: by making the QByteArray one a
Q_WEAK_OVERLOAD. This is trivial for QStaticByteArrayMatcher, which
isn't exported, but require QT_REMOVED_SINCE magic for
QByteArrayMatcher, which is.

The additional const char* overload has shielded us from the worst
fall-out so far, it seems, but it makes for a truly horrible overload
set:

    matcher.indexIn(str, 3);

Q: Is the 3 here the length of the haystack or the value of the from
parameter?

A: It depends on decltype(str)!

If the (const char*, qsizetype, qsizetype=0) overload is the better
match, then 3 limits the haystack's length.

If, otoh, the (QByteArray(View), qsizetype) overload is the better
match, then it's the value of the from parameter.

As if this wasn't bad enough, QByteArray implcitly converts to const
char* by default!

A follow-up patch will therefore deprecate the (ptr, size) overloads,
so we de-inline the QByteArrayView ones to avoid having to touch the
implementation once more.

Found during 6.3 API review.

Pick-to: 6.3
Change-Id: I9640e0bdd298d651511adebcc85f314db9221d34
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-01-23 09:48:28 +01:00
Marc Mutz
3d3558dc8f QStaticByteArrayMatcher: fix searching in 2+GiB haystacks
Add a test (same techniques as for the 4+GiB check in
tst_qcryptographichash).

Takes ~1s to build the 4GiB test data here, and skips
when RAM is too low:

  $ qtbase/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher haystacksWithMoreThan4GiBWork
  [...]
  QDEBUG : tst_QByteArrayMatcher::haystacksWithMoreThan4GiBWork() created dataset in 891 ms
  [...]

  $ (ulimit -v 2000000; qtbase/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher haystacksWithMoreThan4GiBWork)
  ********* Start testing of tst_QByteArrayMatcher *********
  [...]
  SKIP   : tst_QByteArrayMatcher::haystacksWithMoreThan4GiBWork() Could not allocate 4GiB plus a couple hundred bytes of RAM.
     Loc: [/home/marc/Qt/qt5/qtbase/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher.cpp(242)]
  [...]

Found during 6.3 API review.

[ChangeLog][QtCore][QStaticByteArrayMatcher] Fixed searching in
strings with size > 2GiB (on 64-bit platforms).

Fixes: QTBUG-100118
Pick-to: 6.3
Change-Id: I1df420965673b5555fef2b75e785954cc50b654f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-23 01:06:57 +00:00
Marc Mutz
3ec587666f QByteArrayList: optimize 32-bit builds of legacy join() helper
On 32-bit machines, qsizetype is int, so we don't actually need to
QT_REMOVE_SINCE the QByteArrayList_join() helper, because it didn't
change.

Thanks to Thiago for showing me the QT_POINTER_SIZE trick in a similar
change to QVersionNumber.

Pick-to: 6.3
Change-Id: Iae6e315107e42da51fcb4e7325b6d40b9c3fe0bc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-01-22 13:08:05 +01:00
Volker Hilsheimer
902087a090 Revert "Offscreen: Implement QPlatformBackingStore::toImage"
This reverts commit 77895514d5419b77535de093b544aee30686cd22, which
is in principle correct, but results in XPASS'ing tests in qtdeclarative
that we need to adapt first.

Originally reverted only for 6.3, but now also in dev given the amount of
tests that have a QEXPECT_FAIL for the offscreen platform in qtdeclarative.

Change-Id: Ic914655c737c3b279c14a66220775f3c7a6cdab8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 8498d1a14b5a8392ee6b50a87b82f9d85d13193e)
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-01-22 11:30:13 +00:00
Marc Mutz
dd798220a0 QByteArrayList: micro-optimize join(QByteArray)
Null- vs. emptiness of the separator is not significant for join(), so
skip the isNull() check in the conversion ctor of QByteArrayView from
QByteArray by using the named conversion function that exists for this
purpose instead.

Pick-to: 6.3
Change-Id: I6ef07cc9bcc0bc8b87ecadc5cfaac9793cfb1b77
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-01-22 08:36:50 +01:00
Marc Mutz
31a39bd55d QByteArrayList: simplify the join() overload set already now
... instead of waiting for Qt 7.

Found in API review.

[ChangeLog][QtCore][Potentially Source-Incompatible Changes]
[QByteArrayList] The join() overload set has changed. Code such as
qOverload<>(&QByteArrayList::join) will have to be rewritten,
e.g. using lambdas. We advise against taking addresses of library
functions other than signals and slots.

Pick-to: 6.3
Change-Id: I67449df9adc2efea7f1163034caa135f31f39e7c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-22 04:12:48 +01:00
Patrick Stewart
806ba27419 qopengl.h: Move C header #include(s) out of the QT_NAMESPACE
The Clang backend of MSVC declares nullptr_t in namespace std there,
then expects to find it under ::std::nullptr_t to define a ::nullptr_t.
That breaks with a namespaced build, of course.

Fix by moving the QT_BEGIN_NAMESPACE to just before the first typedef
that declares a Qt-owned name.

Done-with: Marc Mutz <marc.mutz@qt.io>
Pick-to: 5.15 6.2 6.3
Fixes: QTBUG-95309
Change-Id: I56f2709c4664a7d0de84918f43b6d53cb3710612
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-22 01:57:49 +00:00
Marc Mutz
dc6453694e [doc] QStaticByteArrayMatcher: remove references to C++ < 17
This class is universally supported by all Qt6-capable compilers.

Pick-to: 6.3 6.2
Change-Id: Ib03ed8f73fe656e47f4d0f8f50c3a8ff95b6d8d4
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-21 23:43:17 +01:00
Thiago Macieira
2549f18995 QHash: rewrite the x86 aeshash function for len >= 16
The loop for 32 bytes is left unchanged, but the tail operation for 16
to 31 bytes is replaced with an overlapped load-and-scramble. This
should make the operation even faster.

Also updated the key creation back to something similar to what Go does.

This massively improves performance as well as the bit spread. Histogram
for the bits in the hash value for the testcase from QTBUG-91739:

|| Bit || Before ||     After ||
| 0 | 35.0300%   |   50.4800% |
| 1 | 42.5250%   |   50.2400% |
| 2 | 46.0100%   |   50.0000% |
| 3 | 67.5150%   |   49.9400% |
| 4 | 56.5150%   |   50.0000% |
| 5 | 51.9950%   |   50.0000% |
| 6 | 58.9800%   |   50.1400% |
| 7 | 55.9550%   |   50.0000% |
| 8 | 41.9850%   |   49.9200% |
| 9 | 69.9700%   |   49.6400% |
| 10 | 68.4950%  |   50.0000% |
| 11 | 37.4950%  |   50.3000% |
| 12 | 61.9950%  |   49.8200% |
| 13 | 53.4900%  |   50.0000% |
| 14 | 63.0200%  |   49.9800% |
| 15 | 54.9700%  |   50.1000% |

Task-number: QTBUG-91739
Pick-to: 6.2.3 6.2 6.3
Change-Id: Icad7c1bad46a449c8e8afffd16cb7fe7ffd3584f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-01-21 14:08:01 -08:00
Thiago Macieira
b5d480d01d QHash: fix iteration of x86 AES hash code for len >= 32
[ChangeLog][QtCore][QHash] Fixed a bug in the qHashBits() function,
which affected the hashing of QByteArray, QString (and their View
classes), QLatin1String and QBitArray, which caused the hash to not
include the final 32 bytes of the data source. As a result, QHash
containers where the initial string was the same had a serious
performance degradation on x86 CPUs with AES support.

Fixes: QTBUG-91739
Pick-to: 6.2.3 6.2 6.3
Change-Id: Icad7c1bad46a449c8e8afffd16cb74dd43440f6c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-01-21 14:08:01 -08:00
Thiago Macieira
517821b173 QHash: improve aeshash's page detection code
We don't need to test for actually crossing a page boundary. It suffices
to check if we're in the upper half or the lower half of the page. In
the upper half, we load ending at the end; in the lower half, we load
starting at the current position. This way, it can never crash.

Pick-to: 6.2.3 6.2 6.3
Change-Id: Icad7c1bad46a449c8e8afffd16cb743e622b3405
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-01-21 14:08:01 -08:00
Marc Mutz
e1654aeb2e QStaticByteArrayMatcher: add a useful comment
Took me a few seconds to figure this out, and I'm the author of the
class, so leave a comment for my future self (and anyone else).

Pick-to: 6.3 6.2 5.15
Change-Id: I65a7aa6f8abf9d671f7d9ba45400f19e0f46728f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-01-21 20:45:11 +00:00
Marc Mutz
e7115b7530 QStringConverter: use QStaticByteArrayMatcher
The Boyer-Moore tables can be calculated at compile-time, and the
needles are long enough to make skipping worthwhile, even for small
haystacks.

Pick-to: 6.3
Change-Id: I3237812490367ed0491eb8d1667c6da67f38c517
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-21 21:45:11 +01:00
Marc Mutz
f091f371c4 QByteArrayMatcher users: use the new QByteArrayView overloads
The new overloads mean that when passing QByteArrayView or
QLatin1String objects, we don't expand them into .data() and
.size() anymore.

Pick-to: 6.3
Change-Id: I0c898e0463d0bf81ce1f7d57e10e64f23bd84587
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-01-21 20:11:32 +00:00
Sona Kurazyan
e502906305 Add a note for making ResultStoreBase's internal members private
There's no class inheriting from ResultStoreBase (and likely won't be),
so the destructor was marked to be made non-virtual in Qt 7. For the
same reason, the internal members don't need to be protected, and the
class shouldn't have "Base" in its name. Add a note about it.

Task-number: QTBUG-99883
Change-Id: I00d7a96d99d2c326d29bd421235a15d68b4d4e5c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-21 16:38:24 +01:00
Marc Mutz
e6d4967f0b QArrayDataPointer: don't overload qSwap(), provide ADL-swap()
qSwap() is our wrapper around

   using std::swap;
   swap(lhs, rhs);

it needn't and shouldn't be overloaded.

ADL swap() should be, though, so qSwap(), std::ranges::swap() and all
the other adl_swap()s out there all find the optimized version.

Qt 5.15 has it correct, Qt 6 wrong. Fix it.

Can't pick to 6.2 because, while backwards-source-compatible, because
the generic qSwap() template provides the name for both qualified and
unqualified calls, it's not forwards-source-compatible: A new user of
ADL swap

   // compile error w/o `using std::swap`, pessimization otherwise:
   swap(dp1, dp2);

would break or performance-regress when going back to an older
version.

Pick-to: 6.3
Change-Id: I725949a4aa9ae438a182b4b7552ff2dced767e2f
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-21 13:10:19 +01:00
Marc Mutz
f29566c5a4 Prevent repeated instantiations of some qRegisterNormalizedMetaType<>s [1/N] (QtGui)
Create macros that wrap the magic developed in
7d63efc16f and apply it to all
Q_DECLARE_METATYPE invocations that show up in Clang -ftime-trace for
a PCH'ed QtGui build.

Effects on compile times:

Clang 10 -ftme-trace:

  $ ClangBuildAnalyzer --analyze qtgui-before.trace  | head -n6
  Analyzing build trace from 'qtgui-before.trace'...
  **** Time summary:
  Compilation (523 times):
    Parsing (frontend):          628.3 s
    Codegen & opts (backend):    304.5 s

  $ ClangBuildAnalyzer --analyze qtgui-after.trace  | head -n6
  Analyzing build trace from 'qtgui-after.trace'...
  **** Time summary:
  Compilation (523 times):
    Parsing (frontend):          546.0 s
    Codegen & opts (backend):    304.4 s

GCC 11 time (bash builtin):

before:

  $ time for ((i=0; i < 3; ++i)) do touch src/gui/painting/qpolygon.h ; ninja libQt6Gui.so; done

  real    4m13,539s
  user    49m24,416s
  sys     3m18,177s

after:

  $ time for ((i=0; i < 3; ++i)) do touch src/gui/painting/qpolygon.h ; ninja libQt6Gui.so; done

  real    3m55,697s
  user    45m19,941s
  sys     3m7,370s

Task-number: QTBUG-97601
Pick-to: 6.3
Change-Id: Ia8e37a58937568a7ed21cfeb4b27274deca4d53b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-21 11:22:35 +00:00
Marc Mutz
4440387b85 QStringConverter: fix int/qsizetype mismatches (ex Win32)
I can't test on Windows, so skipped the platform-specific code.

Pick-to: 6.3 6.2
Change-Id: Id13d4abc447ddd5d17fb67b670b83207877456f6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-21 12:22:35 +01:00
Marc Mutz
569f8efd82 QTableWidgetSelectionRange: make relational operators noexcept
Also remove the superfluous inline keyword.

Pick-to: 6.3
Change-Id: I2cd2fc46687626a6f9eab60553bc3022c7eed6de
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-01-21 07:03:07 +01:00
Sona Kurazyan
b292928e35 Optimize ContinuationWrapper used for support of move-only continuations
After QFuture continuations became non-copyable (see earlier commits),
we have to always use ContinuationWrapper to save the continuations
inside std::function, since it requires the callable to be copyable.
Optimize the wrapper, by storing the callable directly (instead of using
a ref-counted QSharedPointer) and introducing a fake copy-constructor
that makes sure that it's never called.

Pick-to: 6.3 6.2
Change-Id: I0ed5f90ad62ede3b5c6d6e56ef58eb6377122920
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-21 01:51:20 +01:00
Sona Kurazyan
afdae3618a Create QFutures returned by QtFuture::when* methods via QPromise
This is required to ensure that the continuation attached to a
QFuture returned by QtFuture::when* methods is cleaned in the destructor
of the associated QPromise, so that it doesn't keep any ref-counted
copies to the shared data, thus preventing it from being deleted.

Task-number: QTBUG-99534
Pick-to: 6.3
Change-Id: If4e2929b2e638d6b48c95f0aef9dc886066cedbe
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-01-21 01:51:20 +01:00
Sona Kurazyan
614847eae9 Use QPromise when creating continuations to avoid memory leaks
Continuations were using QFutureInterface to create and return the
associated future to the user. Attaching a continuation to the returned
future could cause memory leaks (described in an earlier commit). Use a
QPromise when saving the continuation, to make sure that the attached
continuation is cleaned in the destructor of the associated QPromise, so
that it doesn't keep any ref-counted copies to the shared data, thus
preventing it from being deleted.

Task-number: QTBUG-99534
Pick-to: 6.3 6.2
Change-Id: I52d5501292095d41d1e060b7dd140c8e5d01335c
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-01-21 01:51:20 +01:00
Sona Kurazyan
a8794503eb Fix memory leaks when capturing a QFuture in its continuation
Capturing a QFuture in the continuations attached to it results in
memory leaks. QFuture's ref-counted data can only be deleted when the
last copy referencing the data gets deleted. The saved continuation
that keeps a copy of the future (as in case of the lambda capture) will
prevent the data from being deleted. So we need to manually clean the
continuation after it is run. But this doesn't solve the problem if the
continuation isn't run. In that case, clean the continuation in the
destructor of the associated QPromise.

To avoid similar leaks, internally we should always create futures via
QPromise, instead of the ref-counted QFutureInterface, so that the
continuation is always cleaned in the destructor. Currently QFuture
continuations and QtFuture::when* methods use QFutureInterface directly,
which will be fixed by the follow-up commits.

Fixes: QTBUG-99534
Pick-to: 6.3 6.2
Change-Id: Ic13e7dffd8cb25bd6b87e5416fe4d1a97af74c9b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-21 01:51:20 +01:00
Volker Hilsheimer
c83ab25674 Remove obsolete virtual method after submodules adjusted
Amends cb27ed30f7 after follow-up
change 43fb6953fb940edfec358a2d1c01e05705712829 in Qt Svg.

Task-number: QTBUG-99642
Pick-to: 6.2 6.3
Change-Id: Ice190dc9d1bdcb08d74c86edf0028cf50266d94e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-21 01:30:50 +01:00
Ulf Hermann
9f1854acf8 JSON: Further improve the duplicate handling in the parser
Avoid some unnecessary comparisons and add more tests.

Task-number: QTBUG-99799
Change-Id: I3aee9f0b62461d38dadbe8e969444e1cd1f94e68
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-01-21 00:53:49 +01:00
Thiago Macieira
6c6b342061 QFactoryLoader: merge the global statics into a single struct
Drive-by update one more for to ranged-for and make sure we don't create
the global statics on destruction.

Change-Id: I5e52dc5b093c43a3b678fffd16b5ff674dfd17ae
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-21 00:53:49 +01:00
Thiago Macieira
2fbcc18309 QFactoryLoader: replace indexed loops with ranged ones
Better code style. I need to optimize QCborValueRef::toString() to avoid
a round-trip through QCborValue.

Change-Id: I5e52dc5b093c43a3b678fffd16b5f1f99851cf5f
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-21 00:53:49 +01:00
Thiago Macieira
b7a8051269 QFactoryLoader: use RAII for QLibraryPrivate
Good style.

Change-Id: I5e52dc5b093c43a3b678fffd16b5f15fddb9d8b4
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-21 00:53:49 +01:00
Thiago Macieira
d5cac0b19b QFactoryLoader: use QDirIterator instead of QDir
This showed up on a benchmark when the number of files in the directory
was way too big.

Change-Id: I5e52dc5b093c43a3b678fffd16b5ef9a938abc63
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-21 00:53:49 +01:00
Allan Sandfeld Jensen
664c56d6b1 Work-around crash in QThreadPool QThread usage
This works around mismatch in threads starting and restarting QThreads,
and is safe since we don't need to establish a binding, and objectName
access in QThreadPool is locked behind a mutex.

Pick-to: 6.3 6.2
Fixes: QTBUG-96718
Change-Id: Id3f75e4f8344796ca658899645219fe3373ddd6d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-21 00:53:49 +01:00
Thiago Macieira
0f5a1725a0 QFactoryLoader: remove check-before-use of a directory
Unnecessary. We can't read a directory's entries if it doesn't exist or
isn't a directory.

Change-Id: I5e52dc5b093c43a3b678fffd16b5edce70eb651e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-20 15:53:49 -08:00
Thiago Macieira
21beaf8745 QFactoryLoader: there's only one of this, so removeOne(this)
Change-Id: Ice04365c72984d07a64dfffd16b47b4f8223e3fd
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-20 15:53:48 -08:00
Thiago Macieira
ddba24535f QFactoryLoader: add setExtraSearchPath() (for QPA plugins' use)
This is added specifically for the QPA platform and theme plugins, to
honor the QT_QPA_PLATFORM_PLUGIN_PATH environment variable and the
(inadvisable) -platformpluginpath command-line argument.

This removes the last QFactoryLoader used with an empty path (also the
only two that could be reached), which were causing a scan of the
application's binary directory whenever the platform plugin path was
set. In case of applications installed to /usr/bin, the entire /usr/bin
was scanned, which can be qualified as "not good".

Fixes: QTBUG-97950
Pick-to: 6.3
Change-Id: Ice04365c72984d07a64dfffd16b47fe1d22f26d3
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-01-20 15:53:48 -08:00
Thiago Macieira
7bc788ed0c QFactoryLoader: separate the updating of each plugin path
I'm going to need to call this with a different path.

Pick-to: 6.3
Change-Id: I5e52dc5b093c43a3b678fffd16b5ef59376498ee
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-01-20 23:53:48 +00:00
Thiago Macieira
c062fed427 qsimd_p.h: add a hack to allow AVX to work with MinGW
GCC is unable to emit the SEH metadata about the stack aligning that is
required to execute AVX aligned instructions (VMOVDQA, VMOVAPS, etc.),
so it just doesn't align the stack. That causes crashes on a 50/50
chance every time the compiler attempts to address a stack-aligned
variable. In a debug-mode build, because it always loads & saves
everything on the stack, the chance of a crash happening is a near
certainty.

So we hack around it by going behind the compiler's back and instructing
the assembler to emit the unaligned counterparts of the instructions
every time the compiler wished to emit the aligned one. There's no
performance penalty: if the variable is actually aligned, the unaligned
instruction executes in the exact same time.

Change-Id: Ib42b3adc93bf4d43bd55fffd16c29cac0da18972
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-01-20 20:48:23 -03:00
Thiago Macieira
970b249140 qsimd.h: move the rest of the __xxx__ definitions that MSVC lacks
The Intel compiler is now based on Clang, so it always defines the
macros like Clang and GCC do, so we don't need to worry about it any
more. We only need to define the macros that MSVC lacks.

Change-Id: Ib42b3adc93bf4d43bd55fffd16c10f0f6fef43ef
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-01-20 20:48:23 -03:00
Volker Hilsheimer
5e155be550 Fix version in which SH_Table_AlwaysDrawLeftTopGridLines was added
Since it shows up as a new enum value in the 6.3 header review, it's
reasonable to assume that it was added for 6.3.

Pick-to: 6.3
Change-Id: If766ef56f3354644fbda09088514e55b28a44f32
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2022-01-21 00:48:23 +01:00
Marc Mutz
b31c4e38dc QWindowPrivate: de-inline dtor and ctor
It's private API, but exported, so de-inline the dtor to pin the
vtable in QtGui instead of potentially duplicating it in every library
that uses the class.

Ditto ctor, but that's just code hygiene: we don't want the code to be
duplicated across all users.

Pick-to: 6.3
Task-number: QTBUG-45582
Change-Id: I91ea38be20fc67795466a68ca5721837255b33a0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-01-20 21:57:45 +00:00
Volker Hilsheimer
d86a02b468 Windows XP style: Fix coding style violations
Fix various violations of the coding style or general inconsistencies.
No claim for completeness.

* indentation and line breaks
* consistent scopes for case statements where needed
* add curly-brackets for if-statements where needed
* removed {} where not needed
* const'ify a few obvious local variables
* remove random empty lines
* use auto when type is obvious from cast

Deliberately not touching nested if-statements that could be merged into
one.

Pick-to: 6.3
Change-Id: Ie22b36568f33e18d5f15c751c7fd76e1490133b9
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2022-01-20 22:57:45 +01:00
Marc Mutz
b1b0c2970e QtCore: replace qSwap with std::swap/member-swap where possible
qSwap() is a monster that looks for ADL overloads of swap() and also
detects the noexcept of the wrapped swap() function, so it should only
be used when the argument type is unknown. In the vast majority of
cases, the type is known to be efficiently std::swap()able or to have
a member-swap. Call either of these.

For the common case of pointer types, circumvent the expensive trait
checks on std::swap() by providing a hand-rolled qt_ptr_swap()
template, the advantage being that it can be unconditionally noexcept,
removing all type traits instantiations. Don't document it, otherwise
we'd be unable to pick it to 6.2.

Effects on Clang -ftime-trace of a PCH'ed libQt6Gui.so build:

before:

  **** Template sets that took longest to instantiate:
   [...]
   27766 ms: qSwap<$> (9073 times, avg 3 ms)
   [...]
    2806 ms: std::swap<$> (1229 times, avg 2 ms)

   (30572ms)

after:

  **** Template sets that took longest to instantiate:
   [...]
   5047 ms: qSwap<$> (641 times, avg 7 ms)
   [...]
   3371 ms: std::swap<$> (1376 times, avg 2 ms)
   [qt_ptr_swap<$> does not appear in the top 400, so < 905ms]

   (< 9323ms)

As a drive-by, remove superfluous inline keywords and template
ornaments.

Task-number: QTBUG-97601
Pick-to: 6.3 6.2
Change-Id: I88f9b4e3cbece268c4a1238b6d50e5712a1bab5a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-01-20 22:56:12 +01:00
Laszlo Agocs
b083c27d0a QVulkanWindow: make it possible to override the enabled features
We already have a precedent for this: the QueueCreateInfoModifier
callback. Following the pattern, add a EnabledFeaturesModifier that
can alter the VkPhysicalDeviceFeatures that is passed to
vkCreateDevice().

[ChangeLog][QtGui][QVulkanWindow] QVulkanWindow can now invoke a
callback to alter the VkPhysicalDeviceFeatures object used to create the
Vulkan device. This allows enabling 1.1, 1.2, and extension features.

Fixes: QTBUG-99803
Change-Id: I5ede0c6bc3430cbb304d4961eb9e44faad5ce4d7
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-01-20 22:56:11 +01:00
Laszlo Agocs
79aad61fc1 Enable all supported 1.0 device features in QVulkanWindow
[ChangeLog][QtGui][QVulkanWindow] QVulkanWindow is now enabling all
Vulkan 1.0 features reported as supported from the physical device.

Pick-to: 6.2 6.3 5.15
Task-number: QTBUG-99803
Change-Id: Ib9cfcd449904c67b07e0e2d4ade5bcaeb4cb0ce6
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-01-20 22:56:11 +01:00
Sona Kurazyan
7f318327e5 QtConcurrent: use variable templates for compile-time checks
Noticed during the API review.

Pick-to: 6.3 6.2
Task-number: QTBUG-99883
Change-Id: I19571343a0cf0609beae2422ef1f69f7a34eb9ac
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-20 22:56:11 +01:00
Noah Davis
f0371487ce QTabBar: Improve scrolling with high resolution mouse wheels
The current behavior for handling the angle delta of a wheel event
changes index the instant there is a change in angle delta. This works
fine for mouse wheels that send events with 120 angle delta units and
there is also already behavior defined for devices with pixel deltas,
but there is nothing good for handling events from high resolution mouse
wheels that don't have pixel deltas.

This patch makes it so that the current index doesn't change until the
accumulated angle delta for the X or Y axis reaches 120.

[ChangeLog][QtWidgets][QTabBar] Scrolling with a high resolution mouse
wheel changes the current index at a rate more like a normal mouse
wheel.

Task-number: QTBUG-97844
Pick-to: 6.3
Change-Id: I2e7fd88984a253f6ef8a0008deb7233e4cb4d84a
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-01-20 18:01:27 +00:00
Timur Pocheptsov
9ac323f7cd QTlsBackend/QSslSocket - check the arguments we pass to QObject::connect
Not to have warnings about invalid (nullptr) parameters.

Change-Id: I5fdfa7e99df0f3c9907055cf244efa5a56b21c11
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-20 19:01:27 +01:00
Alexey Edelev
4dc977d5ee Add documentation for the Android Multi-ABI related variables
Document:
  QT_ANDROID_BUILD_ALL_ABIS - cache variable
  QT_ANDROID_ABIS - cache variable
  QT_PATH_ANDROID_ABI_<ABI> - cache variables
  ANDROID_ABIS - new argument of qt6_add_executable function

Pick-to: 6.3
Task-number: QTBUG-99261
Change-Id: I7061065a6f329864ec9004ef41121f1225c5fc80
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2022-01-20 19:01:27 +01:00
Laszlo Agocs
f0057f0269 Fix queue passed to vkQueuePresent
We do not test actively test setups where a separate graphics and
present queue is used because there is no combined queue at all. (it
won't be tested because we neither want to nor have the possibility to
do so)

However, QVulkanWindow (unlike, say, QRhi's Vulkan backend) attempts
to support this. It turns out the argument passed to vkQueuePresent is
wrong: the present is to be submitted to the present queue. So fix
this up.

Pick-to: 6.3 6.2 5.15
Fixes: QTBUG-73470
Change-Id: Ic9b589aba52e3326637216b98a074e27fdc3e3b9
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-01-20 17:02:39 +01:00
Samuli Piippo
003a37aef1 wasm: fix installation when staging prefix is used
Change-Id: I2f9acdd977702f78c75eaeb67fc67f1b82836ff7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-01-20 10:06:55 +02:00
Thiago Macieira
df8456061e convertDoubleTo: add an x86-64 intrinsics version
The UB that the C and C++ standards talk about do not apply if we use
intrinsics. We can rely on the processors' architectural behavior
instead.

There are two ways to detect a conversion that cannot be represented in
the result. One would be to check if the #IE bit got set in the MXCSR,
but in order to do that we'd need two issue an STMXCSR+LDMCXSR pair to
clear the bit first and then another STMXCSR at the end to see if it got
set. Those instructions are 4 uops long and necessarily target memory,
so that's a bit slow.

This commit implements the second way, which is to check if the result
of the conversion is the "undefined" value. Unfortunately, that value is
a valid, precise value that double can hold for all data types except
unsigned 64-bit, so we need to recheck if that was the actual value
stored in the original double.

This implementation targets 64-bit exclusively because that avoids
having to deal with the 64-bit intrinsics not even being defined in 32-
bit code (converting a double to 64-bit integer in 32-bit is messy). The
unsigned implementation is only implemented with AVX512F because of the
unsigned conversion instructions that were introduced then.

Change-Id: I89446ea06b5742efb194fffd16bb9f04b2014bab
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-01-19 20:57:51 -08:00
Morten Johan Sørvig
3ad4fff7d5 Use QStylePainter when painting widgets
This makes it easier to set global painter options
which affect all style painting.

Change-Id: I6a38204ed2d874255e92345e6a6a50d27939fb24
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-01-20 04:11:03 +01:00
Ivan Tkachenko
321e51d926 Doc: Cross-link QString's methods
Arguably, when talking about «null-string» constructor, it might be
useful to read about which strings are considered null, and which
methods one can use to test that.

Change-Id: Ie30144f33000aac53f4041cfb99da28a79dad946
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-19 21:08:48 +03:00
Marc Mutz
552d1c9166 QVersionNumber: don't detach() in rvalue QList/QVector ctor
Qt 5 uses begin() so the fix there will be to use cbegin().

Found by Clang -ftime-trace pin-pointing repeated instantiations
of QList<int>::data().

Pick-to: 6.3 6.2 5.15
Task-number: QTBUG-97601
Change-Id: I6410e5b303766fdbc7e158a9ac1263adec973099
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-19 15:15:37 +00:00
Marc Mutz
5d4f8a947c QColorTransform: optimize member-swap()
We know decltype(d), so we don't need to jump though the ADL-enabling
that qSwap() does. Just call QExplicitlySharedDataPointer's
member-swap directly.

Found through Clang -ftrace-time over PCH'ed libQt6Gui.so build:

  **** Templates that took longest to instantiate:
    [...]
    4050 ms: qSwap<QExplicitlySharedDataPointer<QColorTransformPrivate> > (87 times, avg 46 ms)

which is gone afterwards.

Task-number: QTBUG-97601
Pick-to: 6.3 6.2
Change-Id: Ie054848922a50dbf746781491cb28e598c0e12bc
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-19 16:15:37 +01:00
Laszlo Agocs
6dd09664b2 rhi: d3d: Fix up non-vsynced presentation
Doing Present(0, 0) is not necessarily sufficient to get rid of
blocking. It may very well start blocking after a few frames.

This does not apply to a non-flip-discard swapchain (when running
with QT_D3D_NO_FLIP=1), but for flip-discard we should also try using
DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING and DXGI_PRESENT_ALLOW_TEARING in
case a swap interval of 0 is wanted.

Pick-to: 6.3
Fixes: QTBUG-99949
Change-Id: I9cb13b139ba04e41b4f25b94bcd3d1e973496414
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-01-19 15:19:38 +01:00
Volker Hilsheimer
d671bab0e3 Win32: always allow the event loop to be woken up by posted events
We set the wakeUps atomic to prevent multiple WM_QT_SENDPOSTEDEVENTS from
being posted. However, this might happen right after the event processing
thread cleared the atomic, but before it processed the previous
WM_QT_SENDPOSTEDEVENTS message. In that case, we end up with a set
atomic  and an empty event queue, resulting in the event loop to block
even though there are posted QEvents.

To prevent that, always reset the atomic when we handle the
WM_QT_SENDPOSTEDEVENTS message. In that case, we either call
sendPostedEvents, or startPostedEventsTimer. The former already resets
wakeUps; reset it in the latter as well.

Fixes: QTBUG-99323
Pick-to: 6.2 6.3 5.15
Change-Id: I931c02be9c42b02e8ca20daba5059cd8185f0a37
Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
2022-01-19 14:22:52 +01:00
Kai Köhne
b07e5fcd1b Doc: Remove "Docs about UI Design" book overview
Recommending a Qt 4 book in Qt 6 documentation tells us something about
how much we maintain the list :)

The other books might still be good sources. Anyhow, the chances of a
customer looking exactly in this place to learn good books about icons are
not very high. So let's just ditch the page, and use external links instead.

Pick-to: 6.3
Change-Id: I8013a5ab9d3416fe795f4aaed647e26db79508a1
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2022-01-19 14:22:52 +01:00
Marc Mutz
f7ac5968fc QPolygon: de-inline setPoint()
In Qt 5 times, the core of QList::realloc() was out-of-line by design,
because it was independent of T.

Now that QList is QVector, its equivalent detachAndGrow() function on
QArrayDataPointer is inline and instantiated for each type anew. We
therefore need to be careful to not use detach()ing QList operations
in non-generic code inline code (in public, but also private,
headers), because (common) PCH builds force this code to be compiled
over and over again. Generic code is only instantiated when used in a
TU, so that's ok. But for non-generic code, the only option is to
de-inline.

If there is an effect on compile-times, it's hidden in the run-by-run
noise of building QtGui, but at least this entry is gone afterwards
from clang -ftime-trace:

  **** Templates that took longest to instantiate:
  [...]
    4676 ms: QList<QPoint>::operator[] (261 times, avg 17 ms)

Added 'inline' to the definition of the setPoint(int, QPoint)
overload, since MinGW used to complain about it missing.

Task-number: QTBUG-97601
Pick-to: 6.3
Change-Id: Ie6f67da7ef39a16c98a7451d37b6d96531656392
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-19 12:58:22 +00:00
Marc Mutz
49e263ef4b QPropertyBindingPrivate: move static_assert()s to .cpp file
One of them has managed to percolate up to the top of the Clang
-ftime-trace list of expensive template instantiations when building
libQt6Gui.so with -pch:

  **** Templates that took longest to instantiate:
    7882 ms: std::is_trivially_destructible<QPropertyBindingSourceLocation> (135 times, avg 58 ms)

The checks aren't really necessary, because the compiler would
complain about the union's deleted dtor if any of the members were not
trivially destructible. Keep it around, though, but in the .cpp file.

Task-number: QTBUG-97601
Pick-to: 6.3 6.2
Change-Id: I74a513a907735bde298e0bd9557d10abbcee5c91
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-19 13:58:22 +01:00
Marc Mutz
a5229a57ef QDBusMessage: de-inline createReply(QVariant)
The building of the QList has percolated to the top of the lists of
most expensive template instantiations in Clang -ftime-trace PCH
builds of libQt6Gui.so:

  **** Templates that took longest to instantiate:
    7137 ms: QList<QVariant>::operator<< (260 times, avg 27 ms)
    7115 ms: QList<QVariant>::append (263 times, avg 27 ms)
    7071 ms: QList<QVariant>::emplaceBack<const QVariant &> (256 times, avg 27 ms)
    6651 ms: QtPrivate::QMovableArrayOps<QVariant>::emplace<const QVariant &> (256 times, avg 25 ms)
    [...]
    5649 ms: QArrayDataPointer<QVariant>::detachAndGrow (256 times, avg 22 ms)
    [...]
    4668 ms: QArrayDataPointer<QVariant>::reallocateAndGrow (256 times, avg 18 ms)

Task-number: QTBUG-97601
Pick-to: 6.3
Change-Id: Ib766e70e4f741e057f9032bf232160cf6e83f4b9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-19 07:18:40 +01:00
Thiago Macieira
559051851a QString: use char16_t in ucstr{n,i,}cmp & ucstreq instead of QChar
Change-Id: I0e5f6bec596a4a78bd3bfffd16c907b827f08519
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-18 21:38:12 -08:00
Thiago Macieira
d5fa6aa58c QString: optimize equalStrings() with a template in ucstrncmp()
If the SIMD code has already determined that the byte content differs,
we don't need to actually subtract the bytes we loaded from memory in
vector operations to return a sorting result.

Change-Id: I0e5f6bec596a4a78bd3bfffd16c908b2902e1b1b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-18 21:38:12 -08:00
Thiago Macieira
3d70b291ed QString: merge the two ucstrcmp overloads into a template
So we don't accidentally make modifications to one and not the other.

Change-Id: I0e5f6bec596a4a78bd3bfffd16c94f1025aea521
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-18 21:38:12 -08:00
Thiago Macieira
2932c3f942 QString: introduce ucstreq() to optimize equalStrings()
If the lengths aren't equal, the strings can't be equal either, so we
can skip the entire comparison. Some of the front-end functions that
call these entry points already check for this, actually.

Change-Id: Ib42b3adc93bf4d43bd55fffd16c8ceb9594512f2
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-18 21:38:12 -08:00
Thiago Macieira
b386346468 QString: make ucstricmp() parameters match the compareStrings'
The compareStrings() entry points take QStringView and QLatin1String,
which are both ordered [size, pointer], so match that in the ucstricmp()
parameters. This further reduces the prologue of the compareStrings()
functions before reaching the case-sensitive comparison.

There's no need to do the same for the case-sensitive functions because
they're getting inlined.

Change-Id: I0e5f6bec596a4a78bd3bfffd16c8ffc980c8af0c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-18 21:38:12 -08:00
Thiago Macieira
2c2e2a67c3 QString: add Q_NEVER_INLINE for ucstricmp()
Case-insensitive comparisons are not common, but both GCC and Clang
inlined the ucstricmp() functions into QtPrivate::compareStrings(), with
the side-effect that a lot of unnecessary setup code saving CPU
registers was executed in the prologue of those functions.

After this, Clang 13 emits both compareString() functions without any
push/pop to save registers on x86-64; GCC 11 still emits a few, but
fewer than before (it's emitting some unnecessary overhead for the
loops).

Change-Id: I0e5f6bec596a4a78bd3bfffd16c8fc2c0be9165f
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-18 21:38:12 -08:00
Thiago Macieira
ba0864ae52 QString: remove the old unaligned 4-byte compares in ucstrncmp()
This is very old code, predating the public Qt history (Qt 4.5). It
predates all other SIMD code in qstring.cpp, actually. Now that we do
have implementations for MIPS DSP, ARM Neon and x86 SSE2, this content
has very little value. It would be relevant for other architectures Qt
still supports (POWER and RISC-V come to mind), but I guess the
compiler's auto-vectorizer functionality can do a better job than this
content.

Change-Id: I0e5f6bec596a4a78bd3bfffd16c90733fb0d8f22
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-18 21:38:12 -08:00
Pino Toscano
099e0fff61 CMake: add support for GNU/Hurd
Add a "HURD" CMake platform specification, so it can be properly
checked in the build system.

Set QT_DEFAULT_MKSPEC to the existing hurd-g++ mkspec.

Hurd supports $ORIGIN in RPATH, so enable it.

Hurd uses X11, so add it to the X11_SUPPORTED list.

Enable few more feature checks that apply to Hurd as well: either
because they are provided by GNU libc itself, or because they are
implemented on Hurd.

Check and set the ELF interpreter, as it is a common functionality of
the GNU toolchain.

Change-Id: Id347033560bbc5a2a4e2c3abb493c948c002b40e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-01-19 01:53:14 +01:00
Edward Welbourne
7fea7dfaf3 Restore std::as_const() where a qAsConst was lost between 5.15 and 6
Amends commit 837a29b0b92c72b7b9d66a427c24a9fa8037f4f4's fix for
shadowing to take account of the loss of const-qualification of
uiLanguages where it was then used in a ranged-for loop.

Pick-to: 6.3 6.2
Change-Id: Ic4021bd9917cb27832a197126cc80a7f384a14a2
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-18 20:42:19 +00:00
Mårten Nordheim
7e82cefb72 QNetworkRequest: Document how Qt handles 301 and 302 status codes
To make it explicit

Pick-to: 6.3 6.2 5.15
Task-number: QTBUG-92909
Change-Id: I8f8dc99628168a566158acef72ae2a5e001eef88
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-01-18 18:43:55 +00:00
Edward Welbourne
26082a0dd2 Remove (set but) unused member from QTimerPrivate
Change-Id: I004fef8ce84cdc74837f674239c05901000bee33
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-18 16:23:56 +01:00
Pino Toscano
13a11f1c35 QProcess/Unix: fallback on _POSIX_PIPE_BUF w/ missing PIPE_BUF
PIPE_BUF is optional in POSIX, e.g. "where the corresponding value is
equal to or greater than the stated minimum, but where the value can
vary depending on the file to which it is applied." [1]

GNU/Hurd does not provide PIPE_BUF, so fallback to its minimum
acceptable value, that is _POSIX_PIPE_BUF.

[1] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html

Also, explicitly include <limits.h> in this file, to make sure PIPE_BUF
or _POSIX_PIPE_BUF are available without relying on other headers to
pull <limits.h>.

Change-Id: Ifae964db81841e1d31fc09e73b45594af9a326d1
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-18 06:42:51 +01:00
Thiago Macieira
86b346823e QString::toLatin1_helper_inplace: simplify the code
Hot function, so help the compiler out. In particular, this removes any
touch to the ref count, so there are no atomic operations or dead code
leading to memory allocations and deallocations.

Change-Id: I0e5f6bec596a4a78bd3bfffd16c9a0fbd8dd2c12
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-17 19:56:41 -08:00
Thiago Macieira
a59e736171 QMetaType: add a missing check for null d_ptr
Bug introduced in 6.0. This is the only unprotected d_ptr I could find.

[ChangeLog][QtCore][QMetaType] Fixed a bug that would cause
QMetaType::compare() and QVariant::compare() to crash on invalid meta
types and variants.

Pick-to: 6.2 6.3
Fixes: QTBUG-99960
Change-Id: I0e5f6bec596a4a78bd3bfffd16cb1f7b2d146688
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-18 03:56:40 +00:00
Marc Mutz
9ab44777d6 QRhiGles2: replace two QSet<int> with QDuplicateTracker
Apart from a more fitting, minimal, API, QDuplicateTracker also
transparently uses C++17 pmr::monotonic_buffer_resource to avoid,
or at least reduce, memory allocations.

Pick-to: 6.3
Change-Id: Ied2574734949b2dadc1bcbaa9d1e3c0ed98ba50a
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-01-18 04:56:40 +01:00