Commit Graph

40343 Commits

Author SHA1 Message Date
Edward Welbourne
13d2e13290 Make counts of various types of test result add up correctly
Added tests for repeated skips and failures (from within void lambdas,
to simulate skips and failures from within event handlers). These
exhibit yet more ways to count more than one outcome for a test.  The
new QTest::failOnWarning() can also provoke more than one failure from
a single test, and several existing selftests exhibited various ways
for the Totals line's counts to add up to more than the number of
actual tests run.

Fixed counting so that only the first decisive incident is counted.
Tests can still report later failure or skipping, but only the first
is counted.

Added a currentTestState in qtestlog.cpp, by which it keeps track of
whether the test has resolved to a result, and clearCurrentTestState()
by which other code can reset that at the end of each test. This
brought to light various places where test-end clean-up was not being
handled - due to failure or skipping in a *_data() method or init, or
a skip in cleanup.

Fixes: QTBUG-95661
Change-Id: I5d24a37a53d3db225fa602649d8aad8f5ed6c1ad
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-01-13 19:47:22 +01:00
Edward Welbourne
95e4996688 Revise the explanation for leaving QTest::qWait() as it is
The recently aborted attempt to act on the comment's recommendation
revealed a major performance regression, so mention that instead of
the now historical compiler problem that used to be our reason for not
simply calling qWaitFor().

Change-Id: I81714b556998217a833c21b4208118b7292b7a96
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2022-01-13 14:47:46 +00:00
Friedemann Kleint
e376c229e9 uic/Python: Import base class for flag values
Extend the logic extracting enum base classes to flags
to handle things like  QAbstractItemView::EditTriggers.
Exclude the Qt namespace.

Amends de15836dbf.

Fixes: PYSIDE-1773
Task-number: PYSIDE-1404
Pick-to: 6.2 6.2.3 6.3
Change-Id: Ib0cd0836a91f330e5bc3307690062a965abec7eb
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
2022-01-13 15:47:46 +01:00
Ulf Hermann
657a18c7fa QMetaType: Allow conversion of derived gadget types to their base types
A derived gadget has an is-a relationship with its base type. It
should be convertible. In fact, canConvert() already tells us it is.

Change-Id: I71a5ac9afd78e88adb23b4d0e757f34077f63207
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-01-13 13:56:36 +00:00
Kai Köhne
873a8edff8 Doc: Fix snippet to match actual QFileInfo behavior
The documentation was already updated in abfac029ce,
but the snippet still incorrectly suggested QFileInfo::size would
report the actual size of an .lnk file on Windows.

Pick-to: 5.15 6.2 6.3
Change-Id: I03b96b2efcb713fbc4dd30fc526e1209806bf5cf
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2022-01-13 14:56:36 +01:00
Laszlo Agocs
a325016aa9 rhi: Add the basic infrastructure for tessellation support
...but this will only be supported with Vulkan and OpenGL 4.0+ and
OpenGL ES 3.2+ for the time being.

Taking the Vulkan model as our standard, the situation is the
following:

- Vulkan is ok, qsb secretly accepts .tesc and .tese files as input
  already (plus QShader already has the necessary plumbing when it
  comes to enums and such) To switch the tessellation domain origin to
  bottom left we require Vulkan 1.1 (don't bother with
  VK_KHR_maintenance2 on top of 1.0 at this point since 1.1 or 1.2
  implementations should be common by now). The change is essential to
  allow the same evaluation shader to work with both OpenGL and
  Vulkan: this way we can use the same shader source, declaring the
  tessellation winding order as CCW, with both APIs.

- OpenGL 4.0 and OpenGL ES 3.2 (or ES 3.1 with the Android extension
  pack, but we won't bother with checking that for now) can be made
  working without much complications, though we need to be careful
  when it comes to gathering and setting uniforms so that we do not
  leave the new tessellation stages out. We will stick to the Vulkan
  model in the sense that the inner and outer tessellation levels must
  be specified from the control shader, and cannot be specified from
  the host side, even though OpenGL would allow this. (basically the
  same story as with point size in vertex shaders)

- D3D11 would be no problem API-wise, and we could likely implement
  the support for hull and domain shader stages in the backend, but
  SPIRV-Cross does not support translating tessellation shaders to
  HLSL.  Attempting to feed in a .tesc or .tese file to qsb with
  --hlsl specified will always fail. One issue here is how hull
  shaders are structured, with the patchconstantfunc attribute
  specifying a separate function computing the patch constant
  data. With GLSL there is a single entry point in the tessellation
  control shader, which then performs both the calculations on the
  control points as well as the constant data (such as, the inner and
  outer tessellation factors).  One option here is to inject
  handwritten HLSL shaders in the .qsb files using qsb's replace (-r)
  mode, but this is not exactly a viable universal solution.

- Metal uses a different tessellation pipeline involving compute
  shaders. This needs more investigation but probably not something we
  can prioritize in practice. SPIRV-Cross does support this,
  generating a compute shader for control and a (post-)vertex shader
  for evaluation, presumably in order to enable MoltenVK to function
  when it comes to tessellation, but it is not clear yet how usable
  this is for us.

Change-Id: Ic953c63850bda5bc912c7ac354425041b43157ef
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-01-13 13:44:29 +01:00
Yuhang Zhao
c1f7194b44 QStandardPaths_win: Add mapping for DownloadLocation
Un-special-case for DownloadLocation. I assume the original
code is written like that to be compatible with some really
old versions of Windows.

Change-Id: I643401910bae9a061f2e02c651971b4f2dd46901
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2022-01-13 20:13:49 +08:00
Marc Mutz
54945d58b3 QApplication: port manual users of QMutableEventPoint
... to new static setter API, which doesn't depend on undefined
behavior.

These users didn't use QMutableEventPoint::from(), but static_cast<>,
so they were only found when the non-static setters were removed,
locally.

Task-number: QTBUG-99615
Pick-to: 6.3
Change-Id: I37faf17b2b180e0f6e8bb4e5f46951a2cc29678d
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-01-13 09:19:23 +01:00
Yuhang Zhao
ae7e11e5c6 QStandardPaths: Remove old MinGW workaround
From the comments the workaround is for MinGW
older than v7, now our CI has MinGW v9 trunk,
it should be safe to drop this.

The magic number is replaced by the official function,
although it was introduced in Win8, Qt6's minimum
supported platform is Win10, so it's also safe to do.

As a drive-by, remove two unused includes.

Change-Id: I891fe3883f17d4914932784868d7446299d32c65
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-13 13:14:30 +08:00
Yuhang Zhao
6241dcb9a4 QStandardPath: fix typo
Pick-to: 6.3 6.2
Change-Id: I12837ce614ea91a8a72191092dc8c835f74107cc
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-13 10:10:50 +08:00
Marc Mutz
5beb842b98 QWindowSystemInterface: port to QMutableEventPoint static setter API
This code was actually ok (no UB), but it's in the way of making
QMutableEventPoint a befriendable namespace, so port from using
QMutableEventPoint to QEventPoint instances + QMutableEventPoint
static setters.

Task-number: QTBUG-99615
Pick-to: 6.3
Change-Id: I1f123837d62a2200e36faf89f6912ee59be2f915
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-01-13 02:27:36 +01:00
Thiago Macieira
214df31916 Add a few explicit conversions back from int
Suppresses GCC's -Wconversion, which is not enabled by default.

error: conversion from ‘int’ to ‘quint8’ {aka ‘unsigned char’} may change value [-Werror=conversion]

Change-Id: I0e5f6bec596a4a78bd3bfffd16c998102bd51f7c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-12 16:36:54 -08:00
Thiago Macieira
ed753eb5fb QString::compare: fix comparing a 4GB string to 1 QChar
If the size() was larger than INT_MAX, the result would be wrong (and
UB).

Pick-to: 6.2 6.3
Change-Id: I0e5f6bec596a4a78bd3bfffd16c99763e66c2013
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-12 16:36:54 -08:00
Robert Löhning
0bc7f94bd8 Q*Parser: Replace "data" with "contents" in strings
...to be clearer and avoid confusion with "data section".

Change-Id: I13319be0e3e12aecf1e0e86c256007dfe6cb98c6
Pick-to: 6.3
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-12 23:10:01 +01:00
Ivan Tkachenko
2baa7eb260 QRollEffect: Remove assignments that have no effect
Value of the member variable `done` will be overwritten after the end of
each `if` block.

Pointed out by PVS-Studio static analysis tool:
https://habr.com/ru/company/pvs-studio/blog/542760

Change-Id: Icaf965aaebfa8a238dd3569689e1496a30d4b6d1
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-01-13 01:10:01 +03:00
Thiago Macieira
6099e96d9e QJsonObject: use the UTF-8 string comparator in sorting
No change, the two functions are identical for case-sensitive
comparison. But this allows us to remove the comment that explained why
we were abusing the Latin1 comparator.

Change-Id: I0e5f6bec596a4a78bd3bfffd16c98bbcac6c9dc9
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-01-12 13:49:03 -08:00
Thiago Macieira
8623e8ed08 QByteArray: remove left-over Q_NEVER_INLINE after we removed the tables
The comment made a reference to the case tables that used to exist in
qbytearray.cpp prior to commit 9dd8e655cd
("Limit QByteArray's 8-bit support to ASCII"). Now that the parameter is
a function pointer, not a table, inlining is actually beneficial: we
definitely don't want the compiler to emit function calls via the
function pointer.

At least GCC 11 was already doing constant-propagation of the parameter:
While it didn't inline the function, it cloned it and propagated the
constant in each of the two clones. There were 4 copies of this
function: const and non-const, upper and lower.

Change-Id: I0e5f6bec596a4a78bd3bfffd16c912a16602e20a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-01-12 21:47:07 +00:00
Timur Pocheptsov
cd446a7e25 QMacStyle: fix a regression introduced by a button type change
Since we (re)use NSButton to render tab items, the 'momentary push in'
button type breaks the tab. Temporary restore the old 'push on/push off'
type if rendering a tab.

Pick-to: 6.2 6.3 5.15
Fixes: QTBUG-99743
Change-Id: I54b11c1a35373292ecf0bcd5cf7b4ea4203cc031
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-01-12 22:27:21 +01:00
Timur Pocheptsov
c30af31f99 QSslSocket (SecureTransport) add TLS 1.3 ciphersuites
At some point we decided to support a custom set of ciphersuites specified
by QSslConfiguration (which if you ask me was never a good idea). The law
of unforseen consequiences bit us again: since we now give a set of ciphesuites
to QSslConfiguration and set ciphesuites from the configuration a socket has,
we are limited by the ciphersuites we know about at the moment of 'coding'.
Meaning if an SDK was updated and CipherSuite.h later adds more ciphersuites,
we miss them and 'don't support them', while we ... actually do.

This patch tries to add some more ciphersuites introduced in TLS 1.3 (interesting,
SecureTransport does not support TLS 1.3, but TLS 1.3 suites can be used in TLS
1.2 session).

Pick-to: 6.2 6.3 5.15
Task-number: QTBUG-99368
Change-Id: I439b63845c4893e5621cffaf3bcaf62e2b643c74
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-12 22:27:21 +01:00
Thiago Macieira
eabb3fd2f0 QVariant: fix incorrect warning about duplicated alias where there isn't
We were always matching a type name to itself because we forgot to
advance the iterator after we did match. The issue was introduced in
commit 46dc8e453a.

Fixes: QTBUG-99620
Task-number: QTBUG-96916
Pick-to: 6.3 6.2
Change-Id: Ib42b3adc93bf4d43bd55fffd16c8a5df6306e404
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Jonas Kvinge <jonas@jkvinge.net>
2022-01-12 11:37:32 -08:00
Kai Köhne
623200643c Doc: Replace "C:\Documents and Settings" paths
"C:\Documents and Settings" isn't a real path anymore since Windows Vista.
Replace it by C:\Users, or - in the snippet for QDesktopServices that
is for demoing a path with space - with C:\Program Files.

Pick-to: 6.2 6.3 5.15
Change-Id: I1bef97b6482180a6467fffcd1d62d6c168bcb389
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-12 20:37:21 +01:00
Kai Köhne
23ffc22072 QStyle docs: Use since enum attribute
Use the explicit [since ...] instead of plain text to mark
when new enums were introduced.

Pick-to: 6.3
Change-Id: I13655931c91a509fa64cd545b49c517e975d4cc7
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-12 19:37:21 +00:00
Marc Mutz
11becbe910 QTzTimeZonePrivate: fix UB (data race on m_icu)
The fallback m_icu QIcuTimeZonePrivate is lazily constructed, which
means that two threads each with their own copy of a QTimeZone with a
shared QTzTimeZonePrivate will race over who gets to set m_icu,
e.g. when concurrently calling QTimeZone::displayName().

Fix by protecting m_icu with a mutex. For simplicity, use a static
mutex, not a per-instance one (which would delete the
QTzTimeZonePrivate copy constructor, which clone() relies on). This is
sufficient for 5.15. For Qt 6, going forward, we could make this
lock-less, too.

[ChangeLog][QtCore][QTimeZone] Fixed a data race on Unix platforms when
implicitly-shared copies of QTimeZone objects were used in certain ways
(e.g. calling displayName()) from different threads and Qt was
configured with ICU support.

Pick-to: 6.3 6.2 5.15
Change-Id: I7e57aef3dd44a90289ad86d0578ece1e54920730
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-01-12 19:37:21 +00:00
Laszlo Agocs
bfc713530a rhi: Add queries for vertex input/output limits
Mainly because we do have legacy code in the Qt 5 graphical effects that
tries to dynamically determine the max number of varyings. Make it
easier to port such code.

Change-Id: I846cab2c2fe7b4cd473b5ced0146ca36f1c8169b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2022-01-12 20:37:20 +01:00
Allan Sandfeld Jensen
96269ecc77 Draw extended RGB solid colors
Pass extended RGB colors through the paint engine.

Change-Id: I2e212cd4c76aaa65439746352c0da2b9db4a506d
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-01-12 18:28:24 +01:00
Tor Arne Vestbø
996061a1c0 macOS: Implement QCALayerBackingStore::scroll for improved performance
The CALayer backingstore never had a scroll implementation because we
were relying on the QRasterBackingStore implementation, but as it turned
out that implementation was not applicable for the CALayer backingstore.

We now implement scroll() by determining which part of the back buffer
can be scrolled directly in-place, and then scrolling the rest by
copying from the front buffer. We have to handle both cases, as clients
may scroll multiple times before flushing, and the scrolled area may
overlap both valid back-buffer content and content that needs to be
pulled from the front-buffer.

Pick-to: 6.3 6.2
Change-Id: Icc09c9488386925116779c9024669a4329b38247
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-01-12 18:13:52 +01:00
Volker Hilsheimer
999d856bc8 Adapt SQL drivers to Qt 6 change of QVariant::isNull
In Qt 5, QVariant::isNull returned true if either the variant didn't
contain a value, or if the value was of a nullable type where the type's
isNull member function returned true.

In Qt 6, QVariant::isNull only returns true for variants that don't
contain a value; if the value contained is e.g. a null-QString or
QDateTime, then QVariant::isNull  returns false.

This change requires a follow up in the SQL drivers, which must
still treat null-values the same as null-variants, lest they write data
into the data base.

Add a static helper to QSqlResultPrivate that implements isNull-checking
of variants that contain a nullable type relevant for Sql, and add a
test case to the QSqlQuery test that exercises that code.

Pick-to: 6.2 6.3
Fixes: QTBUG-99408
Fixes: QTBUG-98471
Change-Id: I08b74a33aa3235c37d974f182da1f2bdcfd8217e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-12 17:41:07 +01:00
Andrey Mozzhuhin
66f0149693 QHttpNetworkConnection: Always set proxy settings to all channels
Proxy settings should always be set to all channels because after switching
from HTTP/2 to HTTP/1.1 they may all be used.

Problem was made in commit 8b9d246225. It is
introduce the QHttpNetworkConnectionPrivate::activeChannel field, which value
is 1 got HTTP/2 by default, but can later be changed to 6 if the remote host
doesn't support HTTP/2.

Pick-to: 6.3 6.2 5.15
Change-Id: Idcdeb22ec806520965f30a22045f99aa009a7362
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-12 16:41:07 +00:00
Marc Mutz
716c916c40 QSinglePointEvent: port away from QMutableEventPoint::from()
Use the new static QMutableEventPoint setters, which do not depend on
undefined behavior.

Made it a separate commit, because, while straight-forward, it's a lot
of changes compared to other users.

Task-number: QTBUG-99615
Pick-to: 6.3
Change-Id: I580b6b225421a1e908f04c8e30adcdef6540ea52
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-01-12 15:14:18 +00:00
Marc Mutz
b17c4d0e2e QFlatMap: re-implement insert() via insert_or_assign()
Avoids code duplication.

Pick-to: 6.3 6.2
Change-Id: Ic69e46108baf97a0dc9215866d6c707136ee40b2
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2022-01-12 16:14:18 +01:00
Marc Mutz
6891e10f97 QFlatMap: add insert_or_assign
This does exactly what insert() on Qt associative containers does, but
allows to express the intent of using the STL-incompatible Qt insert()
semantics, in an STL-compatible way, instead of leaving the reader of
the code wondering what semantics are expected.

This is part of a very-long-term goal of fixing Qt associative
container's insert() behavior, in which QFlatMap, being an affected,
but private-API type, is used for proof-of-concept purposes.

Task-number: QTBUG-99651
Pick-to: 6.3 6.2
Change-Id: I69010285438259918aef659d3235180c1b5be696
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2022-01-12 16:14:18 +01:00
Mårten Nordheim
8c5e31536a QCache: fix potential crash in trim()
We use raw pointers to the Nodes in the QHash which is
inherently fine, but we are then subject to invalidation when
nodes are moved around during deletion.

In trim() we don't actually need to iterate the linked-list
since the node we are interested in is always chain.prev

Pick-to: 6.3 6.2 6.2.3
Fixes: QTBUG-99710
Task-number: QTBUG-99224
Task-number: QTBUG-99240
Change-Id: I9c2ed69b29e3cadca013113a3553deb44d7382fc
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-01-12 14:27:59 +00:00
Yuhang Zhao
831b3506fc QOperatingSystemVersion: Make implementation consistent on all platforms
Only Windows is using lambda function, change to static member
function to be consistent with other platforms.

QOperatingSystemVersionBase::current()'s implementation is exactly
the same on all platforms, so move it to the common source file
instead of implementing it three times on each platform.

Change-Id: I4099235b3b041a9a374e21d537649047ee03e62b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-12 21:00:45 +08:00
Volker Hilsheimer
4a4240f1bd Don't access QObject::objectName during QThread start
This is a data race, as the thread accesses QObject::objectName on the
QThread instance while the thread owning the QThread might modify the
objectName.

Instead, make a copy in the QThreadPrivate that can be accessed safely.

Task-number: QTBUG-96718
Pick-to: 6.3 6.2 5.15
Change-Id: I10701551d498993ca5055daf161636bfb648840c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-12 12:44:38 +01:00
Yuhang Zhao
e9fd1c6aab QScreen_win: retrieve user friendly monitor name
[ChangeLog][QtGui][QScreen] QScreen::name() now returns the user friendly name
instead of the GDI device name on Windows. This is consistent with other
platforms and also obeys the documentation.

Fixes: QTBUG-74317
Pick-to: 6.3 6.2
Change-Id: Iefbfaa1f9fd504277a0b5eb8c7a1fc13257c01f2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-01-12 14:20:17 +08:00
Tor Arne Vestbø
11a4546ce9 Add Q_FLAG for QEventLoop::ProcessEventsFlags
Helps debugging when printing the flags.

Pick-to: 6.3 6.2
Change-Id: Icb306bb1efaf9d3c645c2ac86796d95da5afc4a3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-12 04:38:14 +01:00
Tor Arne Vestbø
f3db9abebf eglfs: Unset shared raster compositing context before deletion
Change-Id: Ib0f615c76ac62f1177e44faaa733e67014f4185d
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-01-12 04:38:14 +01:00
Morten Johan Sørvig
eef865cdc5 Make QCursor::setPos() use the correct screen
setPos() takes a screen argument, however this argument
indicates which cursor should be moved only and is
not usable as an argument to toNativePixels() since
the position may be on a sibling screen.

Add call to QScreen::virtualSiblingAt to get the target
screen.

Task-number: QTBUG-99009
Pick-to: 6.3 6.2 5.15
Change-Id: I8714ebc93a283c58bc67911315f787c484fb0dd8
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-01-12 03:17:47 +01:00
Zhang Hao
38a66aa53a xcb: Correctly update primary screen status with RandR 1.5
This amends d8f37d94e5 .

Fixes: QTBUG-99605
Pick-to: 6.3
Done-with: Liang Qi <liang.qi@qt.io>
Change-Id: Ia4cf67d6ebeed36596c0342302aa0b4af01769bc
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-01-12 03:17:47 +01:00
Lorn Potter
8f7bebb611 wasm: ensure cursor reverts after window resize
This partially reverts 97be0cca17
but without the crash

We temporarily override the wasm cursor while leaving the
application/window cursor alone to mimic what desktop application
behavior is like.

Pick-to: 6.3
Fixes: QTBUG-99111
Change-Id: I23df48b2eaa82830593f1753ec23d14fe375b70c
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-01-12 11:41:10 +10:00
Marc Mutz
66a183298a QPointingDevice: avoid double lookup in Private::pointById()
Use the newly-added try_emplace() function, to work around Qt's
associative container's broken insert() behavior (which is
equivalent to STL's insert_or_assign()), forcing either a double
lookup:

   auto it = c.find(key);  // lookup 1
   if (it == c.end())
      c.insert(key, ~~~);  // lookup 2

or the usual size-check trick:

    const auto oldSize = c.size();
    auto &e = c[key];
    if (c.size() != oldSize) {
        // newly inserted

onto any lookup-or-initialize-like code. try_emplace beats them
both in terms of efficiency and readability.

Pick-to: 6.3
Change-Id: I4c52d2f2d5175991db4931d29c688de125f5b032
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-01-12 01:03:15 +00:00
Marc Mutz
d4611ba3a5 QFlatMap: add an alias for using QVarLengthArrays
... in an attempt to foster the use of this data structure by making
it less onerous to spell.

Pick-to: 6.3 6.2
Change-Id: Ib9d17029c75278edde6ba90f65f68af179a6d230
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-01-12 02:03:15 +01:00
Bernhard Rosenkraenzer
234e0eadc8 QWizardLayoutInfo: make == and != operators const
This fixes building with clang 10.0 in C++20 mode.
http://eel.is/c++draft/diff.cpp17.over

Thanks to Ville Voutilainen <ville.voutilainen@qt.io>
for pointing out this better fix.

Task-number: QTBUG-81917
Pick-to: 6.3 6.2 5.15
Change-Id: I8ce5776ddcd061b4615239e38caa5ad07950b66d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-12 01:03:15 +00:00
Marc Mutz
f044664c68 QFlatMap: add try_emplace (w/o hint)
QFlatMap, like its public brethren, features the broken Qt-style
insert() behavior (what the STL calls insert_or_assign()), which
makes its insert() unusable for actual STL-style insert() work,
with no replacement except the size-check-and-index-operator trick:

    const auto oldSize = c.size();
    auto &e = c[key];
    if (c.size() != oldSize) {
        // inserted
    }

Even though QFlatMap::insert() appears to return the correct info,
it's useless, because the old value has been assigned over by the
time insert() returns.

Pick-to: 6.3 6.2
Change-Id: If4173c42523a128dfd22ab496dde0089ba73f41c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2022-01-12 02:03:15 +01:00
Marc Mutz
5327bae6f0 QEventPoint: forward-declare QMutableEventPoint before befriending it
Otherwise the friend declaration declares the name, which here is ok,
but can cause duplicate names in other situations.

Pick-to: 6.3 6.2
Change-Id: I695f9c5c116b90ba52e1b99e15f31e732e63d357
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-01-12 02:03:15 +01:00
Marc Mutz
3917838d64 QFlatMap: optimize construction from existing containers
Use {copy,move} ctors instead of default-ctor, followed by
(move|copy)-assignment.

Pick-to: 6.3 6.2
Change-Id: Id2fd53050cd353a9374fd065ac25d753d42d1be9
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2022-01-12 02:03:15 +01:00
Marc Mutz
e809d4e3cc QFlatMap: fix pointless reallocations on repeated range-insert()s
When looping over range-insert(), the repeated shrink_to_fit() calls
would cause cause reserved (or geometrically-grown) capacity to be
shed, breaking the underlying container's growth strategy.

Fix by not shedding excess capacity.

Pick-to: 6.3 6.2
Change-Id: I10915a06fc9442039c192486a55e48083da7c839
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2022-01-12 02:03:15 +01:00
Laszlo Agocs
cdfbe70923 rhi: Improve the handling of HDR capable texture formats
Add some sort of autotest for both RGBA16F and the new RGB10A2. The
latter is introduced particularly because ideally we should have a
texture format that corresponds to the D3D/Vulkan swapchain color
buffer format with HDR10.

Change-Id: I1e1bbb7c7e32cb3db89275900811c0bcaeac39d6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-01-11 22:38:35 +01:00
Laszlo Agocs
0be28d1030 rhi: Add some docs for the hdr info queries
Change-Id: I9b3b62ac83642a7d3e474c991e572877b9e46ca5
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-01-11 22:38:35 +01:00
Thiago Macieira
bb35b2f64d QByteArray: fix append() with a negative length
The documentation says that if it's negative, we find the null
termination. This bug was introduced with the clean up to use
QByteArrayView in commit 8897aa071a.

Fixes: QTBUG-99640
Pick-to: 6.3 6.2
Change-Id: Ib42b3adc93bf4d43bd55fffd16c89fa4a960f3a9
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-11 15:12:30 +00:00
Shawn Rutledge
17dca04a61 Use QTextCharFormat::fontFixedPitch to remember Markdown backtick spans
If the editing app (like qtbase/examples/widgets/richtext/textedit)
has controls only for setting a specific font, and someone uses it to
write markdown "from scratch", then we need to detect that they chose
Courier or some other fixed-pitch font, and write the backticks,
because Markdown has no syntax for selecting a specific font family.
If the user loads markdown into such an application, the font
is set to QFontDatabase::systemFont(QFontDatabase::FixedFont).
Round-trip editing was already working, as long as such a font exists.
QTextCharFormat::setFont() calls setFontFixedPitch(font.fixedPitch()),
but for the chosen "mono" font, font.fixedPitch() can be false.
For semantic completeness and separation of concerns, we now
set fontFixedPitch explicitly if a `backtick` span is encountered.
As a followup to f1e60de665 this
should get its autotest passing reliably.

Fixes: QTBUG-99676
Pick-to: 6.3 6.2 5.15
Change-Id: I4987a1f0f819f82ec64546bdc3ef53e7d29933de
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-01-11 15:04:25 +00:00
Øystein Heskestad
2a086a9857 Replace QString with QStringView and use qsizetype in QPdfEnginePrivate
Task-number: QTBUG-98763
Change-Id: Iab09d5a4d23215fd44e4b2cf4212688cd8f27a63
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-11 15:39:14 +01:00
Marc Mutz
ae49252dbc QMutableEventPoint: add static overloads of setters
These overloads don't require a cast from QEventPoint to
QMutableEventPoint, thus avoiding undefined behavior.

Port easy users of QMutableEventPosition::(const)from()
to the new API.

Pick-to: 6.3
Task-number: QTBUG-99615
Change-Id: I4e9228322134ef7c712ca478ee8286466efc3585
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-01-08 09:00:10 +00:00
Michal Klocek
7819edabf6 Revert "Implement QTest::qWait() in terms of QTest::qWaitFor()"
This reverts commit 5c908c8263.

git-bisect points to this commit as the cause for serious test
regressions in the qtwebengine module where test time execution
goes up 10 times (at least for debug builds), causing timeouts.

The reason for the time regression in test execution is caused
as the 'processEvents' call is no longer executed with
'remaining' time:

QCoreApplication::processEvents(QEventLoop::AllEvents, remaining)

'processEvents' do not spin for the whole duration and instead it calls
'predicate' after all event processing but before proceeding with new
events. This introduces significant Chromium's message pump lag
and makes test execution much slower.

In case of relanding this change we need to go through all tests and
extend timeouts, which is not feasible at the moment.

This is a quick-fix for 6.3.

Change-Id: I90696479bfb9f0a0b8a8acc5bb7e7058b7d0c462
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit f2d0b327e4e6a6c4b72998c290d554d6c4a8f5b6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2022-01-08 04:51:12 +00:00
Marc Mutz
d0bcbbebc3 QGuiApplication: remove an unneeded const_cast
QPointingDevicePrivate::pointById() already returns (mutable)
EventPointData*, so the eventPoint member is mutable, too.

Task-number: QTBUG-99615
Pick-to: 6.3 6.2
Change-Id: Iae1e665cab4b83b63e0e693bf7c4689e99aa3bae
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-01-08 02:52:08 +01:00
Laszlo Agocs
0739170d4b rhi: gl: Prevent breaking with ES when querying the sampler mapping table
Send the full QShaderVersion down the line, not just the version number.

Change-Id: I895d552fc47e0eb4ca92f32f117cd5a1d4d9015a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-01-07 14:31:38 +01:00
Mitch Curtis
75abba6487 Add PreselectFirstFileInDirectory platform theme hint
This allows Qt Quick Dialogs to accurately check whether it should
select the first file in a directory when a file dialog is opened.

While we're here, fix an incorrect version on the last theme hint
that was added.

Task-number: QTBUG-98562
Change-Id: I08cc8a0fbed28a42d1212016c6ee7fc5459578bf
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-01-07 13:31:38 +00:00
Øystein Heskestad
0edbf7f97d Use ranged for loops instead of QString::utf16
Task-number: QTBUG-98763
Change-Id: I27a854121a783e67afcc4f8634ea7c8c921430c2
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-07 14:31:38 +01:00
Øystein Heskestad
18671b0491 Replace QString::utf16() with data() in memcpy() and QByteArray ctor
QString::utf16() needlessly detaches fromRawData() to ensure a
terminating NUL. Use data() where we don't require said NUL, taking
care not to call the mutable data() overload, which would detach,
too.

Task-number: QTBUG-98763
Change-Id: I7075a8f18ab1f82ebbcf8cfab1643e8ab7f38d51
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-07 14:31:38 +01:00
Marc Mutz
a5b158ed6d QFlatMap: fix const iterator API
Iterators model pointer, so const must be shallow.

Pick-to: 6.3 6.2
Change-Id: I90494c98762f1494efcca4965ee739540333f5d7
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-01-07 14:31:38 +01:00
Marc Mutz
e6cd1eb079 QFlatMap: fix mixed rvalue/lvalue insert overloads
They never worked.

Pick-to: 6.3 6.2
Change-Id: I9a15c848416419823f28ea580248fbe93a4365dd
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2022-01-07 14:31:38 +01:00
Tor Arne Vestbø
2e11918456 macOS: Handle momentum scroll NSEventPhaseBegan when scroll had ended
We use nextEventMatchingMask to look for future momentum scroll events
when the non-momentum scroll ends, to continue the scroll uninterrupted
from the perspective of client code. But we're not guaranteed to find
a future momentum scroll event, as observed on macOS 12.1, so if we
then see a momentum NSEventPhaseBegan we need to treat it as a scroll
begin from Qt's perspective.

Fixes: QTBUG-97841
Pick-to: 6.3 6.2 5.15
Change-Id: I412abe0891660eda32a42a08d7dc7dee9eaa73aa
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-01-07 07:02:20 +01:00
Yuhang Zhao
00d197662d QHighDpiScaling: fix typo in doc
Pick-to: 6.3 6.2
Change-Id: I7f874e85484a6ab4be0280e736b57141bdebc656
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-07 12:25:04 +08:00
Yuhang Zhao
44cd0c6c5f QFontDatabase: remove outdated comments
QtBase/2526df506bda99f9497e83a4e6820557a722660e has
resolved what the comment said.

As a drive-by, remove the unused QSystemLibrary include,
which is forgotten in 2526df506b.

Amends commit 2526df506b

Pick-to: 6.3
Change-Id: Iab5c7d00e22d306be63d7588ea44bf73d377793d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-01-07 12:25:04 +08:00
Yuhang Zhao
e8882ac896 QOperatingSystemVersion_win: Allow override as Windows 11
And added some later Windows Server versions.

Change-Id: I81415f1044d11458a4b4d19b01ce90e357f9d111
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-07 09:39:08 +08:00
Laszlo Agocs
7cbac745dc rhi: Returns mapping tables by value from QShader
As these are QList and QHash. All existing usages are based on this
anyway, no value in being able to indicate "not available" - an empty
container fulfills the same role.

Change-Id: I8059025fa7a4acb6fc674cd98b16fcafa19ed85d
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-01-07 01:03:47 +01:00
Marc Mutz
d2055fcee5 QGuiApplication: remove a use of QMutableEventPoint
The 'persistentPoint' reference is never used as a QMutableEventPoint,
so don't cast to it (which is UB).

Pick-to: 6.3 6.2
Task-number: QTBUG-99615
Change-Id: I7fdfb2427a09d691242bf1fa28e202ba326ea678
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-01-06 21:06:10 +00:00
Shawn Rutledge
f1e60de665 QTextMarkdownImporter: don't apply text char format to list item block
We want an ordered list item's number to be rendered with default char
format, like the others in the same list, even if the list item's text
begins with a span that has a different char format.  So insert the
list item's block with a default char format first, then change the
char format of the cursor to suit the text that's about to be inserted.
In HTML interpretation, it means the <li> does not have a style, but
contains a styled span.

Fixes: QTBUG-92445
Task-number: QTBUG-3583
Task-number: QTBUG-99148
Pick-to: 5.15 6.2 6.3
Change-Id: I7eb58a8d1171c16503cac01c8cce109d9f12e1af
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2022-01-06 22:06:09 +01:00
Laszlo Agocs
0d98a1faf7 rhi: gl: Do not just rely on GL_COMPRESSED_TEXTURE_FORMATS
Pick-to: 6.3 6.2
Task-number: QTBUG-98937
Change-Id: I64f2783ae64ad3ef77a389999ded4c9ba2c46ee5
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-01-06 14:56:32 +01:00
Laszlo Agocs
0a59101495 rhi: Add support for separate image and sampler objects
For Direct 3D, Metal, and Vulkan this is natively supported. (and
makes no difference in particular for D3D and Metal because they do
not have the legacy combined image sampler concept anyways)

With OpenGL it will work too, but this relies on SPIR-Cross magic and
is still using a combined sampler (e.g. a sampler2D) in the GLSL
shader. The GL backend walks back and forth in the mapping tables from
the shader baker in order to make this work, which is presumably
slightly more expensive than combined image samplers.

Do note that combined image samplers (i.e. sampler2D in the shader and
QRhiShaderResourceBinding::sampledTexture() in code) continue to be
the primary, recommended way for any user of the rhi for the time
being.

Change-Id: I194721bc657b1ffbcc1bb79e6eadebe569a25087
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-01-06 14:56:25 +01:00
Andy Shaw
c20b213eab SQLite: Update SQLite to v3.37.0
[ChangeLog][QtSQL][SQLite] Updated SQLite to v3.37.0

Pick-to: 6.3 6.2 5.15
Change-Id: I5b6ec6f7a3c4be551ce73d46557e43bbce657854
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-01-06 13:55:53 +00:00
Kai Köhne
17eb0f2d8a Keep original text for text/plain mime data
For historical reasons, QTextDocument[Fragment]::toPlainText replaces
nbsp character (U+00A0) with a normal space, and U+2029, and U+2028
characters with a line feed character.

This behavior differs from native (plain) text editors. It also creates
an asymetry, because the characters in question can be pasted into the
document, but not copied out of it.

Use the newly introduced QTextDocumentFragment::toRawText()
to avoid this conversion.

[ChangeLog][QtGui][Drag&Drop] Special characters like &nbsp; are now
preserved in the text/plain part of the clipboard when copied from
a QTextEdit or QLineEdit.

Fixes: QTBUG-99572
Change-Id: If01a5dd98127a59be15a425dc029c7303bce18f1
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-01-06 07:58:44 +01:00
Kai Köhne
93c1f481ab Add QTextDocumentFragment::toRawText()
Like QTextDocument::toRawText(), QTextDocumentFragment::toRawText()
does allow access to the raw string without normalizing nbsp,
line separator, paragraph separator unicode characters.

[ChangeLog][QtGui][Text] Added QTextDocumentFragment::toRawText() function.

Task-number: QTBUG-99572
Change-Id: Ia74150a3870ea0e6326fdcda4d9d0410019124ae
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-01-06 07:58:39 +01:00
Frank Su
f19ce3898e CMake: link OpenSSL to openssl tls backend instead of QtNetwork
TLS backend has become plugins since Qt 6.2.
QtNetwork does not need these links anymore.

Also removes unnecessary condition since openssl tls backend is enabled
only if OpenSSL is enabled.

Pick-to: 6.2 6.3
Change-Id: I4cc0422531d567ad015f9648fbb2bcd51f634cb9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2022-01-06 10:10:52 +08:00
Laszlo Agocs
8efe2d54b7 rhi: Expose HDR output info in a saner way
Don't bother with exposing the IDXGIOutput6. Instead, report the values,
just the ones that matter for tonemapping or transfer functions in a
cross-platform way that's also prepared for Metal's different way of doing
things.

Change-Id: I28c7b6144f8267a9d3d44eff1e40697fb543385f
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-01-06 02:43:40 +01:00
Marc Mutz
abe802cd00 QTzTimeZonePrivate: use ctor delegation instead of init()
This makes it obvious that the code in init() is only called from the
constructor and its m_icu handling doesn't need mutex protection (to
be added in a subsequent commit).

Since the input to the ctor is the result of a virtual function,
factor said virtual into a static function and call that instead.

Pick-to: 6.3 6.2 5.15
Change-Id: I7c49f2e865201a2ce2b2d86b19dae29c6d337e0e
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-05 21:29:54 +01:00
Marc Mutz
23aa51991d QTzTimeZonePrivate: fix permanently-detaching m_icu
The m_icu member is a mutable QSharedDataPointer, which means that
only the non-const API subset is accessible, and so any access to it
will always detach, in 5.15 even a check like if (m_icu), which the
code luckily doesn't use (Qt 6 added a operator bool() const).

We don't need detaching behavior here, though, since, once set, m_icu
is never changed. So just use a QExplicitlySharedDataPointer instead,
and never call detach() (which would do the wrong thing). Just in case
someone does add a detach() later, instantiate
QExplicitlySharedDataPointer over QIcuTimeZonePrivate directly. This
requires making displayName() overloads from QTimeZonePrivate visible
in QIcuTimeZonePrivate. Add an assertion that QIcuTimeZonePrivate is
final, with instructions on what to do if it fails. Finally, hold a
pointer-to-const to avoid race conditions in the pointee.

The code still contains a data race, due to the lazy initialization of
m_icu, but now we have at least a fighting change to fix it.

Pick-to: 6.3 6.2 5.15
Change-Id: I32c343822dac43f96d9fbc4c759fa44138861eae
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-05 20:29:42 +00:00
Marc Mutz
2dea20e4b0 QFutureCallOutInterface: de-inline dtor
Pick-to: 6.3
Task-number: QTBUG-45582
Change-Id: I5f3411e1dcea4b76fb0e729f612516db3163c93a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-05 21:29:31 +01:00
Morten Johan Sørvig
08ea8aaa8b wasm: don’t exit on clean return from main()
Qt 6 uses Emcripten’s default of not exiting the runtime
when main() exits. Make qtloader not transition to
the “Exited” state when main() exits with code 0, since
this would hide the app canvas.

(The app state tracking code in qtloader is by now
outdated, and should be revisited.)

Pick-to: 6.3
Change-Id: Ib47898f1dd93d87b2675f20cd39f96ac3cb681a7
Reviewed-by: David Skoland <david.skoland@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2022-01-05 21:25:49 +01:00
Morten Johan Sørvig
eb62b6ac02 wasm: always use requestAnimationFrame for updates
The compositor was posting update events and flushing/redrawing
using a zero-timer. Change this to use the request_animation_frame
API from Emscripten, which makes sure we flush window
content at the next native paint event.

This has the additional benefit that hidden canvases
(e.g on hidden tabs) won’t get frame events, and then
stop painting.

We support both well-behaved QWindows, where the window
calls requestUpate() and then paints/flushes on the
following deliverUpdateRequest(), and also less well
behaved windows which paints at any point during event
processing.

Pick-to: 6.3
Change-Id: I747d6f7ace86ceddaa18ab86b6a0ee833f98991b
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2022-01-05 21:25:38 +01:00
Thiago Macieira
e3e2674100 QGlobalStatic: invert the order of destruction and setting the guard
This is how the old implementation did it: the Type member was a member
of Holder, but the guard was set to Destroyed in the HolderBase
destructor, which ran after. I find the way I implemented in
commit81a31beeb25eaf14d5c5f42fe26aa49d6ef29bf8 to be more natural, but
it caused regressions at runtime for code that attempted to reenter the
global static on destruction.

Not unit-tested because I don't know if we want to keep this forever.

Pick-to: 6.3
Fixes: QTBUG-99192
Change-Id: Ib42b3adc93bf4d43bd55fffd16c09d7f835d121e
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-05 17:03:45 -03:00
Marc Mutz
602a186cb4 QScopedValueRollback: explicitly disable move semantics
For RAII objects, it's natural to have move semantics enabled these
days. So if a RAII type does _not_ offer it (and, as in this case,
cannot be made to offer it), be explicit and disable moves, too.

Change-Id: I5636a0c7ff2fc51982ce9a406f975b07d51af01a
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2022-01-05 10:26:41 +01:00
Marc Mutz
91e210137c QArrayDataOps: remove unused header <algorithm>
The header only uses std::destroy(), which is in <memory>, not
<algorithm>.

Doesn't change anything, because <algorithm> is still transitively
included via qcontainertools_impl.h.

Pick-to: 6.3 6.2
Change-Id: Ib6a94ea56d5819f916c80a2e307c99b328f3d61d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-05 10:26:41 +01:00
Marc Mutz
b8431bef37 QRandom: remove dead pre-C++11 code
All compilers support C++11 unrestricted unions in Qt 6.

Gets rid of another instance of to-be-deprecated-in-C++-23
std::aligned_storage.

Pick-to: 6.3
Task-number: QTBUG-99122
Change-Id: I5e6dc025893c79d0c516fc2d3801ec071615b9cc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-05 10:26:41 +01:00
Marc Mutz
bf81cd8d92 De-inline ctors/dtors in qabstractanimation_p.h
Also add explicit, where missing, and use NSDMI to simplify default
ctor implementations.

For the ctors, this is just about code hygiene. The classes are
exported, so de-inlining the ctors prevents them from being duplicated
in other libraries.

Ditto dtors, except in the case of dtors, being virtual functions, we
also avoid duplicating vtables, which has its own set of problems (see
bug-report).

Task-number: QTBUG-45582
Change-Id: I11536844b751f2e81269a5637153f84c8874ab10
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-05 08:22:00 +01:00
Marc Mutz
85c31d976f QAbstractAnimation: add missing forward-declaration
QUnifiedTimer is declared as a friend using an unqualified name that
hasn't been forward-declared before. In this situation, the friend
declaration declares the name. This is subtle, and while it's ok here,
in other situations it can actually lead to two different names being
declared.

Fix by adding the missing forward declaration.

Pick-to: 6.3 6.2 5.15
Change-Id: Ie9f5165578f1d88c6bee1afa23ef43847755a0eb
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-01-05 08:22:00 +01:00
Timur Pocheptsov
eabaa8a08e QMacStyle: use the 'momentary push in' type for push buttons
In the past, we were using different hacks to emulate the 'default' button
and a normal button (and them in a pressed/not pressed active/non-active
states). In macOS 12 old trick stopped working and UI looks a bit different:
non-default buttons never get accent color even if pressed. Instead of relying
on a combination of 'push on-push off' type's states and highlight, we can
use the 'momentary push in' (highlighted == YES gives an impression of a pressed
button) + setting a key equivalent (thanks to Tor Arne for the hint) gives
the desired 'default button' look.

Pick-to: 6.2 6.3 5.15
Task-number: QTBUG-98483
Change-Id: If7d665d217420b7732b556d98d9e0313258ff93e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-01-05 04:16:43 +00:00
Giuseppe D'Angelo
9ea1f0f8b9 Fix qobject_cast on partially destroyed QWidget/QWindow
QWidget and QWindow use bits in QObjectPrivate to provide for a couple
of shortcuts -- one in qobject_cast, and another in the isWidgetType() /
isWindowType() functions in QObject. These can be optimized by simply
looking at the bits, without actually doing more expensive runtime
casts.

These bits were set on construction, but not unset on destruction.  The
result was for instance that destroying a QWidget would report that the
object was still a QWidget when ~QObject was reached.

Fix this

1) by setting the bits only when QWidget / QWindow constructors start;

2) by resetting the bits once ~QWidget / ~QWindow are completed.
Technically speaking this is not 100% correct in the presence of data
members, but luckily those classes don't have any.

Amend an existing test for QWidget (whose comment said exactly the
opposite of what the test actually did) and add a test for QWindow.

Some other code was wrongly relying on isWidgetType() returning true
for destroyed QWidgets; amend it as needed.

[ChangeLog][QtCore][QObject] Using qobject_cast on partially constructed
or destroyed QWidget/QWindow instances now yields correct results.
Similarly, using the convenience isWidgetType() / isWindowType()
functions now correctly return false on such instances. Before,
qobject_cast (and the convenience functions) would erroneously report
that a given object was a QWidget (resp. QWindow) even during that
object's construction (before QObject's constructor had completed) or
destruction (after QWidget's (resp. QWindow's) destructors had been
completed). This was semantically wrong and inconsistent with other ways
of gathering runtime type information regarding such an object (e.g.
dynamic_cast, obj->metaObject()->className() and so on).

Pick-to: 6.3
Change-Id: Ic45a887951755a9d1a3b838590f1e9f2c4ae6e92
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-01-05 02:47:47 +01:00
Albert Astals Cid
7e7f5f9783 Use block char format to render list item bullets and numbers
It needs to be rendered with the format of the block not the format of
the first letter of the block; otherwise if the first letter is black or
italics or something, but the rest of the block isn't, the list item
text looks out of place.

Task-number: QTBUG-3583
Fixes: QTBUG-99148
Pick-to: 6.3 6.2 5.15
Change-Id: I63d8d6d6b7cee6bd9938fe1cf42a5f90da1bc0d3
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-01-05 00:11:28 +01:00
Marc Mutz
a06ea83eab QDefaultAnimationDriver: don't promote timerEvent() to public
Leave it as protected. Private API, so no BC constraints apply.

Change-Id: I876456a05372c9d3b83cb7a6410eeaa6c44f1d52
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-01-04 22:36:54 +01:00
Marc Mutz
36709d7dd5 QPointerEvent: de-inline point(i)
This function contributed 1.2s of the total 361s (0.34%) to KDDockWidgets
compilation time, according to a trace generated by Sergio Martins:

    **** Time summary:
    Compilation (146 times):
      Parsing (frontend):          343.2 s
      Codegen & opts (backend):     18.1 s

    **** Templates that took longest to instantiate:
      [...]
      1228 ms: QList<QEventPoint>::operator[] (59 times, avg 20 ms)
      1213 ms: QList<QEventPoint>::detach (59 times, avg 20 ms)
      1209 ms: QArrayDataPointer<QEventPoint>::detach (59 times, avg 20 ms)
      1202 ms: QArrayDataPointer<QEventPoint>::reallocateAndGrow (59 times, avg 20 ms)

Task-number: QTBUG-97601
Pick-to: 6.3
Change-Id: I5f4ff9843f7deff9f390c465df28cba3391e048b
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-01-04 21:36:54 +00:00
Shawn Rutledge
316389c123 doc: Update details about QSystemTrayIcon
- StatusNotifierItem is now more widely implemented (but I'm sure the
  list could be even longer); but Unity is obsolete
- XEmbed is nearly obsolete, so list it after StatusNotifierItem
- fix the links: it was meant to have friendly anchor text rather
  than showing the whole URL inline

Pick-to: 6.2 6.3
Change-Id: Id81059f9484a8144b6402e74a500edf81d845b65
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
2022-01-04 20:16:22 +01:00
Laszlo Agocs
23f8d6c57f rhi: Drop the profiler for now
The system we inherited from the original Qt 5.14 introduction of QRhi
is a text stream based solution where resource creation and frame
timings are sent in a comma-separated format to a QIODevice.

This, while useful to get insights about the number of resources at a
given time, is not actively helpful. The frameworks built on top (Qt
Quick, Qt Quick 3D) are expected to provide solutions for logging
timings in a different way (e.g. via the QML Profiler). Similarly,
tracking active resources and generating statistics from that is
better handled on a higher level.

The unique bits, such as the Vulkan memory allocator statistics and
the GPU frame timestamps, are converted into APIs in QRhi. This way a
user of QRhi can query it at any time and do whatever it sees fit with
the data.

When it comes to the GPU timestamps, that has a somewhat limited value
due to the heavy asynchronousness, hence the callback based
API. Nonetheless, this is still useful since it is the only means of
reporting some frame timing data (an approx. elapsed milliseconds for
a frame) from the GPU side.

Change-Id: I67cd58b81aaa7e343c11731f9aa5b4804c2a1823
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-01-04 13:00:40 +01:00
Alexey Edelev
18e62ed3b7 Pass QT_BUILD_STANDALONE_TESTS to Android external project if defined
If we configure qtbase standalone tests for multiple Android ABIs,
external project also needs the QT_BUILD_STANDALONE_TESTS flag enabled
to avoid configuring the whole qtbase but not only tests.

TODO: Need to forward all cache variables that are defined by user to
the external project since otherwise the configuration of the external
project will differ. Created QTBUG-99537 to track this.

Pick-to: 6.3
Change-Id: I3aec1391c850fb37696dc50416e0ff2a2646e759
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2022-01-04 12:50:28 +01:00
Alexey Edelev
d62463305d Fix build of multiple apks in a single project tree
ExternalProject_Add_Step adds the step timestamp file as the
dependency to a '-complete' file generated by add_custom_command
that is run inside the ExternalProject_Add function. Since the
'-complete' file path is computed using CMAKE_CURRENT_BINARY_DIR
we run into the issue if ExternalProject_Add and
ExternalProject_Add_Step are run from the different source
directories and have the different default binary directories as
well. This change suppresses the behavior by adding the
'EXCLUDE_FROM_MAIN TRUE' flag. We may do this since the target
related to the step is added to the dependency chain of executable
target and the chain of external project is not used for now.

Pick-to: 6.3
Change-Id: I7203261b61cfa56bcd9e49ac3e8d7ecb217a5a6c
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2022-01-04 12:50:24 +01:00
Alexey Edelev
2cb50b9fef Update internal function signatures
Update _qt_internal_add_android_deployment_multi_value_property and
_qt_internal_add_android_deployment_property signatures to match the
_qt_internal_add_android_deployment_list_property signature.

Pick-to: 6.3
Change-Id: Ie4fb2ebe96c783222fc4b56c3186e22b96cbbb95
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-01-04 12:50:18 +01:00
Alexey Edelev
585f46c811 Collect the apk dependencies regardless of target
_qt_internal_collect_target_apk_dependencies function is common for
all targets, but its signature was telling that it's target-specific.
This also causes an issue when we had more than one target in tree
that produce apk, since only first target got the property after
respective finalizer was executed. This change generalize the function
and uses _qt_internal_apk_dependencies target to store the extra
library directories from the build tree.

_qt_internal_add_android_deployment_list_property signature is also
changed to support reading values from multiple lists of multiple
targets.

Amends d20f4ae706

Pick-to: 6.3
Change-Id: I5b40fa96a0eb73348c0029e2b13c63a9465cb520
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2022-01-04 12:50:14 +01:00
Kai Köhne
6205cb161d Update copyright year to 2022
Pick-to: 5.15 6.2 6.3
Change-Id: If6f1d6f9f82a601f8e2b6d36650d6e737518aa60
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2022-01-04 12:44:19 +01:00
Laszlo Agocs
04cdde30d6 rhi: Enable exposing separate image and sampler objects from the shader
Adds the following in a QShader/QShaderDescription:

- a list of separate images
- a list of separate samplers
- a list of "combined_sampler_uniform_name" -> [
  separate_texture_binding, separate_sampler_binding ] mappings
  (relevant for GLSL only)

On the QShader (and qsb/QShaderBaker) level not having separate image
(texture) and sampler objects exposed in the reflection info is not
entirely future proof. Right now we benefit strongly from the fact
that Vulkan/SPIR-V supports both combined and separate
images/samplers, while for HLSL and MSL SPIRV-Cross translates
combined image samplers to separate texture and sampler objects, but
it is not given that relying on combined image samplers will always be
possible in the long run; it is mostly a legacy OpenGL thing that just
happens to be supported in Vulkan/SPIR-V due to some benefits with
certain implementations/hw, but is not something present in any newer
APIs.

In addition, before this patch, attempting to run a shader with
separate textures and samplers through qsb will just fail for GLSL,
even though SPIRV-Cross does have the ability to generate a "fake"
combined sampler for each separate texture+sampler combination. Take
this into use. This also involves generating and exposing a
combined_name->[separate_texture_binding,separate_sampler_binding]
mapping table for GLSL, not unlike we have the native binding map for
HLSL and MSL. A user (such as, the GL backend of QRhi) would then use
this table to recognize what user-provided texture+sampler binding
point numbers correspond to which auto-generated sampler2Ds in the GL
program.

Take the following example:

layout(binding = 1) uniform texture2D sepTex;
layout(binding = 2) uniform sampler sepSampler;
layout(binding = 3) uniform sampler sepSampler2;

Inn the reflection info (QShaderDescription) this (assuming a
corresponding qtshadertools patch in place) now gives one entry in
separateImages() and two in separateSamplers().  Assuming sepTex is
used both with sepSampler and sepSampler2, the GLSL output and mapping
table from QShaderBaker will have two auto-generated sampler2Ds (and
no 'texture2D' or 'sampler').

One immediate benefit is that it is now possible to create a shader
that relies only on separate images and samplers, feed it into qsb,
generate all the possible targets, and then also feed the SPIR-V
binary into a tool or library such as Tint (e.g. to generate WGSL)
that canot deal with combined image samplers.

Change-Id: I9b19847ea5854837b45d3a23edc788c48502aa15
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-01-03 14:57:01 +01:00
Marc Mutz
66a79287f1 [doc] QCoreApplication::installTranslator() doesn't take ownership
Document it.

Pick-to: 6.3 6.2 5.15
Change-Id: I25d305945bf29348d6ea5756fbf80c418f812d0f
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-01-03 13:35:13 +00:00
Laszlo Agocs
5ae238f90f rhi: Add the basics for HDR swapchains
...backed by support in the backends for D3D11 and Vulkan.

Expose only what works in practice: scRGB with RGBA16F and HDR10 with
RGB10A2 (or A2BGRA10 etc.). For general use, e.g. to render 2D/3D
content, scRGB (i.e. extended sRGB linear) should be chosen because
that is a linear space.

On Windows with a HDR10 display (and an NVIDIA card) both of these are
known to work, as long as Use HDR is enabled in the Settings for the
display on which the window is created.

When requesting a HDR format and it is not supported, we will fall
back to the default SDR RGBA8/BGRA8 format. However, the behavior
seems to be a bit weird with Vulkan and NVIDIA at least when there is
a HDR display but Use HDR is set to Off: this seems to enable HDR mode
for the lifetime of the window (with the usual set of black screens
while switching over the entire display). Not sure why the driver does
this. With D3D/DXGI, with fewer abstractions in the way, we can check
upfront properly, so that will nicely fall back to the defaults
regardless of why HDR is not available.

Support can also be checked in advance via
QRhiSwapChain::isFormatSupported() as long as the QWindow is
available. (though with Vulkan, as said above, this also seems to
ignore the Use HDR setting of Windows)

Complications, such as moving a window from one screen to another, are
currently not known how they behave. To be seen how this is handled by
the Windows compositor. (from 1903 and up it is said to be able to
automatically downconvert scRGB to SDR so perhaps moving from a HDR to
a non-HDR screen would work - remains to be seen if this needs
something more involved)

When it comes to other platforms and potential future support:
- based on its docs Android 8+ may support scRGB with Vulkan as-is on
a suitable device/display, as long as the application declares
android:colorMode="wideColorGamut" in the manifest.
- for Metal the layer can be made EDR enabled and then
e.g. MTLPixelFormatRGBA16Float/kCGColorSpaceExtendedLinearSRGB should
work. However, this won't be added unless we can test it.
- Linux is unknown.

If one needs access to display specific values such as the min/max
luminance when implementing tonemapping or a transfer function, that
needs platform/API specific approaches, and sadly the kind of data
exposed seems to vary, potentially making it difficult to maintain a
single cross-platform logic. With D3D one can get the
DXGI_OUTPUT_DESC1 from the IDXGIOutput6. This has the min/max
luminances in nits and a bunch of other things. For convenience the
output object is now exposed from the swapchain's nativeHandles()
whenever the D3D backend is used at run time. For Metal one would
presumably access maximumExtendedDynamicRangeColorComponentValue and
co. in the NSScreen. Elsewhere one needs to rely on platform/winsys
specific approaches, if there are any. Remains to be seen longer term
if/how this needs/can be better supported.

Change-Id: I2e61a0e062282d4bfdfba39655941c0f9a795112
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-01-03 14:35:13 +01:00
Alexey Edelev
f90221d8cd Replace ANDROID_ABI argument with the QT_ANDROID_ABI target property
This change tries to make the API more user friendly and prevent wrong
use of multi-abi API. ANDROID_ABI argument of qt6_add_executable was
position-depend and needed to be placed after the executable 'sources'.
Using the target property we solve this problem and provide more
consistent and common way to enable multi-abi build for the single
target.

This meanwhile also requires to execute multi-abi build configuration
in the finalizer, since the property might be set at any point.

Also the priority of the QT_ANDROID_ABI target property now is higher
than the priority of the QT_ANDROID_BUILD_ALL_ABIS variable. So target
will only build packages with the ABIs specified in QT_ANDROID_ABI
property if both are set.

Pick-to: 6.3
Task-number: QTBUG-88841
Change-Id: I3515297ed267974498913c59619433dc234ec217
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2022-01-03 14:35:13 +01:00
Marc Mutz
612417ea70 QRingBuffer: optimize and simplify QRingChunk::toByteArray() futher
- use sliced() instead of mid(), since we know we call sliced()
  in-contract

- replace the manual memmove() with calls to QBA::remove(), but first
  resize() to tailOffset, and only then remove(0, headOffset), so we
  only move Chunk::size() bytes, as the old code did

- don't bother updating the offset members, as we're restricted to
  rvalues now, and we only need to leave behind a partially-formed
  object

This code shows that we desperately need QBA::slice() and/or an rvalue
overload of QBA::sliced(), cf. QTBUG-99218. Add a comment to use these
functions when they become available.

Change-Id: I5d8c7363d443dff69338f6f6a7b4bff9957917ec
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2022-01-03 12:22:53 +01:00
Marc Mutz
7c8126d909 QTestData: fix streaming of u8 string literals in C++20 mode
...fixing tst_QLocale:

  QDEBUG : tst_QLocale::formatDate() expected data of type 'QString', got 'char8_t [64]' for element 1 of data with tag 'unicode in format string'
  QFATAL : tst_QLocale::formatDate() ASSERT: false in file /home/marc/Qt/qtbase/src/testlib/qtestdata.cpp, line 105

In C++20, the type of u8 string literals changed from const char[] to
const char8_t[].

[ChangeLog][QtTest][QTestData] Fixed streaming of u8 string literals
in C++20 mode.

Pick-to: 6.3 6.2 5.15
Task-number: QTBUG-99480
Task-number: QTBUG-99481
Change-Id: I53bd73522a4ebce307f360e225f25590f981d44a
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-01-03 12:22:53 +01:00
Marc Mutz
591a35d6fd QThread: fix UB (invalid enum value) on Private::Priority
The Unix code stores an additional flag, ThreadPriorityResetFlag, in
the Policy enum, but ubsan does not approve:

  qthread_unix.cpp:303:30: runtime error: load of value 2147483648, which is not a valid value for type 'Priority'
  qthread_unix.cpp:304:75: runtime error: load of value 2147483648, which is not a valid value for type 'Priority'

Fix by making the variable of std::underlying_type_t<Priority>.

The masking and unmasking code can now be simplified, too.

In the Windows version, replace some switch targets with equivalent
ones to keep -Wswitch-like warnings, though I hasten to note that both
switches use a default case, so have anyway implicitly disabled said
warning.

Pick-to: 6.3 6.2 5.15
Change-Id: Ie4ea7d05e2928d2755ad12d36535197f85493191
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-01-03 12:22:53 +01:00
Marc Mutz
c953e5c417 QByteArray: avoid detach() in a no-op replace()
When the the replacement has the same size as the replacee, but that
size is zero, the whole operation is a no-op, and there's no need to
detach().

[ChangeLog][QtCore][QByteArray] A replace(pos, n, after) call no
longer detach()es when n == after.size() == 0.

Pick-to: 6.3 6.2
Change-Id: I1e8d7c7fb6383f8bfea3212e49fca8a128535564
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-01-03 11:22:53 +00:00
Lars Knoll
ce14b6c2d3 Avoid crash on app startup if the default font family is empty
Don't call first() on a potentially empty list of families. Fixes
a crash on startup on QNX for me.

Change-Id: I551d21dac8cfd104b774d6442bdbe1db35f8b75c
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-01-03 09:00:04 +01:00
Björn Feber
68c4669ce4 Add PublicShare and Templates QStandardPaths
These directories are common on desktop operating systems. "Public" is
used for sharing files with other users and "Templates" lets you add new
files to the file creation desktop menu (for example in a file
manager). An example use in a Qt application would be KDE's KIO having
default icons for both directories.
This is where they point to:
Windows: C:/Users/Public, C:/Users/<USER>/AppData/Roaming/Microsoft/Windows/Templates
macOS: ~/Public, ~/Templates
Unix: ~/Public, ~/Templates

Task-number: QTBUG-86106
Task-number: QTBUG-78092
Change-Id: Ifca60c7d2a6dc2109ec290e8fb109ee2d5ca4d38
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-01 18:34:30 +02:00
Marc Mutz
ffcf4f4001 Extract Header qforeach.h from qglobal.h
Task-number: QTBUG-99313
Change-Id: Ie89314ca7022e88c1fea957880c5aa4a41640744
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-30 17:45:08 +00:00
Marc Mutz
f0ffe35149 QThread/Unix: extract duplicate code
Extract function terminate_on_exception() that de-duplicates the
#ifdef'ery around the try/catch and the handling of the pthread
cancellation pseudo-exception.

Apart from de-duplicating complex code, it will also help suppressing
a ubsan false positive, which is why we're picking it all the way to
5.15.

Pick-to: 6.3 6.2 5.15
Change-Id: I99ad2c0618b8dc30801931df09400c6611d9f9e4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-30 17:45:07 +00:00
Marc Mutz
c760fba40e QWindow: use std::exchange when ... exchanging values
Replaces a three-liner with a more elegant, idiomatic one-liner.

Pick-to: 6.3
Change-Id: I57fbe5d808dffa44f6fceffb97c47f0c84ccd3df
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-30 17:45:07 +00:00
Marc Mutz
c064b6bbfd QWindowPrivate: fix inconsistent inline on some methods
Two functions' implementations were marked as inline, when their
definitons weren't. This is non-sensical, bordering on dangerous, so
remove the inline keyword.

Pick-to: 6.3 6.2 5.15
Change-Id: Iece21f9552aede273fa1f5a7aef0c94307fa5142
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-30 17:32:09 +01:00
Nicholas Bennett
c90bb65926 Docs: Add other Unix paths to the Linux table in QStandardPaths
Added Unix to the title of the enum
QStandardPaths::StandardLocation docs Linux paths table as this
also aplies to Unix based OS's such as QNX.

Fixes: QTBUG-63695
Pick-to: 6.2 6.3
Change-Id: I37b1bb6167984ccf7877baf2e6e764337121a947
Reviewed-by: Tommi Mänttäri <tommi.manttari@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-30 14:54:58 +02:00
Marc Mutz
1181af9452 Eradicate Q_FOREVER from header files
The qgenericatomic.h occurrences are getting in the way of splitting
up qglobal.h, so inline the define.

Task-number: QTBUG-99313
Change-Id: I0d6e3553c5ed4ac9e426bef2fe07d2672d73c671
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-28 23:09:41 +01:00
Marc Mutz
a6bca753c9 QLocale: replace use of append(QString(n, c)) with resize(size() + n, c)
Avoids a temporary QString creation.

Change-Id: Ibc87a3f1bf2979780e4a2cce7e1757f97c39a9be
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-28 23:09:39 +01:00
Marc Mutz
795df9cdda QLocale: replace a few getData() with viewData()
Both multi-arg as well as QStringBuilder support QStringView these
days, so there's no need for a temporary QString, even one
fromRawData(), with all its extra codegen, when QStringView can do the
job just fine.

Change-Id: Ie9031aef85c5f0b535e94d9e414b7bd71ad909f7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-28 23:09:37 +01:00
Jarek Kobus
9453038921 Fix pattern type matching
Amends 3c747aafa4

Pick-to: 6.3 6.2 5.15
Change-Id: I2753b627c269cbb50009ef5e9c2ffa274e0ccf5c
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Alex Richardson <arichardson.kde@gmail.com>
2021-12-28 13:45:42 +01:00
Eirik Aavitsland
61a136bf26 Remove unused internal flag from raster painting engine
Just a leftover from code that has been replaced long ago.

Task-number: QTBUG-95237
Pick-to: 6.3 6.2 5.15
Change-Id: I8b1b0f319683ecfb2c93cc51a047616fe29770f7
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-12-28 11:20:13 +00:00
Jeremie Graulle
3162f04dee Windows: Fix handling of childGroups() when fallbacks are disabled
When fallbacks are disabled for QSettings then it should not be
falling back to any child groups or keys that might exist in a
fallback set of settings.

Fixes: QTBUG-85295
Change-Id: I563999293a103702035c8d3b027b59b94ca43c0e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-12-27 10:41:43 +01:00
Lorn Potter
be5508fad0 wasm: hardcode idealThreadCount for some browsers
Browsers like Safari do not support the hardwareConcurrency property.
Will hard code it to 2, as iOS only supports that amount.

Pick-to: 6.3 6.2
Change-Id: Icb35d3b698b28d8191a554167dc8cc262b806fb2
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-12-24 09:45:58 +10:00
Tor Arne Vestbø
2c3198ab5f macOS: Sanitize scroll deltas for NSEventPhaseCancelled
On macOS 12.1 the NSEventPhaseCancelled phase can in some situations
report deltas, which causes the scroll to "jump". This happens for
example when initiating a momentum-scroll, and then putting two
fingers on the trackpad to cancel the momentum phase, which starts
a new NSEventPhaseMayBegin phase. When then lifting the two fingers
again, we get an NSEventPhaseCancelled event with deltas, but the
deltas seem like uninitialized data (has a x-value, after doing
a purely vertical scroll e.g.).

Task-number: QTBUG-97841
Pick-to: 6.3 6.2 5.15
Change-Id: I14e765b6111e53e7d3d0da219d4ac7fefe5243d0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-12-23 19:53:22 +01:00
Thiago Macieira
60db7a5dc1 Doc: QSysInfo::productType: remove the "will be" note about Qt 6
Fixes: QTBUG-99413
Pick-to: 6.2 6.3
Change-Id: Ib42b3adc93bf4d43bd55fffd16c360797871011b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-23 15:26:35 +00:00
Thiago Macieira
1ed19dc018 QString: reorganize some template functions
This is going to screw up the git blame functionality (which is why they
were forward-declared instead of implemented on-site) but the
alternative is that Qt Creator thinks qstring.cpp had almost no
functions inside.

Pick-to: 6.3 6.2
Task-number: QTCREATORBUG-25594
Change-Id: Ib42b3adc93bf4d43bd55fffd16c1986f1a3c1574
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2021-12-23 11:41:32 -03:00
Tamas Martinec
d0908d0095 Document the State Machine Framework changes in the Core Migration Guide
Added section about having the State Machine Framework moved to its
own module.

Pick-to: 6.2
Pick-to: 6.3
Task-number: QTBUG-89285
Change-Id: I95d065230708d5b505d04309fd6ca21007d878dc
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Juha Vuolle <juha.vuolle@insta.fi>
2021-12-23 16:14:54 +02:00
Morten Johan Sørvig
23964ce05f wasm: Use new event dispatcher for QtGui
The event dispatcher implementation is now in QtCore,
except for the call to QWindowSystemInterface::sendWindowSystemEvents().

Implement QWasmWindow::requestUpdate() using emscripten_request_animation_frame(),
instead of the previous registerRequestUpdateCallback() function
which now is removed.

Pick-to: 6.3
Change-Id: I7a13eb5391d48dba0f2afe4704ef3188b8daa74b
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2021-12-23 11:21:57 +01:00
Morten Johan Sørvig
e98f5de6e1 wasm: add virtual processWindowSystemEvents()
The QtCore event dispatcher will be used from QtGui
as well. Add virtual function where window system events
processing can be added.

Pick-to: 6.3
Change-Id: Ia6eda9ae18b2e91189ef9f60b6621d19a83313de
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2021-12-23 11:21:53 +01:00
Yuhang Zhao
054b814daa Add QObject::isQuickItemType() for convenience
Change-Id: Ibde4e919ba028117336974eb7a804aa11c1ee086
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-12-23 17:38:47 +08:00
Oliver Eftevaag
b369dc6021 QTextHtmlParser: fix prefix lookahead and html comments
The hasPrefix() function would only use the second 'lookahead' parameter
to check if there was more unparsed text after the current character.
When it's obvious from the codebase that it should actually look ahead
of the current character being processed, and compare againt that future
character.

Html comments were also not handled quite right. Partially because of
the broken hasPrefix() function, but also because it would advance the
current index tracker by 3 instead of 2. Remember that the beginning of
an html comment is <!-- meaning that there are only supposed to be 2
dashes required, not 3. The result would be that something like this
<!----> would not automatically close, because the current index tracker
would jump over the first 3 dashes when it begins a comment, and the
remaining unprocessed string would be ->

Also, because of the broken lookahead in hasPrefix(), a comment could
actually be started with just <!- not requiring a second dash at all.

Pick-to: 6.3 6.2 5.15
Fixes: QTBUG-99147
Change-Id: I8f4d4a1107eaf2dae16d16b7b860525d45a1c474
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-12-22 15:56:30 +01:00
Volker Hilsheimer
0462d24dcd Deliver context menu event with correct coordinates to widgets in popups
If a popup is open, Qt delivers events to the popup child under the
mouse, so we need to correctly translate the local position of the
context menu event to that child's coordate system.

This is already done correctly for regular mouse events, so use the same
logic here.

Fixes: QTBUG-99371
Pick-to: 6.2 6.3 5.15
Change-Id: Ief24c755e76d4d1aa2304b06662ed26ae309f684
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-22 14:09:56 +01:00
Volker Hilsheimer
41f96866ee Windows: Don't crash in mouse handling when QApplication is recreated
We store the primary pointing device in a static variable to avoid the
lookup for each mouse event. However, when QApplication is destroyed,
then the device is destroyed, and the pointer needs to be reset so
that QApplication can be created again by the same process without the
first mouse event crashing the program.

Use QPointer to prevent the pointer from becoming dangling.

Fixes: QTBUG-99319
Pick-to: 6.2 6.3
Change-Id: Ie534c5eee48afb83e3a4adf70fc6cb4a2c310a7a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
2021-12-22 01:34:56 +01:00
Tor Arne Vestbø
7bd243b3fb macOS: Don't read keyCode of non-key events when inserting newlines
When the system input method decides to trigger an insertNewline
message it might come from a synthetic NSEvent of type AppKitDefined,
which does not respond to the keyCode message. Accessing the keyCode
would result in an exception being thrown.

We guard for this scenario by moving the keyCode access into the
key-press and -release specific parts of the KeyEvent constructor,
making the KeyEvent usable with generic NSEvents (even if that
means it will only pull out the timestamp and modifiers).

We also prefer to use the currently interpreted NSEvent, if one is
available, when preparing the synthetic newline event. This ensures
that we get a valid timestamp and modifiers, since the synthetic
AppKitDefined event that the system IM generates does not provide
valid values for these.

Fixes: QTBUG-99186
Pick-to: 6.2 6.3
Change-Id: I050ae2aa2d8ded1be3541f746e6c052f3546e27c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-12-22 01:34:56 +01:00
Marc Mutz
6d4102729f QRingBuffer: remove QByteArray::resize()-shrinks work-around
QByteArray::resize() is now documented to not shrink capacity(), so
remove the extra reserve(0) work-around.

Change-Id: I3d5d944b9f01f8f84b31599548773198903aad4c
Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
2021-12-21 22:56:00 +01:00
Marc Mutz
c47c98ea2b QDateTime: fix UB (signed overflow) in addDays()
The comment indicated that the author expected any overflow to be
caught by a bounds check in the subsequent function, however, signed
overflow is UB, so anything can happen.

Fix by using our API for safe additions instead.

Pick-to: 6.3 6.2 5.15
Change-Id: I41909defffa5305b02fdfcf6d5808e0d9fd5924f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-21 20:36:46 +01:00
Marc Mutz
52da10f645 QVariantAnimation: fix UB (FP 0/0) in interpolated() arg calculation
When startProgress, endProgress, and progress were all 0 (as provoked
by tst_QPropertyAnimation::startWithoutStartValue()), we'd calculate
0/0 and ubsan complained:

  qvariantanimation.cpp:284:60: runtime error: division by zero

Fix by detecting progress - startProgress == 0 and setting
localProgress = 0.0 in that case. This is a logical result, even
though it might not be what IEEE754 rules would have yielded.

A more comprehensive change that aims to reliably keep localProgress
∈ [0,1] and thus avoid the infinities when endProgress ==
startProgress, is outside the scope of this patch, which deals only
with the UBSan error.

Pick-to: 6.3 6.2 5.15
Change-Id: I5258b054a2060006795f49fb1cd7604aea3ed46b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2021-12-21 20:36:34 +01:00
Igor Kushnir
b330016cf2 QMimeDatabasePrivate: deduplicate QStandardPaths uses
Change-Id: I81dc76ddcf2aaa8aa6fdca504384ed72ad27f344
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-21 21:21:50 +02:00
Igor Kushnir
0dbbda670d QMimeDatabasePrivate: deduplicate QStringLiteral
defaultMimeType() cannot be moved out of the class and defined in
qmimedatabase.cpp, because it is called from QMimeType::isDefault() in
qmimetype.cpp.

Return m_defaultMimeType constant by reference rather than by value from
the inline helper function. This eliminates useless copying of QString
when calling code needs only a reference, and so improves performance.
Even though m_defaultMimeType is initialized with a QStringLiteral and
its QArrayDataPointer has d == nullptr, QArrayDataPointer's ref() and
deref() still have to compare d with nullptr to decide that no reference
count manipulation is needed. Compilers might be unable to reorder these
checks with surrounding code because they guard reference count
manipulation. Branch misprediction could further harm performance.
Optimizing these checks out can be difficult for compilers.

Change-Id: I3ffa0fdc5ad948452301dd9688073b5323a7983b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-21 21:21:50 +02:00
Marc Mutz
11409f4c02 QStringBuilder: handle freeSpaceAtBegin() in op+=
Amends 9b320edb53.

The above commit made the mistake of relying on the 30yr+ old
fundamental relation

    size() - capacity() == freeSpaceAtEnd()

which, however, Qt 6's prepend()-optimization (freeSpaceAtBegin())
broke. Because of that, while size() - capacity() may be large enough
to hold the new data, if freeSpaceAtBegin() > 0, then freeSpaceAtEnd()
may not.

Fix by inspecting freeSpaceAtEnd() instead of capacity(). The
following reserve() call is unaffected, since it internally already
adds freeSpaceAtBegin() to the requested size, which is why the
unconditional reserve() in 9b320edb535a0fbe118933d2e983b73f90c32685^
worked while 9b320edb535a0fbe118933d2e983b73f90c32685's capacity()
check did not.

Fixes: QTBUG-99330
Pick-to: 6.2 6.3
Change-Id: I520f36216011423f97a24484263acd40d8b1fa43
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2021-12-21 18:14:17 +01:00
Igor Kushnir
1efae2dcad QMimeDatabasePrivate: construct QString from QStringLiteral
In the changed code no QLatin1String overloads exist, so replacing
QLatin1String with QStringLiteral improves performance by eliminating
allocations.

Change-Id: I77530fe72c309b0609f40b1dc34189bd3454c813
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2021-12-21 17:05:20 +02:00
Igor Kushnir
b45141a4c6 QMimeDatabasePrivate: pass QLatin1String to QStringBuilder
This should be more efficient than passing QStringLiteral.

Change-Id: Ia96633c9db6cb287dd9c196e739047b8a46abb4d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-21 17:05:20 +02:00
Igor Kushnir
6ad6df88dc QMimeDatabasePrivate: remove Release-only fallback
When mimeTypeForFile()'s `mode` argument equals none of MatchMode
enumerators, an assertion fails or the default MIME type's name is
returned if assertions are disabled. Simplify and optimize this code by
assuming MatchDefault in the unsupported-mode case.

Change-Id: Iada36e0c96c378aefaa3a9d4a170222f764e94b6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-21 17:05:19 +02:00
Morten Johan Sørvig
5a47e29914 wasm: prevent thread cross-talk when logging
Emscriptens implementation of fprintf does not provide
mutal exclusion when called from multiple threads, for
the emsdk versions Qt 5.15, Qt 6.2, and current dev
is using.

Pick-to: 5.15 6.2
Change-Id: Ied92730b735b11e4e5e85442de48fc25cbad0611
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2021-12-21 15:05:19 +00:00
Volker Hilsheimer
d99800dcac Make sure that QCocoaWindowManager is initialized in static builds
If code has no external references, then with a static build of Qt the
linker is free to strip those object files from the final executable.
This is what happened with QCocoaWindowManager, which had no exported
symbols, and no callers from other files.

To prevent the linker from stripping the object file and to ensure that
the constructor function gets called during startup, move that
function declaration to the QCocoaIntegration code, which is always
loaded.

Fixes: QTBUG-99280
Pick-to: 6.2 6.3
Change-Id: Icdafea372a1b42c6ecdb43e36aeb0a04a70e3d4e
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-21 14:51:30 +01:00
Alexey Edelev
bde2764ab0 Check if QML plugin has the embedded QML files before copying to the Android bundle
We can detect if QML module has the embedded into the plugin QML files
using the 'prefer' record from qmldir files. No need to duplicate QML
files inside the android_rcc_bundle if 'prefer' record starts
with ':/'.

Pick-to: 6.3
Fixes: QTBUG-95984
Change-Id: Iee4f2248e3c0239c4f95a5db6e8fb3f16be636c5
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-12-21 13:17:37 +01:00
Igor Kushnir
153ded9b95 QMimeDatabasePrivate: remove unused output parameter
mimeTypeForFileNameAndData()'s output parameter int *priorityPtr (named
differently "accuracyPtr" in the definition) is never used by its
callers. Remove it to shorten the code and slightly improve performance.

Change-Id: Ibc3d169501e89584b4318074ccb780580dc70fb6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-21 12:13:57 +02:00
Igor Kushnir
7a4da201b5 QMimeDatabasePrivate: remove duplicate file-opening code
Don't open the file in mimeTypeForFile(), because mimeTypeForData()
opens a closed device in the same ReadOnly mode. mimeTypeForData() also
returns mimeTypeForName(defaultMimeType()) when the opening fails.

Change-Id: If0b03e2bef3c1b1a2093157e005373adc4e289ed
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-21 12:13:57 +02:00
Igor Kushnir
9eca0def34 QMimeDatabasePrivate: remove pessimizing const qualifier
mimeTypeForData() returns its local `QMimeType result` variable by
value. Make this variable mutable to allow moving from it.

Change-Id: Ic76e8382a5cacecc02e834a55f1ea86593c60674
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-21 12:13:57 +02:00
Igor Kushnir
49b726fa71 QMimeDatabasePrivate: remove duplicate else-if branch
In mimeTypeForFileExtension(), the `else if (matchCount == 1)` branch
differs from the `else` branch only in a comment. Remove the branch with
duplicate code, adjust the comment and simplify the `if` condition.

Change-Id: Ib97a057880373ab3ab9b585e688b38fe1f542ba2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-21 12:13:57 +02:00
Janne Juntunen
02f14d7afe qtestblacklist: add webOS support
Added support for blacklisting autotests for webOS platform
since it looks like we might have to blacklist some of those.

Task-number: QTQAINFRA-4706
Change-Id: I212be15161bd042f1511000ced2c8c022c3206e1
Reviewed-by: Jason McDonald <macadder1@gmail.com>
2021-12-21 12:13:57 +02:00
Volker Krause
7f54e113b9 Make QAbstractItemModel::insert|move|remove(Columns|Rows)[s]() invokable
Useful for example for calling those from QML.

Change-Id: I07fe32944c76b58cb074b6dd7eff17af1f0ae00f
Reviewed-by: David Faure <david.faure@kdab.com>
2021-12-21 08:04:17 +01:00
Zhang Hao
8678ab9354 Use qint64 to replace int while qt_transform_image_rasterize
When rotating a very large image(for example,the image size is
42000*24000),using QTransform will cause the the variable of the
qt_transform_image_rasterize function exceeds the range of int.
Fix this by Use qint64 to replace int.

Fixes: QTBUG-99163
Done-with: Eirik Aavitsland <eirik.aavitsland@qt.io>
Pick-to: 6.3 6.2 5.15
Change-Id: I11e2873fbb1f432953a1a8e07054f9478dd90fbd
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-12-21 09:24:56 +08:00
Igor Kushnir
047d8f36de QMimeDatabase::mimeTypeForFile: don't create QFileInfo on UNIX
When mode != MatchExtension is passed to
QMimeDatabase::mimeTypeForFile(const QString &fileName, MatchMode mode) const
a QFileInfo object is always created and used to check
QFileInfo::isDir(). Replace this expensive approach with a very cheap
(bitmask) S_ISDIR check under Q_OS_UNIX. QT_STAT is already called for
other reasons, so we just reuse its result in the S_ISDIR check.

Extract almost all code from
QMimeDatabase::mimeTypeForFile(const QString &, MatchMode) const;
QMimeDatabase::mimeTypeForData(QIODevice *) const;
QMimeDatabase::mimeTypeForFile(const QFileInfo &, MatchMode) const
into
QMimeDatabasePrivate::mimeTypeForFileExtension(const QString &);
QMimeDatabasePrivate::mimeTypeForData(QIODevice *);
QMimeDatabasePrivate::mimeTypeForFile(const QString &, const QFileInfo *, QMimeDatabase::MatchMode)
respectively. This refactoring is a less convoluted and more efficient
alternative to adding more mutex-unlocking hacks. The existing
QMutexLocker::unlock() calls are thereby eliminated.

The following table contains the average results of the benchmark
tst_QMimeDatabase::benchMimeTypeForFile() on my GNU/Linux system before
and at this commit. The numbers denote milliseconds per iteration.
This commit does not measurably affect performance when
mode == MatchExtension, therefore the MatchExtension section contains a
single column with results common to both commits (it is interesting to
compare benchmark results across match modes).

        data row tag                        before  at
MatchDefault:
        archive                             0.012   0.010
        OpenDocument Text                   0.012   0.010
        existent archive with extension     0.022   0.018
        existent C with extension           0.016   0.012
        existent text file with extension   0.017   0.012
        existent C w/o extension            0.072   0.067
        existent patch w/o extension        0.10    0.10
        existent archive w/o extension      0.064   0.060
MatchExtension:
        archive                                 0.0081
        OpenDocument Text                       0.0076
        existent archive with extension         0.012
        existent C with extension               0.0075
        existent text file with extension       0.0076
        existent C w/o extension                0.0122
        existent patch w/o extension            0.0091
        existent archive w/o extension          0.0091
MatchContent:
        archive                             0.0098  0.0078
        OpenDocument Text                   0.0098  0.0078
        existent archive with extension     0.051   0.047
        existent C with extension           0.051   0.047
        existent text file with extension   0.053   0.049
        existent C w/o extension            0.058   0.054
        existent patch w/o extension        0.099   0.095
        existent archive w/o extension      0.054   0.050

Change-Id: I01b37c9645f0d8d35fd1a6ea1c7a99be2faeeb73
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: David Faure <david.faure@kdab.com>
2021-12-20 20:43:27 +02:00
Alexey Edelev
fe7fc3f23e Copy only files that belongs to QML module
Instead of copying all files that the QML module directory contains,
this approach only copies files that belong to the QML module
according to the qmlimportscanner output.

Pick-to: 6.3
Fixes: QTBUG-97834
Change-Id: I881a6fba28ca24be4f33de8693b41b6dfefe8d6b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-12-20 18:08:10 +01:00
Marc Mutz
620220413e CMake: don't treat Q_CORE_EXPORT special
Let CMake create a qtcoreexports.h just like for every other Qt
library, include it in a fitting place in qglobal.h. Currently, that's
in the middle of the file, but that will be cleaned up in subsequent
commits.

Task-number: QTBUG-99313
Change-Id: I3ea9f4772b0ad63c7e8431689146cac3336c5ccf
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2021-12-20 13:32:28 +01:00
Tianlu Shao
87b93c29be QtConcurrent::run crashes on program exit
When an application is about to be closed and all the
destructors are called, if there isQtConcurrent::run on
the way, it crashes as the internal threadpool pointer
is nullptr.

Fixes: QTBUG-98901
Pick-to: 6.2 6.3
Change-Id: Idd84d1518fc6a225263e6666a0f1de2ccef79c82
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2021-12-20 13:18:26 +01:00
Ivan Solovev
5cc7510801 QZipReader: update to unzip partly broken archives
The problem was discovered while providing a fix for the linked issue.
The original zip archive is very old, and it does not contain separate
entries for directories, only for files.
As a result, QZipReader algorithm was failing to create all the
necessary subdirectory structures, and unzipping failed.

This patch detects such case, and creates a directory hierarchy based
on the file paths.

Task-number: QTBUG-81503
Pick-to: 6.3 6.2 5.15
Change-Id: I204f9b620853b3ffcbb9cbf6fe08fb5958776ea0
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-12-19 18:58:40 +01:00
Thiago Macieira
8db16bfa7e QString: use char16_t in isAscii() instead of QChar
Drive-by simple clarification of the code that needed to be touched
anyway.

Pick-to: 6.3 6.2
Change-Id: Ib42b3adc93bf4d43bd55fffd16c14f984b0fb592
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2021-12-18 18:09:21 -03:00
Thiago Macieira
1a9e7a3aad QString: don't let the compiler emit unnecessary looping
When AVX2 was enabled, we know we don't need to loop in qt_is_ascii()
(QtPrivate::isAscii(QLatin1String)).

Pick-to: 6.3 6.2
Change-Id: Ib42b3adc93bf4d43bd55fffd16c14f8f95ae8678
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2021-12-18 18:09:19 -03:00
Thiago Macieira
449f6d5f61 QString: replace an #if with if
Pick-to: 6.3 6.2
Change-Id: Ib42b3adc93bf4d43bd55fffd16c111291d1e8ddd
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2021-12-18 18:09:17 -03:00
Marc Mutz
9b320edb53 QStringBuilder: fix quadratic behavior in op+=
QByteArray and QString honor a reserve(n) faithfully, meaning that if
n > capacity(), then capacity() == n after the reserve() call.

This is expected behavior, and also what libstdc++'s std::vector does.

The problem is QStringBuilder's op+=, which calls reserve()
unconditionally to ensure capacity for its resize-after-append
magic. If a user builds up a string by repeatedly appending
string-builder expressions, these repeated minimal-progress reserve
calls destroy the string's natural geometric capacity growth, turning
it linear instead, and hence the whole construction becomes quadratic.

Fix by calling reserve() only when necessary, and for a maximum of
O(logN) times, N being the separate calls to QStringBuilder's op+=.

This guarantees amortized-linear runtime of string building again.

Need to insert an explicit detach() call in reserve()'s stead, lest a
detach() in the following data() would reset capacity() to size().

Copied a useful comment from the QByteArray case to the QString case.

[ChangeLog][QtCore][QStringBuilder] Fixed quadratic behavior when
repeatedly appending string-builder expressions (using operator+=) to
QString/QByteArray objects.

Pick-to: 6.3 6.2
Change-Id: I1c210a8d0026c227e55e5e30a46fb747660bb66e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
2021-12-17 23:50:01 +01:00
Lars Knoll
1cc5948839 QHash: Return void from QHashPrivate::Data::erase()
This removes some calculations that are not required in
80% of the cases where d->erase() is being called (as
the return value is ignored). When removing lots of
elements from the hash, the ++it could loop quite a
bit until it found the next valid item in the hash.

This chain of changes combined improve the overall performance of
QHash by 10-50% depending on the operation. Deletes are twice
as fast, reads around 20% faster, inserts around 10% faster.

Task-number: QTBUG-91739
Fixes: QTBUG-98436
Change-Id: I2d82a7c9dd1dd0a4da8402e6d95bfd620caeff3a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2021-12-17 20:21:28 +01:00
Thiago Macieira
46dc8e453a QVariant: use a typedef name when saving user types to QDataStream
Due to the way Qt 5 and 6 registered type names, they end up producing
different type names for the same content for a typedef. For example,
because Q_DECLARE_METATYPE can't manage a comma (it's a macro), users
are forced to write something like:

 using MyTypeMap = QMap<QString, MyType>
 Q_DECLARE_METATYPE(MyTypeMap)

Qt 5's Q_DECLARE_METATYPE's argument "MyTypeMap" was the only name we
knew about the type, so that's what got saved in the stream. However, Qt
6 QtPrivate::typenameHelper is much more clever and obtains the name
from the compiler itself, so it "sees through" the typedef and registers
"QMap<QString,MyType>" as the official type name.

If another library/plugin has a different typedef name for the same type
(e.g., StringTypeMap), it's indeterminate which type gets saved and will
even change from run to run (depends on the QHash order).

[ChangeLog][QtCore][QDataStream] If QDataStream is used with a
QDataStream::Version < Qt_6_0 to serialize a user type that was
registered via a typedef with the metatype system, the typedef's name is
used in the stream instead of the non-typedef name. This restores
compatibility with Qt 5, allowing existing content to read the same
QDataStreams; reading from older Qt 6 versions should not be affected.
(Note: if more than one typedef name is registered, it's indetermine
which name gets used)

Fixes: QTBUG-96916
Pick-to: 6.3 6.2
Change-Id: I2bbf422288924c198645fffd16a8d811aa58201e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-12-17 17:54:05 +01:00
Lars Knoll
9c9cdbedf1 QHash: Add and use a Bucket helper class
Introduces a QHashPrivate::Data::Bucket class. This class
helps avoid repeated bitshift and masking operations when
locating bucket entries in the hash.

Change signature of some internal methods to use Bucket
instead of the private iterator, so we can avoid repeated
encoding/decoding steps for the bucket index.

Task-number: QTBUG-91739
Task-number: QTBUG-98436
Change-Id: I9ed2205bf886f9c20a5be109fd88456eec4d1540
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-17 17:37:49 +01:00
Marc Mutz
c31fecd27f QByteArray: fix UB (precondition violation) in replace()
If after.isNull(), then we called memcpy with a nullptr, which is UB,
even if the size is zero, too.

memmove() has the same precondition.

Fix by guarding the memcpy() call with an explicit length check.

The Qt 5.15 code is sufficiently different to not attempt to pick
there.

Pick-to: 6.3 6.2
Change-Id: I86a2f00ede6ca8fab8d4222f84dccf375c4a2194
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-17 12:34:27 +01:00
Thiago Macieira
4631b61c81 Q_{APPLICATION,GLOBAL}_STATIC: use variadic macros
We can't remove Q_GLOBAL_STATIC_WITH_ARGS, for compatibility reasons.
It's also the only way to pass uniform initialization (i.e., initialize
the value as value{with_braces}), though I don't think this is used
almost anywhere due to the fact that you couldn't pass more than one
argument. But Q_APPLICATION_STATIC is new in 6.3, so we have time to
change it.

[ChangeLog][QtCore][QGlobalStatic] The Q_GLOBAL_STATIC macro is now
variadic. Any extra arguments are used as constructor arguments,
obliterating the need to use Q_GLOBAL_STATIC_WITH_ARGS().

Pick-to: 6.3
Change-Id: Ib42b3adc93bf4d43bd55fffd16be3656a512fe53
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2021-12-17 07:56:24 +00:00
Marc Mutz
48b4f144e7 QRingBuffer: simplify QRingChunk special member functions [2/2]
Use NSDMI and let the compiler generate the default ctor, too.

Statically assert that it's still noexcept (we marked it as such,
because MSVC still doesn't noexcept(auto) when an SMF is =default'ed.

Simplify the other ctors, too, relying on NSDMI. Keep one instance of
tailOffset(0), in the 'reserving' ctor, because it's inconsistent with
the other ctors which all do tailOffset{chunk.size()}, so it's best to
leave this explicit, lest the next reader wonders whether it was
forgotten.

Pick-to: 6.3
Change-Id: I0d9f91aa5bc89377c4144589df8786b502e956a4
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-17 07:52:40 +00:00
Dimitrios Apostolou
725fc4da44 Properly indent qtestlib's XML output
Also regenerate the expected output for tst_selftests, to match new
output. Changed one line source code in tst_seftests for the
same purpose.

Change-Id: I930ba4bb290568d6f67a8910a781725f01f08bf1
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-17 07:03:26 +01:00
Yuhang Zhao
18bc5d652f Windows QPA: Enhance debug information
https://docs.microsoft.com/en-us/windows/win32/winmsg/window-styles
https://docs.microsoft.com/en-us/windows/win32/winmsg/extended-window-styles
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowpos

Change-Id: I54392b36c52c4318c0d2d5489bbfd582ff7bccb3
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-12-17 13:18:22 +08:00
Marc Mutz
dc1c0536bb QByteArray: optimize replace() a bit
These days, we perform the alias check unconditionally, so the remainder of the function can assume that *this and after do not overlap. So memcpy() suffices, we don't need memmove().

Pick-to: 6.3 6.2
Change-Id: Ib6966facfe643b0aaf50d902709f5fe926bed527
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-17 03:20:22 +01:00
Tatiana Borisova
387797e923 Fix INTEGRITY runtime qobject issue
- There is no space symbol in the expression evaluation by GHS compiler.
  Because of space in prefix constant, begin pointer is moved too far and
  skips 1 letter in the class name. In result, on testing stage we see:

  I/O: FAIL!  : tst_QObject::property() Compared strings are not the same
  I/O:    Actual   (property.typeName())    : ropertyObject::Alpha
  I/O:    Expected ("PropertyObject::Alpha"): PropertyObject::Alpha

Pick-to: 6.2 6.3
Change-Id: I52759860fd26b8d50df96dcc4ab0a6b005329a9f
Reviewed-by: Kimmo Ollila <kimmo.ollila@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-16 19:45:08 +02:00
Marc Mutz
795e7dd091 QString: scope a loop variable correctly
The variable idx isn't used outside the respective loops, so make it loop-local.

Change-Id: I62807cb244b068ce4df42812a0e4b99a1f488adc
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
2021-12-16 18:45:07 +01:00
Marc Mutz
6830bdc140 QString: fix UB (pointer arithmetic on nullptr) in qLastIndexOf
Says ubsan:

  qstring.cpp:10484:17: runtime error: applying non-zero offset 18446744073709551614 to null pointer

If we search for a null needle, we stored 0-1 in a size_t variable and
unconditionally appied that offset to the needle's data() pointer. That
being the nullptr, ubsan complained.

To fix, set sl_minus_1 to 0 if it would underflow. In that case,
sl_minus_1, n, and h, are not used, anyway, so their values don't
matter as long as we don't invoke UB.

Pick-to: 6.3 6.2 5.15
Change-Id: Idca4e845c77838dfc84acdb68bbbc98382b5e1d5
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-16 18:45:07 +01:00
Lars Knoll
d1626ca6b0 Fix hash lookup using the value of a key iterator
QHash::operator[] could grow the hash even if the key being
looked up already existed. This in turn invalidated all iterators.
Avoid this by refactoring findOrInsert() to not grow if the key
already exists.

Added advantage is that this should make lookups of existing keys
slightly faster.

Fixes: QTBUG-97752
Pick-to: 6.3 6.2
Change-Id: I9df30459797b42c434ba0ee299fd1d55af8d2313
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2021-12-16 18:44:01 +01:00
Thiago Macieira
19d231e47d QThread::idealThreadCount: use the thread affinity set
Instead of returning the total number of logical processors in the
system, which we may not be allowed to wholly run on, use the affinity
set that the calling thread is allowed to use.

Implemented for Linux and FreeBSD only, with up to 4x the number of
processors than CPU_SETSIZE has as default (that would be 4096 logical
processors on Linux, 1024 on FreeBSD). Implementation for Windows is
possible, but the API there is always limited to 64, so I'm unsure if it
is correct. Darwin (macOS) does not have this capability.

Testing:

 $ ./tst_qthread idealThreadCount | grep QDEBUG
QDEBUG : tst_QThread::idealThreadCount() Ideal thread count: 8
 $ taskset 3 ./tst_qthread idealThreadCount | grep QDEBUG
QDEBUG : tst_QThread::idealThreadCount() Ideal thread count: 2

[ChangeLog][QtCore][QThread] idealThreadCount() will now return the
number of logical processors that the current process (thread) has
assigned in its affinity set, instead of the total number of processors
in the system. These two numbers can be different if the process is
launched by the parent with a different affinity set, with tools like
Linux's taskset(1) or schedtool(1). This is currently implemented for
Linux and FreeBSD.

Change-Id: I2cffe62afda945079b63fffd16bd086f64f5f314
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-16 09:24:26 -08:00
Thiago Macieira
c54fb03446 QGlobalStatic: don't use a std::aligned_union if we can be a union
Simplifies further the code with C++11 unrestricted unions.

Pick-to: 6.3
Task-number: QTBUG-99122
Change-Id: Ib42b3adc93bf4d43bd55fffd16c0b6677441bf55
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2021-12-16 17:24:26 +00:00
Volker Hilsheimer
e832a805c1 QCache: remove dead code
The Node::replace overloads and the Node::create method are not used
anywhere (including in QHash).

Pick-to: 6.2 6.3
Change-Id: I1f1f8c847c8f1181cd31d95d01997226f94b5fc4
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-12-16 14:02:28 +01:00
Marc Mutz
735e2f787a QRingBuffer: simplify QRingChunk special member functions [1/2]
Let the compiler generate the copy and move SMFs.

Statically assert that the move SMFs are still noexcept.

Pick-to: 6.3
Change-Id: I1c569bdf893a5f2cda972c0dd8196cab62494fcb
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-16 12:47:39 +01:00
Marc Mutz
e381288146 QRingBuffer: restrict QRingChunk::toByteArray() calls to rvalue *this
It's only user, QRingBuffer::read(), calls it on an rvalue, so we
don't need the lvalue overload, and we can devil-may-care-like just
std::move(chunk) in the non-isShared() case.

Change-Id: I99c16862f5586125c6346ce5f969dc735de738b8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-16 12:47:39 +01:00
Marc Mutz
b01c05ef9b QtWidgets: auto-test-export private classes, unbreaking ubsan builds
These classes are used in their respective tests, but since these only
seem to access data members, the missing export macro was never
detected. UBSan, however, checks the type_info on each access, so it
needs the (polymorphic) class exported.

Do so (for -developer-builds).

Change-Id: I97b41cfb5dd7f1665cdf4f7a819a42fbf0388621
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-16 09:12:57 +01:00
Marc Mutz
a663b56627 QSslSocket: export QSslSocketPrivate, unbreaking ubsan builds
Only individual members were exported, but that's not enough; ubsan
needs the vtable and type_info:

  qtbase/src/plugins/tls/openssl/CMakeFiles/QTlsBackendOpenSSLPlugin.dir/qtls_openssl.cpp.o:(.data.rel+0x1f8): undefined reference to `typeinfo for QSslSocketPrivate'

Pick-to: 6.3 6.2
Change-Id: Ic22805af1ac7f4b3ad48532e4ba689d12ee4a4b9
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-16 09:12:09 +01:00
Marc Mutz
e14d0ff8f2 QRingBuffer: simplify QRingChunk::detach()
Just use the QByteArray(ptr, n) ctor instead of the (n,
Qt::Uninitialized) one + memcpy() + std::move().

Pick-to: 6.3
Change-Id: I127219c21556e683d15136f7e6f7b3576b7b2444
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-16 00:01:41 +01:00
Marc Mutz
81bf3e68b9 Make QRingBuffer a move-only type
There's no sense in copying a ring buffer. Moving is enough. This
marks an important step on the way to preventing accidental copies of
ring buffer content, because the 'QList buffers' member can now no
longer be implicitly shared. While the compiler will still emit the
code for detach()ing, it will now never be executed.

Pick-to: 6.3
Change-Id: I968bfe3e50c46720ed4baca55c99c1f9c518f653
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-16 00:01:41 +01:00
Marc Mutz
758a830f7e QRingBuffer: overload append() for rvalues
The majority of append() callers in QtBase pass rvalues, so overload
append() to avoid the need for manipulating QBA's atomic ref counts.

Also adjust a caller that could pass by rvalue, but didn't, to do so.

Pick-to: 6.3
Change-Id: I3d9e60b0d04ef837bfdc526e1f0f691a151006f9
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-15 18:36:00 +00:00
Marc Mutz
63a35898f4 QIODevice: use QVLA to hold the ring buffers, not QList
The only users of more than one read- or write channel are the SCTP
code and QProcess. SCTP being pretty rare, optimize for the common
case of at most two QRingBuffers for reading (QProcess) and one for
writing.  Even with more channels, QVLA shouldn't be slower than QList
- on the contrary.

Need to adjust tst_toolsupport and TypeInformationVersion, as
QFilePrivate::fileName has changed.

Pick-to: 6.3
Change-Id: I3baf982ba1f4dc51463be8730e414f6164072d8b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-15 17:35:13 +00:00
Marc Mutz
7ef6140170 QLogging: fix potential missing NUL-terminator when calling OutputDebugString
The string returned from QStringView::utf16() is, in general, not
NUL-terminated, as OutputDebugString() requires. Though we only ever
call win_outputDebugString_helper() with an actual QString, it's not
100% clear said QString doesn't originate from, say, a QStringLiteral,
in which case QString::utf16() would have to (an does) detach() to
ensure the NUL-termination.

So, take by const QString&, but use QStringView::mid() to avoid
copying the substring content twice.

Amends a049325cc7.

Pick-to: 6.3 6.2 5.15
Change-Id: Ie42a6000c75c6a55d629621d89e0cf498b174d29
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-15 18:35:13 +01:00
David Skoland
12511c9941 Declare params in qwasmclipboard unused
Without this, it won't compile with the -developer-build configure
option (warnings are errors)

Pick-to: 6.3 6.2
Change-Id: I114370e918d63bd6e8855b5f750999cf372e2f6d
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2021-12-15 18:04:48 +01:00
Morten Johan Sørvig
44d2f97bff wasm: implement socket notifier support
Implement socket notifier support using Emscripten’s
socket callbacks.

This is sufficient for supporting non-blocking (tunneled)
TCP and UDP sockets on the main thread.

Change-Id: Ib9ee2698d029fb94d954c6872f8e118b0aa15499
Reviewed-by: David Skoland <david.skoland@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2021-12-15 17:06:11 +01:00
Morten Johan Sørvig
76d12eea22 wasm: implement host lookup for socket tunneling
Emscripten implements support for tunneling TCP and
UDP sockets through a WebSockets connection. This support
is implement for the BSD sockets API, which means that
Qt’s existing socket classes can be used, with some
adjustments.

For example, the flow for making a TCP connection to
example.com:1515 can look like this:

1) The application resolves “example.com”.
   Emscripten creates an internal mapping to a private
   IP and returns that IP: 172.29.1.0.
2) The application connects to 172.29.1.0:1515.
   Emscripten makes a WebSocket connection to example.com:1515,
   and forwards the TCP data over this connection
3) On example.com:1515, a WebSockify intermediate server
   accepts the WebScoket connection and forwards the
   TCP data to the target sever, as specified by the
   WebSockify configuration.

Emscripten’s local getaddrinfo() implementation is fast,
which means don’t need caching or the thread pool. Instead,
special-case lookupHostImpl() for Q_OS_WASM. The implementation
calls QHostInfoAgent::lookup() and then posts resultReady
using QHostInfoResult.

Change-Id: Iaf31efb701ae7cc11752a63cc6b8346d4f09107e
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2021-12-15 17:06:11 +01:00
Morten Johan Sørvig
4184a127fa macdeployqt: don’t err on unexpected otool output
Binaries with multiple slices (e.g. arm64, x86_64)
will have an extra line for the slice, like:

“/path/to/QtGui.framework/QtGui (architecture arm64)”

The parsing code will skip this line since it does
not match the regexp. In other words the parsing works
by looking for lines which matches, and finding lines
which don’t match is not an error condition.

Pick-to: 6.3
Task-number: QTBUG-98466
Change-Id: I0afebdc0dd19e76de00157518f3409d690f18fc0
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-12-15 15:43:16 +01:00
Alexey Edelev
f51d677948 Fix the copy path of the binary when building for Android in QtCreator
The target path of copy command should include
'libs/${CMAKE_ANDROID_ARCH_ABI}' to make the apk build procedure work
correctly in QtCreator.

Amends 87db26bdfe

Pick-to: 6.3
Change-Id: Icaffc3d7418a9a4994f86e453b329a69452c5f0b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-12-15 13:07:10 +01:00
Ralf Habacker
2e2f1e2af7 Add css media rule support for QTextDocument::setHtml()
CSS styles can contain '@media <rule> {...}' blocks, which were
previously ignored for all values except "screen".

To use a media rule other than the default "screen" rule,
specify it before calling setHtml() with setMetaInformation()
and the new info value 'CssMedia'.

[ChangeLog][Gui][QTextDocument] Add css media rule support
for QTextDocument::setHtml()

Pick-to: 6.3
Fixes: QTBUG-98408
Change-Id: Ie05f815a6dedbd970210f467e26b116f6ee3b9ca
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-12-15 11:36:37 +00:00
Marc Mutz
5f305e51b5 QRingBuffer: simplify QRingChunk::clear()
Clear should bring the QRingChunk into the default-constructe state,
so just assign {} instead of calling assign(QByteArray()), which is
equivalent, but has to manipulate QBA's atomic ref-count, which makes
it unlikely the compiler will optimize this call.

Pick-to: 6.3
Change-Id: Idab9c92ec84392d484395042db2427c668756efa
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-15 08:20:28 +01:00
Yuhang Zhao
5d12942676 Windows QPA: Correctly respond to WM_ERASEBKGND
According to Microsoft Docs [1], applications should
return non-zero in response to WM_ERASEBKGND if it
processes the message and erases the background and
that's indeed the case for Qt.

Although I can't see any visual difference, this patch
obeys the official documentation at least.

[1] https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-erasebkgnd

Pick-to: 6.3 6.2
Change-Id: I8aa0bfb25259013bfc2ca4074f05a97c7865159c
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-12-15 13:02:39 +08:00
Yuhang Zhao
877d6cf6f6 Windows QPA: Remove extra class name from the function name
Change-Id: Iabe7c0093acc9b892182aa7e69e5af50abf61275
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-12-15 09:41:12 +08:00
Marc Mutz
9a7d2a7acf QVarLengthArray: avoid std::aligned_storage (deprecated in C++23)
Add some scaffolding to prevent us from running into BC issues due to
the underspecified nature of std::aligned_storage.

Qt 5.15 uses a union { char[], double, qint64 } instead of
std::aligned_storage, so doesn't need the fix.

References:
- https://github.com/cplusplus/papers/issues/197
- wg21.link/p1413

Task-number: QTBUG-99122
Pick-to: 6.3 6.2
Change-Id: I212be7000376c2db33b8cb244a6e862cc4dad544
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-15 01:33:05 +01:00
Marc Mutz
daaa3088ec QVarLengthArray: don't allow syncqt to export base classes
Check, in tst_qvarlengtharray, that the forwarding header still works.

Pick-to: 6.3
Change-Id: Ia03cf48457f538287880bb676aea3fa44aeb255f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-15 00:04:45 +01:00
Marc Mutz
c4016f9564 QByteArray: sprinkle API with noexcept
Mark (const) data()/begin()/end()/size()/empty() and similar as
noexcept.

Move some trivial definitions into the class body.

Pick-to: 6.3
Change-Id: I6f3ab792264347cdc6a476dacecf065f59f16ff9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-14 22:53:12 +01:00
Pasi Petäjäjärvi
64cff16e0d QNX: Fix QLockFile support
Implement getting pid by process name and enable using flock().

Pick-to: 6.2
Change-Id: I500e645b451baddea788d834374a7ae29a4d223f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-14 21:50:52 +02:00
Tor Arne Vestbø
ae6dc7d6df Fix qt_scrollRectInImage when scrolling outside of the image
We were clipping the source rect to the image, both pre and post
scrolling, but did not apply the same logic to the target position.
By computing the target position based on the already clipped source
rect we ensure that the target position is also correct.

This was causing valgrind warnings on Linux, and crashes on Windows,
when trying to test the lower level QBackingStore::scroll() function.
The reason we were not seeing this in practice was that QWidget does
its own sanitation and clipping of the arguments before passing them
on.

As a drive-by, fix the access of image to use constBits instead of a
manual cast, and rename variables to better reflect their use.

Pick-to: 6.3 6.2 5.15
Change-Id: Ibc190c2ef825e634956758f612a018f642f4202b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-12-14 14:11:26 +01:00
Lars Knoll
340c0c2ab0 QHash: Improve memory-allocation strategy
Be smarter when allocating memory for the real data in
addStorage(). As the amount of entries in there follow
a binominal distribution, we know pretty well, how many
there will be at least and at most. This avoids most of
the reallocations of the storage when not rehashing, while
Tessil's tests show that the total memory consumption has
not changed.

Task-number: QTBUG-91739
Task-number: QTBUG-98436
Change-Id: I98854bfbde8b2a16e788bfa1890c694d38fd09b5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-13 18:58:36 +01:00
Lars Knoll
9836dbd6ee QHash: increase minimum buckets to a full span
Change the minimum amount of buckets to be at least
128, ie. one full Span. This will simplify some assumptions
in the code.

Regeneration of rcc test-data needed because the extra buckets
causes the order of the keys to change.

Task-number: QTBUG-91739
Task-number: QTBUG-98436
Change-Id: Ic0c7da03570cc4c4e6aacc9645e536aec3667a98
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-13 18:58:36 +01:00
Mårten Nordheim
333a284ccf QHash: Move span constants to its own struct
To avoid needing a templated Span to access them

Task-number: QTBUG-98436
Change-Id: I5c3b16f9a806986b14ed794a3818990aa3ead0f7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2021-12-13 18:58:36 +01:00
Mårten Nordheim
e508c4c094 QCache: Adapt to upcoming QHash changes
QHash changes some of its preconditions, so we must not call
findNode without verifying !isEmpty()

Task-number: QTBUG-91739
Task-number: QTBUG-98436
Change-Id: I2701b9a01187530f541a7c9a12db56c92f856d87
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-12-13 18:58:36 +01:00
Vladimir Belyavsky
20d869f4c5 QGlyphRun: always use stored bounding rect even if it's empty
QGlyphRun's bounding rectangle may have zero width, e.g. when it
contains only non-printable characters. Some code, e.g.
QTextLine::glyphRuns(), may pre-calculate bounding rectangle for
QGlyphRun and store it inside via QGlyphRun::setBoundingRect().

Previously, we would ignore empty rects as an indication that no
bounding rect had been set on the QGlyphRun. This should be
checking for valid rects instead, to allow for runs containing
non-printable characters exclusively.

Fixes: QTBUG-96463
Pick-to: 6.2
Change-Id: Ia934749cfda37e60ebf98fb76536434054baa4d1
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-12-13 16:43:47 +00:00
Mike Achtelik
3f6041fb82 QNetworkAccessBackend: Fix living QObjects after QCoreApplication shutdown
Since switching to the plugin bases system for the network backends,
Qt again retains some QObjects after QCoreApplication shutdown.
This was previously fixed in QTBUG-84234, so make sure we destroy the
newly introduced QObjects as well.

Task-number: QTBUG-84234
Change-Id: Ibb411c2dfb716b8f2aea2a3e366253fbd9dd8f64
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-13 16:18:06 +01:00
Mårten Nordheim
85c5ae2ab8 QHash::insert: Remove outdated \note
It was added in 5.15 when QHash could have multiple entries per key.

Pick-to: 6.2 6.3
Change-Id: Ifb855b05dd65bbc67bb64bf2567229394525b2aa
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-12-13 14:16:25 +00:00
Thiago Macieira
81a31beeb2 Rewrite Q_{GLOBAL,APPLICATION}_STATIC with C++17 goodies
Especially static inline variables. This greatly reduces the amount of
code that existed in macros, moving them to templates.

Additionally, this removes one level of indirection from
Q_APPLICATION_STATIC by removing the std::unique_ptr. We now directly
manage the object's storage.

Change-Id: I2cffe62afda945079b63fffd16bcc825cc04334e
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2021-12-12 14:25:42 -08:00
Sona Kurazyan
ed546ff216 QtFuture::connect: exclude QPrivateSignal from the resulting future type
Filter out the last argument of type QPrivateSignal from the signal's
arguments passed to QtFuture::connect().

Pick-to: 6.2
Fixes: QTBUG-92501
Change-Id: Idcd6baba1f01fcc94fa64b1c7030a629d01ed7a1
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-12-11 21:47:17 +00:00
Thiago Macieira
799660d679 QLockFile/Linux: skip QFileInfo if we're just doing string manipulation
Avoids a lot of overhead. Could be even simpler, but we don't need to
duplicate QFileSystemEntry.

Pick-to: 6.2
Change-Id: Ib42b3adc93bf4d43bd55fffd16beda971e4b2ae7
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Igor Kushnir <igorkuo@gmail.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2021-12-11 11:54:36 -08:00
Thiago Macieira
154d87f23f Enable other integer sizes in the bootstrap library's QAtomicInteger
They're not atomic anyway. But it does make it possible to use
QAtomicInteger in both bootstrapped and non-bootstrapped code.

Change-Id: I2cffe62afda945079b63fffd16bcc67e082d92ae
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-12-11 11:54:36 -08:00
Marc Mutz
c38639089f QVarLengthArray: assert that the range passed to erase() is valid
We already checked that the two iterators, indvidually, are valid, but
we didn't check that the range formed by them is valid, namely that
the end iterator is reachable from the start iterator.

Add an assert, because if the range isn't valid, we run into UB in the
std::move() algorithm two lines later.

Qt 5.15 uses std::copy() here, which has the same precondition, so the
assertion would make sense there, too.

Pick-to: 6.2 5.15
Change-Id: I90b7e846455ff86383a8971bea908036684961d8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-11 17:27:05 +01:00
Marc Mutz
7670db3146 QVLA: separate control from inline storage [11/11]: qHash()
A previous attempt to make qHash() a hidden friend ran into an ICE on
Clang, so to simplify the implementation, QVLABase::hash() is public
for now.

Use QtPrivate::QNothrowHashable_v to simplify the noexcept clauses.

Fixes: QTBUG-84785
Change-Id: Ibb520bde7b1d6dc45846bd8e1fa27c39c401b96a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-11 16:57:08 +01:00
Marc Mutz
d3d284bec4 QVLA: separate control from inline storage [10/N]: range-insert()
Also added a QVLABase::resize_impl() because insert(it, n, v) was the
only function moved down into QVLABase to call resize().

Task-number: QTBUG-84785
Change-Id: I5dd0092216d73b28b957a01845325d744a5c0ba9
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-11 16:56:56 +01:00
Marc Mutz
69f05a384f QVLA: separate control from inline storage [9/N]: range-append()
Task-number: QTBUG-84785
Change-Id: Ieca9b3b8608b9500393d2d9d1910380799aba2ea
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-12-11 08:10:34 +01:00
Marc Mutz
99894e33ba QVLA: separate control from inline storage [8/N]: emplace()
Moving emplace() takes care of the bulk of insert()-like operations in
QVarLengthArray. What's missing now is just the pseudo-ranged
insert(i, n, x) and append(ptr, n) operations.

Task-number: QTBUG-84785
Change-Id: I8be7f50ecab3de79b617436c46d3feec065b4f88
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-11 08:10:30 +01:00
Marc Mutz
d666e7a779 QVLA: separate control from inline storage [7/N]: erase{,_if}()
Implement erase()/erase_if() using removeAll()/removeIf()

These functions are now on QVLABase, so we no longer instantiate a
different sequential_erase{,_if}() per Prealloc.

Task-number: QTBUG-84785
Change-Id: I339759bc02b0e3104f7d1273ce6d5e09b493610c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-11 08:10:26 +01:00
Marc Mutz
4af6ba40c2 QVLA: separate control from inline storage [6/N]: emplace_back()
Move emplace_back() down from QVarLengthArray to QVLABase.

Task-number: QTBUG-84785
Change-Id: I29020737007f245c3b52fd7960369262510c0d52
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-11 08:10:23 +01:00
Marc Mutz
61be5c94ed QVLA: separate control from inline storage [5/N]: Move reallocate()
This is the core of QVarLengthArray. To move it down into QVLABase, we
need to pass Prealloc and this->array as additional function
arguments.

Task-number: QTBUG-84785
Change-Id: I082fa4ef957fcde7b8fcc3ca421621aa01ba5d59
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-11 08:10:20 +01:00
Marc Mutz
e01f3e8b5a QVLA: separate control from inline storage [4/N]: cleanup casts
Remove some reinterpret_casts that became useless when we ported
'ptr' to be a 'void*'.

Task-number: QTBUG-84785
Change-Id: I886304da50e18152abc664d2adf094617c37887f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-11 08:10:17 +01:00
Marc Mutz
a13a2d6b61 QVLA: separate control from inline storage [3/N]: Extract Further Base Class
It turns out that some functionality (most prominently, the verify()
function that contains the asserts), depends on nothing but the size
member, so Extract QVLABaseBase, a non-template class, to hold the data
members, and the size()- and capacity()-related member functions.

Task-number: QTBUG-84785
Change-Id: Ic21855fd6147b67507c122b6f091b44a3ba997f5
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-11 08:10:14 +01:00
Marc Mutz
8de6762112 QVLA: separate control from inline storage [2/N]: Move Up Methods [3/3]
Move the remaining methods to the QVLABase base class that can be moved,
being those which do not depend on QVLAStorage::array.

Include the relational operators this time around.

Task-number: QTBUG-84785
Change-Id: I0f22b076791496833cba033c1be2a69ec8b129a1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-11 08:10:10 +01:00
Marc Mutz
8bdca0f27c QVLA: separate control from inline storage [2/N]: Move Up Methods [2/3]
Move all methods to the QVLABase base class that can be moved, being
those which do not depend on QVLAStorage::array.

Skip relational operators for the time being, but move the methods
which are defined out-of-line now.

Task-number: QTBUG-84785
Change-Id: I355c0581f74d79d9bae37861b32d795ddcb2fb69
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-11 08:10:05 +01:00
Marc Mutz
b1ae3bbdab QVLA: separate control from inline storage [2/N]: Move Up Methods [1/3]
Move all methods to the QVLABase base class that can be moved, being
those which do not depend on QVLAStorage::array.

Skip relational operators for the time being, as well as the methods
which are defined out-of-line.

Keep the old definitions around as long as qdoc cannot, yet, associate
derived-class \fn with base-class definitions, via using-declarations.
We don't want to export the QVLABase class in the docs.

Task-number: QTBUG-84785
Change-Id: Ic61e6029e07faca5be99d7e2e197d5bc7fe74c4e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-12-11 08:10:02 +01:00
Marc Mutz
85e92f2e5f QVarLengthArray: deprecate prepend()
All Qt 6 containers have "fast" prepend these days. Except
QVLA. Instead of enabling "fast" prepend for QVLA, slowing down
idiomatic QVLA use, simply deprecate prepend().

There appear to be no users of this function in qtbase outside tests.

[ChangeLog][QtCore][Deprecation Notices][QVarLengthArray] Deprecated
prepend() because QVarLengthArray is the only Qt container without a
"fast" prepend. If you require that functionality, even though it's a
linear operation, then use insert(cbegin(), ~~~) instead.

Change-Id: I39ff1dd7d4de7fc08d5380a5a7450dd8c8996fe2
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-11 03:15:11 +00:00
Volker Hilsheimer
bae0a159d8 Fix item view auto-scrolling during drag'n'drop
Amends 71aaf831d1, which wrongly assumed
that dragMoveEvent will be called and update the dragged position as we
scroll the viewport. This is not the case, so we have to do so manually
when the view is in DraggingState.

Since dragMoveEvent cannot be faked, and since we cannot fake a
mouseMoveEvent (it would throw off the drag'n'drop state machine),
calculate the new draggedPosition based on old position and the new
offset.

As with all drag'n'drop, we cannot test this using an auto test.

Task-number: QTBUG-96124
Fixes: QTBUG-98961
Change-Id: Ifcfc1a11aa7258ec4610a548a276b4dd4a814590
Reviewed-by: Zhang Hao <zhanghao@uniontech.com>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-12-10 23:51:18 +00:00
Volker Hilsheimer
9da1f6b608 Fix widget gesture grabbing
After 7369c31ca1f446e81eda1c93ba13767ffcd83efe, unaccepted touch points
were not grabbed anymore in calls to activateImplicitTouchGrab. However,
gesture recognition relies that widgets for which a gesture has been
partially recognized grab also unaccepted touch points.

Add a parameter to allow the implicit grabbing to take place also for
unaccepted event points.

Add test case that replays touch events similar to what Squish is doing,
and fails without this fix.

Pick-to: 6.2
Change-Id: Idb0b20301b1827be57a03013a59043d97c2ee7b6
Reviewed-by: Stefan Gehn <stefan.gehn@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-11 00:51:10 +01:00
Igor Kushnir
4229de1685 Remove redundant QDir::fromNativeSeparators() call
QFileSystemEntry::QFileSystemEntry(const QString &filePath) already
calls this function. Calling it repeatedly changes nothing but wastes
CPU time. Neither the line modified in this commit nor the
QFileSystemEntry's constructor have been changed since 2011's commit
"Initial import from the monolithic Qt." Other constructor overloads of
QFileInfoPrivate don't call QDir::fromNativeSeparators().

Change-Id: I01e54662efd96e87c4a686369dc0b265b47e5938
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-11 01:30:07 +02:00
Eskil Abrahamsen Blomfeldt
b00404abff Trust CoreText-provided vertical metrics on macOS
In f761ad3cd9 we added a cross-platform
consistent approach to vertical spacing of text. However, this has
created problem on macOS, as some of the default fonts on the system
have inconsistent metrics. Specifically, Monaco is missing the
typographical metrics flag in its OS/2 table, and the alternative
metrics in the table are about 30% larger than the typographical
metrics (which match what is used natively). As a result, the fonts
look the same on macOS as on other platforms now, but different from
when the same fonts are used in native apps.

We can't have fonts look wrong on their native platform, so we
revert this change for CoreText, trusting the metrics we get from
the system instead. We keep the consistent approach for the FreeType
engine, as its main use case is cross-platform consistent text
rendering.

[ChangeLog][macOS][Text] Fixed an issue where certain fonts, such as
Monaco, would have a different line spacing than expected.

Pick-to: 6.2
Fixes: QTBUG-97818
Change-Id: I0a3dbe4636d67779935e645066b1e51c1517dc6d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-12-10 23:15:39 +01:00
Marc Mutz
6a42363feb QVarLengthArray: widen append(p, n)'s contract
It's a bit weird that the (counted-)range-append() allows n < 0, but
requires p != nullptr even when n == 0.

Fix by allowing p == nullptr iff n == 0.

[ChangeLog][QtCore][QVarLengthArray] The counted-range-append()
function (append(ptr, n)) now accepts ptr == nullptr, provided n == 0,
too (was: triggered assertion).

Pick-to: 6.2
Change-Id: Ifb97170a930e97cb8f4194282cada0faf820cc53
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-10 19:50:08 +01:00
Laszlo Agocs
bc4570ed24 rhi: Auto-rebuild rt by tracking attachment id and generation
Unlike the shader resource binding lists that automatically recognize
in setShaderResources() when a referenced QRhiResource has been rebuilt
in the meantime (create() was called i.e. there may be completely
different native objects underneath), QRhiTextureRenderTarget has no
such thing. This leads to an asymmetric API and requires also rebuilding
the rt whenever an attachment is rebuilt:

rt = rhi->newTextureRenderTarget({ { texture } })
rt->create()
cb->beginPass(rt, ...)
texture->setPixelSize(...)
texture->create()
rt->create() // this should not be needed
cb->beginPass(rt, ...)

Avoid having to do that second rt->create().

Change-Id: If14eaa7aac3530950498bbdf834324d0741a7c4d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-12-10 15:08:51 +01:00
Marc Mutz
48b75def5d QList: fix typo in QList(It, It)
Remove scaffolding in the test again.

[ChangeLog][QtCore][QList] Fixed a regression that caused the range
constructor to fail for pure input_iterator's.

Pick-to: 6.2
Fixes: QTBUG-99036
Change-Id: I72d01a9c44c3862c335d96538f26a453b4c7c554
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-10 13:48:37 +00:00
Marc Mutz
0800947d7d QVarLengthArray: fix UB (precondition violation) in range-erase()
When the range-erase() function is called with an empty, valid range,
it passed equal iterators to both the first and the last arguments of
std::move(f, l, d) (the algorithm, not the cast). This is UB, since it
violates the algorithm's precondition that d ∉ [f,l). For non-empty
ranges, f > d, thus d < f, hence d ∉ [f,l), so everything is ok
_there_.

Fix the empty range case by returning early.

Reviewers may question the precondition, expecting that std::move(f,
l, f) just be a no-op, but the algorithm, as specified, performs
self-move-assignments in that case, which need not be supported. In
fact, the Hinnant criterion, itself only applicable if one calls for
self-swap-safety, asks for self-move-assignment-safety only for
objects in the moved-from state. QVarLengthArray, itself, meets only
the Hinnant criterion; self-move-assignment of non-empty QVLAs invokes
UB.

So, the UB here is real.

Qt 5.15 uses std::copy() here, which has the same precondition as
std::move(), and the same fix applies there, too.

[ChangeLog][QtCore][QVarLengthArray] Fixed a bug where range-erase()
could invoke undefined behavior when called with an empty range.

Pick-to: 6.2 5.15
Change-Id: I656aa09d025168d6d9ef088ad4c6954d216f0d54
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-10 06:42:49 +01:00
Marc Mutz
f917b0d4b9 QVLA: separate control from inline storage [1/N]: Extract Base Classes
In this first patch of the series, we move the fields (a, s, ptr) and
(array) into each their base class, separating concerns: The QVLABase
class is independent of Prealloc, while the QVLAStorage class is
independent of T (only depends on Prealloc, alignof(T) and sizeof(T),
and that can probably be reduced even further in later patches, since
we ought to need only alignof(T) and sizeof(T) * Prealloc, and
alignment can be substituted with std::max_align_t).

Doing so while keeping all member functions on QVLA, however, means we
need to sprinkle 'this->' in front of every data member access. C'est
la vie.

Task-number: QTBUG-84785
Change-Id: Iafbf97f41b9743b6dc2bfc13f3486d73e854b7cf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-09 23:12:12 +00:00
Kai Köhne
b34be3868b Doc: Use find_package(Qt6 REQUIRED COMPONENTS ...) idiom
Using REQUIRED as a prefix instead of suffix works better with
OPTIONAL_COMPONENTS, and is also the order in the CMake manual.

Task-number: QTBUG-98867
Pick-to: 6.2
Change-Id: I1ab68408b95d8edf06272a3b9fceccd8d8e597fc
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2021-12-09 22:20:04 +01:00
Edward Welbourne
7586e1980f Use QLatin1String::arg() directly
No need to wrap the QLatin1String in a QString() to get at arg now.

Change-Id: Iac90e052b88077b9c2bd3e7eca6bc31935baa4b8
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-09 20:54:26 +01:00
Edward Welbourne
91e8d8027d Tidy up in QTapTestLogger::addIncident()
After we've checked m_wasExpectedFail, we might as well set it
promptly, since one of our earlier checks is on the same
condition. Explain what that check is about, fix a typo in another
comment and make the local ok variable const, since it can be.

Change-Id: Ie04c0ad4248e47b116d3e22046116d39cf2ac6df
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-09 20:54:26 +01:00
Edward Welbourne
6729a4b29c TAP test logger: avoid dangling space on TODO and SKIP lines
If an incident has an empty description we produced output with a
dangling space. Avoid triggering the inanity 'bot with those.
Reorganise the code to save some duplication.

Change-Id: I1dc29fa8ad4449a4584f11dddcf002e405cd9238
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-09 20:54:26 +01:00
Edward Welbourne
98a42b1627 Remove spurious class prefixes from subclass code
The subclass's code can refer to the base's public enums without
needing the (long) class prefix.

Change-Id: I4824440d216695aee9345776faba2e510130425e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-09 20:54:26 +01:00
Edward Welbourne
8d120174e9 Avoid duplicated code by reworking #if-ery around an if/else
Change-Id: I08376d2dfd071989fab9ee18dbb90ab8670ed20f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-09 20:54:26 +01:00
Edward Welbourne
8d0b5270fa TAP test logger: skip XFail results as well as pass after an XFail
The rationale for skipping pass after XFail is "to emit a single test
point for" the test; emitting several XFails violates that aim.

Task-number: QTBUG-96844
Change-Id: Ia8626dfc2dded234b3aa530fc2dc2324f1e28400
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-09 20:54:26 +01:00
Edward Welbourne
24b4f5b16c Ignore blackisted Pass and XFail when ignoring their plain forms
It makes no sense to include output for a blacklisted test that would
have been excluded had it not been blacklisted.

Task-number: QTBUG-96844
Change-Id: I164e0c26a921101cbf8986904851260d181be00f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-09 20:54:26 +01:00
Edward Welbourne
77a93e6df3 Make Skip an incident in test logging
Skip ends the test (albeit inconclusively).  Rearrange the enums in
the abstract logger, move code to handle skip between relevant
function and tidy up various things that became simpler as a result.

Also reorder the message enum, and its switches, to separate testlib's
internals from the usual Qt messages, and put each group in ascending
order of severity.

Task-number: QTBUG-96844
Change-Id: I2c7a634b9f849830d64eafa750155e66e244b729
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-09 20:54:26 +01:00
Edward Welbourne
5c908c8263 Implement QTest::qWait() in terms of QTest::qWaitFor()
A comment in the existing implementation encouraged doing so, but for
a bug in GCC 6. We no longer care.

Change-Id: Ia8cb2bc5e184510e3d756e8bbfe6bc0e852e6830
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-09 20:54:25 +01:00
Edward Welbourne
d41d3274d4 Replace out-of-date comment on QTRY_IMPL(), about qWaitFor()
A comment on QTRY_IMPL() helpfully mentioned the bug number of the
issue that prevented us from using qWaitFor; and MSVC < 2017 are no
longer supported so it looked possible to make the change suggested.
However, the implementation has, in the mean time, grown some features
not (currently) provided by qWaitFor(), so update the comment.

In the process, fix one minor error in QTRY_TIMEOUT_DEBUG_IMPL() where
parentheses enclosed the wrong text; (2 * timeoutValue) would not
produce the intended result if timeoutValue were 1 + 500, for
example. The macro parameter should be enclosed, not the expression
using it as parameter to a further macro.

Task-number: QTBUG-59096
Change-Id: Ie16e297def9d1f983cd5964bc628b2c3c0aaecda
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-09 20:54:25 +01:00
Edward Welbourne
37bc11e707 Refactor QTEST*_MAIN() implementations
The various variants duplicated some rather complex code around
varying setup in the middle. Rework in terms of a macro that defines
main() and takes the setup code as a parameter. That setup code also
had some common structure, so package that in a setup macro that takes
the class to be used.

Reworked various testlib selftests that were using QTEST_MAIN_IMPL();
change to use the new QTEST_MAIN_WRAPPER() and TEST_MAIN_SETUP().
These might be better dealt with by supporting a second form of the
initMain() test-setup function in the test classes, that takes
references for argc and argv, to let a test massage its command-line
options.

Change-Id: I7fb16b38d51c80ba2f5c9c82f3b7a37ffc636795
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-09 20:54:25 +01:00
Edward Welbourne
b67c367e0e Tidy up testlib's parsing of -callgrind parameter
Invert a condition to turn a nested if (that was missing one of its
layers of braces) into an else-if chain, split some long strings to
limit line length.

Change-Id: I10d90487a09affe981aa11c3588281aeb3666df5
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-09 20:54:25 +01:00
Alexandru Croitor
197753d8ae CMake: Mark the new deployment API as being in Technical Preview
Amends 22c92f3967

Task-number: QTBUG-98545
Change-Id: Ifaa7e4884f0eb1caa6d3d4906a2701f8fa5e43c2
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2021-12-09 19:59:55 +01:00
Alexandru Croitor
0a28c55a87 CMake: Fix some of the CMake commands not using the right doc group
Augments e0ecb0ded2

Pick-to: 6.2
Change-Id: I4eea51b66ffa5ffe45faa3c51a4b65a526dd73e7
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2021-12-09 19:59:55 +01:00
Marc Mutz
e297e80fd0 QVarLengthArray: make reallocation strongly exception safe
The old code had several bugs:

- it immediately clobbered *this with new state, before having copied
  over the elements from the old to the new buffer

- when buffer relocation threw, it would keep the new (partially-filled)
  buffer and throw away the old

- it unconditionally used std::move() for non-relocatable types, making
  it impossible to restore the original buffer when a move throws

Instead of clobbering *this with new state, do all the work on the
side and change *this only once the reallocation has happened
successfully.

Also use q_uninitialized_relocate_n() and unique_ptr in the
implementation to simplify the code. The former got the necessary
update to use std::move_if_noexcept() instead of an unconditional
std::move() for the non-relocatable case.

[ChangeLog][QtCore][QVarLengthArray] The append()-like functions are
now strongly exception safe. This means reallocation will now use
copies instead of moves, unless the value_type has a noexcept move
constructor.

Fixes: QTBUG-99039
Change-Id: I031251b8d14ac045592d01caed59d4638c3d9892
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-09 18:59:55 +00:00
Marc Mutz
c1f510b359 QVarLengthArray: implement append() via emplace_back()
Less code duplication, means less functions to move into the
upcoming QVLABase.

Change-Id: I67a817c971a4e5a81ae45ff30282878be1bde2aa
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-09 18:49:33 +01:00
Marc Mutz
7db44f60b1 QVarLengthArray: inline some trivial reallocate() wrappers
These functions don't deserve to be defined outside the class body,
as they're trivial wrappers around reallocate().

Cleans up the header somewhat, in preparation of the upcoming
QVLABase/QVLAStorage split.

Change-Id: Ib4062eca4214a67e67f472a7c1e4bf4d9813c8a4
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-09 18:49:33 +01:00