Commit Graph

40813 Commits

Author SHA1 Message Date
Yuhang Zhao
77d0ad6657 Windows QPA: Add some offset to the system menu when appropriate
Before this patch, the system menu will always appear on
the top-left corner of the window if the window doesn't
have the standard window frame. However, this doesn't look
very good on most situations, especially when the window
has a homemade title bar. This patch adds an extra check
for this kind of situations. This patch will automatically
apply an appropriate offset for the system menu if the user
is trying to use a self-made title bar for their frameless
or customized windows.

Pick-to: 6.3 6.2
Change-Id: I55e1c4ac26a4051ca48928d4a2ac3456dce117d1
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
2022-03-01 13:08:02 +08:00
Yuhang Zhao
7261c81152 Windows QPA: fix window style correction for context help button
According to Microsoft Docs [1][2], WS_MINIMIZEBOX and WS_MAXIMIZEBOX
must be accompanied by the WS_SYSMENU style, and the WS_EX_CONTEXTHELP
style is not compatible with WS_MINIMIZEBOX and WS_MAXIMIZEBOX. This
patch adds additional checks for these situations.

[1] https://docs.microsoft.com/en-us/windows/win32/winmsg/window-styles
[2] https://docs.microsoft.com/en-us/windows/win32/winmsg/extended-window-styles

Pick-to: 6.3 6.2
Change-Id: If32f8b42e25cfc67ffd1e84cc4b061f21a01042a
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
2022-03-01 12:29:36 +08:00
Yuhang Zhao
770ea68588 Windows QPA: Use less magic number
The correct calculation of the invisible frame margin and the window
border width (they are the same thing actually) is the thickness
of the size frame plus the thickness of the padded border. When
DPI is 96, both of them is 4px and thus the invisible frame margin
and window border width is 8px. So previously the empirical
magic number can work normally is because the error is very small.
It's not a big thing because even on a high DPI screen the error
is still very small. For example, on my 4K monitor with 200%
scaling, the error is only 2px, human eyes almost can't find the
visual difference. But since we now know how to calculate these
values correctly, let's use the correct calculation instead. The
magic numbers and empirical expressions just make people confused.

Pick-to: 6.3 6.2
Change-Id: Ieda4796231935f2ad1b6f28e4aa4af5b5bce2256
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
2022-03-01 09:11:51 +08:00
Giuseppe D'Angelo
9c947c131d QLabel: remove some dynamic allocations
QLabelPrivate uses pointers and dynamically allocated objects as a form
of optional. To add insult to injury, the objects are implictly shared,
compounding the effects in terms of required allocations.

Just use std::optional instead.

Change-Id: Ica582dc0d2a9ab56f45ce305290541383b7ddeef
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-03-01 01:55:08 +01:00
Liang Qi
404c5dc49f xcb: free a randr monitors pointer after usage
This amends 9a4c98e556.

Pick-to: 6.3
Fixes: QTBUG-101302
Change-Id: Ia7a2f82550843a90a5e101788e3835bf3332f697
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-28 23:44:15 +01:00
Marc Mutz
6f50e54138 QFlags: fix missing bitwise xor operators in QT_TYPESAFE_FLAGS builds
Add tests that cover them.

Pick-to: 6.3
Fixes: QTBUG-101300
Change-Id: I5a8af4a91d796cc4d287b813bd5cc13da3d7e766
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-28 23:09:31 +01:00
Alexandru Croitor
8b5648743e CMake: Clean up docs of deployment variables for 6.3
Clarified the docs that using the deployment variables is for avoiding
hard-coding of specific paths.
Added docs on how to customize the variable defaults
Added example doc snippet demonstrating how to modify the values.
Added upstream doc links where relevant.

Pick-to: 6.3
Fixes: QTBUG-100924
Change-Id: I938dcadd776c8b7019da4709dfced166454a6c92
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2022-02-28 23:08:21 +01:00
Alexandru Croitor
34a4fe0166 CMake: Rename FindZSTD to FindWrapZSTD
And the target ZSTD::ZSTD to WrapZSTD::WrapZSTD.
This should allow building Qt with the
-DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON set.

Pick-to: 6.2 6.3
Fixes: QTBUG-100537
Change-Id: I748601e4ad6f518323bf1034d6fc1de582c815e1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-02-28 23:08:20 +01:00
Alexandru Croitor
0ada264dda CMake: Clean up qt_deploy_runtime_dependencies for 6.3
Ensure both versioned and versionless functions
are available.

Use the versioned function in the implementation of
qt6_generate_deploy_app_script.

Move the low-level warning to the top of the documentation page,
after the TP message.

Clarify documentation of the EXECUTABLE and
ADDITIONAL_ options, that they take relative paths and can use
generator expressions, but can't reference raw target names.

Adjust documentation snippet to cover mac / windows cases.
This mostly coincides with the internal implementation of
qt_generate_deploy_app_script.
Also adjust it to show case more options, like installation of a
helper app and its dependencies.

Output the working directory when executing the deploy tool.

Remove the MACOS_BUNDLE option, it serves no good purpose at the
moment, we already detect bundles by checking if the dir name has
an '.app' suffix.

Pick-to: 6.3
Fixes: QTBUG-100923
Change-Id: If7e5d65ce920eb69fd45f004aa4c5bad800c7ba9
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-28 23:08:20 +01:00
Friedemann Kleint
95603e09c9 Fix assert showing default-constructed QPrintPreviewDialog
Fix call to qBound(), avoiding an assert introduced
by ad5c5bb541.

Pick-to: 6.3
Fixes: QTBUG-101297
Change-Id: I823cdfcd2491c6bb4c87058318479d188ca38742
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-28 12:39:54 +01:00
David Faure
74a4d88e9a QAbstractItemModel: fix persistent index corruption when moving columns
QHeaderView creates persistent indexes in
_q_sectionsAboutToBeChanged(), called by the slot connected to
rowsAboutToBeMoved/columnsAboutToBeMoved.

In the case of rows, QAbstractItemModel emits the signal *before*
preparing to update persistent indexes in itemsAboutToBeMoved(),
so it can see the ones newly created by QHeaderView, all is well.

In the case of columns, the emit was done *after* calling
itemsAboutToBeMoved(), so the additional persistent indexes created by
QHeaderView were ignored, and in endMoveRows() we could end up with:
ASSERT failure in QPersistentModelIndex::~QPersistentModelIndex: "persistent model indexes corrupted"

This bug has been there since the very beginning of beginMoveColumns(),
but was undetected because moving columns in a model is pretty rare
(in my case there's a QTransposeProxyModel that turns columns into
rows in the underlying model, and a proxy that handles dropMimeData...)

Pick-to: 6.3 6.2 5.15
Change-Id: I74bad137594019a04c2a19c2abb351ff3065c25a
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2022-02-28 09:43:37 +01:00
Timur Pocheptsov
af05f278ed QMacStyle: fix tool buttons (in checked mode)
While switching to the 'momentary push in' button type, the old code that
shows button as pressed/checked was removed. Since 'square' buttons
were sharing this part with rounded push buttons, the change broke
checked square buttons. So we retain the old code for this particular
case.

Also, add a minimal baseline test for this scenario: square button,
triggering 'toolbutton' style with/out 'checked' state.

Fixes: QTBUG-100802
Pick-to: 6.3 6.2
Change-Id: Ib7b15b13ead834c7bb2cd36de76ccd5bedb07810
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-28 08:46:21 +01:00
Marc Mutz
5a39173c34 Don't allocate in qt_asciiToDouble()
The sscanf implementation ensured NUL-termination of the input data,
by copying it, and appending NUL.

Since this function is ignoring trailing garbage and reports the
progress back, we could be parsing the first double in a multi-MiB
buffer. And we'd been copying and copying the buffer for every double
scanned. This is clearly not acceptable.

An alternative is to use the max-field-width feature of scanf. By
giving the size of the input data as the maximum field width in the
format string, we stop sscanf from reading more than the available
data.

This code should let everyone's alarm bells go off: a format string
constructed at run-time is really the last thing one should consider,
but I haven't found a way to pass the field width as an argument, so
bite the bullet and go through with it. Copying potentially MiBs of
data is the worse of the two evils.

Pick-to: 6.3
Fixes: QTBUG-101178
Change-Id: Ibaf8142f6b3dab4d5e3631c3cc8cc6699bceb320
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-25 08:08:21 +00:00
Yuhang Zhao
64d65a645c Windows QPA: Highlight the first entry in the system menu
This is what native Win32 applications usually do.

Pick-to: 6.3 6.2
Change-Id: I19f1170113b4064f1d683dbd13b7de7d263105f0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
2022-02-25 12:43:16 +08:00
Yuhang Zhao
56fa390d72 Windows QPA: More debug enhancements
Pick-to: 6.3
Change-Id: Ibf03fa82f14cf704267b85348ce11ee2d505ff24
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-25 09:30:35 +08:00
Pasi Petäjäjärvi
93a3d09840 Fix compiler warnings about unused parameters
When FEATUREs getiffaddrs and ipv6ifname are not enabled variables are
unused.

Pick-to: 5.15 6.2 6.3
Change-Id: I0fde7ef3a4ee1e89927e2c5550ac24fba76ba155
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-25 01:45:53 +02:00
Thiago Macieira
a072de78dd QTextFormat: remove unnecessary namespace-scope stream op declarations
These two pairs already exist as hidden friends inside the two classes.

Pick-to: 6.3
Change-Id: Ic15405335d804bdea761fffd16d4a3bc633e6d53
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-02-24 15:45:53 -08:00
Giuseppe D'Angelo
b20cf7feee QLabel::setPixmap(): remove the no-op self-masking
When calling QLabel::setPixmap() with a 1bpp pixmap (i.e. a bitmap), and
that pixmap didn't have a mask set, QLabel would then set the pixmap as
its own mask.

This seems to be a no-op due to how QPixmap::setMask is coded:

  void QPixmap::setMask(const QBitmap &mask) {

    // ...

    if (static_cast<const QPixmap &>(mask).data == data) // trying to selfmask
      return;

  }

Moreover, in order to convert the pixmap to a QBitmap, the code would just
straight downcast it, triggering UB (if the input to setPixmap wasn't a
QBitmap to begin with).

I *guess* this was done this way to avoid a QBitmap::fromPixmap call,
which however is not expensive at all if the pixmap is already 1bpp,
which QLabel::setPixmap checks explicitly (before attempting to mask the
pixmap). I don't know the historical reasons for the code to have the
shape it had (and the code history is from before open governance).

So get two birds with one stone: remove the no-op and also the UB.

Change-Id: Ibab20492c2945bd1d01f98a18b168fabc56292b0
Pick-to: 6.3 6.2 5.15
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-24 22:41:59 +01:00
Thiago Macieira
96a025c28b QRandomGenerator: find getentropy() on macOS
It's in <sys/random.h>. The header exists on Linux and on FreeBSD and
declares getrandom(), which we don't use, so it's harmless.

Pick-to: 6.3
Change-Id: Ibf4acec0f166495998f7fffd16d69005ab59df3b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-02-24 12:29:43 -08:00
Thiago Macieira
75e0d1b5c1 Make sure all qtbase private headers include at least one other
See script in qtbase/util/includeprivate for the rules.

Since these files are being touched anyway, I also ran the
updatecopyright.pl script too.

Change-Id: Ib056b47dde3341ef9a52ffff13ef677e471674b6
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-24 12:07:00 -08:00
Volker Hilsheimer
4cca8ee527 QGuiApplication: use translation-based layout direction unless explicitly set
The stored layout direction used to get changed during initialization
to what was auto-detected based on the translation. Changing the
translation then overwrote that stored value, even if an explicit call
to setLayoutDirection was made by the application.

Calling QGuiApplication::setLayoutDirection(Auto) has so far been a
no-op.

Change this logic so that the stored layout direction continues to be
LayoutDirectionAuto also if it's set based on auto-detection, and only
overwrite it when explicitly called with a non-Auto value. This way,
applications can set a layout direction that stays unchanged even when
translators are installed.

Add test coverage that uses a QTranslator.

In practice, this is not a change of behavior, unless applications called
setLayoutDirection(Auto) (which is no longer a no-op), or called
setLayoutDirection() and then installed a translator and expected the
translator's layout direction to come into effect in spite of the explicit
setting.

[ChangeLog][Gui][QGuiApplication] Calling setLayoutDirection with a non-
auto value now disables the auto-detection based on installed
translators. Applications that explicitly set a layout direction and also
want translators installed afterwards to take effect should reset the
layout direction to Auto, which is now no longer a no-op.

Fixes: QTBUG-100632
Pick-to: 6.3
Change-Id: I1fdcebd43a9b1b468ff95bf15f53f441bb214e08
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-02-24 19:46:01 +01:00
Ievgenii Meshcheriakov
cba40055b1 Network: Use public suffix database in DAFSA format
This saves 91kiB of text size and makes it easier to use
a locally installed database when available.

[ChangeLog][Third-Party Code] Moved attribution of
The Public Suffix List from Qt Core to Qt Network.

[ChangeLog][Third-Party Code] Added attribution of new libpsl
library to Qt Network. libpsl is available under
the BSD 3-Clause "New" or "Revised" License.

Task-number: QTBUG-95889
Change-Id: Ibd37c7a94fdf235e75d96fec20d427fb5c2bd2a4
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-24 19:36:26 +01:00
Kai Köhne
1058f053e5 MSVC: Raise minimum version of Visual Studio 2019 to 16.7
The compile-time check for /permissive- only works from Visual Studio
16.7 onwards. Older compiler versions will fail the check, even if
/permissive- is passed.

Let's rather bail out with a more explicit error in this case.

[ChangeLog][Windows] The minimum MSVC version was raised to
Visual Studio 2019 version 16.7 (VC++ version 14.27). Trying to use
an older version will now result in a compile time error.

Pick-to: 6.3
Task-number: QTBUG-101049
Change-Id: Ibfa2930e1186eb63d8fed69efe161a9d79ccb1be
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2022-02-24 19:36:25 +01:00
Giuseppe D'Angelo
2b6daa610e QColorDialog: code tidies
Combine two flag-like enumerations using a bitwise OR, not a plus.
Cleanup for the follow-up commits.

Change-Id: Iceb05bf5ea0635d623ba9a7d145606e80b7f21f3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-24 19:36:25 +01:00
Volker Hilsheimer
a74cdf778c Implement QFormLayout::set/isRowVisible
Hiding a row in a form layout is inconvenient to do as access to the
widgets in each row is cumbersome. In addition, a row might include a
layout for the label or the field column, and we can't hide layouts and
instead need to navigate to the widgets inside the layout. And even if
an application developer does all that, the spacing calculation doesn't
ignore hidden rows.

Add setRowVisible and isRowVisible APIs with the usual overloads.
Implement the logic to traverse a layout item to its contained widgets,
so that they are explicitly hidden when a row is hidden, and skip hidden
rows in the spacing calculation.

[ChangeLog][Widgets][QFormLayout] New APIs setRowVisible and isRowVisible
to hide and show rows in a form layout.

Fixes: QTBUG-6864
Change-Id: I6af98409802f331c4523e91d7dac8a97762c579d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-24 17:07:43 +01:00
Fabian Kosmale
3fd43fafba QVariant: use std::swap for swapping known type
Amends b1b0c2970e

Task-number: QTBUG-97601
Pick-to: 6.3 6.2
Change-Id: I5161360f10e052d21c91044b2c9bf4260467e585
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-24 12:36:05 +01:00
Pasi Petäjäjärvi
3a151faec2 QNX: Fix support for abstract Unix-domain socket
As QNX claims to support abstract Unix-domain sockets, its getsockname
always returns for socket that has not been bound to local name
address_len of sun_path as maximum length (106) even when it does not
contain valid address.
https://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.neutrino.lib_ref/topic/u/unix_proto.html

Pick-to: 6.2 6.3
Change-Id: I0f0f5c05611c8db6af35377dde16450f58c83c56
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-24 07:49:37 +00:00
Pasi Petäjäjärvi
df270368ee Fix getsockopt option_value initial initialization
On some platforms, some of the options we're getting the value
for may be a single byte, so attempting to read the full int
produces garbage.

Found with IP_MULTICAST_TTL and IP_MULTICAST_LOOP on QNX. See:
https://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.neutrino.lib_ref/topic/g/getsockopt.html#getsockopt__IP_MULTICAST_TTL

Pick-to: 5.15 6.2 6.3
Change-Id: Id9f7f249c6c4be0c3f94c5904d402b4ec4e17b59
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-24 07:49:10 +00:00
Alexey Edelev
708eb85e38 Allow calling qt6_android_add_apk_target twice
If qt6_android_add_apk_target is called manually in user project this
might cause duplicated targets issue when calling the finalizer(either
manually or in a defer call).
Skip the qt6_android_add_apk_target body if target is already
registered in _qt_apk_targets list.

Pick-to: 6.3
Change-Id: I36ef569227e0c5f0f077446bbe5d7e8d8fc0bfc6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-24 03:42:28 +01:00
Martin Storsjö
7341251e0e QHash: Fix building for i386 after "add support for VAES and AVX512VL"
Fix a typo from da1720485e,
where mm_cvtsz_si128 was undefined when building for a 32 bit
target. The code would make it seem this was a typo, with the
listing of defines didn't match between 32 and 64 bit.

Change-Id: Ica24d88e7f71ecd1d24ed990773711f9105f3ec8
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-02-24 03:59:53 +02:00
Marc Mutz
dd9f4a2033 Un-export QConfFile
Only clearCache() is used by tests. Ubsan build also passes.

Makes it easier to reason about the mutex handling in the class' ctor
and dtor.

Change-Id: I917991cfecda71dcd0a5bea7705a7f7f3a3e75b7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-23 23:07:45 +01:00
Michal Klocek
a232927474 Add back accidentally removed check for QT_FEATURE_system_zlib
This commit amends be2745e478

Pick-to: 6.3
Change-Id: I2fd687e12440cc40ad25b65cbfcc1ce261d04258
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-23 17:41:59 +01:00
Andreas Buhr
2f6faca901 Add tests to QAbstractItemModelTester checking only one change in flight
This patch adds checks to QAbstractItemModelTester checking
that only one change is in flight at a time.

Change-Id: I15fe1ad1274649aa652ed6489a889df72c8a8292
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-23 14:42:27 +01:00
Eike Ziller
3ab49ee040 MimeDatabase::mimeTypeForFileNameAndData: Do not open file unnecessarily
If the file extension already matches uniquely, we do not need to do any
actual file operation.

Pick-to: 6.3
Change-Id: Ide8b82eefbcd13348b78b28b66230a91e1e3c5d8
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-23 08:44:23 +01:00
Thiago Macieira
fa2830dc6e qHash: fix running on CPUs without AVX2
The extra "V" accidentally enabled AVX2 code in the aeshash128()
function.

Fixes: QTBUG-101082
Change-Id: Ibf4acec0f166495998f7fffd16d63e220dbe02d0
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
2022-02-22 22:31:38 -08:00
Lorn Potter
af36dc7d76 wasm: move user configurable settings
Both INITIAL_MEMORY and PTHREAD_POOL_SIZE are settings users can
change, they are not interface settings.

Fixes: QTBUG-100693
Pick-to: 6.3 6.2
Change-Id: Ie1547c7f52c9fe109a313260616705728024b6b8
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: David Skoland <david.skoland@qt.io>
2022-02-23 12:04:37 +10:00
Sona Kurazyan
196e10bce4 Fix formatting in qbytearrayalgorithms.h
Pick-to: 6.3
Change-Id: I1ff15049e73b8ce02101b5d84b2ac02d5fb69abb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-23 02:39:14 +01:00
Giuseppe D'Angelo
8123a69e6e QRegularExpression: print the pattern when warning
Just as a minor debugging helper: when warning that an invalid
regular expression object is being used to match, also print
the used regular expression pattern.

Change-Id: I0f99bcf4ca87ec67d04ed91d9dc315814f56d392
Fixes: QTBUG-76670
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-22 21:15:31 +01:00
Marc Mutz
b727f2190f Protect headers against min/max macros
... using the usual pattern, which, being idiomatic, doesn't need a
comment explaining it.

Pick-to: 6.3
Change-Id: Id6b12450495a18f89e1f83f2018b6218b03ff6a7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-22 20:12:29 +00:00
Marc Mutz
a87edb9ae9 QStringEncoder/Decoder: make base class ctors protected
Base class dtors should either be public and virtual or else
non-virtual and protected. We don't need polymorphy, so make them
protected.

Because ~QStringConverter is now user-declared, the move special
member functions are suppressed. Re-add them using = default.

[ChangeLog][QtCore][Potentially Source-Incompatible Changes]
[QStringEncoder/Decoder] The destructors of the base classes of
QStringEncoder and QStringDecoder are now protected, to prevent
slicing.

Change-Id: I72cc5b98af1a6533a46080b537e1900808e1f130
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-22 21:12:29 +01:00
Alexey Edelev
d10bbc2e6a Convert Android paths to JSON compatible
Convert paths in the QT_ANDROID_EXTRA_PLUGINS and QT_ANDROID_EXTRA_LIBS
target properties to a JSON compatible, when generating deployment
settings using finalizers in user projects.

Pick-to: 6.3
Change-Id: I8878435d69688c21e44b22339dc84495b9cea5eb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-22 21:12:27 +01:00
Sona Kurazyan
9c35ab1cc2 Make QByteArrayView's numeric conversion methods inline
Make the implementations of these methods free functions in the
QtPrivate namespace, so that they can be called also from
QByteArrayView's corresponding inline methods.

These methods were added in 6.3, so we can still make them inline
without breaking BC.

Fixes: QTBUG-101077
Pick-to: 6.3
Change-Id: Id50c6d4df5471127ae787a544a5651ced9aece99
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-22 19:23:39 +01:00
Viktor Arvidsson
cfe421cee2 Windows QPA: Calculate window frame for frameless windows the same for all code paths
When we add the WS_THICKFRAME/WS_CAPTION window flags to a
frameless window the return value of AdjustWindowRectEx is no
longer 0. This works fine when creating the window since the version
of QWindowsGeometryHint::frame used during creation checks the
FramelessWindowHint, however later when the window changes
screen, the screen change code checks the fullFrameMargins which
uses a version of QWindowsGeometryHint::frame that does not
early out, causing a missmatch in the geometries of the backing
store and platform window.

This fixes aero snapping shortcuts for frameless windows on multi
monitor setups.

Fixes: QTBUG-84466
Pick-to: 6.2 6.3
Change-Id: I2357ea32669e4676645549996a3ac6073f3df15c
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
2022-02-22 18:03:11 +00:00
Marc Mutz
330f2132ca QStringEncoder/Decoder: add missing noexcept
The interesting part is what cannot be noexcept:

- nameForEncoding() and ctor from Encoding: because they don't handle
  all valid values of type Encoding, so have a narrow contract

- encodingForHtml(): because it allocates memory (→ QTBUG-101046)

Change-Id: I30cdc19a32537be047e43955e3337e4d6ccc363f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-22 18:16:24 +01:00
Alexey Edelev
4b8bc8b5bb Make android function sequence mutable
When building Qt itself or Qt standalone tests (but not user projects),
qt6_android_add_apk_target and qt6_android_generate_deployment_setting
can now be called at any time after the Android executable target is
created.

Note: Because we're now using genexes when we build Qt as described
above, Qt developers are required to use Unix-style paths for the
following target properties:
    QT_QML_IMPORT_PATH
    QT_QML_ROOT_PATH
    QT_ANDROID_PACKAGE_SOURCE_DIR

Pick-to: 6.3
Fixes: QTBUG-100796
Change-Id: Ida788f0d58bc0c028a89eed9d115babe27144325
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-22 17:22:59 +01:00
Andy Shaw
baa2d09d0d SQLite: Update SQLite to v3.37.2
Fixes: QTBUG-100907
Pick-to: 6.2 6.3 5.15
Change-Id: I6e31b2ba19443ed6554a343423dcfd2ca6d0ac2f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-22 15:44:48 +01:00
Shawn Rutledge
c5792dcfd6 Make QGuiApplicationPrivate::lastCursorPosition.toPoint() safe to use
QGuiApplicationPrivate::lastCursorPosition is initialized with qInf();
so before Qt has seen a mouse move event, attempting to convert to
QPoint is an error. It's best to have one place where we do the qIsInf()
check rather than several (and otherwise prefer using the QPointF as-is
rather than converting to QPoint at all).

Introduce a helper class that contains a QPointF, and provides a safe
conversion to QPoint, as well as simple accessors for clients using
QPointF.

Fixes: QTBUG-52472
Task-number: QTBUG-45045
Change-Id: I83fad1bfb658e03fa876344552f1d5bb751d9f81
Pick-to: 6.2 6.3
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-02-22 14:48:38 +01:00
Volker Hilsheimer
29a7489769 Always include qt_windows header first
qt_windows takes care of setting NOMINMAX, which prevents native headers
from defining `min` and `max` as macros, breaking the build. So include
that header always as the first header.

Pick-to: 6.3
Change-Id: I82cd8b21d263102000e6e66f135465bc2c126db4
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2022-02-22 14:48:38 +01:00
Marc Mutz
66203133e3 QStringConverter: make explicit what should never have been implicit
As a drive-by, remove the GCC 7 constexpr work-around.

[ChangeLog][Potentially Source-Incompatible Changes]
All QStringEncoder/Decoder constructors are now explicit.

Change-Id: I0972e2736115993d44a48e73dbf4b08a1c94bef2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-22 12:20:15 +00:00
Marc Mutz
87c6e340a9 QStringConverter: fix move special member functions of State class
By copying 'd' instead of the (larger, on 32-bit platforms),
state_data variadic member, we may corrupt the state (by copying only
half the state).

Fix by copying state_data instead, which is guaranteed to be the
larger of the two.

The move-assignment operator must be self-assignment-safe in the
moved-from state (Hinnant Criterion), so we need to use memmove(), not
memcpy().

[ChangeLog][QtCore][QStringEncoder/Decoder] Fixed a potential data
corruption in the move constructor and move-assignment operator on
32-bit platforms.

Pick-to: 6.3 6.2
Change-Id: I7bbc475a6eecec618a011b23814cada35ce61d10
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-21 23:20:18 +01:00
Edward Welbourne
dcd87049bb Treat invalid Q(Date)?Time as null when used as an SQL value
In Qt 5, QVariant::isNull() was true when the contained object had an
isNull() that was true; this is no longer true in Qt 6, so we now have
QSqlResultPrivate::isVariantNull() to test is-or-contains
null. However, for date-times, QSqlDriver::formatValue() treats
invalid QDateTime as NULL, since it needs its toString(Qt::ISODate),
which will be empty if invalid. As QDateTime's isValid() is more
stringent than its !isNull(), this can lead to one that's neither
valid nor null, such as QDateTime(QDate(), QTime(0, 0)), producing an
invalid entry in a database.

Do the same for QTime, as its isValid() is more stringent than
!isNull(), and its toString() likewise returns empty on invalid
(although it's not clear it's possible to construct one that's neither
valid nor null). For QDate valid and null are simply complementary.

[ChangeLog][QSql] Handling of QDateTime and QTime values passed to SQL
now consistently treats invalid as null. Some values of these types
are neither valid nor null, which could lead to invalid data being
given to the SQL database. Invalid values are now treated as null to
prevent this.

Task-number: QTBUG-98471
Pick-to: 6.3
Change-Id: I145411280d6bcc53dc0dc5f4a1cb938d995fd6bc
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-21 20:37:28 +01:00
Piotr Srebrny
8761078629 Remove unused variable which causes compiler error
Pick-to: 6.2 6.3
Change-Id: I87348370d10d2047e8fa861d7675bc0cd3db080b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2022-02-21 18:02:48 +00:00
Kai Köhne
f9880e5c8f Do not warn about qtnamespacemacros.h header in syncqt
Fixes syncqt warning:

  -- Running syncqt for module: 'QtCore'
  QtCore: WARNING: C:/Users/qt/work/qt/qtbase/src/corelib/global/qtnamespacemacros.h does not include QT_BEGIN_NAMESPACE

Change-Id: I8ad8b0b7faf8bc1643103cafcd12cd2990980a0b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-21 15:34:31 +01:00
Michal Klocek
b82061688d Add missing zconf.h
Zlib headers includes also configuration header, this should be also
installed.

This commit amends be2745e478

Fixes: QTBUG-101065
Change-Id: Ide8a59258469fa793966f636ee54f18211ed8fd6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-21 14:52:35 +01:00
Mårten Nordheim
b1d8fb3279 3rdparty: Update double-conversion
The old patch is removed but another was needed to fix a warning from
MSVC about truncation which is taken from
e634f265db5d296bd7a780f9813d6b8573f5bd90 in the master branch.

Since there is no other changes to the double-conversion directory
between 3.2.0 and that change we are essentially using that commit
directly.

Pick-to: 6.3
Fixes: QTBUG-100988
Change-Id: Ia69f39f61ef989907fdf097f897bece0b3af7194
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2022-02-21 14:52:35 +01:00
Alexandru Croitor
04f49e6881 CMake: Clean up qt_deploy_qt_conf for 6.3
Ensure both versioned and versionless functions
are available.
Document that the first argument should be an absolute path
and check that in the code.
Move the low-level warning to the top, after the TP message.
Use a few more options in the doc snippet.
Mention what the default values are.

Pick-to: 6.3
Fixes: QTBUG-100922
Change-Id: I0d852733e51750f4c8f15721b707cb1d27dfee9a
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-02-21 14:07:52 +01:00
Alexandru Croitor
2305656a4e CMake: Clean up qt_generate_deploy_app_script for 6.3
Mention in the docs that qt_generate_deploy_app_script does not
currently support cross-build scenarios.

Use the value of QT_DEPLOY_BIN_DIR instead of CMAKE_INSTALL_PREFIX
in the qt_deploy_runtime_dependencies call done by
qt6_generate_deploy_app_script. This matches what we say to do in the
documentation of qt_deploy_runtime_dependencies.

Pick-to: 6.3
Task-number: QTBUG-98545
Fixes: QTBUG-100921
Change-Id: Ie9bfddeaf503d3efe7a73b2e4148bbf0601d693e
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-02-21 14:07:51 +01:00
Thiago Macieira
4be85491e0 QHash: split the x86 AES hash into three separate functions
Instead of performing decisions inside the single aeshash() function, we
have three implementations instead. Those decisions are permanent for
each CPU, so the branch predictor should be pretty good, but hashing is
somewhat performance-sensitive.

We're only adding three of the four possible combinations of AVX512VL
and VAES. Excluded from the implementation are the CPUs that support
AVX512 but not VAES, which are the Skylake-based ones. Those are mostly
found in server CPUs (Intel Xeon Scalable line) as well as top-end
workstations (Intel Core i9), but never made into general desktop and
laptop parts. For those, the performance will remain what it was in Qt
6.3.

VAES is supported in Intel architectures codenamed Sunny Cove and
Gracemont and their successors. That means it's supported in both the E
and P cores of the Intel Alder Lake (12th Generation Core), as well as
future Atom lines. But neither Atoms nor hybrid CPUS have AVX512 (at
least when the E cores are active).

AVX512+VAES is supported for Ice Lake (10th Generation Core), Tiger Lake
(11th) as well as later generation with AVX512 support enabled. Like in
qstring.cpp, we restricted ourselves to 256-bit operations, which don't
cause performance impact and because the 512-bit VAESENC operates on the
fused Ports 0 and 1, so it has the exact same throughput as two 256-bit
VAESENC.

Change-Id: I6fcda969a9e9427198bffffd16cece9c37dbdbd3
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-02-20 16:53:31 -08:00
Thiago Macieira
b313a5ec32 QHash: invert the case that is excluded: use VAES and AVX512VL
It's not worth having both cases, since they run at the same time. The
difference is which CPUs they run for: the non-VAES AVX512 code can run
on the Skylake-based AVX512 CPUs, which aren't a usual target for Qt
(servers and workstations), while the AVX512 and VAES case includes the
Ice Lake and Tiger Lake desktop and laptop CPUs.

This is not a good trade-off, but is an stepping stone for the next
commit.

Change-Id: I6fcda969a9e9427198bffffd16cecbe76e03c884
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-02-20 16:53:29 -08:00
Thiago Macieira
da1720485e QHash: add support for VAES and AVX512VL
The strategy is explained in the aeshash() function. I've chosen to
exclude the case of simultaneous VAES and AVX512VL support for len <= 32
case. Instead, the aeshash128_lt32_avx256() does not attempt to use
VAES, because we wouldn't be getting sufficient benefit at the cost of
code expansion (AESENC can dispatch 2 per cycle). See simulation at
https://analysis.godbolt.org/z/8Y54PMWGj.

The code is slightly convoluted with unexpected indentation so most of
the important lines in the algorithm aren't changed by this commit.

Change-Id: I6fcda969a9e9427198bffffd16ceca30f5e924b5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-20 16:53:27 -08:00
Thiago Macieira
e5373a043d CMake: remove obsolete #FIXME
Also confused Qt Creator.

Pick-to: 6.2 6.3
Change-Id: Ic15405335d804bdea761fffd16d4f209df4311a8
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-02-20 16:52:50 -08:00
Lorn Potter
5a7b836ca7 wasm: make input callback returns consistent
Change-Id: I43d9db1723d85eef69cfa2e51da4a6a640e8b3c5
Reviewed-by: David Skoland <david.skoland@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-02-20 22:28:24 +00:00
Mårten Nordheim
db5b8bbea3 Http2: Fix redirect-handling
The redirect handling for http2 was a little simple. E.g. not handling
relative URLs.
Fix this using the redirect response parsing function which the http1
protocol handler already uses.

Fixes: QTBUG-100651
Pick-to: 6.3 6.2 5.15
Change-Id: Ic0cec4cacc92707e7a7fde1f4665f80995a6057e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-02-20 22:47:25 +01:00
Marc Mutz
ef6c4dfb1c QStringConverter/Encoder/Decoder: make move noexcept
The State state data member had non-noexcept move-SMFs, which were
inherited by the move-SMFs of QStringConverter, QStringEncoder and
QStringDecoder.

To fix, because it is called in the move-assignment operator, we need
to mark State::clear() as noexcept, and, since that can perform an
indirect call through clearFn, require the clearFn to be noexcept,
too.

The only users of clearFn were in Qt5Compat; a separate fix should
have been merged there by the time this lands.

Change-Id: Ibe8147970886526b6a479960050e108607b63874
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-20 20:57:46 +01:00
Marc Mutz
29b18a0179 QSettings: overload value() instead of using a default argument
... of non-trivial type, which needs to be constructed every time the
function is called, no matter whether the user supplies one or not.

Effects on Linux AMD64 O2 C++20 tst_qsettings builds, as an example
heavy-duty QSettings::value() user:

GCC 11.2 libstdc++ (TEXT -= 4.6%):

     text    data     bss     dec     hex filename
   662317   10952    2824  676093   a50fd tst_qsettings-00-baseline
   631849   10960    2824  645633   9da01 tst_qsettings-01-qvariant

Clang 10.0.0 libc++ (TEXT -= 2.8%)

     text    data     bss     dec     hex filename
   808448   10616    2832  821896   c8a88 tst_qsettings-00-baseline
   785890   10624    2832  799346   c3272 tst_qsettings-01-qvariant

Pick-to: 6.3
Task-number: QTBUG-98117
Change-Id: I7366f063e3ec34c040fd35ffd274e8ed5a722132
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-20 16:22:50 +01:00
Alexander Neumann
d49f5752a5 Fix QMetaType::typeName returning wrong result for clang-cl
Pick-to: 6.2 6.3
Change-Id: I94fa1d56d98b8caae514b37fbf6432985195d827
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-20 10:33:33 +00:00
Volker Hilsheimer
2d935dc7f9 Document change to style sheet selectors for enum properties
The change is presumably an unintentional side effect of QVariant and
QMetaType system changes in Qt 6, but it arguably is a good change.

Document it in the porting guide, while evaluating whether (and figure
out how) we want to support integer values as well.

Pick-to: 6.3 6.2
Task-number: QTBUG-99642
Change-Id: Id1589c594bcdc2afe5c4fd0e47a158cd5e03e52f
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2022-02-20 11:21:58 +01:00
Marc Mutz
955106c4fb QStringConverter: make name matching locale-independent
The existing name lookup code used C's toupper() function for
case-insensitive comparison. However, that function's result depends
on the current locale.

Since the matcher is supposed to match the likes of "iso-8859-1" and
"latin-1", matching may fail in locales, such as Turkish, where
toupper(i) is İ (or i, if the former isn't representable in the current
charset), but toupper(I) remains I, causing a False Negative.

To fix, use the US-ASCII-only QtMiscUtils::toAsciiLower() function,
which has the added advantage that it's inline.

Pick-to: 6.3 6.2
Change-Id: I70613c0167d84e3dc3d282c61c716b5dd0b3e6bb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-20 00:58:52 +00:00
Thiago Macieira
b2298b7e94 qsimd_p.h: let the generator script generate the ARCH target strings
__attribute__((target("arch=xxxx"))) does not work because the compilers
(GCC at least) don't test the CPU features that they are targeting, so
we keep getting "inline failed" compiler errors.

GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90129

Upstream patch: https://github.com/opendcdiag/opendcdiag/pull/59

Change-Id: I6fcda969a9e9427198bffffd16cea09fda4406d2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-02-19 13:40:21 -08:00
Thiago Macieira
8b78439980 qsimd_p.h: add x86-64-v4
Change-Id: Ib42b3adc93bf4d43bd55fffd16c1106092205f0d
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-02-19 13:40:18 -08:00
Thiago Macieira
ad65bbe4c0 qsimd_p.h: disallow building with just -mavx2 instead of full x86-64-v3
It's probably a user mistake that they didn't know what they really
wanted. Since no processor that supports AVX2 fails to support the rest
of x86-64-v3, we should enable all of that so we can make use of its
features. Notably, we may want to use FMA at some point in QtGui, and
the compiler will likely use BMI, BMI2, and LZCNT on its own (see
qnumeric.h).

Compiling with -mavx2 will produce GCC these errors:

 qsimd_p.h:266:8: error: #error "Please enable all x86-64-v3 extensions; you probably want to use -march=haswell or -march=x86-64-v3 instead of -mavx2"
 qsimd_p.h:263:49: error: ‘__BMI__’ was not declared in this scope
 qsimd_p.h:263:59: error: ‘__BMI2__’ was not declared in this scope
 qsimd_p.h:263:70: error: ‘__F16C__’ was not declared in this scope
 qsimd_p.h:263:81: error: ‘__FMA__’ was not declared in this scope
 qsimd_p.h:263:91: error: ‘__LZCNT__’ was not declared in this scope; did you mea

Change-Id: Ib42b3adc93bf4d43bd55fffd16c10f8b6a775f3f
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-02-19 13:40:16 -08:00
Thiago Macieira
5f7e02efb8 qsimd_p.h: Restore compatibility with C code
The qCpuHasFeature() macro doesn't work in C mode in x86 because it
tries to use enums only available in C++ mode, but the qCpuFeatures()
function does. You can write:

  if ((qCompilerCpuFeatures & cpu_feature_avx2) ||
      (qCpuFeatures() & cpu_feature_avx2))

In C code and this will compile.

Change-Id: Ic15405335d804bdea761fffd16d50dc4f17f572e
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-02-19 13:40:15 -08:00
Thiago Macieira
ff63a38bb8 qsimd_p.h: group the two HWRNG-related functions
Change-Id: Ic15405335d804bdea761fffd16d50c62ebdf6c0d
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-02-19 13:40:13 -08:00
Thiago Macieira
ec39010390 qsimd_p.h: move macros up
Change-Id: Ic15405335d804bdea761fffd16d50c5a18275b23
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-02-19 13:40:11 -08:00
Thiago Macieira
3cccacd624 qglobal_p.h: move QT_SUPPORTS_INIT_PRIORITY to outside the C++ section
Change-Id: Ic15405335d804bdea761fffd16d50d9c5fc5e237
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-02-19 13:40:09 -08:00
Thiago Macieira
20575393f4 qtnamespacemacros.h: make Q_MANGLE_NAMESPACE() available in C mode
Pretty sure that's what the macro was for anyway.

Change-Id: Ic15405335d804bdea761fffd16d50d94b95192db
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-02-19 13:40:08 -08:00
Andreas Buhr
1ee1e4f6ac QAbstractItemModel: make naming of arguments consistent
The signals rowsAboutToBeMoved/rowsMoved have the same arguments,
but use different argument names. This patch aligns the naming,
making it consistent. Same for columnsAboutToBeMoved/columnsMoved.

Change-Id: I1cefe54319e569b8d57f6579ae9d5c3e33b66dc2
Reviewed-by: David Faure <david.faure@kdab.com>
2022-02-19 16:32:57 +01:00
Marc Mutz
0ef4e6d4bf Use QtMiscUtils::toAsciiLower() around the code
... instead of self-rolled versions in at least three TUs.

QByteArray's asciiLower() cannot be completely removed, yet, because
it's used for indirect calls.

Change-Id: Icf4e7605184f0a1157967c78cbd7632b283c4a9d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-19 07:29:37 +01:00
Marc Mutz
0f52ec8d52 QByteArray: Extract Function QtMiscUtils::caseCompareAscii()
Change-Id: Id9c385f4df4f33792738cd134fabb9cc03cab809
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-19 02:09:35 +01:00
Michal Klocek
be2745e478 Install 3rdparty headers for static builds
For static builds we need 3rdparty headers to be installed.
Leaf modules like qtwebengine needs 3rdparty libs and header for
zlib, freetype, harfbuzz, png, jpeg. Without those the Chromium bundled
versions are used, however it might end up badly if qt has already
bundled one.

Introduce new header only modules with additional arguments for
qt_internal_add_module:

 * EXTERNAL_HEADERS to pick exactly which headers are public
 * EXTERNAL_HEADERS_DIR to include whole directory preserving the
   files directory structure

Fix qtsync so it keep directory structure for all non-qt modules when
syncing headers and do not generate warnings for headers files.

Task-number: QTBUG-87154
Task-number: QTBUG-88614
Change-Id: If1c27bf8608791cd4e0a21839d6316a445a96e9f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-19 01:52:32 +01:00
Allan Sandfeld Jensen
6944b4df7b Revert "Correct haswell function target for clang"
This reverts commit 1cc0494f7d.

Reason for revert: Not a fix, but a break

Pick-to: 6.3 6.2
Change-Id: Ie41d8870dbd52f87059f6bad2335e272409c3046
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-19 00:52:32 +00:00
Thiago Macieira
6323ccfa73 qsimd: Remove QT_COMPILER_SUPPORTS_SIMD_ALWAYS
All[*] compilers support it, always. The last to not support it was GCC
4.8, which we don't support in Qt 6.

[*] Anecdotally, clang-cl doesn't but clang-cl isn't supported and that
would be an upstream problem: clang-cl developers must find a solution
that either matches Clang or cl.exe.

Change-Id: I54f205f6b7314351b078fffd16d0a5ed5b7afae5
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-02-18 15:46:41 -08:00
Thiago Macieira
181d7ea053 QJsonValueRef: add non-const operator[]
These can't be done before Qt 7, unlike their CBOR counterparts, for
binary-compatibility reasons: in 6.x, QJson{Const,}ValueRef must hold a
pointer to an extant QJsonArray or QJsonObject. So this is implemented
for Qt 7 / bootstrap only for now.

Unfortunately, they can't be tested either.

Change-Id: I54f205f6b7314351b078fffd16d067d735c4fe2b
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-18 15:46:41 -08:00
Thiago Macieira
b852584556 qsimd: update the generator script from OpenDCDiag
I'd been making changes to that and improving it for the past 2 years
without bringing it back into Qt.

The list of features is mostly the same, except:
- removed TSX features
- removed features specific to Xeon Phi processors
- added CET and AVX512FP16 features
- added the bit for hybrid CPU detection

See matching update at https://github.com/opendcdiag/opendcdiag/pull/49

Change-Id: I6fcda969a9e9427198bffffd16ce860b5a38aece
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-02-18 15:46:41 -08:00
Marc Mutz
0e60e4bf19 QDesktopServices: make QOpenUrlHandlerRegistry a non-QObject
It seems to have been a QObject solely for its single slot.

But since Qt 5, slots need no longer be defined on QObjects, so we can
remove the inheritance from QObject now. We still need a QObject as
the context object in connect(), but that can be just be an aggregated
naked QObject.

Saves 26 relocations, ~1.5KiB in TEXT and ~0.3KiB in DATA on optimized
GCC 11.2 Linux AMD64 C++20 builds.

Pick-to: 6.3 6.2
Change-Id: Ic45a8e892ec2bd5de5de8fbd32ec7a167c501803
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-18 20:29:37 +01:00
Marc Mutz
5f338040f4 QColor: avoid Unicode table lookups in fromString()
All color names supported by QColor are US-ASCII.

Enforce this with a static_assert, then use this fact to perform the
case-folding of the input in US-ASCII instead of Unicode.

Avoids lookups in the Unicode tables.

Add QtMiscUtils::toAsciiLower() to foster sharing.

Change-Id: Ie0e123405d772943313dc4be1808667b152770b1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-18 18:50:49 +01:00
Edward Welbourne
795c94658d Expand testing of QDateTime's isNull() and isValid()
Bring out the asymmetry between date and time more clearly; when date
is valid, an invalid time is ignored in favor of QTime(0, 0). At the
same time, eliminate an un-needed variable from the code that
implements this special handling. (Left over from when the QTime was
passed by const ref, rather than by value.)

Change-Id: I81d8a9026cbb7887a8c638a2761b3db54c088af7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-18 17:44:53 +01:00
Edward Welbourne
bc91be6a5f Update QTimeZone documentation on the limitations of MS's data
Describe the work-around of ignoring claims of DST prior to 1900.

Change-Id: Ia8a2e6530b285cc8012423ba174fea47732e9ecb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Jaishree Vyas <jaishree.vyas@qt.io>
2022-02-18 17:44:53 +01:00
Edward Welbourne
9a0949a25b Correct handling of start-of-rule situations in QTZP_win
A recent change made sure the handling of a time before the first rule
would be handled correctly; but I wrongly supposed relevant code would
only be exercised in that case. However, it is also run when the
moment after which we want a transition is after the last transition
in the rule for its year: we fall through to the next rule and need to
find its first transition.

This amends commit d98b43005e.

Change-Id: Idb9114a2e272ff9cdb80312f33a0b1e6cd02d582
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-18 17:44:53 +01:00
Edward Welbourne
aafefc094d Extract functions: move some code to TransitionTimePair
Documenting the case where a year starts in DST belongs on the pair
whose job is to work that out. The selection of which transition to
report based on an isDst flag could be said once instead of thrice if
made into a method there, too.

Change-Id: Ice59bb8594097c53bc2fefe1706434462b225274
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-18 17:44:52 +01:00
Friedemann Kleint
f17648bf55 Fix arguments of error message in QFile::copy()
Amends d34282dba0.

Task-number: QTBUG-100867
Pick-to: 6.3
Change-Id: I075908a51192084055b07ecaa38d9fe32a97a242
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-18 16:59:21 +01:00
Tor Arne Vestbø
1741034090 Ensure QMainWindow has WA_TranslucentBackground when using unified toolbar
Otherwise the QWindow will not end up with a surface format with an alpha.

This issue had been hiding in the shadows because we hard-code the backing
store image format to include an alpha, but was discovered when trying to
use RHI to flush the backing store, which does respect the window format.

Pick-to: 6.2 6.3
Change-Id: Ie2b28ca605fc7aa1b1ed22885c8f56e76d3a0305
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-02-18 15:26:32 +01:00
Fabian Kosmale
8079361852 typeNameForCast: use add_pointer instead of string manipulation
Relying on string manipulation leads to -Wredundant-parens warnings in
the best case, and to non-compiling code (when using typedefs) in the
worst case.
We can avoid both issues by simply generating code that uses
add_pointer, which takes care of reference types (even typedef'd ones),
and creates no warnings about parens (as we don't write any anymore).

Fixes: QTBUG-100915
Pick-to: 6.3 6.2
Change-Id: Ic5b1cbfda20d920d11f51beeb62e9479261d5f00
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-02-18 13:44:41 +01:00
Mårten Nordheim
9078b41dde QHttp: Move the emission of requestSent
Moved to after the header is actually written, not just generated.
For requests with data (put/post) we may have to wait for a callback
before the data to write is available. Since we then delay writing the
header as well it would be disingenuous to emit requestSent().

Pick-to: 6.3
Change-Id: I76c2d40ca48faaa1f6730ce8b3d5a8a4c3156f8f
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-02-18 13:44:41 +01:00
Joerg Bornemann
2088e8ae21 Fix warnings in bootstrap lib on Windows
This amends commit 174af05400.

Pick-to: 6.3
Change-Id: Ifc11b3c332f2b7fd16074420a0d730997ae13395
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2022-02-18 13:44:40 +01:00
Pasi Petäjäjärvi
f1d521f076 QNX: Silence compiler warning by initializing variable
qtbase/src/corelib/global/qlogging.cpp: In function 'void qDefaultMessageHandler(QtMsgType, const QMessageLogContext&, const QString&)':
qtbase/src/corelib/global/qlogging.cpp:1555:11: warning: 'severity' may be used uninitialized in this function [-Wmaybe-uninitialized]
     slog2c(NULL, QT_LOG_CODE, severity, formattedMessage.toLocal8Bit().constData());
qtbase/src/corelib/global/qlogging.cpp:1535:9: note: 'severity' was declared here
     int severity;

Pick-to: 6.2 6.3 5.15
Change-Id: Ic0d41a024056528cac51a88086ac7e492c94bb4a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-18 12:44:40 +00:00
Alexey Edelev
e391022d9c Provide missing variables to the ABI-specific external projects
External projects complain about missing host Qt if its location
is different from the one is used when Qt for Android was compiled,
when building multi-ABI package.
This propagates the QT_HOST_PATH, QT_ADDITIONAL_PACKAGES_PREFIX_PATH,
QT_ADDITIONAL_HOST_PACKAGES_PREFIX_PATH variables to the ABI-specific
external projects.

Amends a88b53f713

Pick-to: 6.3
Change-Id: I97fbaa3c21819dd3e9ad2a3f20fe20e74da27ef1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-18 13:44:40 +01:00
Andy Shaw
a14f2d5914 Windows: use QSystemLibrary instead of LoadLibrary directly
Using QSystemLibrary ensures that it will only use the expected copy of
the system library and not one that has been placed in the application's
working directory or elsewhere in the PATH environment variable.

Pick-to: 5.15 6.2 6.3
Change-Id: Ic4234334f73482b38ee5f06345bf11f8c029edc5
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-18 10:02:52 +01:00
Thiago Macieira
4ccd974ada QDebug: unexport most of the class for Qt 7
Only a few helper methods need to be exported.

Change-Id: I74249c52dc02478ba93cfffd16d2e8eac8a13182
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 22:20:07 -08:00
Ievgenii Meshcheriakov
1e468432f6 Update public suffix list
Fixes: QTBUG-100990
Pick-to: 5.15 6.2 6.3
Change-Id: Icfcc7882be35b85bfd8828c6950e2cf23f7ede65
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-18 06:03:49 +01:00
Zhang Hao
72931f4920 Fix UI mismatch when QPrinter::setDuplex
Amends fa854f214a. If user call
QPrinter::setDuplex method, the QPrintDialog explicitDuplexMode value
won't update.

Fix this by:
1) handle device-specific default and value set in QPrinter in
QCupsPrintEngine(Private)
2) handle the explicitly user-selected value in QPrintDialog(Private)

Done-with: Michael Weghorn <m.weghorn@posteo.de>
Pick-to: 5.15 6.2 6.3
Fixes: QTBUG-99504
Change-Id: I1a471a8554e83aa4bec8bb95fcc95f9135b0ac8c
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-02-18 12:19:17 +08:00
Zhang Hao
715ed74c89 Sync QPrinter orientation when PageSetup Orientation selected
QPrinter orientation will not effect when PageSetup Orientation selected

Fix this by sync PageSetup orientation property to QPrinter.

Fixes: QTBUG-100261
Pick-to: 5.15 6.2 6.3
Change-Id: I264852ea18317308dfcfb58c880f5e8ad8d299bd
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-02-18 09:06:10 +08:00
Thiago Macieira
9e0f1b905a qsimd/x86: lower the target architecture for load-time code
That is, allow QtCore to get loaded and print its "missing features"
text without crashing with an undefined instruction. We'll still
abort(), so it's still a "crash", but it'll happen after the message is
printed.

Tested with Intel's Software Development Emulator[1]:

$ sde64 -wsm -- ./libexec/rcc
Incompatible processor. This Qt build requires the following features:
    fma movbe avx f16c rdrnd bmi avx2 bmi2 avx512f avx512dq avx512ifma avx512cd sha avx512bw avx512vl avx512vbmi avx512vbmi2 gfni vaes avx512vnni avx512bitalg avx512vpopcntdq

[1] https://www.intel.com/software/sde

Change-Id: I6fcda969a9e9427198bffffd16ce8b86524a566e
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-02-17 17:02:18 -08:00
Thiago Macieira
b7c37e5978 qsimd: Initialize the current state as soon as QtCore loads
Instead of lazily initializing. We usually don't do this in Qt, but in
this case there are two very good reasons for it:

1) the call tp qCpuFeatures() was not trivial, with the need to preserve
   a bit of state in the caller function across the call. GCC appeared
   to generate better code than Clang in this regard, but it still
   implied more cost than we'd like to do runtime detection in
   performance-sensitive places in Qt.

2) the early initialization allows us to use the detected state in GNU
   indirect functions on platforms that support it.

In order to do this, I had to rewrite the QT_NO_CPU_FEATURE environment
variable parsing without QByteArray and instead rely on string.h's
strtok().

This can't be done for static Qt builds on platforms that don't support
the GNU init_priority variable attribute or the MSVC equivalent[1],
because otherwise we can't guarantee that this bit of code runs before
everything else in Qt. For those platforms, we keep the existing lazy
initialization.

For shared builds in those platforms, we can use the dynamic
initialization. All known linkers will sort the static initialization
code in the order in which the .cpp are linked into the library.

The x86 QSimdInitialized variable will be removed in the next commit.

[1] https://docs.microsoft.com/en-us/cpp/preprocessor/init-seg?view=msvc-170

Change-Id: I6fcda969a9e9427198bffffd16ce885a27f6b9e2
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-02-17 17:02:18 -08:00
Thiago Macieira
b2a9646be9 QIODevice::readAll: allow reading from a huge non-sequential devices
On 32-bit systems, the non-sequential device could be pointing to a
device of 2 GB or more in size. If so, we should allow reading up to
the limit (2 GB - overhead), like we do for sequential devices in the
block above.

It could also happen on 64-bit systems, but the chance that you do have
a file bigger than 8 EB is remote.

[ChangeLog][QtCore][QIODevice] Changed readAll() handling of large
non-sequential devices like files that are bigger than the maximum
QByteArray size (on 32-bit systems, just under 2 GB). Previously,
readAll() always returned empty; now it will attempt to read from the
device.

Task-number: QTBUG-100546
Pick-to: 6.3
Change-Id: I74249c52dc02478ba93cfffd16d1a14ac92c77bb
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2022-02-17 17:02:18 -08:00
Marc Mutz
e4fe301a77 QColor: port parsing to QAnyStringView
The private setColorFromString() function was never called from inline
code in Qt 6 (didn't check Qt 5, which doesn't matter for BC purposes).

This is in preparation of adding a QColor::fromString(QAnyStringView).

Change-Id: I265d7c388370e2e7bb417db1573658346aad4690
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-18 01:04:42 +01:00
Allan Sandfeld Jensen
40bc850597 Fix bootstrapped AVX512 code
SIMD_ALWAYS isn't defined and function targets not working during bootstrap

Fixes: QTBUG-100817
Change-Id: I3008db3a32d28f9e4285517a6a23198307e236bc
Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-17 23:35:41 +01:00
Noah Davis
bfcf47ab9d testlib/qasciikey: Add keypad navigation keys
Needed to prevent qasciikey.cpp from failing an assertion when
Qt::Key_Select is used in tests.

Change-Id: I56aa517e8f6f332636b3df106d7265677d1b33ee
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-02-17 16:05:23 -05:00
Morten Johan Sørvig
738a11eeac wasm: reliably determine QScreen position
Fix bug where QWindow content would be drawn with an
offset from the QScreen’s topLeft if the page was scrolled.

On Qt for WebAssembly, screen geometry is equivalent
to canvas geometry, where the canvas position is the
position of the canvas on the document body.

getBoundingClientRect() is the correct function to use
here, however it returns a rect relative to the viewport.
Offsetting this rect by offsetLeft/Top can work in some
bases, but this offset is relative to HTMLElement.offsetParent
and not necessarily to the document body.

Determine the correct QScreen position by subtracting
the body position from the canvas position (both relative
to the viewport).

Change-Id: Ifb7fd28adedbf997d63f79f9b626cfcf3664ff54
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2022-02-17 20:17:38 +00:00
Alexey Edelev
f63bd1a800 Move generating of the QML related android deployment settings
Use _qt_internal_generate_android_qml_deployment_settings from
QtQml module when generating corresponding Android deployment
settings.

Task-number: QTBUG-97795
Change-Id: Ib509160e841fde98e818b0758bdfaff421dbc259
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-17 18:53:55 +01:00
Allan Sandfeld Jensen
65a02da1b5 Make large inputs to qNextPowerOfTwo give undefined output
Fixing documentation and removing tests.

[ChangeLog][Important Behavior Changes] The qNextPowerOfTwo()
functions now have preconditions.

Change-Id: If6d5e8bee66826910e89be7cac388a1f0422ebfd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-17 17:20:34 +00:00
Kai Köhne
4cdfe6f117 Do not highlight the Image Scaling Example anymore in Qt Creator
Pick-to: 6.3
Fixes: QTBUG-100645
Change-Id: I9f2e2c022a00a024917327028b403d36ca2a4b48
Reviewed-by: Kimmo Leppälä <kimmo.leppala@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-17 18:16:42 +01:00
Noah Davis
a792df2ace QGnomeTheme: remove unneeded Q_D
Change-Id: I3fcb1de9487bfdfab16bae5603fed09ef72e01ba
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
2022-02-17 11:26:42 -05:00
Patrick Griffis
8c77825bb7 Respect AT_SPI_BUS_ADDRESS env var on Linux
Change-Id: Ic277b5ebe2d752360cebdb2ff728ca219f9d7124
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
2022-02-17 07:56:41 -06:00
Kai Köhne
669f0e92aa CMake deployment: Make it more explicit what platforms are supported
That only Windows and macOS are supported is mentioned, but deep down in
the description. Let's make it more prominent.

Pick-to: 6.3
Change-Id: Ia34a10f2fcbe0b2f86b5a0c5585277e169b11fa6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-17 13:55:58 +00:00
Kai Köhne
fc9d1a3c89 Doc: Remove cmake-variables qdoc group
The group is not used anymore. It also prevents qdoc to properly put
the variables in the breadcrumb menu (under "CMake Variables in Qt6 Core")

Pick-to: 6.3
Change-Id: I1afe3b1cb7be8dcdda9a6c6e1235e4457800179d
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-02-17 06:54:43 +00:00
Noah Davis
43caaca740 QGnomeTheme: Allow Space, Return, Enter and Select to press buttons
GTK buttons can be pressed with Space, Return and Enter, so this should
be considered native behavior for GTK based desktop environments.
Qt::Key_Select is also included here because QAbstractButton has been
pressable with Qt::Key_Select for a long time.

Change-Id: I2c279ad05d1a10e5968a18996b8b40a83d2251fa
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-16 18:46:06 -05:00
Allan Sandfeld Jensen
1cc0494f7d Correct haswell function target for clang
Clang uses arch names directly, and not the "arch=xxx" format of GCC.

Appears we do not use this target though.

Pick-to: 6.3 6.2
Change-Id: I1d295f25fe2278c5c6bc0f617496555e28427bea
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-16 22:47:13 +01:00
Alexey Edelev
fedd4f26ad Add missing dependency to the qvkgen tool when generating vulkan code
Pick-to: 6.3 6.2
Fixes: QTBUG-100574
Change-Id: Ib68a3d77e5d3c9a9fc541a69a2748b94ade3ceef
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-16 22:47:13 +01:00
Morten Johan Sørvig
2ed3cc8e7a wasm: move canvas configuration to Qt implementation
The required canvas configuration is an implementation
detail; move it out of the .html file (which we expect
that users will replace), and into the QWasmScreen
constructor.

This also enables using a div element as the container
element (instead of a canvas), since Qt then can create
and configure the canvas during QWasmScreen construction.

Change-Id: Ia849517d00fa3e8ec307065a524c0c91296dd490
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2022-02-16 21:20:36 +01:00
Noah Davis
97eeded5fc QPA: add ButtonPressKeys ThemeHint
Platforms should allow more than just Qt::Key_Space and Qt::Key_Select
to press buttons. KDE Plasma developers want to be able to press buttons
with Return/Enter. GTK allows buttons to be pressed with Return/Enter,
so this should be considered the native behavior for GNOME as well.
Adding this ThemeHint allows customizing the keys that can press a
button via a QPlatformTheme subclass.

Change-Id: I73284e9b73590fbdd0b94a0cb4557e94b3722af9
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-02-16 15:10:00 -05:00
Kai Köhne
3cd8099cfc Doc: Fix cmake example snippets
The argument to file(GENERATE...) is called CONTENT, not CONTENTS.

Pick-to: 6.3
Change-Id: I22fb9eb966223e034b2606cf24315d3cf6a03df1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-16 17:41:43 +01:00
Marc Mutz
f310f426d0 qvkgen: optimize generated string tables
Use qOffsetStringArray instead of array-of-const-char* to hold
strings. Saves 174 relocations, as well as over 4KiB in combined TEXT
and DATA size on optimized Linux GCC 11.2 C++20 AMD64 builds.

Pick-to: 6.3
Task-number: QTBUG-100536
Change-Id: I5849168d0340f78664e566920f92ad136f9dc435
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-16 16:49:16 +01:00
Thiago Macieira
1f7089437a CBOR: disable UUID and QRegularExpression support in bootstrapped builds
We don't need them.

Drive-by opportunity to ensure byteData() didn't return null. It could
happen.

Change-Id: I74249c52dc02478ba93cfffd16d1e1fc060cdaef
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-16 01:59:51 -08:00
Thiago Macieira
a1b2c474fd QPluginParsedMetaData: avoid the indirection through QCborMap
value[x] is the same as value.toMap()[x] but avoids the refcounting up
and down just to call the operator[] overload. We're calling the
operator[] overload taking an integer, which means it could match an
array, but we know the data member won't be one because of how
QPluginParsedMetaData::parse() parses.

Change-Id: I2cffe62afda945079b63fffd16bd5c690b2bfee4
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-16 01:59:51 -08:00
Axel Spoerl
ea0e0a8652 Eliminate double arrow in QToolButton
- InstantPopup mode is set and
- application uses a stylesheet that does not apply to QToolButton

Task-number: QTBUG-100401
Pick-to: 6.3 6.2
Change-Id: Iadf752ad9280d59763f4efc1938927a9b83e6ad9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-16 10:57:20 +01:00
Thiago Macieira
8de0493896 QMetaObjectBuilder: fix addProperty() recording of the property type
Issue introduced by commit 465701bb98.

[ChangeLog][QtCore][QMetaObjectBuilder] Fixed a bug that would cause
addProperty() to use the incorrect type for the property if the
property's name matched a valid type registered with QMetaType.

Pick-to: 6.2 6.3
Change-Id: Ic15405335d804bdea761fffd16d402f2c9611f30
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-16 01:47:09 -08:00
Thiago Macieira
d34282dba0 QFile::copy: add the underlying error messages to ours
Fixes: QTBUG-100867
Pick-to: 6.3
Change-Id: Ic15405335d804bdea761fffd16d401a7c16f32f9
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-16 01:47:09 -08:00
Thiago Macieira
8f1a827d91 QIODevice::read: don't truncate to int(readBytes)
QByteArray in Qt 6 *can* hold more than 2GB-overhead of data.

Untestable.

Fixes: QTBUG-100546
Pick-to: 6.2 6.3
Change-Id: I74249c52dc02478ba93cfffd16d1a0ab398efe9c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-16 09:47:09 +00:00
Zhang Hao
d978c230a4 Do not highlight the HTTP Example anymore in Qt Creator
Pick-to: 6.3
Fixes: QTBUG-100647
Change-Id: I413b37daf784f3a4975caa5a48273f4a83aa1da6
Reviewed-by: Kimmo Leppälä <kimmo.leppala@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-16 14:40:34 +08:00
Alexandru Croitor
e5b3436255 CMake: Add default launch screen storyboard for iOS apps
Bundle a default LaunchScreen.storyboard file for an iOS app and make
sure it's referenced in the generated Info.plist file.

When launching Qt examples, it ensures the app uses the whole screen
space on the device rather than just a square-ish part of it.

The storyboard file is a copy of the qmake one, which qmake adds
to the Xcode projects it generates.

A custom launch screen can be provided either by setting the
QT_IOS_LAUNCH_SCREEN variable or by setting the
QT_IOS_LAUNCH_SCREEN target property.
The value must be an absolute path to the launch screen file.

The automatic addition of the launch screen entry in the Info.plist
file can be prevented by setting the QT_NO_SET_IOS_LAUNCH_SCREEN
variable to TRUE.

The automatic bundling of the launch screen file in the application
bundle can be prevented by setting the
QT_NO_ADD_IOS_LAUNCH_SCREEN_TO_BUNDLE variable to TRUE.

The current implementation has a limitation that only one launch
screen storyboard and one iOS executable can exist within a project.

If there are multiple executables in the project, all of them will
use the launch screen that is specified last (the last
qt_add_executable call).

Because of this limitation, the API is marked as Technical Preview,
to be improved upon in the future. For now it simply serves as an
improvement to the out-of-the-box experience of iOS apps built
with CMake.

Amends 4d838dae5a

Pick-to: 6.2 6.3
Fixes: QTBUG-95837
Change-Id: I6b067d703d635122959a1ef17fcca713da694a86
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-16 05:14:24 +01:00
Mårten Nordheim
a1fb3971f2 QHash: fix off-by-one in assertions
Coverity-Id: 378365
Coverity-Id: 378366
Coverity-Id: 378399
Coverity-Id: 378427
Coverity-Id: 378468
Coverity-Id: 378472
Pick-to: 6.3 6.2
Change-Id: Ib1efeacb59030b9d004320e56f560367f564d207
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-16 04:24:21 +01:00
Marc Mutz
a24ef92468 QColor: eradicate QT_STRINGVIEW_LEVEL
It's not used and not useful.

Task-number: QTBUG-100861
Pick-to: 6.3 6.2
Change-Id: I30f7f41311182f056f2f6d5a9b49385fb09d194e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-16 04:20:51 +01:00
Sona Kurazyan
221df41572 Move QBindingStorage methods marked for removal to removed_api
From the API review.

Pick-to: 6.3
Change-Id: I676ff811a3b3d43ebcbee78ed0210d669d642947
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-16 02:28:53 +01:00
Thiago Macieira
d1f077a435 QJsonValueRef: don't export the entire class in Qt 7
Change-Id: I54f205f6b7314351b078fffd16d061ca8870b453
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 17:00:05 -08:00
Thiago Macieira
705ea62f9e QJsonValueConstRef: prepare for Qt 7
Instead of storing a pointer to the QJsonArray or QJsonObject (like the
Qt 4 & pre-5.15 versions did), do like QCborValueConstRef and store the
pointer to the QCborContainerPrivate.

Unlike QCborValueRef, we must keep the is_object bit because of API
behavior that assigning an Undefined to an object reference deletes it
from the container. I've chosen to use size_t instead of qsizetype for
this because then we don't lose any bits of the index. Therefore, the
index in the case of objects is stored as pair count (like before),
different from QCborValueRef which stores the actual index in the
QCborContainerPrivate.

It's the LSB (on little-endian architectures) so the calculation of
2 * index + 1 is the actual value stored in memory or in the
register. Unfortunately, right now, both Clang and GCC don't realize
this and generate unnecessary instructions. Clang:

0000000000000000 <QJsonValueConstRef::concreteType(QJsonValueConstRef)>:
   0:   mov    %rsi,%rax
   3:   shr    %rax
   6:   mov    %rsi,%rcx
   9:   or     $0x1,%rcx
   d:   test   $0x1,%sil
  11:   cmove  %rax,%rcx

[GCC code is identical, except it uses an AND instead of TEST]

That OR at offset 9 is a no-op because it sets a bit that is already set
in those conditions. At least they don't do unnecessary shifts.

Change-Id: I89446ea06b5742efb194fffd16bb7aadb6a9b341
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 17:00:05 -08:00
Thiago Macieira
a747ab0b72 QJson{Array,Object}: rewrite & simplify some iterator functions
Instead of manipulating indices in multiple functions, make some call
the others. This reduces the number of places porting must happen at, if
we wanted to.

Change-Id: I89446ea06b5742efb194fffd16bb78d24e0528b2
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 17:00:05 -08:00
Thiago Macieira
01fe59a3b7 QJsonObject::removeAt: stop dividing and multiplying by 2
Change-Id: I89446ea06b5742efb194fffd16bb7d17182c6a2a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:05 -08:00
Thiago Macieira
d263147921 QJsonValueRef: optimize the assignment
Inline some content to avoid unnecessary round-trips through
qcborvalue.cpp, qjsonarray.cpp and qjsonobject.cpp.

Unlike the CBOR counterparts, JSON support has this extra functionality
that assigning Undefined causes the item to be removed from the object
(arrays don't have that behavior, they just become null).

And unlike QCborValueRef, we detach on assignment, not on the obtention
of the QJsonValueRef. This is more dangerous, so we may want to revise.

Change-Id: I89446ea06b5742efb194fffd16bb775e9566ca1a
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 17:00:05 -08:00
Thiago Macieira
c1780165ee QJsonValueConstRef: optimize to{Int,Integer,Bool,Double,String}()
The CBOR-based implementation from Qt 5.15 simply created a QJsonValue and
then called the equivalent function on that result. For integrals and
double where the QJsonValue matched the asked type, the cost was minimal
anyway. For the other types and when the type didn't match, this
resulted in up/down the reference counter in QCborContainerPrivate and
an out-of-line call to the destructor.

This improves the performance for code like:

  for (QJsonValue v : array) {
      if (v.toString() == x) {
          doSomething();
      }
  }

This change propagates the inadviseable behavior of allowing a
dereference of the end() reference in concrete() to concreteType() (and
unit-tests it) but does not do the same for the toXxx() functions. Doing
that causes a dereference of QList's end() iterator, which is UB
(asserts false in debug mode).

Change-Id: I89446ea06b5742efb194fffd16bb3beccd1098e4
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:04 -08:00
Thiago Macieira
dccd1e87f5 QJsonValueConcreteRef: optimize concrete()
Inline the content to avoid a round-trip through qjsonarray.cpp and
qjsonobject.cpp.

This change revealed an inadviseable unit test check that dereferences
the end() iterator to get its type. I haven't changed it, but have
marked with ###. I also fixed a likely copy&paste mistake in that test.

Change-Id: I89446ea06b5742efb194fffd16bb774f3bfbe5f5
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:04 -08:00
Thiago Macieira
e99417106f QJsonObject::erase: erase unnecessary and wrong code
Commit 35adb74ddd ("Reimplement JSON
support on top of Cbor") accidentally forgot to multiply by 2 the index
stored in the QJsonObject::iterator. The same mistake was propagated
when QJsonObject::iterator was converted to QJsonValueRef. This had no
ill effects because the o->elements container would always contain more
elements, but it meant the check was ineffective and meant nothing.

So instead of doing nothing when the iterator does not point to this
container, simply assume it does. Bad things will happen if you try to
erase an iterator that points to another container, but that's true for
almost all container/iterator mechanisms.

Drive-by modernization of some of the surrounding lines.

Change-Id: I89446ea06b5742efb194fffd16bb7c322c2fc4f2
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:04 -08:00
Thiago Macieira
f276f9ec6b QCborValue: use assignContainer() in few more places
Change-Id: I5e52dc5b093c43a3b678fffd16b6eb65ef37399d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:04 -08:00
Thiago Macieira
ccea344640 QCborValue: optimize the array-to-map conversion
Yes, this is a cold function, but we can do it in-place if we want to.

Done in three separate passes so the autovectorizer can do its thing, if
it wants to.

Change-Id: I5e52dc5b093c43a3b678fffd16b6eb34d02fc40b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:04 -08:00
Thiago Macieira
f4d49910be QCborValueConstRef: optimize to{Integer,Bool,Double,String,ByteArray}()
The initial implementation from Qt 5.13 simply created a QCborValue and
then called the equivalent function on that result. For integrals and
double where the QCborValue matched the asked type, the cost was minimal
anyway. For the other types and when the type didn't match, this
resulted in up/down the reference counter in QCborContainerPrivate and
an out-of-line call to the destructor.

This improves the performance for code like:

  for (QCborValue v : array) {
      if (v.toString() == x) {
          doSomething();
      }
  }

Change-Id: I5e52dc5b093c43a3b678fffd16b6022da4e2d446
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:04 -08:00
Thiago Macieira
afe2f80c6a QCborValueRef: merge the operator[] into a template
Change-Id: I5e52dc5b093c43a3b678fffd16b6e94ad9d3f39b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:04 -08:00
Thiago Macieira
832fcbf37f QCborValue: merge the const operator[] into a template
Change-Id: I5e52dc5b093c43a3b678fffd16b6ec4b7d841955
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:04 -08:00
Thiago Macieira
072f0d5717 QCborValue: merge the non-const operator[] into a template
Change-Id: I5e52dc5b093c43a3b678fffd16b6e7b32b3e2835
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:03 -08:00
Thiago Macieira
f1c305cbd2 QCborMap: merge the operator[] methods into a template
Change-Id: I5e52dc5b093c43a3b678fffd16b6e7a123338178
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:03 -08:00
Thiago Macieira
11ea172178 QCborMap: merge the constFind methods into a template
Change-Id: I5e52dc5b093c43a3b678fffd16b6e558c4e1f089
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:03 -08:00
Thiago Macieira
3531f578d3 QCborArray: allow large but in-range keys
The 0x10000 limit should not apply if the key is a valid index in the
array.

Change-Id: I5e52dc5b093c43a3b678fffd16b6a2a5a69acd61
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:03 -08:00
Thiago Macieira
800f60657d QJsonObject: use QJsonValueConstRef
Change-Id: I5e52dc5b093c43a3b678fffd16b608f32f8eb4b4
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 17:00:03 -08:00
Thiago Macieira
f5762cd4b3 QJsonArray: use QJsonValueConstRef
Change-Id: I5e52dc5b093c43a3b678fffd16b6086dcd1d3268
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:03 -08:00
Thiago Macieira
51fc317041 QCborMap: use QCborValueConstRef
Change-Id: I5e52dc5b093c43a3b678fffd16b606e4249a205b
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 17:00:03 -08:00
Thiago Macieira
64d568b550 QCborArray: use QCborValueConstRef
Change-Id: I5e52dc5b093c43a3b678fffd16b6077e5c4abd63
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 17:00:03 -08:00
Thiago Macieira
04dc959d49 Introduce Q{Json,Cbor}ValueConstRef
I screwed up when I wrote QCborValueRef by not having the ConstRef
type. The code worked, but it wasn't const-correct, allowing you to
write:

  const QCborArray &arr = something();
  *arr.begin() = QCborArray();

This mistake was brought over to QJsonValue in Qt 6.0, so it has to be
fixed for QJsonValue too. The actual fixes are in the next couple of
commits.

This change is believed to be binary-compatible: the Q{Json,Cbor}ValueRef
classes continue to have the exact same size, except that they're now
empty and have a new base class. They weren't trivial before this commit
doesn't change that.

[ChangeLog][Potentially Source-Incompatible Changes] The iterator
classes for Qt's JSON and CBOR containers (array and map/object) had a
const correctness issue which allowed a const_iterator to mutate the
container being iterated on, even if that container was itself const. Qt
6.4 has a fix for this, but will cause compilation issues where
QCborValueRef and QJsonValueRef were used where the correctness could be
violated. To keep code compiling with both 6.3 and 6.4, either change to
non-const iteration or replace the QxxxValueRef with a const QxxxValue
reference. This change is binary-compatible.

Change-Id: I5e52dc5b093c43a3b678fffd16b6063333765ae0
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 17:00:03 -08:00
Thiago Macieira
9b8f064cd3 QCborValueRef: fix using operator[] to convert an empty array to map
The flag IsContainer was not set, causing the QCborContainerPrivate to
become confused.

This commit also expands and subsumes the existing test for QCborValue
(non-Ref).

Change-Id: I5e52dc5b093c43a3b678fffd16b6a17c6f4a0676
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:03 -08:00
Thiago Macieira
3c7b507d1c QCborValueRef: add a test to confirm that its methods reflect QCborValue
This has found several missing const qualifications, a missing
QCborMap::Iterator method, and a missing one in QCborValue too.

The methods "### TEMPORARY" in this commit are actually removed in two
commits.

Change-Id: I5e52dc5b093c43a3b678fffd16b6939f62954dc4
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 17:00:02 -08:00
Marc Mutz
e7706429bb QLibrary: add a #warning if the fall-back plugin-meta-data parser is used
Change-Id: I4b42f8dbc9fb03fc6e7243ed4914acfb1bdfe62a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-16 01:20:13 +01:00
Ivan Solovev
60799fc141 Android A11Y: Fix value rounding
QAccessibleInterface stores values as QVariants. When dealing with
double values, as a result of some calculation (for example, Slider
value update), rounding errors can be introduced.
When converting double values to QString using QVariant::toString(),
these rounding errors result in strings like
0.30000000000000004 instead of 0.3 or
2.7755575615628914e-17 instead of 0.3 - 3 * 0.1 and similar zeroes.

To fix this issue, this patch introduces a custom conversion for
floating-point values. The idea is to convert QVariant to double,
and then convert double to QString using 'f' format and a suitable
precision, determined from the UI element's minimumStepSize(), if
it has one, otherwise falling back to QString::number()'s default
(which is 6).

Task-number: QTBUG-93396
Pick-to: 6.3 6.2 5.15
Change-Id: Ia5ca7345812e39629e9c191b6d8b896a8f51de80
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-02-15 17:51:33 +01:00
Ivan Solovev
a374d59abc Android A11Y: Announce value together with element name when focused
Before this patch when we focus a new element, only its description
was announced.
For elements like Slider that means that if it had no accessible name
or description, its value would be announced (all is fine here).
But if the slider is defined like that:
 Slider {
     Accessible.name: "int slider"
     value: 5
     from: 0
     to: 20
     stepSize: 1
 }

only the name ("int slider") will be announced, but not the actual
value.

This patch fixes the logic of content description generation. If the
element has value, then it is added to the description and announced
as well.

Task-number: QTBUG-93396
Pick-to: 6.3 6.2 5.15
Change-Id: Ia8667149ebd867945c5f57d951fd6ade0f382598
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-02-15 17:51:33 +01:00
Ivan Solovev
b238f83380 Android A11Y: handle valueChanged events
Before this patch Android A11Y implementation was missing
ValueChanged event handling. As a result, no update was given
when the element's value was changed.

Handling these events allows us to announce value changes on such
objects like Slider, SpinBox, etc...
This is a universal method of value-change announcement, so it
supports all sorts of A11Y gestures.

On the Java side a new function was introduced to announce the
values, because we need to use the actual element's *value*,
not its accessible name or description.

Task-number: QTBUG-93396
Pick-to: 6.3 6.2 5.15
Change-Id: Ic44abd5f01b9b6f5468962131466edaf6a49d498
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
2022-02-15 17:51:33 +01:00
Laszlo Agocs
b48e6e783b Convert Vulkan instance setup from Qt Quick into a Gui helper
Make it possible to reuse what's in QSGRhiSupport from other modules as
well. Both Gui (texture-based widget/backingstore composition) and
Multimedia are potential users of this in the future.

Change-Id: I1b50cc5efd6811e9bc95f6287b9576931d4bcc44
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2022-02-15 15:36:01 +00:00
Øystein Heskestad
6deded8bc4 Change third party SHA-3 implementation to use
Task-number: QTBUG-71327
Change-Id: I14fef2a6f66dfb26f635cc7b6bde2b7cbf733ea7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-15 15:44:51 +01:00
Marc Mutz
d34c3f9e94 QLibrary: use QStaticByteArrayMatcher
Because of code-after-return style, I don't actually know what the
code is used for, but since it's compiled, make sure to not leave a
dynamically-initialized static variable lying around, even if control
never reaches it.

Pick-to: 6.3
Change-Id: I6ce30d8c060f96a2d819ed85f79d18a7ef7e9b05
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-15 15:44:51 +01:00
Alexandru Croitor
1559cd8ff2 CMake: Document source file properties
Pick-to: 6.2 6.3
Task-number: QTBUG-100224
Change-Id: Id4d0e0d84762d9eee2beb10e850d1775ad4f3245
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-02-15 15:44:51 +01:00
Thiago Macieira
d08f59d083 qsimd: simplify the code slightly
Only x86 requires more than 32 different bits in the CPU feature
variable, so enforce the need for 64-bit atomics only for it. Everyone
else can stick to 32-bit atomics, which are supported everywhere.

Change-Id: I54f205f6b7314351b078fffd16cf7c7d50a84102
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 04:20:35 -08:00
Marc Mutz
37a25fce94 QDesktopServices: deprecate destroying URL handlers w/o explicit unsetUrlHandler()
[ChangeLog][QtGui][QDesktopServices] URL handlers that have been passed
to setUrlHandler() must now be removed by calling unsetUrlHandler()
before they are destroyed. Relying on the handler's destructor to
implicitly unset it is now deprecated, because it may already be in use
by concurrent openUrl() calls. Support for implicit unsetting will be
removed in 6.6 and, until then, a qWarning() is raised if it is
exercised.

Fixes: QTBUG-100775
Fixes: QTBUG-100779
Pick-to: 6.3 6.2 5.15
Change-Id: I0c4f91b78f847b135fdeb38766babc892bdc1379
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 12:20:16 +00:00
Fabian Kosmale
06e45cbd6a QFileSystemEngine::canonicalName (Unix): clean up control-flow
When passing a nullptr to realpath, it will allocate memory. That memory
has to be freed (with free) later to avoid a leak, which we so far
didn't.
This patch ensures that we always clean up the memory by using a
unique_ptr. As a drive-by, clean up the control-flow:
- Always pass either the stack buffer or nullptr to realpath.
- Rely on realpath returning nullptr in the error case.
Lastly, fix a few coding-style issues.

Change-Id: Ia906df77324020c267b087ec52a9a6c47aaa2a59
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-15 12:05:33 +01:00
Allan Sandfeld Jensen
e1b76e68d0 Fix clang-cl warning
Warns the include is non-standard, so replace it with standard
includes.

Pick-to: 6.3
Change-Id: I8db4b65a3f706cb31215332277a3378df88a0003
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-15 12:01:31 +01:00
Joerg Bornemann
85970834b5 CMake: Promote qt6_standard_project_setup from technical preview
The API couldn't be simpler (function without arguments), and we want to
use the function on our "Getting Started with CMake" documentation page.

Pick-to: 6.3
Task-number: QTBUG-100793
Change-Id: I83ba66c2970ac7441b425add4df1da2695e50ddb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-15 10:23:03 +01:00
Tor Arne Vestbø
f71d54ee34 Update docs for QSurface::MetalSurface to include iOS
Pick-to: 6.3 6.2
Change-Id: I67fc47b3dc33960e7dfa78890d16d1e7450e30ab
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-15 09:11:00 +01:00
Joerg Bornemann
da27a95aab Compile QNetworkAccessDebugPipeBackend only in developer builds
This fixes a moc warning in non-developer builds.

Change-Id: I879a17715fd682382ce47ce4cfd7e162f8ceb2de
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-15 09:10:59 +01:00
Marc Mutz
3ec76f82ba QBitmap: de-inline dtor
The destructor of this polymorphic class was incorrectly marked for
removal in Qt 6, and, unfortunately, that was carried out. Now it
delivers one of the most-duplicated vtables across all of Qt (at least
four duplicates), and we can never add anything to it until Qt 7
(because existing code de-virtualized it as a no-op).

Task-number: QTBUG-45582
Pick-to: 6.3
Change-Id: I85bd3b13dca9f1fc8cb62ca079a1168a33f71323
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-15 09:08:16 +01:00
Marc Mutz
9b6c288281 De-duplicate vtables, 2022 edition
This de-inlines destuctors of classes whose vtables are proven to be
duplicated even within the set of Qt libraries.

Since these are all private API classes, we can pick all the way back
to 6.2, and we don't need the comment that the dtor must always stay
empty, like for public classes.

As a drive-by, also de-inline the QPaintDeviceWindowPrivate ctor.
That's just code hygiene, it doesn't partake in vtable duplicating.

Pick-to: 6.3 6.2
Task-number: QTBUG-45582
Change-Id: I3477063d6f42edc9a5d352c47900366fd50c3ef6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2022-02-15 09:08:16 +01:00
Yin Jie
60a67dc41e Position QCompleter popup based on the widget's screen geometry
If adding a QLineEdit to a QGraphicsScene as a QGraphicsProxyWidget, the popup
completion of that QLineEdit is drawn in the wrong location. When the completer
getting the rect of screen, it gets the rect of the QGraphicsScene where
QLineEdit is located rather than the rect of the screen, resulting in an error
in the following calculation.

Note that as long as the completer popup is a toplevel widget not parented
to the target widget, it will not be automatically embedded into the graphics
view via QGraphicsProxyWidget. So with multiple views for a scene, or in views
that use transformations, the geometry will still be off.

Pick-to: 6.3
Task-number: QTBUG-20531
Change-Id: If5d8a707ca35a9e4709117b077978145c6143e46
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-15 01:28:30 +00:00
Viktor Arvidsson
7794421bea Windows QPA: Correct mistake when calculating minmaxinfo
Amends 46e9852a1d

The previous code would fail if the windows taskbars are placed
to the top or left on the screen. The mistake was missed because
Windows seems to adjust the window position automatically
in case the window handles WM_NCCALCSIZE and returns 0,
which was the case for me.

Task-number: QTBUG-51327
Pick-to: 5.15 6.2 6.3
Change-Id: I38ef974f7518be63a0bacf080f3359c219284078
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2022-02-14 23:48:23 +01:00
Øystein Heskestad
c6958cbbd6 Add new third party SHA-3 implementation to replace old obsolete one
[ChangeLog][Third-Party Code] Added new SHA-3 implementation to Qt Core.
The code is available under BSD 3-Clause "New" or "Revised" License.

Task-number: QTBUG-71327
Change-Id: Ib1f1003b0ef7e6f6c3787cbbd45f3f06fc667b7e
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2022-02-14 17:32:14 +01:00
Andreas Buhr
d456102962 Make Droid Sans Mono available as fixed font for all Android styles
Fixes: QTBUG-87405
Change-Id: I54ebc06c82c32acd0383ea5fedf78acce4e11977
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-02-14 16:22:28 +01:00
Marc Mutz
40e2bf3495 QFlatMap: temporarily disable some code
... which implements or assumes something about the
broken^Wnon-STL-compliant insertion behavior.

Once this has integrated into all module dependencies, we can
re-implement these APIs using STL-compatible semantics.

Task-number: QTBUG-100092
Change-Id: I54f4f5ce7addd9543866d2c399f48aff50983b88
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-14 13:20:03 +01:00
Eskil Abrahamsen Blomfeldt
d6c4a3edf9 Fix integer overflow for broken QPainterPaths
With some bogus input, we can end up with NaN in the
bounding rects of the control points. This in turn
causes problems later when it is converted to ints
and used in code. To avoid it, we exit early if the
rect is invalid (negative or NaN size).

Pick-to: 5.15 6.2 6.3
Fixes: QTBUG-100217
Change-Id: Idbc6700b85cb30198d69fedbf8f3be3e1ab65e40
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-02-14 12:51:10 +01:00
Kai Köhne
8275611766 Core: Remove 'properties' feature
Even QtCore alone cannot be built without the properties feature since
Qt 5.5. While fixing this is easy, other modules like dbus,
networking are also using QObject::property() and friends liberally.

All in all I doubt that anybody will miss the feature (otherwise it
would have been fixed in the last decade).

Change-Id: Iaf3cc20bda54ee2ff3b809fac8fa82b94ecc88c0
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-14 12:50:59 +01:00
Ivan Solovev
b99fdae5f5 Android A11Y: populate child elements when constructing node info
This commit partly reverts 020a6f0dae.
It restores the code that is responsible for filling the children
for individual elements. Without this code, we have only top-level
element and its children in our accessibility hierarchy.

Fixes: QTBUG-100545
Pick-to: 6.3 6.2 5.15
Change-Id: I0604bbf5f1bdb0b3998a25fec7ed0a1fe554da8d
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-02-14 09:34:36 +01:00
Marc Mutz
c8e03f129e QHashSeed: remove 'pure' attribute on globalSeed()
While 'pure' in GCC is weaker than Stepanov's Regular Procedure from
Elements of Programming (equal result for equal inputs), it does not
allow accesses to volatile memory:

> functions declared with the pure attribute can safely read any
> non-volatile objects

The globalSeed() function reads from an atomic variable that can be
changed at any time from another thread.

Atomics, while not volatile objects in the sense of the keyword, must
fall under the pure attribute doc's exclusion criterion:

The difference between a volatile and an atomic access, while
important for the implementation of the function, is indistinguishable
to the caller of the function: both volatile and atomic objects can
change value without the current thread of execution changing them,
with no way for the caller of the function to distinguish which one
occurred.

Therefore, globalSeed() should not be pure.

5.15 is not affected, as qGlobalQHashSeed() is not marked as pure.

Task-number: QTBUG-62185
Pick-to: 6.3 6.2
Change-Id: I6fc52e2bd41ef4aa3f8039072b47c7a1314b98fa
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-12 12:39:52 +01:00
Marc Mutz
b5c4d1f50b QPkmHandler: make const what it never modified
Pick-to: 6.3 6.2 5.15
Change-Id: I0bda0d93ebe60d4923f3e9eb059cddb61192b1b5
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-12 12:39:52 +01:00
Marc Mutz
f482e2a456 QDesktopServices: fix ABA problem in QOpenUrlHandlerRegistry
The registry is designed to be thread-safe, as is openUrl(), and
handlers are required to be thread-safe, too: "the handler will
always be called from within the same thread that calls
QDesktopServices::openUrl()".

The handlerDestroyed() slot was invoked using AutoConnection
semantics, which, if the registry and the handler happen to not be on
the same thread, is QueuedConnection, which means there's a window in
which the handler is destroyed, but it's still listed in the registry,
and a call to openUrl() may make a call to the (deleted) handler.

Worse, if a handler is deleted and new one registered they may end up
on the same address (ABA, or rather, AA problem), and then the delayed
call to handlerDestroyed() may remove the entries to the new handler,
as well as those to the old.

Fix by using Qt::DirectConnection. This fixes the ABA problem, but
doesn't completely fix the partially-destroyed problem, since
QObject::destroyed() is simply too late. We need to require explicit
unsetUrlHandler() calls, which should happen before destruction of the
handler object starts.

[ChangeLog][QtGui][QDesktopServices] Fixed a bug where destroying and
re-creating a handler object in quick succession could cause the
registration for the handler to be lost.

Fixes: QTBUG-100778
Pick-to: 6.3 6.2 5.15
Change-Id: I76fd81724504cc7f38ac262b43e3e9539fe5ebca
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-12 11:39:52 +00:00
Marc Mutz
42e13b7c61 QDesktopServices: fix UB (data race on handlers)
The handlerDestroyed() function is connected to the handler QObject's
destroyed() signal and removes all entries from the registry for which
the destroyed object was listed as the handler.

While handlerDestroyed() is always executed in the context of the
thread owning QOpenUrlHandlerRegistry-as-a-QObject, the documentation
explicitly states that "the handler will always be called from within
the same thread that calls QDesktopServices::openUrl()", implying that
calling openUrl() from a non-GUI thread is supported. The presence of
the mutex also indicates that this should work.

But then the unprotected access to the handlers variable in
handlerDestroyed() is a data race, because nothing prevents a handler
object from being destroyed concurrent to an openUrl() call.

Fix by locking the mutex.

Fixes: QTBUG-100777
Pick-to: 6.3 6.2 5.15
Change-Id: I9ef857efa609b4d16ee21063ccccd316e119576b
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-12 12:39:51 +01:00
Thiago Macieira
4fd4082c3a QStringView: add missing constexpr so we can use is_constant_evaluated
GCC 12 -std=c++20 says:

 qstringview.h:155:39: error: ‘std::is_constant_evaluated’ always evaluates to false in a non-‘constexpr’ function [-Werror=tautological-compare]

With this, it's possible to declare:

  constexpr QStringView sv = u"Hello, World!";
  QStringView f() { return sv; }

And GCC will generate:

        movl    $13, %eax
        leaq    .LC0(%rip), %rdx
        ret

Writing simply
  QStringView f() { return u"Hello, World!"; }

Causes GCC to emit a comparison loop (the std::char_traits::length
function), but at least there's no function call in either C++17 or
20. Clang 13 is able to reduce the loop to a constant and produces the
same code as the constexpr variable in either mode.

Pick-to: 5.15 6.2 6.3
Change-Id: I74249c52dc02478ba93cfffd16d282fa35a5b883
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-12 07:59:32 +00:00
Ilya Fedin
bc3723d462 Make indicator-application hack work in flatpak
Flatpak doesn't share $XDG_RUNTIME_DIR with the host making
QSystemTrayIcon not to work on Xubuntu/Ubuntu MATE/Ubuntu Budgie.

Although, it shares a subfolder, according to
https://docs.flatpak.org/en/latest/sandbox-permissions.html

Amends 0baa26638d

Pick-to: 6.3 6.2 5.15
Change-Id: I2d0043fc5a4c2c51e8fa1a920f3cada3b07eba6d
Reviewed-by: Dmitry Shachnev <mitya57@gmail.com>
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
2022-02-12 03:01:08 +04:00
Viktor Arvidsson
46e9852a1d Windows QPA: Fix frameless maximize on secondary screens
Frameless windows shouldn't cover the taskbar when maximized.
This has been fixed for the main screen in the past but did not
work for secondary screens. According to the code the MINMAXINFO
is only available for the main screen but I believe this is a
misunderstanding of the Windows documentation.  Besides
we use QScreen::availableGeometry() which seems to be correct.

Fixes: QTBUG-51327
Pick-to: 5.15 6.2 6.3
Change-Id: Ib2205c480359d1a870dcfcf0312fbe417f650e28
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-02-11 23:05:20 +01:00
Allan Sandfeld Jensen
a0d1f6b5aa Remove documentation of non-existing QAccessible state
invalidEntry is commented out

Pick-to: 6.3 6.2 5.15
Change-Id: Iffb661ec85b1b633f56c9aba94c1f0727a93c987
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-11 22:56:35 +01:00
Thiago Macieira
47cf674477 QTimerInfo/Unix: Fix roundToMillisecond when it's already rounded
Don't add 1 ms when it's rounded to 1 ms.

Found when running unit tests on QNX, where the clock did not update
between two subsequent calls to clock_gettime().

All of this ought to be refactored to use std::chrono::nanoseconds.

Fixes: QTBUG-100438
Pick-to: 6.2 6.3
Change-Id: I47dc6426c33d3a66dec946ae3589694745ed1835
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-11 13:02:35 -08:00
Sona Kurazyan
407d076124 Remove mentions of QtConcurrent::runWithPromise from docs
cf043a785a unified QtConcurrent::run() and
QtConcurrent::runWithPromise(). Remove the last mentions of
runWithPromise. Also did some minor cosmetic improvements.

Pick-to: 6.3
Change-Id: Ie3b39600978ccfa4a009d3ff68567a348dc7b166
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2022-02-11 22:02:35 +01:00
Mårten Nordheim
52492ff720 HTTP: Make redirect response parsing more generic
To enable its use in the http2 protocol handler.
This factors out the error-reporting code for HTTP 1, which in
any case has to be done differently for HTTP 2, saving duplication
and simplifying the redirect handling code.

Task-number: QTBUG-100651
Pick-to: 6.3 6.2 5.15
Change-Id: I4b470646a9ad5ee702c9b1921d115e137d3d5b8b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-11 21:54:44 +01:00
Alexey Edelev
eab5ec5a37 Strip the ending slashes for resource folders
Setting a value for the QT_RESOURCE_ALIAS source file property on a
path ending with a slash (a directory) is not handled properly by
CMake. This leads to unpredictable values being set for multiple
directories. Fix this by stripping the the final slash from the file
path, which makes CMake think it's a file rather than a directory.

Change-Id: I7a39be68e6f58bf2726c80108da9947057e7add6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-11 21:54:44 +01:00
Allan Sandfeld Jensen
ace9764c99 Fix tst_qmath when compiled with C++20
On several platforms std::bit_ceil() returns 1 for input values that
would overflow the output. Our test expects 0 though. Since the value
is documented as undefined, avoid it.

Pick-to: 6.3 6.2
Change-Id: I00556893a8f0e1e24f08f73cd112b56148bc5bd0
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-11 20:47:21 +01:00
Ievgenii Meshcheriakov
4082fe8a39 Make QProcessEnvironment(Initialization) noexcept
Use default noexcept constructor to initialize `d` member.
Document Initialization enum.

Fixes: QTBUG-100695
Pick-to: 6.3
Change-Id: I7585ad154a9be40021a205b515ffa7b14f188d67
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-11 20:47:21 +01:00
Morten Johan Sørvig
5958c28d9f wasm: improve qstdweb::EventCallback
We are storing a copy of the this pointer in the constructor,
and later deference it to access EventCallback object
memebers. This makes the class noncopyable: delete
the copy constructor to make sure it isn’t.

Also change the callback API to propagate the event
to the event callback.

Change-Id: Ida4bb192b3e905b260ebeec30293aad71b7d8c49
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2022-02-11 18:15:26 +01:00
Pino Toscano
7c54988b1b Avoid a stack buffer when not needed
Allocate a PATH_MAX-sized buffer on stack only in case we are not using
realpath(X, null), i.e. on platforms with older POSIX versions, macOS,
or Android.

This fixes the build on platforms that do not have PATH_MAX (e.g.
GNU/Hurd), and it provides a minor optimization on realpath(X, null)
platforms.

Change-Id: Icd92a1b15ec18c5eef8113408e9610dfac774101
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-11 15:36:02 +01:00
Christian Ehrlicher
15f7ef26b8 QMdiSubwindow: respect minimum size of subwidgets when shown maximized
Size a QMdiSubWindow is no real toplevel widget, QLayout::activate() did
not properly set the minimum size based on it's children. Fix this by
treating a QMdiSubWindow as a toplevel widget during the calculation.

Fixes: QTBUG-100494
Change-Id: Ia2e6c519c7214c36383facd244711bd932231d40
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-11 07:03:24 +01:00