Commit Graph

38017 Commits

Author SHA1 Message Date
Thiago Macieira
928ce402a4 QHash & QRandomGenerator: cooperate to provide a simpler initial seed
Instead of initializing the whole QRandomGenerator::system(), which in
turn gets to checking CPUID and whether the HWRNG works, trust the
operating system functions for an initial value. On Linux, we'll use 4
or 8 of the 16 bytes of random data that the kernel populates for us on
AT_RANDOM.

This should make Qt applications not stall on an early system launch
without an RNG daemon, if compiled without getentropy() support. And
avoids silly mistakes causing recursion, like QTBUG-78007 found.

Additionally, qt_random_initial_value() will most likely not throw
either. It's marked noexcept, even though SystemGenerator::fillBuffer
could throw on Linux, if the current thread is canceled, but Linux also
has AT_RANDOM. That leaves the other Unix systems without getentropy()
(read: macOS, since the BSDs have getentropy()).

Fixes: QTBUG-69555
Change-Id: Id2983978ad544ff79911fffd1671fca1a9f9044d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-05-23 12:08:43 -07:00
Thiago Macieira
4ef99b8fbb Deprecate qGlobalQHashSeed and qSetGlobalQHashSeed in Qt 6.6
That's two years from when the replacements were added (6.2).

Change-Id: Id2983978ad544ff79911fffd1671f7dd38fede02
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-05-23 12:08:43 -07:00
Thiago Macieira
a24ced7474 Mark QHashSeed::globalSeed() noexcept
It is noexcept, except when initializing. When initializing, let's just
use qEnvironmentVariableIntValue (which we should have used anyway),
which avoids the memory allocation and is noexcept. The QRandomGenerator
functions are not marked noexcept, but are mostly so: they can't throw
regular exceptions, but some implementations do call POSIX Thread
Cancellation Points, which may cause forced stack unwinding. That's
unlikely to happen at the moment of the QHash initialization.

This is also mitigated in the next commit.

Change-Id: Id2983978ad544ff79911fffd1671fd16f8d6378d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-05-23 12:08:42 -07:00
Thiago Macieira
7ac0621ad1 Introduce QHashSeed and switch to size_t seeds
Commit 37e0953613 added a to-do, but we
can actually change the type, since we've documented since Qt 5.10 that
setting a non-zero value (aside from -1) with qSetGlobalQHashSeed was
not allowed. Storing a value to be reset later is simply not supported.

Change-Id: Id2983978ad544ff79911fffd1671f7b5de284bab
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2021-05-23 12:08:42 -07:00
Alex Trotsenko
76bd873030 QProcess/Unix: fix build in debug mode
qprocess_unix.cpp:633:55: error: ‘i’ was not declared in this scope

Change-Id: I152fbd9df6e9d3f31e2c2c8b23a3c1ab87aa237a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-23 16:04:57 +03:00
Mårten Nordheim
6725f0f77d Attributions: Don't mention QT_CRYPTOGRAPHICHASH_ONLY_SHA1
It's only meant for bootstrap builds.
Considering that SHA1 is deprecated by NIST we should not artificially
limit ourselves to using only that.

Task-number: QTBUG-93838
Change-Id: Ib779ad4e4349cfdc71d797eb3ba5ccfb7747e933
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-23 11:47:42 +00:00
Fabian Kosmale
3f7741000c QTestAccessible: Clear objects in EventList when deleted
The list persists events, which reference objects. Those objects might
get deleted by the time we investigate the objects. We cannot change the
event to store a QPointer for BIC reasons, and for normal usage of the
events, that doesn't make sense either.
Instead, connect the objects destroyed signal to a lambda which clears
the events' object member.
In order to access the private member, we befriend the test class.

Change-Id: I036be7053dccde4bdf862173789564e89d729ee1
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-05-23 10:46:03 +00:00
Nodir Temirkhodjaev
ffde36c9a3 qcborstreamreader.cpp: Use QT_TRY/QT_CATCH
To avoid build error with no exceptions:
qtbase/src/corelib/serialization/qcborstreamreader.cpp:1586:9: error: cannot use 'try' with exceptions disabled
        try {
        ^
qtbase/src/corelib/serialization/qcborstreamreader.cpp:1629:9: error: cannot use 'try' with exceptions disabled
        try {
        ^
2 errors generated.

Used compiler: https://github.com/mstorsjo/llvm-mingw

It's not a supported configuration, but the change is simple.

Change-Id: I263ce23b458f114b2330e832c5f4fd2a99cbb973
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-23 09:22:04 +00:00
Li Xinwei
19bb9837a1 Skip building debug bootstrap lib for CMake 3.20 and multi-config build
When building qtbase with CMake 3.20, only release tools will be built
by default in a multi-config build, so it is possible to skip building
debug bootstrap lib.

Task-number: QTBUG-88414
Change-Id: I266ac458ae3c89c593656e4ebdc788ae5797b788
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-05-23 14:00:53 +08:00
Friedemann Kleint
6fff7bb269 QTestlib: Fix formatting of pointers in QCOMPARE
After 1ed8a7bff5,
volatile needs to be specified for toString(), else it is not
used by compare_ptr_helper(). Add an overload.

Pick-to: 6.1 5.15
Change-Id: I3c335f324df346233623272d1014c8360ca33160
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-23 00:23:07 +02:00
Joerg Bornemann
895edcd7cd Support multiple equally named .qrc files in qt_add_big_resources
It is now possible to call qt_add_big_resources with multiple .qrc files
that are in different directories but have the same file name.
Before, this resulted in target name conflict errors.

Pick-to: 6.1
Fixes: QTBUG-93230
Change-Id: Ic3d9d6974a107163aeb7ada0b6f1fa113fb18de0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-22 22:32:27 +02:00
Giuseppe D'Angelo
8789ace197 QPromise: code tidies
Get rid of a reduntant initialization; a data member gets default
initialized anyways.

Change-Id: I85ad4c9a00b3066ccd993dfc2652a3f0164a860e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-05-22 03:20:32 +02:00
Giuseppe D'Angelo
41774f7597 QPromise/QFuture: fix value semantics
In random order:

* QFutureInterfaceBase has a d-pointer, and copy semantics. So,
"naturally" extend it to support move semantics as well. (These get
used by QPromise/QFuture, as they both hold a QFutureInterface*
as a data member). The only addition needed is a check for a null
d-pointer in the destructor.

Drive by, reorganize the code for the copies, and use copy-and-swap
instead of the hand-rolled solution. Also, add a free swap()
overload, and mark the existing one as candidate for inlining
in Qt 7 (doesn't need to be an exported function).

* QFutureInterface inherits QFutureInterfaceBase, again with value
semantics. To be honest, I'm not sure why QFutureInterfaceBase is
polymorphic -- could be a design mistake, as polymorphic classes
don't mix with value semantics. Anyways, reorganize the code for
copies, apply copy-and-swap, and add move semantics. This requires
adding a check into derefT().

* Finally, QPromise was already move-only, but had broken move
semantics: the move constructor was not noexcept (!) and it actually
allocated memory (!!!). Fix that one (can be defaulted now), and
streamline the move assignment via the proper macro.

Drive by, fix the signature of the constructor from QFutureInterface
(take const-ref, not plain ref -- it's eventually copied, so it
can keep the const), and add another internal constructor from
rvalue QFutureInterface that moves from it.

Change-Id: I9d61a9dd4d45f34942d8f34416baa118c0307390
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2021-05-22 03:20:32 +02:00
Lorn Potter
a89754a2f3 wasm: fix tooltips show/hide behavior
When tool tip was trying to show its window became activated causing
tool tip to hide instantly due to a redundant window activation bug on
show/hide/raise/lower.

Fixes: QTBUG-91095
Change-Id: Id215400a79cdc4ed1961731949ca139b575eec88
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-05-21 21:26:51 +00:00
Lorn Potter
8c9fef0473 wasm: Fix visual representation to not show tool tip window title bar
Change-Id: I1adf841a97daa64cd8a0ae799235d99bf961171f
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-05-22 07:26:48 +10:00
Joerg Bornemann
c3b5ca129a rcc: Fix error message when temporary file cannot be opened
If rcc cannot open the file passed with --temp, display the path of the
temporary file, not the one of the output file.

Pick-to: 6.1
Change-Id: I58f8ab2f68ac2f1a19feb6b02974dff9fc8b7ec1
Reviewed-by: hjk <hjk@qt.io>
2021-05-21 23:15:42 +02:00
Lars Schmertmann
46db337975 androiddeployqt: Refactor apkSignerRunner
Avoid to publish all local variables in the lambda and
only provide the necessary information as parameter.

Change-Id: Iea68280f79f90ac3d5f7b9a0a92e073865a1d291
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-05-21 16:05:44 +02:00
Alexey Edelev
34d33becd4 Make the internal Zlib module private
Rename Zlib module to adjust its name to the internal module naming
policy.

Change-Id: Ieb04842bd362a36fbf4247e3559b9907d29c28b8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-21 16:05:44 +02:00
Alexey Edelev
715041b663 Enable UNICODE for all Qt targets and Qt consumers by default
After discussion we decided to opt-out the UNICODE definintion
behavior. To disable UNICODE in user projects the
qt6_disable_unicode_defines function could be used.

Amends 5b64e5950c

[ChangeLog][CMake] Enables the UNICODE and _UNICODE definitions on
WIN32 platforms by default for all cmake projects to reflect the
qmake behavior. Use qt6_disable_unicode_defines function to disable
the default unicode definitions.

Pick-to: 6.1
Fixes: QTBUG-93895
Change-Id: Id70ff7dcf8c74f660ec851f8b950e1e3b94d9fb4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-21 16:05:44 +02:00
Allan Sandfeld Jensen
f1983dcdf6 Correct RGB to Grayscale conversion
The existing conversions weren't handling gamma correctly and used
an ad-hoc definition of gray instead of based on true luminance.

[ChangeLog][QtGui] RGB conversions to grayscale formats are now
gamma-corrected and produce color-space luminance values

Change-Id: I88ab870c8f5e502ddb053e6a14a75102239a26f2
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-05-21 15:37:32 +02:00
JiDe Zhang
b254855aa6 Use __has_* instead QT_HAS_*
Use __has_include instead QT_HAS_INCLUDE
Use __has_feature instead QT_HAS_FEATURE

Change-Id: If9b0af1f4386f7bcae6ca2fb911ffaba422750dd
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-05-21 21:37:32 +08:00
Giuseppe D'Angelo
bf22f91441 QFuture/QPromise: don't check for is_copy_constructible
The check is over-arching. is_move_constructible is sufficient;
we don't have to support "ridiculous" types that are copiable but
have deleted move operations (such types are fundamentally broken).
This is in line with the Move* (legacy) named requirements.

Change-Id: Idc7116b39013501b9be39628a4e7afd35fe15530
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2021-05-21 11:08:11 +02:00
Albert Astals Cid
973700c546 Make sure _q_printerChanged is called even if only pdf printer is available
Otherwise things like the pagesRadioButton don't get properly disabled

Change-Id: Idc0693b6747f13da5afb22e2187af310a5b454f8
Pick-to: 6.1 5.15
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-05-21 11:03:18 +02:00
Robert Löhning
8862685805 QTextHtmlParserNode: Avoid invalid enum values
Fixes oss-fuzz issue 31027

Fixes: QTBUG-93072
Change-Id: I8c7fa31bae79221fbeaf84db7c839fc61c93d48e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Nils Jeisecke <nils.jeisecke@saltation.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-05-21 10:32:47 +02:00
Eskil Abrahamsen Blomfeldt
11a40defff Fix memory leak when using small caps font
The small caps version of a font is kept as a QFontPrivate*
which is manually reference counted, but we neglected to
actually delete it when the reference count went to 0.

[ChangeLog][Fonts] Fixed a memory leak when initializing
a small caps font.

Fixes: QTBUG-93068
Pick-to: 6.1 5.15
Change-Id: Icc7fb7a59bf523da84d2e6fa026940a7d1230525
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
2021-05-20 21:38:25 +02:00
Mårten Nordheim
ea3a4a5003 QHttpNetworkConnectionPrivate::createAuthorization: refactor
Grab a reference to the channel instead of indexing into the array
repeatedly.

Change-Id: I114d571fcfcfd3a751346b513cec728dc2fcda0a
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-05-20 20:31:05 +02:00
Mårten Nordheim
55feb0d08a QHttpNetworkConnectionChannel: remove *authMethod
We store the authenticator right alongside it, which knows the
method.

The biggest change from this is changing a, self-proclaimed, duplicate
method from QHttpNetworkReply. Finding the method name ahead-of-time
is not actually needed, all we need to know is that a supported
authentication method is requested. Also moved that specific
functionality to a more logical location: QAuthenticatorPrivate.

Change-Id: I11627803ccb42b8ec33a28ef1d1e00bf60dc6da9
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-05-20 20:31:05 +02:00
Mårten Nordheim
5a701f5a7e Add function to QAuthenticatorPrivate to check method support
To see if a certain method is supported. To be used in an upcoming patch.

Change-Id: I1a5c2f655585331820701bb54f6991b4aba38273
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-05-20 20:31:05 +02:00
Allan Sandfeld Jensen
fe6dc9dc85 Add runtime ARM64 AES check
Adds runtime CPU detection for Windows and macOS, and switches feature
detection of AES to runtime like for x86,

So far only on ARM64, since gcc doesn't do function versioning on ARM32,
but clang can, so it could be added later.

Change-Id: Ibe5d60f48cdae3e366a8ecd6263534ba2b09b131
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-20 18:31:05 +00:00
Tor Arne Vestbø
40878e7517 macOS: Restore logic to set wantsBestResolutionOpenGLSurface
The logic was removed in 1fc7ca091b when
we removed support for surface-backed views, based on the documentation
for wantsBestResolutionOpenGLSurface noting that layer-backed views
ignore the property.

But in some cases, when plugin views are embedded into host views, and
the host was built with a pre-10.14 SDK, AppKit seems to get confused,
and we still need to set this property.

Fixes: QTBUG-93770
Pick-to: 6.1
Change-Id: Id67f2fcb8c090c0e01c05d00792eaef311146df1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-20 17:40:46 +00:00
Joerg Bornemann
9e8f43e5ac Fix qt6_add_big_resources
The qt6_add_big_resources command was dysfunctional whenever AUTOMOC was
enabled for a target.

We passed multiple object files with the --temp argument of the second
pass of rcc. We must pass exactly one. The spurious object file was the
one that's created by AUTOMOC. Turn off all of AUTOGEN for the C++
source file that's generated in the first pass of rcc.

Enable AUTOMOC for tests/auto/cmake/test_add_big_resource to cover this
situation.

Pick-to: 6.1
Fixes: QTBUG-85051
Change-Id: I6d2ce4953297db0751913456db0a4a126fe33f14
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-20 19:40:46 +02:00
Alexandru Croitor
c4df673dd9 CMake: Replace qt_finalize_executable with qt_finalize_target
It's very likely that we'll have to run certain finalizer code for
targets other than executables.

Rename qt_finalize_executable to _qt_internal_finalize_executable so
it's internal.

Introduce a new function qt_finalize_target which will call the above
internal one when the target is an executable.

This should future proof the API so we have a hook to call code for
any user CMake project that intends to use Qt CMake API.

Change-Id: I03f6f4dcba22461351c247a20241ca7de1a59c1d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-05-20 19:40:45 +02:00
Morten Sørvig
560d839461 wasm: disable the canvas resize observer
We’re seeing crashes on tab close and also when the
page has been open for a minute or two. Skip installing
the handler until we figure out what’s wrong.

Pick-to: 5.15
Fixes: QTBUG-93713
Change-Id: Idd0c4d646de544ebdd2f4d00425faa08645335ac

Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: David Skoland <david.skoland@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2021-05-20 19:40:45 +02:00
Andreas Buhr
f9e543b8a3 Document that QProperty::subscribe might get executed deferred
With the introduction of grouped property changes, notification
calls in bindable properties might be immediate or deferred,
depending on the context. This patch documents that one must not
rely on immediate execution of functions given to subscribe()
and onValueChanged().

Change-Id: I26ec4dbbff17a44ab62037ba1da9ce34c77da972
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-05-20 18:40:45 +01:00
Tor Arne Vestbø
640eb55c13 macOS: Fix warning about comparing different types in QCocoaScreen::isOnline
Pick-to: 6.1
Change-Id: Ieb70108d22bf254c69665e5b3e3a2988703e26a2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-20 17:56:47 +02:00
Tor Arne Vestbø
486b7a8f8a Type erase native interfaces via string instead of typeid
The latter forces users to build with RTTI enabled, as the typeid
use is in our public headers. Surprisingly this is also the case
even without instantiating the relevant template.

Change-Id: Icd18a2b85b250e0b77960797e5c43b7eaf9bd891
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-05-20 17:02:38 +02:00
Dongmei Wang
e253a30238 QFileSystemModel fails to locate a host from root's visible children
In QFileSystemModel, in some cases the hostname in a UNC path is
converted to lower case and stored in the root node's visibleChildren.
When QFileSystemModel sets the UNC path as the root path, it tries to
get the row number for the host, but it didn't convert the hostname to
lower case before getting the row number, which resulted in the host
not found in the root node's visible children. As a result, it returns
-1, an invalid row number. Change the behavior to find the node for the
host using the host name case-insensitive and then get the row number.

Fixes: QTBUG-71701
Pick-to: 5.15 6.0 6.1
Change-Id: Ib95c7b6d2bc22fd82f2789b7004b6fc82dfcb13b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2021-05-20 15:02:38 +00:00
Volker Hilsheimer
c2258e85a3 QXcb: don't dereference pointer before checking
The virtualDesktop pointer is expected to be populated by queryPointer, but
that method handles the case that there either is no reply, or that the
reply doesn't match, in which case the pointer remains nullptr.

Don't dereference it afterwards without checking.

Addresses code checker warning a179d1087759bb6ca9c3380257bd70d6

Pick-to: 6.1 5.15
Change-Id: I5877f26fd3b49327c0de3f2c918bb606bee8ac57
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-05-20 17:02:38 +02:00
Mårten Nordheim
a5dc381b4c QByteArrayView: add compare
There was previously no way to compare QByteArrayView to with another
QByteArrayView case-insensitively without allocating memory.

[ChangeLog][QtCore][QByteArrayView] Added compare(), enabling case
sensitive and insensitive comparison with other QByteArrayViews.

Change-Id: I7582cc414563ddbde26da35a568421edcc649f93
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-20 17:02:38 +02:00
Mårten Nordheim
e8297ba176 QByteArray: Move some free-functions around
Most of them go to qbytearrayalgorithms.h while the deprecated (inline)
version of qChecksum goes to qbytearrayview.h

In preparation for adding compare to QByteArrayView.

Change-Id: If7f65e9e7cd74838e11ebdb952309b811cef079d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-20 17:02:38 +02:00
Assam Boudjelthia
df022972b0 Don't throw an exception on platforms with no permission API
Using the permission API without guards for Android cause exception
on all other platforms, instead we can print a warning with the same
message if QT_DEBUG is defined to also make it less confusing for other
platforms.

Also, return QPermission::Authorized by default for platforms with no
implementation to this API.

Change-Id: Ie01a6a7f8b6a066685d32c861a56e9ded2c06410
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-05-20 09:26:42 +00:00
Alexandru Croitor
6fcc272ac9 CMake: Introduce finalizer mode handling of static plugins
Allow linking all plugin initializer object libraries directly
into the final target (executable or shared library).

The finalizer mode is triggered when the project adds a call
to qt_import_plugins, as well when the project has an explicit
call to qt_finalize_executable or when it is defer called by
CMake 3.19+.

Otherwise the old non-finalizer mode is used, where each plugin
initializer object library is propagated via the usage
requirements of its associated module.

A user can explicitly opt in or out of the new mode by calling
qt_enable_import_plugins_finalizer_mode(target TRUE/FALSE)

The implementation, at configure time, recursively collects all
dependencies of the target to extract a list of used Qt modules.

From each module we extract its list of associated plugins and
their genex conditions. These genexes are used to conditionally
link the plugins and the initializers.

Renamed QT_PLUGINS property to _qt_plugins, so we can safely query the
property even on INTERFACE libraries with lower CMake versions.
QT_PLUGINS is kept for backwards compatibility with projects already
using it, but should be removed in Qt 7.

The upside of the finalizer mode is that it avoids creating link
cycles (e.g. Gui -> SvgPlugin -> Gui case) which causes CMake to
duplicate the library on the link line, slowing down link time as well
as possibly breaking link order dependencies.

The downside is that finalizer mode can't cope with generator
expressions at the moment. So if a Qt module target is wrapped in a
generator expression, it's plugins will not be detected and thus
linked.

Task-number: QTBUG-80863
Task-number: QTBUG-92933
Change-Id: Ic40c8ae5807a154ed18fcac18b25f00864c8f143
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-05-20 00:55:46 +02:00
Karsten Heimrich
06689a2d7a Fix QUrl::fromLocalFile with long path prefix
After commit 3966b571 the function was kinda broken already, though
this got unnoticed since it was not covered by an the auto-test.
This commit adds another test case with Windows native separators
and removes the use of QDir::fromNativeSeparators. Instead use the
original code from QDir::fromNativeSeparators to replace the backslashes.

Pick-to: 5.15 6.0 6.1
Change-Id: I190560d0e75cb8c177d63b142aa4be5b01498da2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-05-19 21:38:38 +02:00
Tor Arne Vestbø
f111c376d6 Granularily disable PCRE2 JIT on macOS ARM
2f8df4d1a8 disabled the PCRE2 JIT on macOS
for ARM, but did so based on the build system architecture configure
test. When doing a universal build these configure tests are based on
the primary architecture (x86_64 in our case), which means we ended up
still enabling the JIT.

We work around it by passing the PCRE2_DISABLE_JIT define only when
building the arm64 slice.

Change-Id: I60df82acb57030ccef8b117a40209eb107b1d5bd
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-19 20:00:56 +02:00
Giuseppe D'Angelo
9c89743d72 QKeyCombination: code tidies
* Use the new QFlags::toInt() instead of an explicit cast.

* Don't apply ~ to an enumerator and then convert the result to an
int; instead, convert the enumerator to int and then bitwise negate it.
The former is going to break in an upcoming commit.

Change-Id: I3a798d61452891d2f61f84e2d8e17237f47c5659
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-05-19 19:48:17 +02:00
Fabian Kosmale
d95e39a9b8 QNetworkAddressEntry: export QDebug stream operator
It already existed, but was only used internally in QNetworkInterface's
debug stream operator.

Change-Id: I36c2b4f6cb228df2f92ec92cc879b6d34f1e3ea1
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-05-19 19:48:17 +02:00
Laszlo Agocs
8827cd657d rhi: gl: Add support for importing an existing renderbuffer object
Normally we only allow creating wrappers for texture objects. These
can then be used with a QRhiTextureRenderTarget to allow rendering into
an externally created texture.

With OpenGL (ES), there are additional, special cases, especially on
embedded. Consider EGLImages for example. An EGLImageKHR can be bound to
a renderbuffer object (glEGLImageTargetRenderbufferStorageOES), which
can then be associated with a framebuffer object to allow rendering into
the external buffer represented by the EGLImage. To implement the same
via QRhi one needs a way to create a wrapping QRhiRenderBuffer for the
native OpenGL renderbuffer object.

Here we add a createFrom() to QRhiRenderBuffer, while providing a dummy,
default implementation. The only real implementation is in the OpenGL
backend, which simply takes a renderbuffer id, without taking ownership.

Task-number: QTBUG-92116
Change-Id: I4e68e665fb35a7d7803b7780db901c8bed5740e2
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-05-19 17:35:35 +02:00
Allan Sandfeld Jensen
2d9cc639a4 Avoid mixing atomic futex changes and QAtomic
Either the mix of futex and atomic, or the mix of 32-bit futex and
64-bit atomic doesn't work. In any case, the existing code leads to
bad behavior.

Pick-to: 6.1 5.15
Fixes: QTBUG-92188
Change-Id: Icc6ba28d6e2465c373d00e84f4da2b92c037e797
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-05-19 16:27:52 +02:00
Andy Shaw
96982bab0c Android: Reset m_usePrimaryClip when clearing the clip data
The variable needs to be set to false when we clear the clip data as
there is no primary clip anymore so we should not try to access it when
setting new data.

Fixes: QTBUG-93831
Pick-to: 6.1 5.15
Change-Id: I309270dc075fcb0457607561ee23e12f7eb6397f
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-05-19 16:27:52 +02:00
Joerg Bornemann
7bc91dbe93 Doc: Extend qt_add_resource documentation
Pick-to: 6.1
Change-Id: Ia76b1e681eb15cc8ad9de04bb80654e35442c82b
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-19 10:31:26 +02:00
Tasuku Suzuki
7d93c6ef9c Fix build without features.library
Change-Id: I53eaaea149324d2495e794ba8bd58544e648e48e
Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-05-19 16:55:50 +09:00
Kimmo Ollila
5762bd236c Add EGLFS OpenWFD plugin for INTEGRITY
This enables OpenWFD EGLFS integration plugin and makes EGLFS the
default platform for INTEGRITY builds.

Change-Id: I65332ca0ae244f40013df435828e2e359200b325
Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-05-19 10:55:48 +03:00
Alex Trotsenko
9c7cabb880 QLocalSocket/Win: fix closed state detection in waitFor...() functions
A delayed close should only be completed in the _q_bytesWritten() slot
as a confirmation of a successful write operation on the socket.
Otherwise, a failed write operation may cause the socket to be closed
unexpectedly within the waitFor...() function, which may result in a
malfunction.

Change-Id: I14cff26734f64a89090b6b5c13037466a6400597
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-05-18 20:03:47 +00:00
Alexandru Croitor
91c65dd80c CMake: Build plugin initializers as object libs
Instead of compiling the plugin initializers as part of a user
project, pre-compile them as object libraries while building Qt.

The installed object libraries can then be used with

    target_sources(qt_module INTERFACE $<TARGET_OBJECTS:plugin_init>)

so that they are linked into the final executable or shared library
via qt module usage requirement propagation.

This reduces the build times of user projects.

The link line placement of the object files should be correct for all
linux-y linkers because the only dependency for the object files is
Core and the Gui -> plugin -> Gui -> Core cycle does not hamper that
from empirical observations.

As a consequence of the recent change not to link plugin initialization
object files into static libraries, as well not having to compile the
files in user projects, we can get rid of the
_qt_internal_disable_static_default_plugins calls in various places.

A side note.

Consider a user static library (L) that links to a Qt static library
(Gui) which provides plugins (platform plugins).

If there is an executable (E) that links to (L), with no direct
dependency to any other Qt module and the intention is that the
executable will automatically get the platform plugin linked,
then (L) needs to link PUBLIC-ly to (Gui) so that the plugin usage
requirements are propagated successfully.

This is a limitation of using

  target_sources(qt_module INTERFACE $<TARGET_OBJECTS:plugin_init>)

which will propagate object files across static libraries only if
qt_module is linked publicly.

One could try to use

  target_link_libraries(qt_module
                        INTERFACE $<TARGET_OBJECTS:plugin_init>)

which preserves the linker arguments across static libs even if
qt_module is linked privately, but unfortunately CMake will lose
dependency information on Core, which means the object files might be
placed in the wrong place on the link line.
As far as I know this is a limitation of CMake that can't be worked
around at the moment.

Note this behavior was present before this change as well.

Task-number: QTBUG-80863
Task-number: QTBUG-92933
Change-Id: Ia99e8aa3d32d6197cacd6162515ac808f2c6c53f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-05-18 22:03:46 +02:00
Tor Arne Vestbø
0855f62791 Fix single argument QT_OVERLOADED_MACRO with pedantic warnings enabled
The use of QT_OVERLOADED_MACRO combined with pedantic warnings would
result in

  warning: must specify at least one argument for '...' parameter of
  variadic macro [-Wgnu-zero-variadic-macro-arguments]

when used with a single argument, as the QT_VA_ARGS_COUNT macro would
end up not passing anything to the last ... argument of the helper macro
QT_VA_ARGS_CHOOSE.

To work around this we extend the arguments passed to QT_VA_ARGS_CHOOSE
by one, adding a zero-count, so that the variadic parameter always has
at least one argument.

Unfortunately this doesn't give us a count of 0 if a overloaded Qt macro
is used without arguments, due to __VA_ARGS__ always being treated as an
argument to QT_VA_ARGS_CHOOSE, even when empty, due to the comma after it.
The result is that we end up calling the 1-argument macro for this case
as well.

Getting a correct zero-count, for both MSVC and GCC/Clang, without using
GCC extensions, is quite involved, so we're opting to live with this
limitation. See https://stackoverflow.com/a/62183700 for details.

Fixes: QTBUG-93750
Pick-to: 6.1
Change-Id: Ib7b26216f36a639642a70387e0d73223633ba6b6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-18 19:07:51 +00:00
Allan Sandfeld Jensen
1fe8ddc7fe Cherry-pick upstream patch for non-gcc/clang/msvc compilers
Fix build w/ non-GCC-compatible Un*x/Arm compilers

Fixes: QTBUG-93779
Change-Id: Ib52e9ded6e2814c7998d6cd798e945da0f87f7a1
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
(cherry picked from commit 4341f6763b8a737ebc07bb78ead22bc05a1a515b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2021-05-18 18:57:25 +00:00
Joerg Bornemann
92185d417d Fix BASE argument of qt_add_resources
The BASE argument of qt_add_resources now denotes the root point of the
alias of the file.  Before, BASE was merely prepended to every file that
got passed to qt_add_resources.

Old behavior:
    qt_add_resources(app "images"
        PREFIX "/"
        BASE "../shared"
        FILES "images/button.png")

Alias is "../shared/images/button.png", and pro2cmake generated
QT_RESOURCE_ALIAS assignments to fix this.

New behavior:
    qt_add_resources(app "images"
        PREFIX "/"
        BASE "../shared"
        FILES "../shared/images/button.png")

The alias is "images/button.png".  No extra QT_RESOURCE_ALIAS assignment
is needed.

The new behavior is in effect for user projects and for Qt repositories
that define QT_USE_FIXED_QT_ADD_RESOURCE_BASE.  Qt repositories will be
ported one by one to this new behavior.  Then the old code path can be
removed.

Pick-to: 6.1
Task-number: QTBUG-86726
Change-Id: Ib895edd4df8e97b54badadd9a1c34408beff131f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-18 16:02:52 +02:00
Giuseppe D'Angelo
861647e8a5 Item models: code tidies
Use QFlags::testAnyFlag instead of relying on implicit conversions.

Change-Id: I7ac8149535ad28e47fbf3e250042892bdf8c3a72
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
2021-05-18 15:33:25 +02:00
Giuseppe D'Angelo
3b0c6bf486 QEventDispatcherCF: avoid QFlags->int implicit casts
Use toInt(), or an explicit cast. (I don't quite know why an atomic int
is involved here, but anyways, it makes these casts necessary.)

Change-Id: I8816ef96bd69a6f3e3f8e025e567e3451069462c
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-05-18 15:31:10 +02:00
Andreas Buhr
8278879c19 Fix QItemSelectionModel::selectionChanged emission
QItemSelectionModel has the property selectedIndexes with
the notification signal selectionChanged. When a row is deleted
or inserted above the current selection, the row number of the
current selection changes and thus the return value of
selectedIndexes changes. This should trigger its notification
signal.
This signal was not emitted. This patch fixes this and
adds a unit test to verify this.

[ChangeLog][Important Behavior Changes][QtCore]
QItemSelectionModel now emits the selectionChanged signal
if only the indexes of the selected items change.

Fixes: QTBUG-93305
Change-Id: Ia5fb5ca32d658c9c0e1d7093c57cc08a966b9402
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
2021-05-18 08:49:56 +02:00
Giuseppe D'Angelo
9a94c4a415 Long live qToUnderlying
"Cherry-pick" of C++2b's std::to_underlying.

[ChangeLog][QtCore][QtGlobal] The qToUnderlying function has been
added, to convert an value of enumeration type to its underlying
value.

Change-Id: Ia46bd8e4496e55174171ac2f0799eacbcca02cf9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-18 02:09:11 +02:00
Giuseppe D'Angelo
8f7873272a qglobal.cpp: build under QT_NO_EXCEPTIONS
The boostrap library is built with exceptions disabled, and its
sources include qglobal.cpp. Therefore, the file must work when built
w/o exceptions.

Amend/partially revert 282b724808 with
the necessary fixes.

Driveby, cleanup an unnecessary QT_THROW (just throw, if we do have
exceptions).

Change-Id: I370c295c21edd3d81a9fa670e60909b29d1c68aa
Pick-to: 6.1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2021-05-18 02:09:02 +02:00
Li Xinwei
42b8bbbef0 CMake: remove unnecessary add_dependencies()
The dependencies to moc, uic and rcc have already been handled by
qt_manual_moc(), qt_enable_autogen_tool() and
_qt_internal_process_resource().

This allows not building some of the debug executables in a
multi-config scenario.

Task-number: QTBUG-88414
Change-Id: I6c162721f3ddf6b4b410345ad012073abbdfd9df
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-17 21:57:22 +00:00
Joerg Bornemann
76eefab088 Add proper dependencies to apk targets
Before, building ${target}_make_apk always re-built the apk, instead of
rebuilding the apk only when inputs changed. This patch fixes that by
moving the creation code from a custom target to a custom command with
proper dependencies.

The androidtestrunner tool now does not check for the existence of an
apk anymore and always runs the make command that is supposed to build
the apk.

The ${target}_prepare_apk_dir target is not needed anymore by the Qt
build but is still used by Qt Creator's Android support. Add a
clarifying comment.

Fixes: QTBUG-93431
Change-Id: I00d65d616fef9511b03b65f879c4bc6cb92dfc30
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-05-17 19:14:44 +02:00
Thiago Macieira
50c838d4b5 Make the exit() methods in QEventLoop and QThread be slots
The documentation for QCoreApplication::exit() even refers to it as
such. Instead of refactoring the documentation to explain that it isn't,
just make it a slot and do the same for the other classes.

Complements 2e6c37fe51.

[ChangeLog][QtCore][QEventLoop] exit() is now a slot, like quit().

[ChangeLog][QtCore][QThread] exit() is now a slot, like quit().

Change-Id: Ic42004c9bf71440eb433fffd167f4a1b89bcac80
Reviewed-by: David Faure <david.faure@kdab.com>
2021-05-17 10:13:52 -07:00
Andre de la Rocha
92198efbd2 Windows QPA: Fix dock widget drag&drop failure
A previous change to fix QTBUG-85431 has caused this issue by emulating
the behavior of the non-enhanced mouse event handler in a particular
case, where mouse move events that did not change position were ignored.
However, some of these events seem to be involved in the dock drag&drop
implementation. This issue is also reproduced in pre-5.15 releases,
predating the QTBUG-85431 fix, by disabling the enhanced mouse event
handler by setting the QT_QPA_DISABLE_ENHANCED_MOUSE env var. However,
the ignored events in the current issue seem to be non-client events
only, while the QTBUG-85431 issue was related to client mouse events.
So we can restrict the test added in the QTBUG-85431 fix and have both
issues fixed.

Fixes: QTBUG-92182
Pick-to: 5.15 6.0 6.1
Change-Id: I98c0c8597912c7f4fe58af375a5a560695a82746
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2021-05-17 19:11:09 +02:00
Assam Boudjelthia
2e373e44ac Add isValid() call to QJniEnvironment
Task-number: QTBUG-92952
Change-Id: I3bce2881c10a8bfcc8771002a3349644c6f05cb3
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2021-05-17 16:30:14 +00:00
Giuseppe D'Angelo
536a4ab079 QFile: code tidies
There's no need of converting a QFlags to int in openExternalFile's
signature; just use the flag.

Also, avoid an implicit QFlags->bool conversion by using testAnyFlag.

Change-Id: Ia2d560bce235c842745d8a6a5fb5d8ac0851fc47
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-17 11:07:35 +02:00
Giuseppe D'Angelo
af38f72e13 Windows QFSFileEngine: avoid some QFlags implicit conversions
Go through fromInt/toInt instead.

Change-Id: I73097e21f59f9e8eb2c9714e22084af0787a53d5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-17 11:07:13 +02:00
Giuseppe D'Angelo
dc5576895d QMetaContainer: code tidies
Turn some implicit conversions into calls to QFlags::testAnyFlag.

Change-Id: I755f8a1afb1ff02e823e747e021e9744d68b4f62
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-17 00:11:32 +02:00
Giuseppe D'Angelo
fca6021f5b QFileSystemMetaData: code tidies
Turn some implicit conversions into calls to QFlags::testAnyFlag.

In one case, move some code using QFlags operators *after* such
operators have been declared by the right macro.

Change-Id: Ib5713f028ce74d1c9054b87cc12eea5715f2bc94
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-17 00:11:28 +02:00
Giuseppe D'Angelo
18e6debca7 QFSFileEngine: code tidies
Turn a couple of implicit conversions into calls to QFlags::testAnyFlag.

Change-Id: I21a0b4c1644986a98a2d0d54ae4b95f9fdc92841
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-17 00:11:26 +02:00
Giuseppe D'Angelo
5ea50054a1 QArrayData: store the right flag type, not an int
There's no reason to be storing `int` in the array data header and
then using it as a QFlags. Just store the QFlags.

Change-Id: I78f489550d74d15a560dacf338110d80a7ddfdd2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-17 00:11:12 +02:00
Giuseppe D'Angelo
8e82c30680 QIODevice: code tidies
Turn an implicit conversion into a call to QFlags::testAnyFlag.

Change-Id: Idbd80bb6a9b5d84952b76d8d7544f617fe693b91
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-16 17:22:38 +02:00
Giuseppe D'Angelo
c568257a52 Event dispatchers: code tidies
Turn an implicit conversion to bool in

* a call to testAnyFlag in one case;
* a comparison against 0 in another case, for consistency with the
surrounding code.

Change-Id: I1eee42ba82c59a72430bf507ea80408c553be889
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-16 17:22:34 +02:00
Giuseppe D'Angelo
5a1c3c29ac QSaveFile: code tidies
Turn a cast into a call to QFlags::toInt(), plus a cast.

This is in preparation for a future patch that will remove the
implicit conversion. So why not casting directly? Because we don't
know if the QFlags is backed by int or uint, so using the wrong
cast won't compile; and we MUST pass unsigned because of the %x
specifier. Granted, one could've used a static_assert, but I prefer
a more flexible and idiomatic solution.

Change-Id: I32a3e0ed69b925e8d56268ec84d9e668ca540188
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-16 17:22:30 +02:00
Joerg Bornemann
97228214bd Doc: Add CMake to the "Resource System" documentation
Pick-to: 6.1
Change-Id: I4c6a7cfb2f6351e9587d47ab6708d92a1a4e42a4
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-05-16 17:05:32 +02:00
Alexey Edelev
282b724808 Make qTerminate available when QT_NO_EXCEPTIONS flag is set
It seems that QtCore could only be compiled with exceptions enabled.
Therefore it doesn't make sense to keep conditonal code under
QT_NO_EXCEPTIONS in qglobal.cpp. qTerminate may be called whether
exceptions are enabled or not.

Pick-to: 6.1
Fixes: QTBUG-93739
Change-Id: Ie49c10f27cfa75360f018e8638603e6a1791450e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-16 15:26:26 +02:00
Giuseppe D'Angelo
0533695ddd QDir: remove an unneeded QFlags->int conversion
Just use the original QFlags. Drive by, use testFlag to check if
it contains a given value or not.

Change-Id: I4d5e8454df33a3f4727855d55f7587143450dda6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-16 11:42:08 +02:00
Giuseppe D'Angelo
5f29ed0d5c QDir(Iterator): code tidies
* Turn some `flags & bit` statements that rely on QFlags->int->bool
implicit conversions, into some more idiomatic `return
flags.testAnyFlag(bit)`. This is in preparation for a future patch, and
to avoid inserting casts (return statements do not contextually convert
to bool).

* Remove a magic constant, replacing it by the symbolic one.

Change-Id: I62fc2b2bf6f0ab8fad121edd19cb2ea0d9e3582a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-16 11:42:05 +02:00
Thiago Macieira
4d24fcd3e1 QDateTime: fix our oversight in Qt 6.0 not changing the ShortData
For 32-bit systems. They're not important (to me), but might as well fix
this oversight.

Change-Id: I755911ae7d0341f49039fffd167b26617db93354
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-05-15 12:14:48 -07:00
Giuseppe D'Angelo
c4947c1c4c QFlags: add test(Any)Flag(s)
QFlags was lacking a named function for testing whether a QFlags object
contains _any_ of the bits set by a given enumerator/other QFlags.

Drive-by, add testFlags taking a QFlags, not just an object of the
enumeration; and simplify the implementation of testFlags to more
closely follow what its documentation says it does.

[ChangeLog][QtCore][QFlags] The testFlags, testAnyFlag and
testAnyFlags functions have been added.

Change-Id: Ie8688c8b0dd393d34d32bc7786cdcee3eba24d1c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-15 17:34:01 +02:00
Giuseppe D'Angelo
671ada5d82 QFileDevice: code tidies
Avoid QFlags->int implicit conversions.

Change-Id: I29905ff66888759c71d1e70064913520c9f09ec2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-14 21:26:40 +02:00
Friedemann Kleint
db32369935 native interface plumbing: Fix ambiguities with existing classes named TypeInfo
As is the case in Qt for Python, causing:

QtCore/qcoreapplication.h: In member function I* QCoreApplication::nativeInterface() const:
QtCore/qcoreapplication.h:163:5: error: reference to TypeInfo is ambiguous
  163 |     QT_DECLARE_NATIVE_INTERFACE_ACCESSOR

Amends 7feeb7c34b.

Change-Id: I7d363e1d8c0a0f648d12f8040afb9d071356cbb8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-05-14 16:35:34 +02:00
Andy Shaw
08cd5580df iOS: Accessibility: Set the correct traits for EditableText
Since the correct accessibility traits for EditableText are not
available as a direct enum value, then we depend on the defaults for a
UITextField to give us this information.

Done-with: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Fixes: QTBUG-93494
Pick-to: 6.1 5.15 5.12
Change-Id: If428414aec5ce571f0f8c0ecccffdbaf1c908120
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-05-14 08:12:10 +00:00
Andy Shaw
a8a6558a84 Allow for arguments that have an equals as part of it
Since you can pass a define to org.gradle.jvmargs that can have the
name=value approach, then we need to ensure that this is accounted for.

Task-number: QTBUG-88989
Pick-to: 6.1 5.15
Change-Id: I2a795bff7ce683eca521b3a987293b3320accb6a
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-05-14 08:12:09 +00:00
Marc Mutz
c8f380bd13 QPageSize: make PageSizeId ctor non-explicit
A QPageSize::PageSizeId is a faithful representation of a QPageSize,
so the corresponding QPageSize ctor shouldn't be explicit.

[ChangeLog][QtGui][QPageSize] Conversion from a QPageSize::PageSizeId
is now implicit.

Pick-to: 5.15 6.0 6.1
Change-Id: I2d32da370c032949686757400cb7c28583d9d8ac
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2021-05-13 17:06:42 +00:00
Giuseppe D'Angelo
e704ff8eba QFileInfo: code tidies
Avoid some QFlags<->int conversions; use the named conversions
instead.

Change-Id: If12c55ca362ed5c2c73182e10562a2d09e80aa49
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-13 17:57:50 +02:00
Giuseppe D'Angelo
aaaa5c6d82 QDateTime: code tidies
Move the ValidityMask / DaylightMask enumerators in the right
enumeration. This allows to use them in a type-safe way through
the StatusFlags flag type.

Also, define the flag operators for StatusFlags.

Change-Id: Icdba7c3f49f18ffb4aff9921d8012ddc3f7cbed7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-05-13 14:32:15 +02:00
Giuseppe D'Angelo
37e3b988c2 QMetaObjectBuilder: replace an int with QFlags
The int was used as a flag the entire time, except in one stance.
So just use the right QFlags type instead, and replace that one usage
with a call to toInt().

Change-Id: I3670e6afdc244df69189dd15b8c2c34573476e2f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-13 14:29:50 +02:00
Giuseppe D'Angelo
81bb764e98 QFlags::testFlag: code tidies
If the condition Int(flag) != 0 is false, it means that flag == 0.
So just check i against 0, which is more in line with what testFlag
behavior is documented to do.

Change-Id: Ia75fa07eee65e67a769fda7c020bf17ada77e9a3
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-13 14:28:45 +02:00
Assam Boudjelthia
23780891a5 Add tests for QAndroidApplication's sdkVersion and activity
While at it, move tst_android under corelib/platform/android.

Change-Id: Icf91cd75cb5e04d03fe6a81d52fba52a485ca41f
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2021-05-13 01:41:36 +03:00
Giuseppe D'Angelo
6e04664a95 QDebug: code tidies
Use the newly introduced QFlags::toInt().

Change-Id: I45337a299d20738767461c36641519a3e9b625d7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-12 23:04:57 +02:00
Giuseppe D'Angelo
9887f32df9 QAbstractItemModel::match: code tidies
Remove a magic number from the code, by adding it (as a private value)
to the right enumeration. Use toInt() to convert to integer.

Change-Id: Id1b00dde900619684b5a3df247d46938439150ca
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-12 23:04:57 +02:00
Giuseppe D'Angelo
cdd6a1f138 QLibrary: fix some implicit QFlags->int conversions
Either be explicit, or just use QFlags directly.

Change-Id: I18cbea4eaa1a0a4bce7665b735e7d785f7a196b2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-12 23:04:57 +02:00
Giuseppe D'Angelo
a3d7028a0e QUrlTwoFlags: add support for operator&=, |=, ^= taking QFlags
Rather than forcing an implicit conversion to int, accept a QFlags
(over either one of the two enumerations) directly.

Change-Id: I56af3a85982ecb66369e4a7105d07de0d6e0c40a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-05-12 23:04:57 +02:00
Tor Arne Vestbø
7feeb7c34b Rejig native interface plumbing
The initial approach for providing public access to native
interfaces via T::nativeInteface<I>() was based on the template
not being defined, and then having explicit instantiations of
the supported types in a source file, so that the accessors
were exported and available to the user.

This worked fine for "simple" types such as QOpenGLContext
and QOffscreenSurface, but presented a problem in the context
of classes with subclasses, such as Q{Core,Gui}Application.

To ensure that a native interface for QCoreApplication was
accessible both from QCoreApplication and its subclasses,
while at the same time preventing a native interface for
QGuiApplication to be accessible for QCoreApplication, the
nativeInterface() template function had to be declared in
each subclass. Which in turn meant specializing each native
interface once for each subclass it was available in.

This quickly became tedious to manage, and the requirements
for exposing a new native interface wasn't very clear with
all these template specializations and explicit instantiations
spread around.

To improve on this situation, while also squashing a few
other birds at the same time, we change the approach to
use type erasure. The definition of T::nativeInteface<I>()
is now inline, passing on the requested interface to a per
type (T, not I) helper function, with the interface type
flattened to a std::type_info.

The type_info requested by the user is then compared to the
available types in a single per-type (T) "switch statement",
which is a lot easier to follow for someone trying to trace
the logic of how a native interface is resolved.

We can safely rely on type_info being stable between the user
application and the Qt library as a result of exporting the
type info for each native interface, by explicitly ensuring
they have a key function. This is the same mechanism that
ensures we can safely dynamic_cast these interfaces, even
across library boundaries.

The use of a free standing templated helper function instead
of a member function in the type T, is to avoid shadowing issues,
and to not pollute the class namespace of T with the helper
function.

Since we are already changing the plumbing for how a user
resolves a native interface for a type T, we take the opportunity
to add a few extra safeguards to the machinery.

First, we add a static assert in the T::nativeInteface<I>()
definition, that ensures that only compatible interfaces,
as declared by the interface themselves, are allowed.
This ensures a compile time error when an incompatible
interface is requested, which improves on the link time
errors we had prior to this patch, and also offsets the
one downside of type erasure, namely that errors are only
caught at runtime.

Secondly, each interface meant for public consumption through
T::nativeInteface<I>() is declared with a revision, which
is checked when requesting the interface. This allows us
to bump the revision when we make breaking changes to the
interface that would have otherwise been binary incompatible.
Since the user will never see this interface due to the
revision check, they will not end up calling methods that
have been removed or renamed.

One advantage of moving to a type-erased approach for the
plumbing is that we're not longer exposing the native
interface types as part of the T::nativeInteface symbols.
This means that if we ever want to rename a native interface,
the only exported symbol that the user code relies on is
the type info. Renaming is then possible by just exporting
the type info for the old interface, but leaving it empty.
Since no class in Qt implements the old native interface,
the user will just get a nullptr back, similarly to bumping
the revision of an interface.

Change-Id: Ie50d8fb536aafe2836370caacb22afbcfaf1712a
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2021-05-12 22:02:05 +02:00
Richard Moe Gustavsen
3224c6d7d1 QDockWidget, macOS: don't drag on native widgets
When using native dock widgets on macOS, it will currently
fail if you try to drag on a dock widget inside QMainWindow
to make it floating. The reason is that the drag will
basically start as as drag inside one NSWindow (QMainWindow),
but continue as a drag on another NSWindow (QDockWidget).
And this is not handled well by AppKit, especially since the
NSView where the drag was started is reparented into a new
NSWindow (the floating QDockWidget) while the dragging is
ongoing. And there seems to be no practical solution to how
we can support this from the cocoa QPA plugin

This patch will therefore change the logic in QDockWidget to
simply make the dock widget floating if you drag on it, rather
than actually starting a drag (but only for the described case).

Pick-to: 6.1 5.15
Fixes: QTBUG-70137
Change-Id: Ic309ee8f419b9c14894255205867bce11dc0c414
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-05-12 20:50:02 +02:00
Karsten Heimrich
776a969bfd Implement QFileSystemEngine::createLink() on MS-Win
Fixes: QTBUG-74271
Change-Id: I9e414dd16546f65e85b5a1a6c70c40dfa4284a6f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-05-12 14:53:12 +02:00
Pekka Gehör
37d6fd60a8 Android: Fix position issue of the EditPopupMenu
Set y for the EditPopupMenu from the previous correct value if select handles values are zero.
The SelectionHandle.bottom() is zero if selection handles have not yet been displayed on the screen.

Task-number: QTBUG-71900
Change-Id: I3694a8edd4f0d8f8799dbac1217a75c375038e66
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-05-12 12:49:46 +00:00