Commit Graph

39391 Commits

Author SHA1 Message Date
Lars Schmertmann
f2b914afc6 Android: Enable QDesktopService
QDesktopServices::openUrl(const QUrl &url) is already implemented
on Android. But even if it is possible to set an URL handler, the
mechanism to invoke it is missing. With this commit the URL handler
will work on Android like it is already working on iOS.

Task-number: QTBUG-84382
Pick-to: 6.2
Change-Id: Ic560bd380f1cc59586861aa1a6a3ea064276a39e
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-09-10 06:41:15 +02:00
Morten Johan Sørvig
5083d9dcd6 macOS: process all activation events synchronously
Commit ed483346 changed the main code path to deliver
activation events synchronously, however it looks like
an additional code path was missed.

Use SynchronousDelivery also in becomeFirstResponder.

Pick-to: 6.2
Change-Id: I9061868b0dd0db0252f281e3a974cffe795af38f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-10 01:09:39 +00:00
Alexey Edelev
76665f2a72 Replace manual android properties reading with genex's
Since qt6_android_generate_deployment_settings uses 'file(GENERATE'
API now, we can use generator expressions when writing target
properties to deployment setting files.
This adds the generic functions to accumulate list and non-list
target properties and write them to a deployment setting file
with respecitve key.

Change-Id: Ibfdc875c84c39166f26b2f12ab59831d4f9a6e00
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-09 23:44:39 +02:00
Alexey Edelev
d20f4ae706 Support deploying of libraries from a build tree when building android apk
If the project consists of an executable and multiple libraries that
are linked to the executable, currently you need to specify them
manually using QT_ANDROID_EXTRA_LIBS target property.

This automates deploying of the libraries that are a part of the
project build tree. _qt_internal_collect_target_apk_dependencies
collects all the known non-imported shared libraries from the project
build tree. When running androiddeployqt we specify extra library
directories that point to the collected library locations in build
tree, to help androiddeployqt resolve shared libraries that are build
as a part of the project.

The described procedure is running automatically if CMake version is
greater than or equal to 3.18 is. For the CMake versions less than
3.18 users need to call a new public qt_finalize_project function at
the end of project's top-level CMakeLists.txt

Task-number: QTBUG-94714
Change-Id: I400ca4e49e940cfc25ae90d65372e79825bee55a
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-09-09 21:49:37 +02:00
David Skoland
db8729b018 Change two types in qurlidna
To avoid comparison between signed and unsigned integers,
and the compiler warnings that come with it.

Change-Id: I1028a980dfde68acc338f0e480fdeec42ed81ffb
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-09-09 18:15:23 +02:00
Tang Haixiang
dfae6416dc Revert "Add Deepin to the list of GTK based desktop environments"
This reverts commit 39f0633f0b.

The Deepin desktop environment is developed based on Qt, but some
applications use dialog boxes of GTK, and some applications use dialog
boxes of Qt. This doesn't look good. The initial commit was trying
to unify this by always using GTK dialogs.

But this turned out to not look good, so instead the plan is that
all application dialogs can be based on Qt. Reverting the original
commit as a result, as it is no longer applicable.

Pick-to: 6.2
Change-Id: I2824b7b2f292f3896c9f94ccce6979f77d66578b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-09 15:36:16 +00:00
Craig Scott
2e4d8d8ec5 Remove inline docs for qt_import_plugins() to avoid duplication
Don't maintain two copies of the docs for qt_import_plugins() in
separate places. Remove the inline docs because they are not the
canonical ones that the user docs contain.

Also remove the TODO and qml plugins. Those are now handled by a
separate command, qt_import_qml_plugins(). Add a "see also" link to
assist in discoverability.

Task-number: QTBUG-95712
Pick-to: 6.2 6.2.0
Change-Id: I3bb872f77a1b57fd5f2f4fe1355625c47e44a351
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-10 01:36:16 +10:00
Craig Scott
1fed96d19f Add documentation for the NO_DEFAULT option for qt_import_plugins()
Task-number: QTBUG-95712
Pick-to: 6.2 6.2.0
Change-Id: I3ba7fa52fa38c2ee1f9080f91894c36504a4f451
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-10 01:36:16 +10:00
Craig Scott
afb7d3b814 Update Qt5:: namespaced targets in snippets to versionless Qt::
The docs for CMake commands all show the versionless commands as the
primary name, with versioned commands added as a note. Use the same
preference for targets for consistency and update the Qt5:: namespaces
to Qt:: rather than Qt6::.

Task-number: QTBUG-95712
Pick-to: 6.2 6.2.0
Change-Id: I6bf1929a11656f88e27bb5877e9521a3a651361e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-10 01:36:16 +10:00
Craig Scott
2ad35d133a Remove unused qt5_... CMake command snippets
Task-number: QTBUG-95712
Pick-to: 6.2 6.2.0
Change-Id: I92535fd96937638bb8997a63455ba5152055b72a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-10 01:36:16 +10:00
Craig Scott
9ad8d2c0d4 Move some CMake commands out of tech preview status
Task-number: QTBUG-95712
Pick-to: 6.2 6.2.0
Change-Id: I6739e5d2fb4716f40e99576a73f57bca51060e92
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-10 01:36:15 +10:00
Craig Scott
944c424ff6 Split up cmake-macros.qdoc into one file per command
Task-number: QTBUG-95712
Pick-to: 6.2 6.2.0
Change-Id: Ieeb4293fb8d17c57fb25e0ac5cd333b07fc53278
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-10 01:36:15 +10:00
Craig Scott
5b58fbf9a2 Move CMake-related doc files into their own subdirectory
This is in preparation for splitting up the cmake-macros.qdoc file into
one file per command.

Task-number: QTBUG-95712
Pick-to: 6.2 6.2.0
Change-Id: I9e56b88139cc6a53cd03cbed3d14404577f89faa
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-10 01:36:15 +10:00
Tor Arne Vestbø
aafed07dee macOS: Don't show QMessageBox::about(Qt) as modal windows
The system behavior is to not show these kinds of dialogs as modal,
and we've documented that for QMessageBox.

However, calling show() instead of exec() is not enough, as the
default constructor of QMessageBox will set the modality of the
widget to application-modal. We need to explicitly override this.

[ChangLog][macOS] QMessageBox::about(Qt) now shows dialog non-modal,
as documented.

Pick-to: 6.2
Change-Id: I6bb59efb81feb23122276a9eede71b2f20c9d7c6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-09-09 15:10:36 +00:00
Alexey Edelev
3a9b5162e6 Collect QT_QML_ROOT_PATH based from the project resources
Use the _qt_internal_collect_qml_root_paths function to collect qml
files from the resources. The function is called only if Qml module is
found.

Pick-to: 6.2
Task-number: QTBUG-93340
Change-Id: I2b5f51e3d7fb8aa82f46e88b2aac5e52bf0930d5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-09-09 17:10:36 +02:00
Øystein Heskestad
9a602e68cf Move QNAM's http header parsing into separate class
Fixes: QTBUG-80701
Change-Id: I43f5e102c15d121dba74e07e3cd4bb8aded1c763
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-09 16:55:50 +02:00
Craig Scott
1fb242ba9f Fix invalid JSON due to missing comma after value
Amends 248828b9a3

Pick-to: 6.2 6.2.0
Change-Id: I606835942e988736786aaf6881ecddc94c8a882c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-09-10 00:11:13 +10:00
Jan Grulich
dda7dab827 Use wayland platform plugin on GNOME wayland sessions by default
Qt wayland platform plugin has improved quite a lot and it is now pretty
much usable on Gnome. It also improves user experience a lot on HiDPI
displays.

Pick-to: 6.2
Change-Id: I943e0bb969f384bdc3c603e290ce9c8358b70f63
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-09-09 16:11:13 +02:00
Martin Storsjö
a126b9be89 normalizeTypeFromSignature: Update for Clang 13
Clang 13 now outputs "unnamed struct" just like GCC, while it earlier
used to output "anonymous struct" (since
https://reviews.llvm.org/D96807).

Therefore, for Q_CC_CLANG check for both "anonymous" and "unnamed".

This fixes the QMetaType testcase when built with Clang 13.

Change-Id: I34de8c2ca05c0e691fbb990b001f011b0f336dc3
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-09-09 08:54:42 +03:00
Tang Haixiang
39f0633f0b Add Deepin to the list of GTK based desktop environments
Deepin prefers the GTK3 theme implementation with native dialogs etc.

Pick-to: 6.2 6.2.0
Change-Id: I54cea9d17c0d7f5e466c700adce5aa68f0cf5564
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-09 00:53:10 +00:00
Alexey Edelev
42d0089d44 androiddeployqt: Add support of multiple qml root paths
If application uses qml files from multiple locations, e.g.
subdirectories inside source directory it's important to provide this
information to qmlimportscanner to produce consistent set of QML
modules that need to be included into the end-point application apk.

This makes possible to specify more than one QT_QML_ROOT_PATH per
target and propagates these paths to the qmlimportscanner using
androiddeployqt tool.

Pick-to: 6.2
Task-number: QTBUG-93340
Change-Id: Ic31017b3f2671108adb6d6118ef1c75f1ccc3ec5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-09-08 23:37:51 +02:00
Volker Hilsheimer
fd3315bc61 macOS: Move pointingDeviceFor helper to top of file
It's confusing to have it in the middle of the code implementing the
various interfaces. Make review of follow up patches easier by moving
it out of the way.

Change-Id: I10f6e8f7642ec0cb14ae31b14a023c6a9ef455d9
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-08 18:39:10 +00:00
Mårten Nordheim
2e520f29a7 OpenSSL: Let people opt-in to use TLS 1.3 PSK callback
It's a workaround for the workaround...

If TLS 1.3 was explicitly chosen and the PSK callback is set then
without this patch the callback is never called since, with TLS 1.3, PSK
would only be queried once at the start of a connection.

It can now be re-enabled with an environment variable. A new API should
be added to address the new requirements of PSK with TLS 1.3:
For session resumption the connection MUST use the same hash algorithm
as in the original session. For new sessions the hash algorithm must be
decided ahead of time, or a default will be used (as defined by the
standard). A user can also pass along multiple identity+key pairs and
the server will pick one it recognizes. This is not something we can
currently do with the preSharedKeyAuthenticationRequired callback.

[ChangeLog][Network][QSslSocket][OpenSSL] When using TLS 1.3 we
suppress the first callback from OpenSSL about pre-shared keys, as it
doesn't conform to the past behavior which
preSharedKeyAuthenticationRequired provided. With this update you can
opt-out of that workaround by setting the QT_USE_TLS_1_3_PSK environment
variable

Pick-to: 6.2 6.1 5.15
Task-number: QTBUG-95670
Change-Id: Ia7454bbbf394cbcb859de333b371d0890b42a1c3
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-09-08 18:28:40 +00:00
Edward Welbourne
4641ff0f6a Add new am/pm format-specifier that preserves locale's case
The existing a, ap, A and AP specifiers all force the case of the
formatted am/pm indicator. The indicators returned by QLocale's
amText() and pmText() methods are those given in CLDR, with no case
coercion. Application writers may reasonably want these strings used
verbatim, rather than having to chose a case and impose it on the
locale's indicators, in defiance of national custom. For example,
while en_US uses upper-case indicators by default, cs_CZ uses
lower-case ones. An application author writing a time format has been
forced to chose which of these locales to be wrong in.

Add support for aP and Ap specifiers, whose mixed case indicates that
the locale's case is to be respected. Amend an existing test-case of
tst_QLocale's formatDateTime() that used Ap (expecting, of course, an
upper-case indicator followed by a stray p) to now expect the
locale-appropriate-cased indicator. Extend formatTime() to test cases
using aP and Ap, to illustrate the difference between en_US and cs_CZ.

Rework QDateTimeParser to also support the new format specifier. This
required expanding its Case enum, used by the getAmPmText() method,
which was formerly shared with QDateTimeEditPrivate; however, as that
class no longer makes any reference to this method, it and the enum
can be made private, allowing a systematic clean-up of their use.
Added test-cases for both serialization and parsing; and amended some
existing parsing tests to verify am/pm indicators are matched
case-insensitively.

[ChangeLog][QtCore][Important Behavior Changes] Time formats used by
QLocale, QTime and QDateTime's parsing and serialization now recognize
'aP' and 'Ap' format specifiers to obtain an AM/PM indicator, using
the locale-appropriate case for the indicator, where previously the
author of a time format had to pick a case that might conflict with
the user's locale. For QTime and QDateTime the locale is always C,
whose indicators are uppercase. For QLocale, the case will now match
that of amText() or pmText(). Previously, 'aP' would have been read as
a lower-case indicator followed by a 'P' and 'Ap' as an upper-case
indicator followed by a 'p'. The 'P' or 'p' will now be treated as
part of the format specifier: if the prior behavior is desired, either
use 'APp' or 'apP' as format specifier or quote the 'p' or 'P' in the
format. The prior 'a', 'ap', 'A' and 'AP' specifiers are otherwise
unaffected.

Fixes: QTBUG-95790
Change-Id: I26603f70f068e132b5c6aa63214ac8c1774ec913
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-09-08 20:28:40 +02:00
Alex Trotsenko
400a7c540e QWindowsPipeWriter: stop reporting errors from write()
To match the Unix behavior, callers of the write() function (i. e.
QProcess::writeData() or QLocalSocket::writeData()) should return -1
only if the pipe is already closed. All data being written must be
buffered and no state transition is allowed in response to this call.

Considering the fact that all callers ignore the return value of the
write() function, there is no point in returning anything other than
void.

Change-Id: I52480fc453e076920209bb8e3d52813279393d70
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-09-08 17:21:05 +00:00
Morten Johan Sørvig
a72066f449 wasm: add DialogExec hack/warning to event dispatcher
Show the warning (and call emscripten_sleep) for the standard
build, but not for the asyncify build.

Change-Id: I695a580ea60897872beee6fa2b6ae70acb9e7dcf
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-08 19:01:54 +02:00
Morten Johan Sørvig
04fd894400 High-dpi configuration change testing
Export configuration() and setConfiguration() from the offscreen
platform plugin using QPlatformNativeInterface. tst_qighdpi can
then resolve and make use of them since it always uses the offscreen
platform plugin.

Add screenDpiChange() auto test.

Change-Id: I459b4df5d94ec4991234a346e3a94618cb3485e9
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-08 19:01:54 +02:00
Morten Johan Sørvig
95d5710d7b Offscreen: add configuration update API
Add support for updating the platform configuration at runtime,
which  enables use cases such as changing the screen configuration
from an auto test.

Provide functions for getting and setting the complete
configuration as a QJsonObject:

    QJsonObject configuration()
    void setConfiguration(QJsonObject)

User code can then either set a completely new configuration,
or make a smaller update by using a get-modify-set sequence:

    // Set the logical DPI for screen 0 to 192:
    auto config = configuration();
    config[“screens”][0][“logicalDpi] = 192
    setConfiguration(config);

This approach means we can expose a minimal but complete
API, at the cost of doing more work in the offscreen plugin
in order to figure out what changed.

Note that this change does not export thew API from the
platform plugin.

Change-Id: If776c36d5ae6d72dca715cc8e89e42768ed32c60
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-08 19:01:54 +02:00
Topi Reinio
1117e732d9 Doc: Fix documentation warnings for Qt Network
The Clang compiler used in QDoc complained about the documentation-
specific overload of QAbstractSocket::bind():

  error: incomplete type 'QHostAddress' named in nested name specifier

Also, fix an attempted snippet inclusion to use the \include command,
and fix the comment tag spacing and indentation.

Pick-to: 6.2
Fixes: QTBUG-96293
Change-Id: Ie4d78933fa7ac0aaf7f3bcc6487e7fd823db5123
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
2021-09-08 18:31:18 +02:00
Tor Arne Vestbø
c138f55591 Clear up QWindow::isActive() documentation
The isActive function does not determine if a window should be active,
but whether it is currently active. The way the documentation was phrased
may have lead people to believe the former.

Pick-to: 6.2 6.2.0 5.15
Change-Id: I05a4cb3d8784a2fefa24bdd42ea96cfdae22b9d1
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2021-09-08 16:22:01 +00:00
David Faure
a9d3506bf9 QTextImageFormat: add Qt7 TODO to remove the default value
Change-Id: I8b60b302c9df7ce7c44b89fe45f813c4532b7bd6
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-09-08 15:43:16 +02:00
David Faure
b67f887a04 QTextOdfWriter: fix exporting pixmaps to ODT
The QVariant returned by resource() can contain either a QPixmap
or a QImage. The code here is now more similar to the one in
qtextimagehandler.cpp.

Also, the quality is 0 when not set, in which case we want a nice PNG
rather than a very very low quality JPG with just a few large blocks of
same-color pixels.

Pick-to: 5.15 6.2
Change-Id: I49db542e2234c8068f85a636a81a7d8cdb7b5876
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-09-08 15:43:16 +02:00
Giuseppe D'Angelo
c44e3b119a Add a conditional noexcept specification to qExchange
Following P2401 (which libstdc++ and MS-STL already implement)
and [res.on.exception.handling]/5 that gives us freedom to
strenghten any noexcept specification.

Change-Id: I17ebd9148a181eb8496ace3a9d8010008160b564
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-09-08 15:43:16 +02:00
Sona Kurazyan
28e194d3b2 Fix QtConcurrent::blockingMapped to work with non-template sequences
The code for deducing the type of output sequence was assuming that the
input sequence is always a template class and was trying to use the
corresponding container type for the output sequence. Fixed the
deduction code, to assume that the output sequence has the same type as
the input sequence, when it's not a template class. Also added tests to
verify that all QtConcurrent functions support non-template input
sequences.

Fixes: QTBUG-30617
Pick-to: 6.2 6.1
Change-Id: I486fe99f3207cfff5dcceb3712cc7de863067edb
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-09-08 15:05:32 +02:00
Craig Scott
2b0e55a3e2 Clean up duplicated code block
Two separate changes addressed the OUTPUT_TARGETS variable not being
set in the calling scope of _qt_internal_process_resource() for a
particular code path, but they did so at different places. Remove one
of them, since we don't need both.

Pick-to: 6.2
Change-Id: Ibc1052e886ec73a99231ada3b7a1bb9e7a873cc4
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-09-08 22:20:06 +10:00
Craig Scott
0d4b2355e5 Fix dependencies on sources generated in a different scope to target
In certain situations, a file generated by add_custom_command(OUTPUT)
may be added as a source to a target defined in a different directory
scope. That makes its GENERATED source property not visible to the
target for CMake versions before 3.20. For 3.20 and later, policy
CMP0118 can make the generated state of a source file global, but that
policy is under the control of the user project, since its value at
the end of the target's directory scope is what is used. Therefore we
can force that global visibility using CMP0118. With CMake 3.18 or
later, we can set source properties in arbitrary scopes, which allows
us to force visibility in the scopes we need it. Use that for all
CMake versions 3.18 and later to make the source file properties
visible to the target.

Making the generated state of a source file visible to the target
isn't enough on its own. In the scope that the file is generated,
there must be a target that depends on the file or else CMake won't
set up the necessary dependencies to ensure that generation happens
before the target tries to use it. Add targets in the generated
file's own scope where we currently might not do that.

Task-number: QTBUG-95200
Pick-to: 6.2
Change-Id: Ic1dfca1a193041de01d7f903b79473b9d47f1d1d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-08 22:20:06 +10:00
Andy Shaw
b919fc8fd0 SQLite: Update SQLite to v3.36.0
[ChangeLog][QtSQL][SQLite] Updated SQLite to v3.36.0

Pick-to: 6.2 6.2.0 5.15 5.12
Change-Id: I05cde47b757455dfd438405bfba1818c7f6eec00
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-09-08 08:20:33 +00:00
Laszlo Agocs
19febad9f2 rhi: Reset resource state tracking tables upon layout-compatible updates
...just like create() would do when requesting a full rebuild.

Not relevant for the OpenGL backend, while D3D and Metal may get away
without doing this, but the Vulkan backend gives visible rendering
errors in Qt Quick once updateResources() is taken into use and a
scene manages to do the "right" amount and types of changes.

The most common source is a changing uniform buffer offset. Consider
how the Qt Quick scenegraph merges uniform data into a single buffer
in unmerged batches (i.e. when a set of geometry nodes cannot be
batched together in a single draw all). While each node gets its own
draw call, each associated srb refers to the same uniform buffer at
binding point 0, just with a different offset.

Without the layout-compatible-update optimization (that is
QRhiShaderResourceBindings::updateResources()) this is not something
that needs extra care: once an srb is built or rebuilt (by calling
create()), the offset, just like the resource itself is fixed and
cannot change. And once create() is called, it conveniently
invalidates all related data structures, leading to the subsequent
setShaderResources() rewrite descriptors (incl. the resource, the
offset, etc.) with Vulkan or do whatever is relevant with other
backends.

updateResources() only does the minimum amount of changes because we
know that the binding list layout has not changed. It turns out this
was a bit too minimal, because certain state tracking data structures
still need resetting, just as if we called create().

The problem is becoming apparent with non-layout data such as the
uniform buffer offset, storage buffer offset, or the storage image mip
level. It however works as expected when changing the resource itself.
E.g. if a binding point now references a QRhiBuffer different than
before, then there is no visible problems, regardless of the buffer
offset being different or the same. Hence being difficult to discover,
until the aforementioned Qt Quick renderer case triggers it.

Why is this?

Changing the resource (buffer, texture, sampler) itself works due to
the guarantees given by the QRhi resource model. Consider the
following:

ubuf is a uniform buffer
ubuf->create();
srb->setBindings({ references ubuf });
srb->create();
// use the srb in some draw calls
// ...
// later, when preparing the next frame we decide we need new data with
// a different size even:
ubuf->setSize(new_size)
ubuf->create();
// fill in new data to ubuf
// use the srb in some draw calls

at this point "magic" happens: note how there is no rebuilding of the
srb itself (no create(), no nothing), yet it will correctly pick up
the now-different native buffer objects underneath ubuf.

This works because there is a certain degree of state tracking
happening that allows recognizing that a resource referenced from an
srb got rebuilt and now has different native objects (e.g. a VkBuffer)
underneath, which in turn needs (with Vulkan) rewriting the associated
descriptor with the new native resource.

Incidentally, this also makes updateResources() work just fine as long
as it replaces the QRhiBuffer/Texture/Sampler reference for the
binding point. However, with the example snippet above there is no way
to change the other associated data such as the buffer offset. (that
would need rebuilding the srb with create(), and that resets all
related state tracking structures)

So once we encounter an updateResources() where the same QRhiBuffer is
now used with an offset different from before, that is not recognized
by setShaderResources() and (with Vulkan) it will not rewrite the
descriptor with the new offset. (unless the changes for another
resource in the binding list trigger it; the granularity here is quite
coarse, i.e. we either rewrite (with Vulkan) all descriptors or none
at all; this makes the problem even less apparent because now
rendering errors occur only when Qt Quick ends with an update where
only the uniform buffer offset, but nothing else changed)

Pick-to: 6.2
Change-Id: I82ee43aa358947288135ff72ec213e091342e9cb
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-09-07 21:47:49 +02:00
Laszlo Agocs
ce9d0491f2 rhi: Improve srb layout serialization helpers
Be idiomatic and return the output iterator one past the last element.
Otherwise passing in a plain pointer (as exercised by the autotest now)
fails to function because we write over the same 4 elements again and
again for each binding.

Pick-to: 6.2
Change-Id: If74463fa5140ffa2b1d5be97b71868848ad46614
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-09-07 21:47:44 +02:00
Thiago Macieira
7e8c7b3ed8 Q_DECLARE_INTERFACE: delete unspecialized qobject_interface_iid()
Instead of making it return a non-useful nullptr.

Change-Id: Ie72b0dd0fbe84d2caae0fffd16a245cce5ea65f1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-09-07 12:09:49 -07:00
Thiago Macieira
da2fd6a903 Q_DECLARE_INTERFACE: add missing const to const qobject_cast
[ChangeLog][Potantially Source-Incompatible Changes] The macro
Q_DECLARE_INTERFACE used to cast away the constness of the QObject
parameter. That is now fixed in this release, but may cause failure to
build source code that depended on this incorrect behavior. If fixing
the const correctness in your code is not an option, insert an explicit
const_cast<IFace *> of the object prior to the qobject_cast call.

Change-Id: Ie72b0dd0fbe84d2caae0fffd16a246a36f0c088f
Reviewed-by: Rui Oliveira
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-09-07 12:09:49 -07:00
Edward Welbourne
0108275b0c Unix fallbackLocale(): use QString::tokenize() rather than split()
We only want the first entry, so avoid all the allocations of
split()ing and just look at the first.

Change-Id: I81beee1856608c932254213f2971fc37bc457c41
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-09-07 21:09:49 +02:00
Tor Arne Vestbø
121fddcf5a Split up close handling in QWidget into a pre and post step
If we are the one initiating the close (from Qt Widget land), we want
to mark the widget as closing as early as possible.

Clarified the role of close_helper by renaming it to handleClose.

Change-Id: Iae250a0ae1583d743c59e99fcb99fdf18d2a1882
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-09-07 21:09:49 +02:00
Andreas Buhr
80256b3683 Revert "QUrl: Remove explicit casts to {const,} void*"
This reverts commit 63c1e7c4a1.
It caused the following compilation error with g++-11.
error: ‘void* memcpy(void*, const void*, size_t)’ copying an
object of non-trivial type ‘class QChar’ from an array of
‘const char16_t’

Fixes: QTBUG-96268
Change-Id: I2680b15aba8d0d867092391fcee3815e7fa4c0bc
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-09-07 18:55:40 +00:00
Doris Verria
f3bc1f8500 Cocoa: Make sure we can display multiple sheets for the same NSWindow
On macOS, to display a modal with Qt::WindowModality set, or of type
Qt::Sheet, we call beginSheet:completinHandler:. However, this method
won't display the specified sheet unless the current active one is
dismissed, which is a different behavior than what we expect for
this case. Use beginCriticalSheet:completionHandler: whenever we
already have an active sheet attached to the NSWindow, which allows
us to display multiple sheets for the same window.

Fixes: QTBUG-91059
Pick-to: 5.15 6.1 6.2
Change-Id: I86bdbcbd63758edbbc48a8aade0178917dcb0e5b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-07 20:18:26 +02:00
Assam Boudjelthia
7dc05252a0 Allow building android{deployqt, testrunner} under target host_tools
When doing a cross build for Android we need only the host tools which
are available under cmake's host_tools target, but androiddeployqt and
androidtestrunner are not part of that. This fixes that.

Pick-to: 6.2
Change-Id: Icdbc4a78ca050b66ec8df656d9ec766ef6c9f4b9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-07 17:08:25 +00:00
Volker Hilsheimer
7166a82844 Refactor QStatusBar to reduce memory allocation
Reading through the code contemplating what might have caused QTBUG-89141
brought up some opportunities for improvement.

* updated coding style and variable names
* use ranged for where possible and meaningful
* replacing a QList of pointers to heap-allocated structs with a list of
  values

Since the QList population code makes sure that we never have gaps (we
only insert within the existing range), the test for null-entries is not
needed, and was perhaps just precausion to avoid nullptr dereference.

Task-number: QTBUG-89141
Change-Id: I4694d820427a221f1334d2428f50069751919aef
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2021-09-07 15:48:35 +02:00
Sona Kurazyan
9f13842fe6 Fix compilation for recursive Qt containers
The operator checks cause compilation errors when trying to check for
their existence for recursive containers. This happens because of trying
to check for the operators on the template parameter type(s), that
inherit from the container itself, which leads to compilation errors.
Introduced alternative versions of the operator checks (with _container
suffix), that first check if the container is recursive, i.e. any of its
template parameter types inherits from the given container, and skips
the operator check, if that's the case.

The fix is done for all Qt container types that had the problem, except
for QVarLengthArray and QContiguousCache, which don't compile with
recursive parameter types for unrelated reasons.

Fixes: QTBUG-91707
Pick-to: 6.2 6.1
Change-Id: Ia1e7240b4ce240c1c44f00ca680717d182df7550
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-09-07 15:48:35 +02:00
Laszlo Agocs
4cde0e484c rhi: Enable serializing a layout description without baking an srb
Pick-to: 6.2
Change-Id: I66d28cc9d5417bcd5d192fa100c21f69fd42fd6b
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-09-07 14:41:11 +02:00
Laszlo Agocs
b6b0c33058 rhi: Make the serialized srb layout description accessible
...by the Qt Quick renderer, for example.

A typical Qt Quick material binding set serializes to 8 uints. This
would not demand a container like QVector. However, being implicitly
shared is essential here due to the intended usage (query the
serialized blob, put it into a cache key, hash it, compare it, all
without any copying and new allocs; we can afford an extra alloc
upon each srb construction, but don't want more afterwards in the
rendering engines)

Also make it clear in the pipeline docs that the optimization Qt Quick
is (soon going to be) doing is legal. (the srb ref in the pipeline can
be dead and dangling as long as every call to setShaderResources()
specifies a layout-compatible alternative)

Pick-to: 6.2
Change-Id: I97efbea1fa3516b10c9832adbab0a21b7bc0845d
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-09-07 14:41:11 +02:00
Zhang Hao
cca8ed0547 QPaintEngineEx: solve compile error
Use the same variable name in function
Amends 6869d2463a2e0d71bd04dbc82f5d6ef4933dc510

Pick-to: 6.1 6.2
Change-Id: If710a53993e84d048f9052f4fcf92eb57635f585
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2021-09-07 12:00:56 +00:00
Mårten Nordheim
e94f75fc50 Remove QNetworkAccessCache::Node's explicit ctor
Change-Id: I2a993bcf96a0c603496e8a420251a7e01f46acee
Reviewed-by: Markus Goetz (Woboq GmbH) <markus@woboq.com>
2021-09-07 13:38:54 +02:00
Alexandru Croitor
c2a2522089 CMake: Copy and install lldb QtCore.py script for lldb and Xcode use
The file was not handled during the qmake -> CMake transition.

qmake had a more generic mechanism to allow embedding dSYM scripts per
Qt module, but it wasn't used as far as I know, so the CMake
implementation only limits it to QtCore.

Pick-to: 6.2
Change-Id: Ibcd818df1897f603ac194092b28d4bd4d1d6c6ae
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-07 12:53:37 +02:00
Alexandru Croitor
fc038ef445 Fix lldbbridge.py loading when using lldb + Python 3 from CLI
or from Xcode.

A command line lldb that uses python3 fails to load the 'utils'
module dependency when importing lldbbridge.py via the dSYM script
debug_script.py.

Add the directory where lldbbridge.py is as an additional import path
to sys.path.

This fixes the bridge to load in both CLI lldb and from within Xcode.

Traceback (most recent call last):
  File "src/corelib/debug_script.py", line 92, in __lldb_init_module
    bridge = import_bridge(bridge_path, debugger, session_dict)
  File "src/corelib/debug_script.py", line 42, in import_bridge
    bridge = imp.load_source(MODULE_NAME, path)
  File "Versions/3.8/lib/python3.8/imp.py", line 171, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 702, in _load
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783,
       in exec_module
  File "<frozen importlib._bootstrap>", line 219,
       in _call_with_frames_removed
  File "Qt Creator.app/Contents/Resources/debugger/lldbbridge.py",
         line 34, in <module>
    import utils
ModuleNotFoundError: No module named 'utils'

Amends 1b73c202ce

Pick-to: 6.2
Change-Id: I521d7530e35ee9c51ae0418d2c532e58ec1952d0
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-07 12:53:37 +02:00
Lorn Potter
70b9e0687b wasm: fix network data URI scheme
Inadvertantly ifdefed out. Tested and works fine

Fixes: QTBUG-96170
Pick-to: 6.2 5.15
Change-Id: Ib26cf76a548146d4212c48b228965348038f34e8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-09-07 20:53:37 +10:00
Thiago Macieira
b631440902 JSON parsing: fix incorrect sign-extension for decoding bad escapes
The parser was lenient in accepting backslashes followed by invalid
characters, but accidentally sign-extended everything above 0x7f causing
broken outputs that weren't valid UTF-16 either.

For example, the sequence "\\\xff" (backslash followed by 0xff) produced
sequence "\ud7bf\udfff" (U+D7BF is not a surogate pair).

Change-Id: Ie72b0dd0fbe84d2caae0fffd16a113c703a7696f
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-06 16:23:01 -07:00
Thiago Macieira
248828b9a3 3rdparty: Update TinyCBOR to v0.6-rc1
Change-Id: Ie72b0dd0fbe84d2caae0fffd16a169a70845d33e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-06 15:41:33 -07:00
Volker Hilsheimer
dad1e14941 Forward touchEvents to children inside QGraphicsProxyWidget
This reapplies the fix from 1ecf2212fa,
using QApplication::translateRawTouchEvent to dispatch the touch event
received by the QGraphicsProxyWidget to the relevant child widgets
under each touch point.

In addition, limit the implicit grabbing of each touch point before
sending the event to those cases where we have to: touch pads, and
if the target widget comes from a closest-widget matching. And don't
call the QTouchEvent override of QEvent::setAccepted() on QTouchEvent
instances in QGraphicsView classes, as this will override each event
point's acceptance state.

This way, we can identify which touch points have been accepted after
event delivery, any only implicitly grab those points that were.
Otherwise, touch points not accepted by a proxied widget hierarchy
will still be part of an accepted event, and be grabbed by the
viewport of the QGraphicsView. This would then lead to infinite
recursion when the QGraphicsProxyWidget passes the TouchUpdate event
on to each touch point's grabber.

Re-activate the test case, and extend it with more combinations.
Refactor touch-event recording to make it easier to test multi-touch
scenarios.

Task-number: QTBUG-45737
Fixes: QTBUG-67819
Pick-to: 6.2
Change-Id: Id5611f4feecb43b9367d9c2c71ad863b117efbcb
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-09-06 19:41:22 +00:00
Ivan Solovev
78dee15da4 Fix QLocale::system() standalone day and month handling
Some backends were missing support for standalone days and months,
also the standaloneDayName() implementation was always using the
same codepath as dayName().
This patch fixes the issues.

Support for narrow format will be added in the following patch.

Task-number: QTBUG-84877
Pick-to: 6.2
Change-Id: I38ee06342cafab544e3c69097bd0e6ae68e85645
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-06 20:40:12 +02:00
Volker Hilsheimer
eb39b5fd36 Doc: fix qdoc warning from wrong function prototypes
std::chrono values are passed by const reference.

Still warnings from undocumented parameters, but rephrasing
the documentation doesn't make it better in this case, so perhaps
qdoc needs a way to suppress the warning. Adding an \omit block
where the parameters or return values are mentioned doesn't help.

Change-Id: I7d495d73d8367d9d90dd33a4880ac7c978382d19
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-09-06 19:44:27 +02:00
Liang Qi
25feb2fe3e xcb: update connection time when possible
At least we try to do it with all events triggered by user.

Pick-to: 5.15 6.1 6.2
Change-Id: I28b399a2517600f7da2c91a50fecdf58b9d81fb6
Reviewed-by: JiDe Zhang <zhangjide@uniontech.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-09-06 19:07:43 +02:00
Ievgenii Meshcheriakov
63c1e7c4a1 QUrl: Remove explicit casts to {const,} void*
Those casts are not needed when passing pointers to simple types
to memcpy.

Change-Id: I686265b0e152aa22e0195ff252c442ab1a122ba7
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-09-06 17:41:53 +02:00
Ievgenii Meshcheriakov
65a2cb6964 corelib: Use char16_t and char32_t types for characters
Use standard char16_t and char32_t types instead of ushort and uint.

Remove members of QUtf8BaseTraits that use those integer types.

Change-Id: I77b1a9106244835c813336a50417f6bbdfada288
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-06 17:41:53 +02:00
Sze Howe Koh
ee2ac8b4ef qt_pixmap_thread_test(): Simplify logic, merge warnings
Pick-to: 6.2
Change-Id: I0c413c14d124bafbd6b2bd94d7a128e19ed83ade
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-09-06 22:56:56 +08:00
Volker Hilsheimer
e9e8d67e31 Fix segfault when closing widget and destroying window in QDialog::done
On OpenSUSE we seem to get an Enter event after or while the QWindow is
closed, and that appears to reset the currentMouseWindow after we
cleared it in QWindowPrivate::destroy. Apply a workaround similar to the
focus_window to make sure that currentMouseWindow and
currentMousePressWindow don't point to destroyed objects.

Pick-to: 6.2
Change-Id: I61afdaa7d8d1d437058624012319460be2f2567f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-06 14:23:17 +00:00
Volker Hilsheimer
197fcdd7ee Doc: mark documentation of internal functions as such to silence qdoc
Pick-to: 6.2
Change-Id: I9523511b9adf40d1280fbf320c24a79aa2860ef2
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Luca Di Sera <luca.disera@qt.io>
2021-09-06 16:23:16 +02:00
Edward Welbourne
c801e35282 Remove redundant break;s following return;s
Pointed out by the INTEGRITY compiler.

Change-Id: Id5f9b994c348308c56c3a25200419be525b9c933
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2021-09-06 15:56:28 +02:00
Craig Scott
f68f6ecf6f Fix cases of output variables not being passed back to calling scope
Some versionless wrappers were not passing back output variables to
their calling scope. Ensure they always are.

Fix qt6_extract_metatypes() to set its output variable in the parent
scope (it was previously setting it erroneously in the local scope).

Some functions had code paths that would not set output variables.
This would allow situations where if the variables had an initial
value set by a higher up parent scope, the output variable would
still have that value in the caller's scope upon return. That could be
misleading, so fix these code paths to explicitly set the output
variable to an empty string instead.

Task-number: QTBUG-96121
Task-number: QTBUG-96219
Pick-to: 6.2
Change-Id: I291775813f025cabdccd4372ac077cdfd3ec090e
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-09-06 23:56:28 +10:00
Craig Scott
a37789e493 Revert "Ensure versionless wrappers do not introduce a new variable scope"
This reverts commit 08180e76e6.

Macros add another level of escaping that functions do not. The
conversion of the versionless wrappers to macros may alter the
behavior, so revert that change.

Task-number: QTBUG-96219
Pick-to: 6.2
Change-Id: Ic5dcff3081123d957888584ba1d76ae0580d9083
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-09-06 23:56:28 +10:00
Tor Arne Vestbø
9877d55a50 macOS: Report preedit cursor position and cursor visibility correctly
Unfortunately QInputMethodEvent::Cursor defines length == 0 as the
cursor being hidden, and length > 0 as being visible. This is the
opposite of what native macOS application do.

A future improvement here would be to base the QInputMethodEvent
logic on QStyle::SH_BlinkCursorWhenTextSelected, which we already
respect for normal selections. That would also allow us to use
QInputMethodEvent::Cursor to set the preedit selection, which
we currently have to fake via QInputMethodEvent::TextFormat.

Pick-to: 6.2
Change-Id: I75b5d8c5403283a0988355e440a98b4df35ec995
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-09-06 14:37:43 +02:00
chenbin
0624eba1b1 Partially modified to use C++11 standard nullptr
Change-Id: I0542c47d1979235206005bf603822b6ea415f2da
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-09-06 09:49:46 +08:00
Volker Hilsheimer
ef8ca68406 Doc: fix qdoc warning, add \inmodule for qdrawutil header
Change-Id: Iddc0273778adf79250b4e767172b1202817507bb
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-09-05 23:07:52 +02:00
Volker Hilsheimer
c111b6b7b1 Doc: fix qdoc warning, function prototype missed return type
Also missed the second set of template parameters.

Change-Id: I81ab09ed77af79415ee72334db900bdb94db5739
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-09-05 21:07:48 +00:00
Volker Hilsheimer
5f3df6e1c7 Doc: fix qdoc warning from wrong see-also
Only QByteArray has a toHex() member, QByteArrayView doesn't.
Since toHex() is linked to from result() already, remove it here
to avoid the wrong impression that there was a toHex() that doesn't
require any memory allocation.

Change-Id: I76f876aca90403baebf9328b794aeaf9be698c46
Reviewed-by: Luca Di Sera <luca.disera@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-09-05 23:07:44 +02:00
Tor Arne Vestbø
2262744ad0 QMessageBox: Reset clickedButton for each invocation of the dialog
When showing a messagebox that has already been show we don't want to
keep around the clicked button of the previous invocation.

Pick-to: 6.2
Change-Id: Ib6f6293d40ab338c550ea344094db871ccf45c46
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-09-04 23:09:30 +02:00
Shawn Rutledge
673ed80fa4 doc: Add the PixelScroll device capability (new in 6.2)
Followup to 69c833dae9

Pick-to: 6.2
Task-number: QTBUG-72167
Task-number: QTBUG-87646
Change-Id: I4ac7cbacd6dc1407ad3b565674a6d6494ec8857f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-04 11:55:27 +02:00
Timur Pocheptsov
c55f61578c QSslCertificate(OpenSSL plugin): fix memory leaks in extension 'parser'
They went unnoticed previously because of lazy evaluation, which is
not the case anymore.

Fixes: QTBUG-96155
Pick-to: 6.2 5.15
Change-Id: I46026a24b354c1db7c10d84fceae06c4ab7cc0fc
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-04 08:25:18 +02:00
Sze Howe Koh
ee5077daf5 QPixmap: Fix crash if created without gui app in secondary thread
The thread checking in in_pixmap_thread_test() is only safe, and only
makes sense, if we have a QGuiApplication. If we only have
QCoreApplication, only null QPixmaps may be created anyway, so
threading makes no difference.

Fixes: QTBUG-95358
Pick-to: 6.2
Change-Id: I93c983a3d6c271b0a19dfd0384862fc151459029
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com>
2021-09-04 03:43:44 +02:00
Tor Arne Vestbø
ae8e96d4c2 macOS: Don't rely on invalidateCursorRectsForView when mouse is over view
Calling invalidateCursorRectsForView will normally result in a updateCursor
callback, where we then set the current cursor using [NSCursor set]. But
if an override cursor is set by AppKit, which happens for example when
hovering over a resizable window's theme frame, then AppKit ignores the
call to invalidateCursorRectsForView. And it will not consult the view
when the override cursor is unset again, which results in the cursor
being reset back to the default arrow cursor instead of the cursor
that was set when we initiated the invalidateCursorRectsForView call.

We need to hit-test to confirm that the mouse is over the view,
as there might be child views in the mix that also have custom
cursors, and we don't want to activate the parent view's cursor
unless we're actually over that view.

Fixes: QTBUG-81552
Fixes: QTBUG-96003
Pick-to: 6.2 5.15
Change-Id: I52573ab7be82f28c6a1cf686bd4b133551cfe98b
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-09-03 22:38:07 +02:00
Volker Hilsheimer
f70421bfc0 Doc: add more notes about full screen windows on macOS
Fixes: QTBUG-68069
Pick-to: 6.2 5.15
Change-Id: I8fc99f708cfa19a9c8cc8d13f6889549c79dd3b3
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-03 21:40:08 +02:00
Volker Hilsheimer
1ebea13765 Doc: fix qdoc warnings from wrong parameter type
QWidget::addAction takes a QKeySequence, not a QShortcut.

Change-Id: Ia10adcf50133b306d484a122ed17dddcf94372a6
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-09-03 21:40:08 +02:00
Volker Hilsheimer
62fc486a77 Doc: fix a bunch of qdoc warnings from wrong prototypes
* name method parameters consistently with their declaration
* don't document parameters that are not there

Pick-to: 6.2
Change-Id: I06ae9fdca357ed29eb7a72802f149eb4914181f4
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-09-03 21:40:08 +02:00
Volker Hilsheimer
2c6de9c099 Doc: add note that hiding a window doesn't close a full screen space
Fixes: QTBUG-52450
Pick-to: 6.2 5.15
Change-Id: I3f819bac470b5a883a74fb58f6fa2d27740eaaf2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-03 21:35:06 +02:00
Joerg Bornemann
4c52dd43ae Fix QMAKE_LIBS_OPENSSL/NOLINK entries in qt_lib_network_private.pri
The file qt_lib_network_private.pri contained the following bit
  QMAKE_LIBS_OPENSSL/NOLINK =
  QMAKE_INCDIR_OPENSSL/NOLINK = C:/openssl/include
  QMAKE_LIBS_OPENSSL =
  QMAKE_LIBS_OPENSSL_DEBUG = -L"C:/openssl/lib/VC" -llibssl64MDd
  QMAKE_LIBS_OPENSSL_RELEASE = -L"C:/openssl/lib/VC" -llibssl64MD
  QMAKE_INCDIR_OPENSSL = C:/openssl/include

The /NOLINK entries are nonsense.  QMake projects that do
  QMAKE_USE += openssl/nolink
would use QMAKE_INCDIR_OPENSSL and discard the QMAKE_LIBS_OPENSSL*
variables.

The QMAKE_*_OPENSSL/NOLINK entries stem from the WrapOpenSSLHeaders
CMake package, and QMAKE_*_OPENSSL from WrapOpenSSL.  It's safe to
assume that both packages use the same include paths.

Remove the QMAKE_LIB parameter from the
qt_find_package(WrapOpenSSLHeaders) call to avoid writing this library
into the .pri file.

Pick-to: 6.2
Fixes: QTBUG-89562
Change-Id: Ibc20f6f90678eb127db7813eb63c5c3e0bff2268
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-09-03 21:35:06 +02:00
Shawn Rutledge
4d8fb1bc6f cocoa: use TouchPad deviceType for trackpad
WheelHandler { acceptedDevices: PointerDevice.TouchPad }
doesn't react unless we use the right type.

Amends 69c833dae9

Pick-to: 6.2
Change-Id: I813de096b87f3af4dfcf5510abc0d0bd9c15b689
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-03 19:53:32 +02:00
Laszlo Agocs
6906516004 rhi: Add a way to tell an srb that only the resources have changed
Until now, after updating the bindings one had to always rebuild the
srb, which can be heavy esp. on Vulkan (release old objects, create
new layout object, descriptor sets). When updating the binding list in
a way that it is fully isLayoutCompatible() == true with the previous
list, this is an overkill. Internally, most notably in
setShaderResources(), we already should have everything in place in
all backends to recognize if the entries in the binding list refer to
QRhiBuffer/Texture/Sampler objects that are different than before, and
so apart from adding an alternative to create() in the API there is
not much else needed here.

Pick-to: 6.2
Change-Id: I2efdd4fd0b24c7ebba694a975ed83509744b044b
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-09-03 17:14:59 +02:00
Kai Köhne
c104af4c44 Doc: Remove unsupported customFilters
customFilters defined in .qdocconf are not supported anymore by Qt
Assistant since Qt 5.13. Therefore remove them from all .qdocconf files,
also to avoid cargo-culting them to new help modules.

Task-number: QTBUG-95987
Change-Id: I664391460637d2e859348da0338e1a4a3ee9f570
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-09-03 15:14:59 +00:00
Laszlo Agocs
65cad49473 rhi: Correct a doc note
It is not true that isLayoutCompatible() can be called before create().
That used to be the case before the optimizations have been added.
The docs are still internal, but let's fix it up.

Pick-to: 6.2
Change-Id: Iee61848f058a06774550af6f38a3253956e4cfd3
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-09-03 17:14:59 +02:00
Laszlo Agocs
6cdf95a970 rhi: Include resource count in srb layout compatibility checks
Relevant for Vulkan, given that descriptorCount is part of
VkDescriptorSetLayoutBinding, meaning two srbs with arrays of
SampledTextures should only be reported as compatible if the
array size matches.

Also reduces the prealloc size for the VLAs. For Qt Quick even a
lower number would be sufficient, but we still keep the number
something fairly high in order to play nice with Quick3D.

Pick-to: 6.2
Change-Id: Id92b7c09b051ebe54b1fa2bf4ba78950fe60ba27
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-09-03 17:14:59 +02:00
Ievgenii Meshcheriakov
19a48b8545 unicode: Regenerate qunicodetables{.cpp,_p.h}
Run unicode utility to regenerate the Unicode tables. This reduces
size of the IDNA mapping tables. Adjust the QUrl client code to use
the new API.

Task-number: QTBUG-85323
Change-Id: Iaa8d6932e611f7aa4009a3fae2972de87b875cf8
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-03 14:43:16 +02:00
Alex Trotsenko
340131b4be QWindowsPipeWriter: suppress a warning on unexpected peer disconnection
The other side can close the pipe at any time independently of us, so
ignore the ERROR_PIPE_NOT_CONNECTED error code if the write operation
failed.

Change-Id: I4f7ccd73c19ca2dd24fa1c9f33b5f60541a7521d
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-09-03 09:31:42 +03:00
Volker Hilsheimer
7ba75d088c QWidget: close the QWindow in QWidget::close
We want to close the window, end full screen mode on macOS, and free
platform resources. This is all done by QWindow::close. QWindow::close
closes the platform window, triggering a closeEvent to QWidgetWindow,
which then calls QWidgetPrivate::close_helper.

This way, closing a window via QWidget::close, QWindow::close, or
interactively by the user are all equivalent.

The QCloseEvent generated by the widget needs to be spontaneous for
window-system generated events (i.e. the user clicked the close button),
and non-spontaneous if the window closes because of a call to
QWindow::close. To keep track of whether the event originated in an
explicit call to QWindow::close, add a boolean to the QWindowPrivate.

Add a test case that verifies that the window resources is destroyed,
and that events are delivered as they should.

Done-with: Morten Johan Sørvig <morten.sorvig@qt.io>
Fixes: QTBUG-46701
Pick-to: 6.2
Change-Id: Iacb6a2c8d5e880b16b0c8f0c9257ed94bed36f5b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-02 20:34:48 +02:00
Mårten Nordheim
05c9894330 QNetworkAccessCache: Style fixes and move asserts
Change-Id: I300d2525d9987737697e2cc6a326be19554902c8
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-02 16:57:42 +02:00
Mårten Nordheim
a253bec500 QNetworkAccessCache: Port to QDeadlineTimer
QDeadlineTimer is semantically more correct than comparing timestamps to
'now'.

Change-Id: I15d9654af2886499392e6409d22f802203aca18d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-09-02 16:57:42 +02:00
Mårten Nordheim
3a7d6767e9 QNetworkAccessCache: move debug logging to specific ifdef
Instead of for any debug output.
Since QTestLib cuts off output after X messages we shouldn't add these
by default.

Another option would be categorized logging, but QNAC should not be very
interesting for 'outside' users

Change-Id: I4c2c2a68ca4962476bfecd679f3229ccf3403aee
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-02 16:57:42 +02:00
Mårten Nordheim
8460a55d32 QNetworkAccessCache: Remove the ctor and init member variables in class
Change-Id: Ic7ce41679d89b496413ef13e6e917bf506b2405d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-09-02 16:57:42 +02:00
Mårten Nordheim
3a8f9286fc QNetworkAccessCache: Rename first and last node
'oldest' and 'newest' to me make me thing of 'least recently inserted'
and 'most recently inserted', which is what they used to mean.
But now the expiration can be set per-request so the semantics don't
work anymore.
So, rename to 'nextExpiringNode' and 'lastExpiringNode'. Also rename the
node member elements "older" and "newer" to the more generic "previous"
and "next".

Change-Id: I582267d09c60c68396e4201e4a20185bbf0942e2
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-09-02 16:57:42 +02:00
Edward Welbourne
7403561f21 Remove a redundant check
Missed in a recent fix to QTimeZonePrivate::dataForLocalTime(), but
noticed during picking back to 5.12

Pick-to: 6.2
Change-Id: I63964952150fedf857b7aef12dfc866097d2e2d1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-09-02 16:35:12 +02:00
Edward Welbourne
f645bb8880 Replace implementation-specific zero test with plain comparison
Various double-to-string converters carefully omit the sign from -0.0,
for which they need to test whether the double is zero. This was
tested by a function that looked at the bytes of the double in an
endian-specific way. Packaging a comparison to zero in a function
seems to avoid the compiler warnings over double-comparison, so retain
the function but make it simpler. The only available benchmark
(QString's number_double benchmark) consistently shows a negligible
improvement in performance.

Change-Id: Id994177e21e4770ced904881d7e84a95cb727605
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-09-02 16:35:12 +02:00
Craig Scott
f266381b1b Clean up output target handling left behind by earlier changes
Previous work removed the no-longer-used code path that could add
targets from qml compiler features. The variable that code path would
populate was not fully cleaned up in that removal. Clean it up now and
move the variables related to output target handling closer to the
only remaining area where they could be generated.

Also ensure that we set the variable named by OUTPUT_TARGETS even if
isBinary ends up being true. We should explicitly set that variable
to an empty string in that case.

Amends 363df5cd70

Pick-to: 6.2
Change-Id: I17de9788b390aac9a7aedb29ab9bdfee99c305af
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-09-02 20:52:22 +10:00
Fabrice Fontaine
035dc537be Fix build on riscv32
riscv32 fails to build because __NR_futex is not defined on this
architecture:

In file included from thread/qmutex_linux.cpp:45,
                 from thread/qmutex.cpp:804:
thread/qfutex_p.h: In function 'int QtLinuxFutex::_q_futex(int*, int, int, quintptr, int*, int)':
thread/qfutex_p.h:116:30: error: '__NR_futex' was not declared in this scope; did you mean '_q_futex'?
  116 |         int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
      |                              ^~~~~~~~~~
      |                              _q_futex

Pick-to: 6.1 6.2
Fixes: QTBUG-96067
Change-Id: Ib6a9bcc496f37e69ac39362cb0a021fccaf311f5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-09-02 09:59:33 +00:00
Alex Trotsenko
5d68858ba7 QLocalSocket/Win: fix waitFor...() functions for write-only socket
There were several issues with the socket state checking when the pipe
reader is not running:

  - the number of object handles in the WaitForMultipleObjectsEx()
    call might have been zero;
  - a call to the waitForDisconnected(-1) might have hung;
  - we did not perform a loop iteration for the waitFor...(0) calls,
    so disconnect detection was unreliable.

These issues are related to the same code, so they don't seem to be
addressable separately.

Change-Id: I3bca872bb4191e6a7d38a693d81f7981af7fe145
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-09-02 08:47:11 +03:00
Liang Qi
9a4c98e556 xcb: support xrandr(1.5) monitor setup
More information about monitor in xrandr 1.5, see
https://keithp.com/blogs/MST-monitors/

Since this change, screen is logical instead of physical.

If xrandr 1.5 and later is installed, Qt screen info will get
from xrandr monitor object instead of xrandr output if only have
1.2 to 1.4.

Users can manipulate monitor as they want, for example, a
combination for two physical screens, half of one screen and etc.

Didn't have chance to access MST monitors, but it should work
if xrandr monitor object was created automatically.

[ChangeLog][xcb] Qt screen info will get from xrandr monitor
object if 1.5 is installed.

Fixes: QTBUG-65457
Change-Id: Iad339cc0d4293b2403b4ef6bf6eb770feb3e685f
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-09-01 20:32:04 +02:00
Thiago Macieira
f3743073a7 qstrnlen: micro-optimize further
This is the kind of loop that the autovectorizer is pretty good
at, but this is really just a type of memchr, so help dumber
compilers and build modes without vectorization.

Drive-up fix the style of the test code.

Change-Id: Ie72b0dd0fbe84d2caae0fffd16a022a35fa24c17
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-01 11:32:03 -07:00
ChunLin Wang
ca69e5aeef Fix QListView assert when the last row is moved in IconMode
After the last row is moved, 0 will be returned when obtaining
row and column data. At this time, QListView::doitemslayout will
not call d->doitemslayout, so the QBspTree data structure will
not be cleaned up, leaving a stale tree structure behind. This
will trigger an assert during paintEvent handling if QListView is
set to IconMode

In QListView::ListMode the test for a valid model index doesn't
use an assert.

Call QListViewPrivate::clear explicitly if the column count is 0
so that the QBspTree and other data structures are cleared.

Add a test case that simulates this scenario by implementing a
model that returns a 0 column count for an index after the model
structure was changed through a move of rows.

Done-with: Volker Hilsheimer
Fixes: QTBUG-95463
Pick-to: 5.15 6.1 6.2
Change-Id: I36419be5459b8ced930c619f538482ea1db4ad03
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-09-01 16:03:15 +00:00
Edward Welbourne
38ec2c830b qlocale_win: Fix non-standalone month names
We have previously been using the standalong (nominative) month names
both when asked for that and when asked for the plain (genitive) month
name, probably because there was no LCTYPE value for the
latter. However, MS's docs for the standalone values do contain a
comment telling us how to get the genitive names.

Rename the old monthName() to standaloneMonthName() and add a
monthName() that calls GetDateFormat() suitably, as described by the
MS doc.

Pick-to: 6.2 5.15
Fixes: QTBUG-92018
Fixes: QTBUG-86279
Change-Id: I27f63198c3a15b792683f476d2019078b0860f99
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-09-01 17:56:46 +02:00
Edward Welbourne
6da648ad83 Add a QLocale(QStringView) constructor
Only a few more internals just needed to change to take QStringView,
to connect up the constructor with internals already long since
converted.

[ChangeLog][QtCore][QLocale] Added QLocale(QStringView) constructor.

Change-Id: Iec31391e6168f333b4b6fc633c3d7d01872f83b3
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-09-01 17:11:44 +02:00
Eirik Aavitsland
dc65267ad8 When clearing QPixmapCache, stop its flushing timer
No need for timer event to reduce cache size when it is already empty.

May also avoid the "Timers cannot be stopped from another thread"
warning at exit, if the global cache object is then deleted by another
thread.

Fixes: QTBUG-96101
Pick-to: 6.2 5.15
Change-Id: Id1aeecfbb43a25a887ebd5cc7242749a74290bb0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-09-01 17:11:44 +02:00
Eirik Aavitsland
a6a3b1e79c Update bundled libjpeg-turbo to version 2.1.1
[ChangeLog][Third-Party Code] libjpeg-turbo was updated to version 2.1.1

Pick-to: 6.2 5.15 5.12
Change-Id: I22a273018229aa35a175f9e903fa605a3eb55c32
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-09-01 17:11:43 +02:00
Ivan Solovev
313de93b1d QDoubleValidator: fix NaN check in validateWithLocale
We can't really compare two NaN's. Should use qIsNaN() for that.

Pick-to: 6.2
Change-Id: Ia514cabe65cfcdeafb39cab91ecdb66f8fae725c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-01 17:11:43 +02:00
Mårten Nordheim
81a9335c65 Fix documentation of QNetworkAccessBackend
The classes themselves were not documented, so...:

Add some documentation for QNetworkAccessBackendFactory.
Add some overall class docs for QNetworkAccessBackend.

The class docs were marked \internal (because they mostly are).
I don't think we yet have a defined way to handle semi-private APIs but
having them be marked \internal and leaving the documentation in source
seems fine (and was what someone suggested a while back).

Add documentation for pure virtual functions which were overlooked.

Pick-to: 6.2
Fixes: QTBUG-88774
Change-Id: Id7fe18ec92372abb96540cd29543608f87ec862e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-09-01 14:51:29 +00:00
Morten Sørvig
81a7344e1d Port to QImage and QPixmap deviceIndependentSize()
Replace the “size() / devicePixelRatio()” pattern with
a call to deviceIndependentSize().

Change-Id: I9d9359e80b9e6643e7395028cd43e3261d449ae7
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-09-01 15:24:05 +02:00
Edward Welbourne
f98d9aa9da Refine QLocale constructor documentation
Fix a typo and swap two sentences to give a clearer reading.

Pick-to: 6.2
Change-Id: I4a24ad5ba2e022edd121eb686de3638af2c242a6
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-09-01 11:27:42 +02:00
Edward Welbourne
b656cea5de Fix corner case in QTimeZonePrivate::dataForLocalTime()
If the local time for which we want data is after the last known
transition, the two transitions we get to bracket it are the last
known and an invalid one. The code checked the former was valid, but
neglected to check the latter, leading to nonsense arithmetic later in
the function. In this situation we unequivocally want the last known
transition, so the problem is easily solved.

Fixes: QTBUG-96152
Pick-to: 6.2 6.1 5.15 5.12
Change-Id: I6fc830ce538e8a572093cd8dfe832e10689bf904
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-09-01 11:26:54 +02:00
Edward Welbourne
5598a15fe7 Mark QLocale's private functions [[nodiscard]]
If only to make the exceptions stand out, so we can see which ones
only exist for their side-effects.

Change-Id: I90b649d4da09f57ab986f29c577993dd12e34721
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-09-01 11:16:52 +02:00
Edward Welbourne
52473c7bf1 Use QByteArrayView::toInt() instead of duplicating its implementation
The code in qEnvironmentVariableIntValue() to parse the text as an int
can now delegate it to QByteArrayView, so that keeping in sync with
QByteArray::toInt(), as a comment requested, is now automatic.

Change-Id: I09a6b7245ecd02f39a850a4ce187f86709282e8c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-31 20:37:14 +02:00
Mårten Nordheim
5ad75eda0c QNetworkAccessCache: Another fix to the linked list insertion
When inserting between two nodes the "previous" node's "newer" was
forgotten and not updated. So every node's "newer" would point to the
"newest" node.

Change-Id: I5b0df8812be5f7f62b3ae363e4c78f582e0e5c43
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-31 17:54:30 +02:00
Fan RuiJie
586d9e6013 Fix text ellipsis not implemented in Tibetan
The original code checks the existence of an ellipsis character first.If
this does not exist (glyph == 0,which is an invalid glyph index), then
it falls back to looking up '.'. But in the Tibetan environment,the
glyphIndex('.') also returns 0, so that it simply doesn't add any form
of "...", and cuts the text instead.

If both the attempts at getting something from the main font fails,
we can do a third pass on the "multi" font engine.

Fixes: QTBUG-95942
Pick-to: 6.1 6.2
Done-with: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Change-Id: I251de3fe92e19be0462c58c2059ecf7d354bfbb0
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-08-31 14:53:45 +00:00
Yang Yuyin
6e9cae0b77 QFileDialogComboBox: member variable is not initialized
initialize d_ptr in the constructor

Pick-to: 6.2
Change-Id: I5a8062dd0a81023e6c1a5858bb8603d279cdbcee
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-08-31 13:18:15 +02:00
Craig Scott
08180e76e6 Ensure versionless wrappers do not introduce a new variable scope
Using function instead of macro prevented the wrappers from being able
to pass back any variables set in the wrapped function. In some cases,
these variables were being explicitly passed back to the caller, but
that isn't needed if you just make each wrapper a macro. This also
makes things more future-proof because any newly introduced output
variables will work without having to update the wrappers.

Task-number: QTBUG-96121
Pick-to: 6.2
Change-Id: Ic4486de668694c06b47e466587b2cdcb969ea047
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-31 17:05:15 +10:00
Volker Hilsheimer
6e2a5312db Revert "Forward touchEvents to children inside QGraphicsProxyWidget"
This reverts commit 1ecf2212fa.

The fix is not correct after all. TouchBegin goes to the correct
widget with the fix, but following TouchUpdate and TouchEnd events
now go to the viewport, as QApplication::translateRawTouchEvent always
gives precedence to the widget that Qt recorded to be the touch
grabber, which is the viewport. This results in infinite recursion,
as the proxy widget trying to send the touch events to the embedded
widget (expecting that translateRawTouchEvent will split it up) ends
up sending the events back to the viewport.

Leave the added test case as QEXPECT_FAIL, reactivate the (never run,
hence unnoticed) test that the fix broke.

Pick-to: 6.2 6.1
Task-number: QTBUG-45737
Task-number: QTBUG-67819
Change-Id: I4810affb3cd066743ae94ab7beb2f0c06b60d211
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-08-30 19:34:50 +00:00
Edward Welbourne
c2a6749af7 Clean up QLocaleData::validateChars() and fix its double-handling
Decrementing decDigits and checking for zero is less complicated than
incrementing a counter to check against it if it's not negative.

A plethora of unenlightening local variables could be replaced by
keeping track of the last character and of a simple state variable
that make checks easier to understand (and explain).
Various conditions could be expressed more simply.

Comment on the condition for omitting grouping characters from the
transcript - it was easy to mistake the comma for a dot !
Comment on the lack of checking of grouping sizes.

Change-Id: Iff8da2376507d2abbbaf5739baf6cbb23e55edaf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-08-30 18:48:39 +02:00
Edward Welbourne
4e9efb0b60 Teach QByteArrayView how to parse numbers
Now that we don't need '\0'-termination on the data, this is possible.
Moved QByteArray's tests to tst_QByteArrayApiSymmetry and added some
more test-cases.

[ChangeLog][QtCore][QByteArrayView] Added numeric parsing methods.

Change-Id: Ic0df91ecfe5dbf6f008d344dd0464d7927f32273
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-30 17:46:00 +02:00
Edward Welbourne
6db5fd5918 Avoid UB (and the consequent need to suppress an MSVC warning)
Converting a negative signed value to its absolute value in the
matching unsigned type can be done by adding one, negating (which we
can now do without the UB), casting and then adding one again.
This is cleaner than casting the negative value to the unsigned type
in order to then "negate" it within that type, about which MSVC
grumbles; we can now avoid the need to suppress that grumble.

Change-Id: I9148ead23c928aeb2b90884a2f2e292fdf3af5e3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-30 17:46:00 +02:00
Edward Welbourne
0564e4afba Remove temporary inlines for qstrtou?ll()
All callers are now converted to use qstrntou?ll().

Change-Id: I279a800a9f19944e544cc8a7ebaba579d18643b3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-30 17:46:00 +02:00
Edward Welbourne
88b54cc22a Rework QLocalePrivate::bytearrayToU?LongLong()
Change it to take a QByteArrayView instead of a plain char *; all its
callers do know the size and propagating it enables the implementation
to call strntou?ll() rather than strtou?ll(), thereby escaping the
need for '\0'-termination.

Fixes: QTBUG-74286
Change-Id: Ie9394786e9fcf25c1d1be2421805f47c018d13bb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-30 17:46:00 +02:00
Edward Welbourne
7d33779a79 Convert various callers of strtou?ll() to call strntou?ll()
Where size is known or can readily be determined.

Change-Id: I442e7ebb3757fdbf7d021a15e19aeba533b590a5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-30 17:46:00 +02:00
Edward Welbourne
5644af6f8a Replace FreeBSD's strtou?ll() with std::from_chars()-based strntou?ll()
Remove third-party code in favor of STL. Implement (for now)
strtou?ll() as inlines on strntou?ll() calling strlen() for the size
parameter. (This is not entirely safe, as a string lacking
'\0'-termination but with at least some non-matching text after the
numeric portion would formerly be parsed just fine, but would now
produce a crash. However, strtou?ll() are internal and callers should
be ensuring '\0'-termination.)

Task-number: QTBUG-74286
Change-Id: I0c8ca7d4f6110367e93b4c0164854a82c5a545e1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-30 17:46:00 +02:00
Mårten Nordheim
522ca997d3 TLS plugins: Prefix with 'q'
For consistency with other plugins.

Pick-to: 6.2
Change-Id: I45507389a42e645c94f1ca3f32262a2181f282f7
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-08-30 12:35:41 +00:00
Assam Boudjelthia
07283f1527 Android: pass -g to testrunner to grant run time permissions
Some Qt modules/tests go through features that require run-time
Android permissions which are granted by user input, that of
course is not ideally possible while running unit tests. So when
installing the app adb can do that for us.

Pick-to: 6.2
Change-Id: I92d33d5213c3779d7ca246ec0fb359d2ead4fa6f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-29 19:39:42 +03:00
Tor Arne Vestbø
52f635b9a0 macOS: Hide mouse cursor when initiating IM enabled text input
Fixes: QTBUG-72744
Pick-to: 6.2
Change-Id: I952710e88a11fd00498562c9011461a010f02f7b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-27 22:41:09 +02:00
Tor Arne Vestbø
3de396590c macOS: Correctly implement attributedSubstringForProposedRange
The substring range refers to the entire text of the focus object,
not just the selection.

As there is no way to pull out the entire text via input method queries
we do the best we can via ImTextBeforeCursor and ImTextAfterCursor.

Returning the correct substring enables input method features such
as backtracking into already committed text with the Hiragana IM,
as well as the Keyboard Viewer's 'Current Text' toolbar.

Pick-to: 6.2
Change-Id: I53286ef1e8e7c5fba37858dda7317ae74d95b528
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-27 22:41:06 +02:00
Tor Arne Vestbø
9e1875483c macOS: Assume input method handles key event
When input methods are enabled for the focus object we send key events
through interpretKeyEvents, which will involve the input method in the
key event processing. The input method will get back to us with callbacks
such as insertText, setMarkedText, or doCommandBySelector.

In the case of insertText, when the inserted text matches the originating
key event's text, we opt to not send the text as an QInputMethodEvent,
and instead fall back to sending it as a normal QKeyEvent. The reason
for this is that Qt's IM protocol was designed to handle composited
text, so sending non-composited (but IM-initiated) text input as IM
events is unexpected (see 2d05d3bd28).

However, we cannot assume that the input method will always call us
back with one of the above mentioned methods. The input method can
very well eat the event as part of its own operation. This happens
for example when pressing and holding 'a' in a US English keyboard
layout, which will pop up an input panel for the various accents
available. Or it may happen when using the AquaSKK third party IM,
which uses the 'l' key to switch the input mode to latin without
producing any characters.

To allow these input methods the freedom to control the processing
of key events we need to reverse the logic for when we send key
events as QKeyEvent. We now assume that the IM will handle the
event, and only trigger QKeyEvent in two cases where we explicitly
were called back by the IM, but decided that a QKeyEvent is needed:

 - If the IM calls insertText and we consider the text simple text
 - If the IM calls doCommandBySelector and we can't find a matching
   selector for the command. We only implement insertNewline and
   cancel, so in all other cases we want to pass on the key event
   to let the focus object handle it, for example for 'Select All'
   and similar key combinations.

Fixes: QTBUG-46300
Fixes: QTBUG-71394
Pick-to: 6.2
Inspired-by: Vladimir Belyavsky
Change-Id: I9a73a8e1baa2ebe0c5df1166a9ec3d9843632bb1
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-27 22:41:03 +02:00
Mårten Nordheim
587d64507a QNetworkAccessCache: Remove unused code
The function was never called. As a consequence receiverQueue was
only ever read and never written.

Change-Id: I30905446452d9f263124d3af08c42e2e1b0cafbe
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-27 21:17:04 +02:00
Shawn Rutledge
ba8f9d8d92 Fix deprecation of QMouseEvent::source() and flags()
Amends 53496e67f0:
- move flags() out of the QT_DEPRECATED_SINCE block in the header
- add QT_DEPRECATED_SINCE block around source() implementation

Pick-to: 6.1 6.2
Change-Id: Id52fa6b04a13efbede3e6ac440060f90b283e773
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-27 20:31:18 +02:00
Edward Welbourne
d95f4d0018 qlocale_win: Simplify and explain month-name format lookup
Retain the given month number and simply subtract one from it in the
one place it's used (once the two array dereferencs are unified). That
makes it clear that the off-by-one numbering is just down to our
arrays, not some weired quirk of the MS API. Simplify a condition by
inverting it: compare to LongFormat instead of ||-ing comparisons to
the other two members of the enum.

Change-Id: Ia03486b7869255ecdb1372de62d5c745d35d0a0a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-27 20:31:18 +02:00
Juha Vuolle
17d7a8dc2e Update Android default SDK from 29 to 30
By the time of Qt 6.2 release all new apps targeting Play store must
target API level 30 (Android 11) or above (starting in 08/2021 for
new apps and 11/2021 for existing apps' updates).

Pick-to: 6.2 5.15
Task-number: QTBUG-94451
Change-Id: Id7fa2fd62899a7259e365c917292c6c3ac0d2b0d
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-08-27 18:31:17 +00:00
Edward Welbourne
7af79ba091 Make clear why QTestLog::addB?XFail() don't add to counters
This reverts commit 904617dfb8 and makes
clear to future readers why that wouldn't be a sensible change.
Update the test's data, eliminating a case of duplicate counting that
was caused by the reverted commit.

Task-number: QTBUG-95661
Pick-to: 5.12 5.15 6.1 6.2
Change-Id: Ice6d3ab06ca171e0d6eb0fac757f1ab774e229f0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-08-27 20:16:18 +02:00
Tor Arne Vestbø
a56b915f71 macOS: Handle replacement range during marking of text
The input method may include already committed text when marking text,
in which case the replacement range reflects the position and length
of the existing text.

We handle this the same way we do replacement ranges in insertText.

Pick-to: 6.2
Change-Id: I148e4701318a59c7e0d9441d157199d7c8606f43
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-27 19:49:55 +02:00
Tor Arne Vestbø
f97e936049 macOS: Handle IM insertNewline by sending synthetic Qt::Key_Return
Depending on the input method, pressing enter may result in simply
dismissing the input method editor, without confirming the composition.
For example with Hiragana, pressing 'a', then 'Tab', and then 'Enter'.

In other cases it may confirm the composition as well, for example
with Hiragana, pressing 'a' and then 'Enter'.

And in some cases the IME will produce an explicit new line, for
example with US English, pressing '~' and then 'Enter', or with
2-Set Korean, pressing 'a', then 'j', and then 'Enter'.

Semantically, the input method has then asked us to insert a newline,
and we should probably do so via an QInputMethodEvent, either directly
or via [self insertText:@"\r"]. This is also how NSTextView handles
the command. But, if we did, we would bypass all the code in Qt (and
clients) that assume that pressing the return key results in a key
event, for example the QLineEdit::returnPressed logic.

To ensure that clients will still see the Qt::Key_Return key event,
we send it as a normal key event. But, we can not fall back to
handleKeyEvent for this, as the original key event may have text
that reflects the combination of the inserted text and the newline,
e.g. "~\r". We have already inserted the composition, so we need to
follow up with a single newline event.

Task-number: QTBUG-39125
Pick-to: 6.2
Change-Id: If1e95687e6d5b06011692175a325f457b0b8a72f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-27 19:49:55 +02:00
Tor Arne Vestbø
f563203f60 macOS: Factor out key event handling into helper struct
This allows us to share code between handleKeyEvent: and flagsChanged:
for parsing the incoming NSEvent, and allows for sending key events
from other call sites in the future without duplicating the parsing
and sending logic.

Pick-to: 6.2
Change-Id: Ic63f740523496a9432e439663a20f78b5bc234c5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-27 19:49:55 +02:00
Tor Arne Vestbø
2945c6223b macOS: Return early from key handler if shortcut was handled
The code paths after accepting a shortcut event can never be hit.

Pick-to: 6.2
Change-Id: Ida77417adb8fcfd25a4b20c4eb86056b3769f014
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-27 19:49:55 +02:00
Mårten Nordheim
b33ccd99e1 QNetworkCookie: Clean up
Rewrite the regex to not capture the things we ignore anyway.
Use capturedView to avoid allocating a string just to turn it into an
int.
Fix a (usually) ifdef-ed out piece of code that was still calling
a QRegExp function.
Make the QRegularExpression static const to save it from having to
recompile every time.

Change-Id: I2f4841a2bc35df4e6cea44aec72432410583f770
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-27 19:22:28 +02:00
Laszlo Agocs
8043a1a75a rhi: gl: Set the screen on the context, if possible
Take the screen from the window, if the window was specified.

When it comes to Qt Quick, this is in fact required in order to
make the behavior on par with Qt 5, see
https://code.qt.io/cgit/qt/qtdeclarative.git/tree/src/quick/scenegraph/qsgthreadedrenderloop.cpp?h=5.15#n1336
try to mirror that in Qt 6 as well. There are still subtle differences
between Qt 5 and Qt 6 in particular when qt_gl_global_share_context is
set (do we set the screen from that or from the window?), for now leave
that question unsettled.

What exactly setting the screen on the context does is platform
specific, and can become relevant with multi screen, multi GPU
systems.

Pick-to: 6.2
Change-Id: Icc90b8fea87bf1e34ecf1dec0702f4d3c411db00
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2021-08-27 18:10:33 +02:00
Giuseppe D'Angelo
7d4d47de70 QObject::connect(): fail to connect to a functor if UniqueConnection is passed
The connect() documentation makes it clear that UniqueConnection does
not work with free functions / function objects and the like; only with
actual PMFs. Rather than silently *ignoring* the flag, be vocal about its
presence by warning, and make the connection fail (as the user has
passed an illegal argument).

[ChangeLog][QtCore][QObject] QObject::connect() now will refuse to
connect a signal to a free function / function object if UniqueConnection
is passed. Note that UniqueConnection has never worked for such
connections -- the flag was simply ignored, and they were established
multiple times. Now, the flag is not ignored and results in a connection
failure (as well as a runtime warning by Qt).

Change-Id: I6509667018c74f9bd24910cde0a1b16c5f84f064
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-27 15:45:25 +02:00
Giuseppe D'Angelo
c9830c2fb9 QToolButton: reimplement the fix for QTBUG-95255
The code in 188d739400 uses a connect() to
a lambda, passing UniqueConnection to avoid establishing the connection
more than once. The problem is that UniqueConnection does not work
with lambdas; it works only with "regular" PMFs to QObject subclasses.

Re-do the same fix, but without a connection: use the checkStateSet()
virtual from the base class that will notify us if setChecked() is
being called on the tool button, and from there synchronize the state
of the default action.

Change-Id: Id512812c562cd6d20bc1a489753b33c269919d32
Fixes: QTBUG-95255
Pick-to: 6.2 6.1
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-27 13:45:25 +00:00
Morten Johan Sørvig
89cda52d66 wasm: enable the new event dispatcher for qtcore
Use the new event dispatcher for all non-GUI threads,
nn practice for the main thread when using QCoreApplication,
and when calling QThread::exec().

Change-Id: I9184d52532e06da7e6a87ee27c7d53e0d15e693a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-08-27 15:45:25 +02:00
Morten Johan Sørvig
ecb92aacab wasm: add new event dispatcher implementation
Add QEventDispatcherWasm to QtCore. The event dispatcher
supports managing event queue wakeups and timers, both
for the main thread or for secondary threads.

Blocking in processEvents() (using QEventLoop::WaitForMoreEvents)
is supported when running on a secondary thread, or
on the main thread when Qt is built with Emscripten’s
asyncify support.

Code is shared for all both modes as far as possible,
with breakout functions which handle main and secondary
thread as well as asyncify specifics,. Some functions
like wakeUp() can be called from any thread, and needs
to take the calling thread into consideration as well.

The current asyncify implementation in Emscripten is
restricted to one level of suspend, and this restriction
carries over to Qt as well. In practice this means we
support one level of exec()-like API.

Note that this commit does not _enable_ use of the
new event dispatcher. This will be done in separate
commits.

Task-number: QTBUG-76007
Task-number: QTBUG-64020
Change-Id: I77dc9ba34bcff59ef05dd23a46dbf1873cbe6780
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-08-27 15:45:25 +02:00
Morten Johan Sørvig
c6362cd55c wasm: add Emscripten module accessor to qtloader.js
After enabling -s MODULARIZE=1 there is no longer a
global MODULE object. Add module() accessor which can
be used to retrieve the Emscripten module.

This does not really fit with the current state tracking
since the app transitions from “loading” to “running” before
the module object is ready. We’ll have to revisit this
at some point.

Change-Id: Ib7191cf4ce436e1de99f84b63ed4c10936fa62b1
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2021-08-27 15:45:24 +02:00
Alexey Edelev
e1fe816d46 Implement generating of private cpp exports
Add the generating of private cpp exports for Qt modules.

Add the GENERATE_PRIVATE_CPP_EXPORTS option to qt_internal_add_module
that is the manual switch for private exports generator. Existing
modules in qtbase doesn't follow any strict convention of using
private cpp export. So there is no clue how to detect if generating of
the private exports is required or not for the module.

Use autogenerated private cpp exports in QtNetwork module.

CPP_EXPORT_HEADER_NAME argument of the qt_internal_add_module function
is replaced by the CPP_EXPORT_HEADER_BASE_NAME and has a different
meaning. The provided name is used as a base name for the private and
non-private headers that contains cpp exports. Header files suffixes
are constant: .h and _p.h for the non-private and private header files
accordingly.

Pick-to: 6.2
Task-number: QTBUG-90492
Change-Id: Icf11304e00379fb8521a865965c19b974e01e62f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-08-27 11:01:47 +02:00
Tor Arne Vestbø
abdd524519 macOS: Check NSEvent.characters to determine dead key state
We map NSEvent.characters to text that we pass on in our QKeyEvent,
but for Qt 4 compatibility we explicitly skip function keys and arrow
keys, as the text these events produce are control characters. See
4dbce2a469.

However, these keys are not dead keys, so we can't use the resolved
text we're planning to pass on to Qt to determine if they are.

Pick-to: 6.2
Change-Id: Ib59f0489ae014379c699600f14634c55161ccc8a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-27 00:29:08 +02:00
Tor Arne Vestbø
294e4c7aa8 macOS: Use current NSEvent to determine if IM text matches key event
Gives us one less state member to worry about in the IM machinery.

Task-number: QTBUG-35700
Pick-to: 6.2
Change-Id: Iaa06b29015f9b9594b8107b74a8931f076a26e12
Reviewed-by: Liang Qi <liang.qi@qt.io>
2021-08-27 00:29:02 +02:00
Mårten Nordheim
b3c0537404 QNetworkCookie: Fix use-after-free
The code was previously calling indexOf() on a temporary, which
QRegularExpression would create backing storage for.
After 11d1dcc6e2 the internals were made
to use the QStringView path, which inadvertently meant that there was
no storage for the temporary string anymore. So we need to keep it alive
ourselves.

Change-Id: I542da7010934594eba3b93261322963866ed9297
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-26 18:16:41 +02:00
Lars Schmertmann
0755eba5e8 Android: Add information about who launched this activity to intents
* With this change, applications can easily determine the source
  of an intent without creating an own extension of QtActivity.
* https://developer.android.com/reference/android/app/Activity#getReferrer()

Task-number: QTBUG-84382
Pick-to: 6.2
Change-Id: I6a5200af1d997640f02e2b934343914fb5f32ccc
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-08-26 15:44:12 +00:00
Ievgenii Meshcheriakov
4bf3010378 QUrl: Implement UTS #46
UTS #46 (https://unicode.org/reports/tr46/) is a successor to
IDNA 2003/2008 standards from Unicode.

The current implementation uses nontransitional processing by default.
An optional argument is added to QUrl::toAce() and QUrl::fromAce() to
allow using transitional processing and to ignore the IDN whitelist.

[ChangeLog][QtCore][QUrl] ACE processing is now performed according
to the UTS #46 standard based on IDNA 2008 instead of IDNA 2003.

Task-number: QTBUG-85371
Change-Id: I46b2e86792bc9699cb6961bae8e283fbff72f874
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-26 16:55:05 +02:00
Ievgenii Meshcheriakov
f5360b7c72 unicode: Regenerate Unicode tables
Re-run unicode utility to update the Unicode tables. This adds
properties and mappings needed to implement UTS #46 (IDNA).

Task-number: QTBUG-85323
Change-Id: Id1de91caddd82095f8f8f2301bfd7bb2ee3fcafd
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-26 16:55:05 +02:00
Alexandru Croitor
80705298ca CMake: Build a subset of tests when targeting iOS in the CI
Add infrastructure to build cmake auto tests in the CI when targeting
iOS.
Currently the are only CI instructions for qtbase.
More work is needed to make it work for other repos.

With this change, we will build a single Widgets application targeting
the iOS simulator. We can't target the device SDK in the CI because
signing fails due to a missing signing certificate and provisioning
profile.

The Coin instructions will now set a QT_BUILD_ENVIRONMENT=ci env var
whose value will be checked in _qt_internal_test_expect_pass, to
ensure we build for the simulator SDK when using a universal Qt.
Without this, xcodebuild will try to build with the device SDK and
fail to build the project.

Pick-to: 6.2
Task-number: QTBUG-95839
Change-Id: Ib39c9527b107b2004746ccbdc9d9d1d658f88c76
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-08-26 16:40:15 +02:00
Alexandru Croitor
1f3949a5a8 CMake: Make _qt_internal_test_expect_pass more configurable
Introduce new options: NO_CLEAN_STEP, NO_BUILD_PROJECT_ARG,
GENERATOR, MAKE_PROGRAM, BUILD_TYPE.

If cache or env var QT_CMAKE_TESTS_ADDITIONAL_CONFIGURE_OPTIONS is
provided, the value is interpreted as a list of additional configure
arguments to pass to the built project.

Also skip adding a test command if there is no BINARY or BINARY_ARGS
option provided.

Pick-to: 6.2
Change-Id: I3a1d82b41a734dcd3f473e59cc64efd00363e49b
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-26 16:40:15 +02:00
Laszlo Agocs
ae306b1c5a rhi: Polish some feature flag docs
Clean a bit, also enhance, e.g. mention textureLod for TexelFetch which
is how Quick3D uses it, and most notably expand the "in practice" notes.
As no application or library can be expected to write fully conditional
code based on all these flags, knowing when a certain feature is
(un)supported in a real run time environment is essential in order to
make informed decisions on when and in what manner (i.e. with or without
conditions), rely on a given feature.

Pick-to: 6.2
Change-Id: I15ea34e11bd345b36248f92de9b1fdb1fdc3e8d9
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2021-08-26 15:31:53 +02:00
Laszlo Agocs
afa0ce9045 rhi: gl: Allow passing in a custom shareContext
We already honor AA_ShareOpenGLContexts and pass in the QGuiApp's
context as the shareContext for the QRhi's QOpenGLContext. Extend this
to also allow specifying a QOpenGLContext in the init params struct.

A good example of this is the backingstore compositor that serves
QQuickWidget and co. If one wanted to implement that with (an
OpenGL-based) QRhi, instead of direct OpenGL calls, then the ability
to create a QRhi that uses a context that shares resources with a
given other context becomes essential.

Pick-to: 6.2
Change-Id: I6bc5ff8e803d467f8795197ac1f12fdc0f73bbd1
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2021-08-26 15:31:53 +02:00
Ivan Solovev
7729989648 QLocale: improve documentation snippet
QString::toDouble() now always uses C locale, so the previous code
snippet does not make much sense, as the results do not depend on the
selected default locale.
The updated snippet uses the default locale, which allows to show the
difference between locales.

Pick-to: 6.2
Change-Id: I76a00429fa5b75cf109cf45bc25280a7fd427e0f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-26 15:31:53 +02:00
Morten Johan Sørvig
8585cd2483 wasm: don’t dereference null reply pointer
Move all access to the reply inside the nullptr check,
while making sure to still call emscripten_fetch_close()
unconditionally where needed.

Make all four Emscripten callback handlers have a similar
structure where we check if the reply is not null and
not in the Aborted state.

(This removes one emscripten_fetch_t nullptr check in
stateChage(), if it is really the case that Emscripten
calls us with a null emscripten_fetch_t then we should
add it back.)

Pick-to: 5.15 6.1 6.2
Change-Id: Iadcbe6338c338cfeb8967490e0951d8b3e1ec5b3
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2021-08-26 15:31:53 +02:00
Tor Arne Vestbø
e68bf3ddaf macOS: Modernize and clean up key event handling
- Pass key event type as QEvent::Type
  - Use proper type for NSEventModifierFlags
  - Use modern Objective-C property access in key handler
  - Modernize flagsChanged implementation using ranged-for
  - Use explicit Qt::Key type in key handling
  - Add FIXME comments for dubious code

Pick-to: 6.2
Change-Id: I533e0a5685108dc3cdccd2b276b4eb7a729d172e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-26 14:53:03 +02:00
Tor Arne Vestbø
146bc0e607 macOS: Move replacement range calculations into helper methods
We're going to need this logic for marked text as well.

Pick-to: 6.2
Change-Id: I461024c3df0c4956c794f16d1cb31fc6b0efe4c5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-26 14:53:02 +02:00
Tor Arne Vestbø
137c28d077 Fix Clang warning about loop variable creating a copy
Change-Id: I2a8b75294ee3bde008bcff37519da087f603ca51
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-26 14:53:02 +02:00
Volker Hilsheimer
98d65c8d42 QGraphicsView: send timestamp information through QGraphicsSceneEvent
Qt relies on event timestamp information to detect double click events.
The information was not passed through QGraphicsSceneEvent, so the
synthesized QMouseEvent delivered for the second press of a double click
to an embedded widget was never recognized as a double click.

This requires addition of a new setter/getter to QGraphicsSceneEvent.
Event though not all QGraphicsSceneEvent instances will have a valid
timestamp, this provides us with more flexibility than adding the API to
several QGraphicsSceneEvent types (mouse, touch, wheel).

Pick-to: 6.2
Fixes: QTBUG-96009
Change-Id: I343f25902286157f6d6670641dfad9c92dd44250
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-26 14:32:26 +02:00
Mårten Nordheim
842ece2117 NetworkAccessBackend: Remove the backend part of the name
For consistency with naming of other plugins.

Slight compatibility break, but this is semi-private API.

[ChangeLog][Network][QNetworkAccessBackend] The NetworkAccessBackend
plugin-type is renamed to NetworkAccess, if you have a plugin marked
NetworkAccessBackend you need to change it to NetworkAccess.

Pick-to: 6.2
Change-Id: Ib5ea02f542254b0f5b8c425c89ee00075a58c956
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-26 14:32:26 +02:00
Mårten Nordheim
4fee73c444 QNetworkAccessManager: move #ifery out of if-condition
for legibility

Change-Id: Id5bc2471e79bb8560cec46068cc72573f6adec34
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-26 12:32:26 +00:00
Mårten Nordheim
0e9b75eab2 QNetworkAccessBackend: emit readyRead less often
Once per iteration of the loop wouldn't theoretically be so bad if there
was no overhead to emitting signals or reading from buffers.

Change-Id: I0e424264fcc95eb2e2e5f8f908cf9ae3a7cc4b7e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-26 14:32:26 +02:00
Volker Hilsheimer
6bf70bc014 Refactor QApplication::translateRawTouchEvent to take a QTouchEvent*
Both call sites just pass the data from an existing QTouchEvent through,
so just pass the QTouchEvent through instead.

Amends 20d4f45a132606f7a910050d468519108486e9cf.

Pick-to: 6.2
Change-Id: If3b9508b83311889b58e109e7f64743985b8b178
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-08-26 09:36:25 +02:00
Volker Hilsheimer
1ecf2212fa Forward touchEvents to children inside QGraphicsProxyWidget
Just sending the event to the embedded widget is not enough, we
have to perform hit-testing for the different touch points, and
send the event to the child widget under the point. Fortunately,
QApplicationPrivate::translateRawTouchEvent provides the logic
that generates multiple events for groups of touch points.

Since that helper always sent events spontaneously, add an
optional parameter to allow sending of non-spontaneous events.

Add a test case that simulates touch events to different widget
configurations inside a QGraphicsProxyWidget.

Fixes: QTBUG-67819
Task-number: QTBUG-45737
Pick-to: 6.2 6.1 5.15
Change-Id: Iffd5c84c64ee2ceadc7e31863675fdf227582c81
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-08-26 09:36:20 +02:00
Giuseppe D'Angelo
f0c2c987e3 QBA(V)/QS(V)::lastIndexOf: fix the search of 1-char needles
When a needle has length 1 (because it's a QChar/char16_t, or because
it's a string-like of length 1) then an ad-hoc search algorithm is
used. This algorithm had a off-by-one, by not allowing to match at
the last position of a haystack (in case `from` was `haystack.size()`).

That is inconsistent with the general search of substring needles
(and what QByteArray does). Fix that case and amend wrong tests.
This in turn unveiled the fact that the algorithm was unable to cope
with 0-length haystacks (whops), so fix that as well. Drive-by, add a
similar fix for QByteArray.

Amends 6cee204d56.

Pick-to: 6.2
Change-Id: I6b3effc4ecd74bcbcd33dd2e550da2df7bf05ae3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-26 07:08:34 +02:00
Luca Di Sera
a2abb01451 Doc: Replace the example for QFileInfo::setFile
The example in the documentation of `QFileInfo::setFile` made no use
of `setFile` and only showed a use of `QDir::setCurrent`.

The example was replaced with a new example showing how `setFile`
changes the file that the information are retrieved from.

The old example was moved under the documentation for
`QDir::setCurrent` as it shows its working.

Fixes: QTBUG-87128
Pick-to: 6.2 6.1 5.15
Change-Id: I8227876cfcb4d582040bda9b4b7f3f7debea1e07
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-08-25 09:35:08 +00:00
David Faure
531b913f61 qdbuscpp2xml: add support for custom types with a new -t option
qdbuscpp2xml can't know about custom types registered with
qDBusRegisterMetaType<> in the server application whose header file
it's parsing. So add support for custom types using a command line
argument. For example:
    qdbuscpp2xml -t 'std::vector<Person>=a{ssss}' peopleserver.h
which generates
    <arg name="people" type="a{ssss}" direction="in"/>
    <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="std::vector&lt;Person&gt;"/>

[ChangeLog][QtDBus][qdbuscpp2xml] Added a -t option to specify how to
handle custom types.

Change-Id: Ic0cad4f4eec8d5dfa48055c3a46cc772b1a60174
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-25 01:03:54 +02:00
Ievgenii Meshcheriakov
655e353557 tst_qurlinternal: Remove nameprep and STD3 rules tests
IDNA 2008/UTS #46 do not use nameprep anymore and have different
validity rules.

Unexport qt_nameprep() and qt_check_std3rules() because they
are not used by any tests anymore.

Task-number: QTBUG-85323
Change-Id: I38c0dbae9a6bd108fbcfac350767aa7e757e786f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-25 00:13:39 +02:00
Giuseppe D'Angelo
bac329a28b QRegularExpressionMatch: add a way to know if a capturing group captured
Relying on the fact that a given capturing group captured a null string
doesn't allow users to distinguish whether a capturing group did not
capture anything, or captured a null substring (say, from a null subject
string).

Perl allows for the distinction: the entries in the @- and @+ arrays are
set to values in case there is a capture, but they're undef otherwise.

PCRE2 gives us the information already in the results "ovector", but
it was simply not exposed to QREM users. So, expose it.

[ChangeLog][QtCore][QRegularExpressionMatch] Added the hasCaptured()
family of functions to know if a given capturing group has captured
something.

Change-Id: Ic1320933d4554e2e313c0a680be1b1b9dd95af0b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-25 00:06:42 +02:00
Topi Reinio
145940e1ef Doc: Fix documentation issues for Qt Core
* Tag deprecated Q(Multi)Map operators in the header to correctly
  match them with documentation \fn commands.
* Add documentation for QByteArrayView comparison operators.
* Add a dummy typedef 'jfieldID' for generating docs correctly
  on non-Android platforms
* Fix other minor issues

Pick-to: 6.2
Task-number: QTBUG-95860
Change-Id: I141d2f75d6aa10557aa374201f09ad74b4cd6e81
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-08-24 23:50:23 +02:00
Alexandru Croitor
eb635dda1e CMake: Fix indentation in _qt_internal_test_expect_pass
Change-Id: Ib92bcd600bbfb0f2ee8ad8e5d44eaecdf9d16916
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-24 21:24:43 +02:00
Alexandru Croitor
5a437d2590 CMake: Fix automatic iOS bundle id extraction
If no Xcode preferences file was found,
_qt_internal_get_ios_bundle_identifier_prefix accidentally assigned
the error output of running PlistBuddy to the bundle id property.

That resulted in a bundle id called
'${team_id}.Doesn't Exist, Will Create: /Users/qt/Library/Preferences/com.apple.dt.Xcode.plist\n.app'

Check that the error variable is empty before assigning.

Amends 4d838dae5a

Pick-to: 6.1 6.2
Task-number: QTBUG-95838
Change-Id: I3a7241528590ae3e9986cfa1f3e91ac983ef54f6
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-24 21:24:43 +02:00
Jonas Kvinge
41b56c31bc Fix inserting node entry in QNetworkAccessCache::linkEntry
When the new entry has the same, or older timestamp than the newest,
it's linked behind the newest entry, but "newest" for the new node
currently isn't assigned to the newer entry.

Fixes: QTBUG-95950
Change-Id: I7ef5f1ce5a9479ce47839c8f1a6011124d3f43de
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-24 16:40:57 +02:00
Alexandru Croitor
3c1125d9fe CMake: Create plugin initializers for static user plugins
Previously we only created object library static plugin initializers
for Qt plugins only, not user-project plugins.

The reason was that if a user tried to install the plugin target via
an export set, CMake would error out saying that the _init library is
not part of the same export set.

Introduce an OUTPUT_TARGETS option that would allow projects to get
the name of the generated _init target, so they can install it if
needed.
This was already done for qt6_add_qml_module, so we just introduce the
same option for qt6_add_plugin.

Now user static plugins will have an _init target created, which will
be propagated to consumers whenever the consumers link against the
plugin itself.

We also need an internal option to disable this propagation, because
it's handled a bit differently for Qt plugins which can be linked
either via finalizers or via usage requirements.

Amends 91c65dd80c

As a result of the implementation change, cleanup example projects
to ensure that they build successfully (the important part is
specifying the CLASS_NAME).

Only plugandpaint works properly with both shared and static Qt
builds.

echoplugin works with a shared Qt build, but not a static one due to
some assumptions in the C++ code about shared plugins.

styleplugin doesn't seem to work properly neither with shared Qt
builds nor static Qt builds, at least on macOS. But it builds fine.
For some reason even if the plugin is found, the style is not applied.

Amends 4caac1feea

Pick-to: 6.2
Task-number: QTBUG-80863
Task-number: QTBUG-92933
Change-Id: I6f631cda9566229b7a63992b23d7d7fa50303eeb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-24 16:10:31 +02:00
David Faure
511bbbdfc0 qdbusxml2cpp: generate "using" rather than "typedef"
It's more modern :)

I was hoping it would allow to forward declare the org::kde::Foo class,
but unfortunately it doesn't, the forward declaration has to use
"using" or "typedef" too...

Change-Id: I9ec2900ac25c1bca75d097aa339fd2a872568f95
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-24 15:34:59 +02:00
Tor Arne Vestbø
bae9aeacbe macOS: Correctly compute marked and selected text range, and use for insertion
The NSTextInputClient protocol expects marked (composed) and selected
text ranges to be relative to the document, not to the current editing
block as Qt typically expects.

Luckily we can use the absolute cursor position to compute an absolute
offset that we can apply to any other positions, such as the selection.

Now that we are computing the ranges correctly we can also use them
during text insertion, when the incoming replacementRange is not valid.

We then transform and sanitize the replacement range to the format that
Qt expects for QInputMethodEvent::setCommitString().

Pick-to: 6.2
Change-Id: I4cb2f7c63adb92e407f38af05adce539c9bed7e2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-24 13:39:06 +02:00
Tor Arne Vestbø
f6b851837d Fix warning about loop variable creating a copy
qxpmhandler.cpp:1162:21: warning: loop variable '[color, index]' of type
  'const std::__1::pair<const unsigned int, int>' creates a copy from type
  'const std::__1::pair<const unsigned int, int>' [-Wrange-loop-analysis]
    for (const auto [color, index] : colorMap)
                    ^

Change-Id: Ifabf1c569efdcd929859227d860f4598250ba5bd
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-24 13:39:06 +02:00
Volker Hilsheimer
01aeb5f7e4 QGraphicsProxyWidget: forward Window(De)Activate events
The nested widget might be a QGraphicsView as well (documented to be
supported), and QGraphicsScene maintains it's own activation status by
counting Window(De)Activate events. We need to make sure that the
embedded widget is informed about its activation status so that deeper
nested children can receive focus.

Forward WindowActivate/Deactivate events to the nested widget, which
will pass it on to all its children. Add test case, which without this
fix fails when verifying the inner scene's isActive state, or later
when testing that focusInEvent is delivered to the embedded widget.

Fixes: QTBUG-94091
Pick-to: 5.15 6.1 6.2
Change-Id: I4e0ecef50685ed081d15c7f76b6c1a4a40ed2682
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-08-24 13:32:07 +02:00
Giuseppe D'Angelo
d48058f197 Unicode: fix the grapheme clustering algorithm
An oversight in the code kept the algorithm in the GB11 state, even if
the codepoint that is being processed wouldn't allow for that (for
instance a sequence of ExtPic, Ext and Any).

Refactor the code of GB11/GB12/GB13 to deal with code points that break
the sequences (falling back to "normal" handling).

Add some manual tests; interestingly enough, the failing cases are not
covered by Unicode's tests, as we now pass the entire test suite.

Amends a794c5e287.

Fixes: QTBUG-94951
Pick-to: 6.1 5.15
Change-Id: If987d5ccf7c6b13de36d049b1b3d88a3c4b6dd00
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-24 12:58:20 +02:00
Eirik Aavitsland
ca604964f6 Painting: handle large and negative dash offset values
The mapping of the dash offset into the dash pattern was susceptible
to int overflow.

Pick-to: 6.2 6.1 5.15
Change-Id: I254ed40b323ef516d10abc8e6008b14cfc23d2a0
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-08-24 08:49:48 +02:00
Eirik Aavitsland
279a434c1c QDashStroker: cap the number of repetitions of the pattern
Since the dashing is computed even outside the clipping and device
area, painting very long dashed lines could consume unexpected amounts
of time and resources. Fix by placing a limit on the dashing, and fall
back to solid line drawing if hit.

Fixes: QTBUG-95594
Pick-to: 6.2 6.1 5.15
Change-Id: Ida05ecd8fe6df402c9e669206fd5cec4a9f5386a
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-08-24 08:49:36 +02:00
David Faure
cf34fca4d0 QDBus: fix ExportScriptableInvokables to allow calling scriptable invokables
The "wantedMask" check in the xml generator didn't distinguish slots
from invokables, so exporting an object with just ExportScriptableInvokables
didn't allow calling Q_SCRIPTABLE methods.

Change-Id: I7b408755da5b28e67a9384d9df95e22dc5de2369
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-23 23:07:30 +02:00
David Faure
7a5f8baa67 qdbusxml2cpp: don't generate an include for all of QtDBus+QtCore
This, however, has to wait for Qt 7 for compat reasons.

Change-Id: I84db4715bf2e9d080d1446d24f0996c78a875e63
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-23 23:07:30 +02:00
Alexey Edelev
f037357232 Add the json option to disable the zstd based compression
Need to disable zstd compression if its support is not built in Qt
for Android. The flag is dected when configuring user's project and
is a part of the deployment settings. This partially fixes loading of
android_rcc_bundle.rcc.

Pick-to: 6.2
Task-number: QTBUG-93340
Task-number: QTBUG-95969
Change-Id: I635afb3f9e182a559d53e9344e07f62788f9837d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-23 20:05:27 +02:00
Tor Arne Vestbø
86d338383e macOS: Highlight selected part of preedit using platform theme palette
QInputMethodEvent::Selection unfortunately doesn't apply to the
preedit text, and QInputMethodEvent::Cursor which does, doesn't
support setting a selection. Until we've introduced attributes
that allow us to propagate the preedit selection semantically
we resort to styling the selection via the TextFormat attribute,
so that the preedit selection is visible to the user.

This allows us to remove the fallback we had for thick and double
underline styles, where we mapped those to the wiggly underline style.
This was needed to distinguish the selected cluster when composing
CJK, but looked out of place.

One disadvantage of faking the selection via text format is that
we will not update the selection color on theme change, e.g. when
switching from light to dark mode, but this is a minor issue that we
can live with until we've introduced a proper QInputMethodEvent
attribute for the preedit selection.

Pick-to: 6.2
Change-Id: I1c45c310107697962e328a4db908d29d2358f756
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-23 17:30:18 +02:00
Eskil Abrahamsen Blomfeldt
1971250de5 Fix default line thickness for fonts
When we are unable to get the line thickness from a font, we
fall back to calculating this based on pixel size and weight.
But the font weight scale has changed in Qt 6, causing the
calculated font weight to be 10x as thick as it should.

This happened e.g. for Titillium Web, but only when using 100%
UI scaling, because the GDI engine was unable to get the correct
line thickness from the font, whereas the DirectWrite engine
succeeded.

[ChangeLog][Windows] Fixes an issue where underlines and other
decorations would be too thick for some fonts.

Pick-to: 6.1 6.2
Fixes: QTBUG-94529
Change-Id: Id2c88f0a145776151be0399ee646f28b3bdf9072
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-23 16:35:36 +02:00
Volker Krause
ec497d5e65 Fix access to content: URLs with transient read/write permissions
The current code assumed that the lack of persistent permissions means
we cannot access the file at all. That however isn't the case for
content: URLs we get e.g. via Intents, those are accessible perfectly
fine via QFile, we just don't have (and can't obtain) persistent
permissions for them.

This is done by continuing in the case of not having persistent
permissions and checking for SecurityExceptions that are thrown when
accessing content: URLs we really have no permission for.

Pick-to: 6.2 5.15
Change-Id: I39115a7730d717eb9517e4f1c1a57e40988001a5
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-08-23 15:36:03 +02:00
Assam Boudjelthia
760e24e867 Android: guard getStateCount() with correct VERSION.SDK_INT
The call getStateCount() was introduced in 29, so cases for
lower API should be handled.

Pick-to: 6.2 6.1
Change-Id: I7f58541c0b16fed91835e6f390afa89378a7af3e
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2021-08-23 15:39:44 +03:00
Zhang Hao
d267060189 QLineEdit: account for the placeholderText when computing lineRect
If in a QLineEdit the placeholderText uses e.g. Tibetan language, then the
height of font as reported by QFontMetrics might be less than the height
of the boundingRect calculated for the placeholderText. This can cause the
placeholderText to display incompletely.

Fix this by using QFontMetrics::boundingRect instead of QFontMetrics::height
when computing lineRect.

Fixes: QTBUG-95341
Pick-to: 5.15 6.1 6.2
Change-Id: I9eef35fd89c5c1d79f6dd703355634d6905ca967
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-23 12:39:44 +00:00
Fabian Kosmale
e4d62651c2 Re-add QPropertyAlias functionality
As QPropertyAlias was public by accident in 6.0, we have to ensure that
it still works in 6.2.
This re-adds some tests for it, and reimplements the unlinking
functionality. To avoid performance regressions in hot-paths,
a new unlink_fast function is added, which behaves like the old unlink:
It ignores the special handling for QPropertyAlias, so that we can skip
the tag check. It is only used in QPropertyObserverNodeProtector and
clearDependencyObservers, where we already know the type of the
observer.

Fixes: QTBUG-95846
Pick-to: 6.2
Change-Id: Ifb405b8327c4d61c673b1a912ed6e169d27c2d8f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2021-08-23 12:39:44 +00:00
Marc Mutz
17357856b5 QMetaEnum: write "proper code"
Rewrite keysToValue() as suggested by a comment:

- Don't use the moral equivalent of
     QString::fromLatin1(keys).split().front().toLatin1(),
  use QStringTokenizer over QLatin1Strings, removing lots of
  allocations.

- Use QL1S instead of raw char* and strcmp(), because that made the
  old code rely on NUL-terminated tokens after splitting, which is no
  longer the case when using QStringTokenizer.

- Use the new stringDataView() instead of stringData() to avoid
  QByteArray dtors littering the code.

- Extract Method parse_scope(), using high-level API operating on QL1S
  to see what it's actually doing, instead of previous low-level
  bit-pushing with char* and ints that did a good job of obfuscating
  the purpose of all the scanning.

- Extract Method lookup() as a lambda to make the main loop of the
  algorithm more readable.

- Extract Method className() to delay looking up the class name until
  it is required (and help with readability). This could be further
  optimized by memoizing the result, but I'm convinced that's not
  worth the effort.

The code now no longer allocates, but we still can't mark the function
as noexcept, because stringDataView() contains a Q_ASSERT, so the
function has preconditions.

Results show that the new code is up to 2x faster than the old, and
never slower (within measurement uncertainty):

 PASS   : tst_QMetaEnum::keysToValue(0 bits set)
-     0.00042 msecs per iteration (total: 56, iterations: 131072)
+     0.00012 msecs per iteration (total: 68, iterations: 524288)
 PASS   : tst_QMetaEnum::keysToValue(1 bits set)
-     0.00079 msecs per iteration (total: 52, iterations: 65536)
+     0.00024 msecs per iteration (total: 63, iterations: 262144)
 PASS   : tst_QMetaEnum::keysToValue(2 bits set)
-     0.0010 msecs per iteration (total: 71, iterations: 65536)
+     0.00040 msecs per iteration (total: 53, iterations: 131072)
 PASS   : tst_QMetaEnum::keysToValue(3 bits set)
-     0.0014 msecs per iteration (total: 98, iterations: 65536)
+     0.00054 msecs per iteration (total: 72, iterations: 131072)
 PASS   : tst_QMetaEnum::keysToValue(4 bits set)
-     0.0017 msecs per iteration (total: 57, iterations: 32768)
+     0.00074 msecs per iteration (total: 98, iterations: 131072)
 PASS   : tst_QMetaEnum::keysToValue(5 bits set)
-     0.0019 msecs per iteration (total: 65, iterations: 32768)
+     0.00088 msecs per iteration (total: 58, iterations: 65536)
 PASS   : tst_QMetaEnum::keysToValue(6 bits set)
-     0.0022 msecs per iteration (total: 74, iterations: 32768)
+     0.0010 msecs per iteration (total: 72, iterations: 65536)
 PASS   : tst_QMetaEnum::keysToValue(7 bits set)
-     0.0025 msecs per iteration (total: 85, iterations: 32768)
+     0.0012 msecs per iteration (total: 79, iterations: 65536)
 PASS   : tst_QMetaEnum::keysToValue(8 bits set)
-     0.0027 msecs per iteration (total: 91, iterations: 32768)
+     0.0012 msecs per iteration (total: 85, iterations: 65536)
 PASS   : tst_QMetaEnum::keysToValue(9 bits set)
-     0.0029 msecs per iteration (total: 98, iterations: 32768)
+     0.0014 msecs per iteration (total: 97, iterations: 65536)
 PASS   : tst_QMetaEnum::keysToValue(10 bits set)
-     0.0033 msecs per iteration (total: 55, iterations: 16384)
+     0.0018 msecs per iteration (total: 62, iterations: 32768)
 PASS   : tst_QMetaEnum::keysToValue(11 bits set)
-     0.0036 msecs per iteration (total: 60, iterations: 16384)
+     0.0022 msecs per iteration (total: 73, iterations: 32768)
 PASS   : tst_QMetaEnum::keysToValue(12 bits set)
-     0.0036 msecs per iteration (total: 60, iterations: 16384)
+     0.0018 msecs per iteration (total: 62, iterations: 32768)
 PASS   : tst_QMetaEnum::keysToValue(13 bits set)
-     0.0039 msecs per iteration (total: 64, iterations: 16384)
+     0.0021 msecs per iteration (total: 70, iterations: 32768)
 PASS   : tst_QMetaEnum::keysToValue(14 bits set)
-     0.0040 msecs per iteration (total: 67, iterations: 16384)
+     0.0023 msecs per iteration (total: 77, iterations: 32768)
 PASS   : tst_QMetaEnum::keysToValue(15 bits set)
-     0.0042 msecs per iteration (total: 70, iterations: 16384)
+     0.0025 msecs per iteration (total: 82, iterations: 32768)
 PASS   : tst_QMetaEnum::keysToValue(16 bits set)
-     0.0053 msecs per iteration (total: 88, iterations: 16384)
+     0.0028 msecs per iteration (total: 92, iterations: 32768)
 PASS   : tst_QMetaEnum::keysToValue(17 bits set)
-     0.0048 msecs per iteration (total: 80, iterations: 16384)
+     0.0029 msecs per iteration (total: 97, iterations: 32768)
 PASS   : tst_QMetaEnum::keysToValue(18 bits set)
-     0.0050 msecs per iteration (total: 83, iterations: 16384)
+     0.0031 msecs per iteration (total: 51, iterations: 16384)
 PASS   : tst_QMetaEnum::keysToValue(19 bits set)
-     0.0051 msecs per iteration (total: 85, iterations: 16384)
+     0.0037 msecs per iteration (total: 62, iterations: 16384)
 PASS   : tst_QMetaEnum::keysToValue(20 bits set)
-     0.0053 msecs per iteration (total: 88, iterations: 16384)
+     0.0041 msecs per iteration (total: 68, iterations: 16384)
 PASS   : tst_QMetaEnum::keysToValue(21 bits set)
-     0.0056 msecs per iteration (total: 92, iterations: 16384)
+     0.0042 msecs per iteration (total: 69, iterations: 16384)
 PASS   : tst_QMetaEnum::keysToValue(22 bits set)
-     0.0056 msecs per iteration (total: 93, iterations: 16384)
+     0.0044 msecs per iteration (total: 73, iterations: 16384)
 PASS   : tst_QMetaEnum::keysToValue(23 bits set)
-     0.0057 msecs per iteration (total: 95, iterations: 16384)
+     0.0044 msecs per iteration (total: 73, iterations: 16384)
 PASS   : tst_QMetaEnum::keysToValue(24 bits set)
-     0.0060 msecs per iteration (total: 99, iterations: 16384)
+     0.0062 msecs per iteration (total: 51, iterations: 8192)
 PASS   : tst_QMetaEnum::keysToValue(25 bits set)
-     0.0063 msecs per iteration (total: 52, iterations: 8192)
+     0.0048 msecs per iteration (total: 80, iterations: 16384)
 PASS   : tst_QMetaEnum::keysToValue(26 bits set)
-     0.000381 msecs per iteration (total: 100, iterations: 262144)
+     0.00014 msecs per iteration (total: 75, iterations: 524288)
 PASS   : tst_QMetaEnum::keysToValue(27 bits set)
-     0.00616 msecs per iteration (total: 101, iterations: 16384)
+     0.0050 msecs per iteration (total: 82, iterations: 16384)
 PASS   : tst_QMetaEnum::keysToValue(28 bits set)
-     0.0062 msecs per iteration (total: 51, iterations: 8192)
+     0.0051 msecs per iteration (total: 85, iterations: 16384)
 PASS   : tst_QMetaEnum::keysToValue(29 bits set)
-     0.0064 msecs per iteration (total: 53, iterations: 8192)
+     0.0050 msecs per iteration (total: 82, iterations: 16384)
 PASS   : tst_QMetaEnum::keysToValue(30 bits set)
-     0.0062 msecs per iteration (total: 51, iterations: 8192)
+     0.0050 msecs per iteration (total: 83, iterations: 16384)

Change-Id: Idff1ef7633862beb318901352516ebb0dde3c058
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-23 12:23:43 +00:00
Joerg Bornemann
c3308b13ca Doc: Add global \versionlessCMakeCommandsNote qdoc macro
When documenting a CMake command, document the unversioned command
'qt_foo' and use '\versionlessCMakeCommandNote qt6_foo' to refer to the
versioned command.  This avoids duplicating the command signature.

Use the new macro where applicable.

Pick-to: 6.2
Task-number: QTBUG-95796
Change-Id: I2e4180fbda0b89acf3d8c036459f591eb2f46475
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-23 13:06:27 +02:00
Ivan Solovev
fd9a94594f QDir: add assert for nullptr ok parameter in qt_cleanPath
Found by CodeChecker.
The function returns early in case of empty path, but the bool
parameter is never updated in this case. It's not a problem
with the current codebase though.
As it's a static local function, the reasonable solution is just
to add an assert, so that we do not get hit in case of refactoring.

Task-number: QTBUG-95727
Pick-to: 6.2
Change-Id: Idc00356c61b5db8b2204a574612c1ea8e65f4a69
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-23 12:32:25 +02:00
Tang Haixiang
77bdce8496 Modify the internal rectangle drawing of CE_RubberBand
adjusted(1, 1, -2, -2) makes the rectangle smaller, but when
rect.x1-rect.x2 = 0. Then x1 + 1, x2-2 leads to x1> x2. This will
make the rectangle flip in advance. So there is a difference
between the updated area and the drawn area.

Add a judgment, when the rectangle we get is large enough, draw the inner rectangle.

Fixes: QTBUG-95716
Done-with: Oliver Eftevaag <oliver.eftevaag@qt.io>
Done-with: Volker Hilsheimer <volker.hilsheimer@qt.io>
Pick-to: 6.2
Change-Id: I0d081a4ad7aee4a563acb988c0ef19a646bf1eea
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-23 16:26:55 +08:00
Eskil Abrahamsen Blomfeldt
d8f815db7f Update Harfbuzz to version 2.9.0
[ChangeLog][Text] Updated bundled Harfbuzz to
version 2.9.0.

Pick-to: 6.2
Change-Id: Ib8fed753b99a127d5a4cc793c5c1d55a0090f902
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
2021-08-23 07:37:04 +02:00
Marc Mutz
d07742f333 QLibrary: use QStringTokenizer in isLibrary()
Rewrite the whole function for readability _and_ performance:

- Extract Method isValidSuffix() as a lambda

- Extract Method isNumeric() as a lambda

- Use a C array of QLatin1String instead of a QStringList to hold the
  statically-sized list of candidate suffixes. This has the nice
  side-effect that the compiler will now throw an error in case the
  #ifdef'ery yields zero candidates (C arrays cannot have no
  elements), e.g. when porting to a new platform.

- Last, not least, replace the parsing with a loop that makes clear
  what's going on and which is forward-iteration-only-compatible, so
  we can use QStringTokenizer directly, without toContainer() to get a
  random-access sequence.

Need to use the C++20 version of all_of(), since QStringTokenizer uses
sentinels instead of end-iterators.

Even though we use higher-level constructs now, the code is still more
efficient than the index-twisting we had before.

Change-Id: I9f3faf3e30f58c9eb8a1487a7ca190681e87767b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-21 01:28:27 +02:00
Marc Mutz
bd52059eef QMetaEnum: avoid quadratic behavior in valueToKeys()
QByteArray (thankfully) doesn't have the prepend "optimization", so
prepend() is a linear operation, calling it in a loop thus makes the
algorithm quadratic.

To fix, simply remember the parts in a QVLA (an upper bound on the
size of which is easily calculated) and then build the result by
reverse-iterating over the QVLA.

This join_reversed() function is possibly useful elsewhere, but I left
it locally in the unnamed namespace to ease cherry-picking.

The new stringDataView() function is more universally useful, too, and
will be used in a subsequent other change. It return QL1S instead of
QByteArrayView because the latter is scheduled to become a non-string
type, and already lacks certain features (e.g. qTokenize() doesn't
work on QBA, due to lack of a Qt::CaseSensitivity argument in
QBA::indexOf()). It's also a Qt 6 addition, so not available in
5.15. We can revisit this decision later, when QBAV (or, possibly,
QU8SV) has caught up.

Amends 05e0dfa006.

Results indicate a ~2x speedup:

 PASS   : tst_QMetaEnum::valueToKeys(1 bits set)
-     0.00026 msecs per iteration (total: 70, iterations: 262144)
+     0.00017 msecs per iteration (total: 90, iterations: 524288)
 PASS   : tst_QMetaEnum::valueToKeys(2 bits set)
-     0.00037 msecs per iteration (total: 98, iterations: 262144)
+     0.00019 msecs per iteration (total: 52, iterations: 262144)
 PASS   : tst_QMetaEnum::valueToKeys(3 bits set)
-     0.00040 msecs per iteration (total: 53, iterations: 131072)
+     0.00021 msecs per iteration (total: 56, iterations: 262144)
 PASS   : tst_QMetaEnum::valueToKeys(4 bits set)
-     0.00047 msecs per iteration (total: 62, iterations: 131072)
+     0.00022 msecs per iteration (total: 60, iterations: 262144)
 PASS   : tst_QMetaEnum::valueToKeys(5 bits set)
-     0.00048 msecs per iteration (total: 63, iterations: 131072)
+     0.00024 msecs per iteration (total: 64, iterations: 262144)
 PASS   : tst_QMetaEnum::valueToKeys(6 bits set)
-     0.00061 msecs per iteration (total: 80, iterations: 131072)
+     0.00027 msecs per iteration (total: 71, iterations: 262144)
 PASS   : tst_QMetaEnum::valueToKeys(7 bits set)
-     0.00063 msecs per iteration (total: 83, iterations: 131072)
+     0.00027 msecs per iteration (total: 73, iterations: 262144)
 PASS   : tst_QMetaEnum::valueToKeys(8 bits set)
-     0.00069 msecs per iteration (total: 91, iterations: 131072)
+     0.00030 msecs per iteration (total: 81, iterations: 262144)
 PASS   : tst_QMetaEnum::valueToKeys(9 bits set)
-     0.00070 msecs per iteration (total: 92, iterations: 131072)
+     0.00031 msecs per iteration (total: 83, iterations: 262144)
 PASS   : tst_QMetaEnum::valueToKeys(10 bits set)
-     0.00074 msecs per iteration (total: 98, iterations: 131072)
+     0.00034 msecs per iteration (total: 91, iterations: 262144)
 PASS   : tst_QMetaEnum::valueToKeys(11 bits set)
-     0.000762 msecs per iteration (total: 100, iterations: 131072)
+     0.00035 msecs per iteration (total: 92, iterations: 262144)
 PASS   : tst_QMetaEnum::valueToKeys(12 bits set)
-     0.00088 msecs per iteration (total: 58, iterations: 65536)
+     0.000381 msecs per iteration (total: 100, iterations: 262144)
 PASS   : tst_QMetaEnum::valueToKeys(13 bits set)
-     0.00094 msecs per iteration (total: 62, iterations: 65536)
+     0.00038 msecs per iteration (total: 51, iterations: 131072)
 PASS   : tst_QMetaEnum::valueToKeys(14 bits set)
-     0.00099 msecs per iteration (total: 65, iterations: 65536)
+     0.00041 msecs per iteration (total: 55, iterations: 131072)
 PASS   : tst_QMetaEnum::valueToKeys(15 bits set)
-     0.0010 msecs per iteration (total: 67, iterations: 65536)
+     0.00042 msecs per iteration (total: 56, iterations: 131072)
 PASS   : tst_QMetaEnum::valueToKeys(16 bits set)
-     0.0010 msecs per iteration (total: 70, iterations: 65536)
+     0.00044 msecs per iteration (total: 58, iterations: 131072)
 PASS   : tst_QMetaEnum::valueToKeys(17 bits set)
-     0.0011 msecs per iteration (total: 73, iterations: 65536)
+     0.00046 msecs per iteration (total: 61, iterations: 131072)
 PASS   : tst_QMetaEnum::valueToKeys(18 bits set)
-     0.0012 msecs per iteration (total: 79, iterations: 65536)
+     0.00048 msecs per iteration (total: 63, iterations: 131072)
 PASS   : tst_QMetaEnum::valueToKeys(19 bits set)
-     0.0012 msecs per iteration (total: 79, iterations: 65536)
+     0.00051 msecs per iteration (total: 67, iterations: 131072)
 PASS   : tst_QMetaEnum::valueToKeys(20 bits set)
-     0.0012 msecs per iteration (total: 80, iterations: 65536)
+     0.00054 msecs per iteration (total: 71, iterations: 131072)
 PASS   : tst_QMetaEnum::valueToKeys(21 bits set)
-     0.0012 msecs per iteration (total: 83, iterations: 65536)
+     0.00090 msecs per iteration (total: 59, iterations: 65536)
 PASS   : tst_QMetaEnum::valueToKeys(22 bits set)
-     0.0012 msecs per iteration (total: 85, iterations: 65536)
+     0.00057 msecs per iteration (total: 76, iterations: 131072)
 PASS   : tst_QMetaEnum::valueToKeys(23 bits set)
-     0.0013 msecs per iteration (total: 87, iterations: 65536)
+     0.00059 msecs per iteration (total: 78, iterations: 131072)
 PASS   : tst_QMetaEnum::valueToKeys(24 bits set)
-     0.0014 msecs per iteration (total: 93, iterations: 65536)
+     0.00065 msecs per iteration (total: 86, iterations: 131072)
 PASS   : tst_QMetaEnum::valueToKeys(25 bits set)
-     0.0014 msecs per iteration (total: 94, iterations: 65536)
+     0.00063 msecs per iteration (total: 83, iterations: 131072)
 PASS   : tst_QMetaEnum::valueToKeys(26 bits set)
-     0.00028 msecs per iteration (total: 74, iterations: 262144)
+     0.00017 msecs per iteration (total: 94, iterations: 524288)
 PASS   : tst_QMetaEnum::valueToKeys(27 bits set)
-     0.0014 msecs per iteration (total: 98, iterations: 65536)
+     0.00063 msecs per iteration (total: 83, iterations: 131072)
 PASS   : tst_QMetaEnum::valueToKeys(28 bits set)
-     0.0014 msecs per iteration (total: 96, iterations: 65536)
+     0.00065 msecs per iteration (total: 86, iterations: 131072)
 PASS   : tst_QMetaEnum::valueToKeys(29 bits set)
-     0.0014 msecs per iteration (total: 98, iterations: 65536)
+     0.00064 msecs per iteration (total: 84, iterations: 131072)
 PASS   : tst_QMetaEnum::valueToKeys(30 bits set)
-     0.0014 msecs per iteration (total: 97, iterations: 65536)
+     0.00064 msecs per iteration (total: 84, iterations: 131072)

Pick-to: 6.2 5.15
Change-Id: Ie456b71b39c118001987716e30642f08f5e8dcdb
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-21 01:28:27 +02:00
Tor Arne Vestbø
62572f0a18 Add note about ImCursorPosition/ImAbsolutePosition not including preedit
The cursor position as reflected by these two properties is not affected
by the offset of the cursor in the preedit area. That means that when
composing text, the cursor position stays the same, at the preedit
insertion point, regardless of where the cursor is positioned within
the preedit string by the QInputMethodEvent::Cursor attribute.

Pick-to: 6.2
Change-Id: Ic2584369f92271e3f242d51f2e647f6f05c72d53
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-21 01:28:26 +02:00
Tor Arne Vestbø
b963888b1c macOS: Handle more NSUnderlineStyles during text composition
Pick-to: 6.2
Change-Id: I2a6cf612506d19736eab007f687a03f6d6595b62
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-21 01:28:26 +02:00
Tor Arne Vestbø
fa6e490374 macOS: Respect default marked text attributes
When the marked text was not an attributed string with built in styling
we used to fall back to a hard-coded underline style.

We now pick up the default marked text style via the markedTextAttributes
property of a temporarily created NSView, which by default is a yellow
background color.

The implementation in NSView respects text system configuration toggles
such as NSMarkedTextAttribute and NSMarkedTextColor, so by setting the
user default NSMarkedTextAttribute to "Underline" the marked text will
look like our old hard-coded default. This can be done in many ways,
including passing `-NSMarkedTextAttribute Underline` on the command
line, or by QSettings::setValue("NSMarkedTextAttribute", "Underline");

Pick-to: 6.2
Change-Id: Iede74836ed1449e77018c13733a675f8e9d84f7d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-21 01:28:26 +02:00
Tor Arne Vestbø
88550e1210 macOS: Clean up code style in [QNSView setMarkedText:]
Pick-to: 6.2
Change-Id: I8a901ac81b64e6fc9bd7fe9ea4e3eaa6257118ce
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-21 01:28:26 +02:00
Tor Arne Vestbø
6c5f996974 macOS: Ensure we provide a preedit format for non-attributed strings
The logic was not taking into account that we were always adding
an QInputMethodEvent::Cursor attribute, so we would never hit the
fallback code.

Pick-to: 6.2
Change-Id: I25bd725025152241a55e3fea60444c20e27db4f9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-21 01:28:26 +02:00
Tor Arne Vestbø
993d8025dc macOS: Simplify validAttributesForMarkedText
We don't need to condition this on IM enablement. The attributes are
only used if we are actually marking text, which only happens for IM
enabled views.

Pick-to: 6.2
Change-Id: I47377cf53cf2bf44a1d9513d317f82c73f083fa3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-21 01:28:26 +02:00
Tor Arne Vestbø
4e2ec5ab5d macOS: Clarify QAppleKeyMapper
Pick-to: 6.2
Change-Id: I6a6fb4a8ee6e9457b3a09b0ef51e71028df3356d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-20 17:14:03 +00:00
Ievgenii Meshcheriakov
c736fb25c7 QUrl: Fix typos in the documentation
URLs can contain underscores, not "undercores".

Pick-to: 6.2
Change-Id: I000ed89649cee0e7c6f283f2d930097961379445
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-08-20 18:09:36 +02:00
Tor Arne Vestbø
1caa7680a1 macOS: Correct QNSPanelContentsWrapper @end marker placement
The incorrect "scoping" of q_IOObjectRetain and q_IOObjectRelease
luckily did not affect their functionality as QIOType helpers.

Pick-to: 6.2
Change-Id: I9b9c2312464c7e6f8e2d2a5856e35efa99ec0c41
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-20 15:45:39 +02:00
ChunLin Wang
9ba4c6beef Fix QScroller::scrollTo failing in QGraphicsView with movable item
When forcing software scrolling through QScroller::scrollTo,
it will start from (0, 0). QGraphicsViewPrivate::canStartScrollingAt
should consider the locationof points, not just the flags of item.

Fixes: QTBUG-70255
Pick-to: 5.15 6.1 6.2
Change-Id: Iebdd5568baa3bdb41c705204dadb2895cfe9c0e2
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-08-20 13:31:45 +00:00
Richard Moe Gustavsen
b7150d22c8 QCocoaTheme: add ButtonText color to standard palette
The standard palette had no value set for ButtonText. The
result was the we drew button text in QtQuickControls2
using Text color instead, which would be wrong in dark
mode, and result in a dark color instead of white.

Note: Widgets hardcode the color "white" directly
in the mac style, and was not affected by the
missing value.

Fixes: QTBUG-89177
Pick-to: 6.2 6.1
Change-Id: Ie2d99bfac9fcc70d45e5bd40ea45becf3fd70d87
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-08-20 14:33:16 +02:00
Morten Sørvig
7b14329d78 Check for correct "Access Denied" error
SetProcessDpiAwarenessContext() returns ERROR_ACCESS_DENIED if the
DPI awareness has already been set, and not E_ACCESSDENIED like
SetProcessDpiAwareness() does.

Pick-to: 6.2
Change-Id: I6b29214773776f31c0622a35494d98c5c9637b0b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-08-20 13:50:24 +02:00
Zhang Qipeng
cd36734ff4 Remove unnecessary type conversion
Change-Id: I3d1b998b84753706ee78ecb5e498f70e9f935fd5
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-08-20 09:35:52 +08:00
Volker Hilsheimer
70b94eea10 macOS: close popups on mousedown within the window frame
On macOS, we close active popups when handling mouse-down events in the
NSView, but not for such events in the window frame. This allows users
to close a window that has a context menu open via the window's close
button, which then leaves open popups behind.

Factor the popup-closing code out into a dedicated method that we can
call from within the NSWindow::sendEvent implementation for mouse down
events.

Fixes: QTBUG-30522
Pick-to: 6.2 6.1 5.15
Change-Id: I9c354efc449cfefff3ed84fa34b1cd8a0da3b4a7
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-08-19 23:38:24 +02:00
Tor Arne Vestbø
bb7fe09963 macOS: Expand QNSView complex text documentation
Pick-to: 6.2
Change-Id: Iceb146d7aafb869a80cebe50e27c3bc98e67ebe1
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-19 19:10:59 +02:00
Tor Arne Vestbø
dcb4b5e7d2 macOS: Tweak method argument names in QNSView complex text implementation
Pick-to: 6.2
Change-Id: I6a7ec683ffe9c18a89326b3e53b4a907cb9a9512
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-19 19:10:59 +02:00
Tor Arne Vestbø
42573d9496 macOS: Restructure QNSView complex text implementation
For better overview of the flow and functionality of the
NSTextInputClient protocol.

Pick-to: 6.2
Change-Id: I8658405c7ff4ae762bfe3e4c11f9a157ae2b9a09
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-19 19:10:58 +02:00
Tor Arne Vestbø
b601eb9c2d macOS: Reorder QNSView instance variables
Pick-to: 6.2
Change-Id: Icde9ee6744290f88eaa2ac197c40ba412543b122
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-19 19:10:58 +02:00
Tor Arne Vestbø
fde6e1a18c macOS: Update QCocoaInputContext documentation
Pick-to: 6.2
Change-Id: I5ae5fe51ddc1512f2627dbc972fbb95360d7ea24
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-19 19:10:58 +02:00
Tor Arne Vestbø
e42eefe044 macOS: Implement QPlatformInputContext::setFocusObject()
Instead of handling the update manually.

Pick-to: 6.2
Change-Id: Iffb28d893146f5d3f6eae8e8c43aaf7fa5281516
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-19 19:10:58 +02:00
Tor Arne Vestbø
e5bebd883c macOS: Add some logging to QCocoaInputContext
Pick-to: 6.2
Change-Id: I8e28cdaf89e8b741a5047f00016e17b8916edece
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-19 19:10:58 +02:00
Tor Arne Vestbø
c7ec8c0973 macOS: Fix member variable name in QCocoaInputContext
Pick-to: 6.2
Change-Id: I7e61df4e6afbfd7e962499f0cfca5739658244dd
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-19 19:10:58 +02:00
Tor Arne Vestbø
f9beb3c4eb macOS: Handle input source change notifications in QCocoaInputContext
Instead of going via QNSView. Also add some logging.

Pick-to: 6.2
Change-Id: Iabed7511572ef22597651efa8047f06227b28533
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-19 19:10:58 +02:00
Tor Arne Vestbø
4ee20e3a2f macOS: Simplify string handling when handling complex text
Pick-to: 6.2
Change-Id: Ib19dab99b836fdd5a5eda5cc54c81f1fea31ce65
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-19 19:10:58 +02:00
Tor Arne Vestbø
a5571ec8a0 macOS: Use helper method for querying input method parameters
Pick-to: 6.2
Change-Id: I379d4ca20101899db2dfbd8f0c5a22f423e40d6b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-19 19:10:58 +02:00
Morten Johan Sørvig
0d0b36a184 wasm: support setting environment again
After enabling -s MODULARIZE=1 there is no longer a
global ENV. Use module.ENV instead.

Change-Id: Ic6958f52c6ceb7014f7f2c78a73f2bce5a43bf41
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-08-19 18:41:53 +02:00
Morten Johan Sørvig
54ff65e768 wasm: fix unused variable warning/error
Change-Id: If6dabc94f6d64695a0b28e73061274f8ea1c4ed6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-08-19 18:41:53 +02:00
Morten Sørvig
16e5bcb4ac wasm: add DialogExec hack back with warning
Previously, this was implemented in QEventLoop. By moving
it to the event dispatcher we can target the warning message
better and provide a suggested workaround for the dialog
case.

The behavior is the same as before: call emscripten_sleep(),
which throws a Javascript exception and returns control
to the browser while leaking the content of the stack.

Pick-to: 6.2
Change-Id: I2979fe4fe5923c27713e85b6725614b60a693e93
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-08-19 18:41:52 +02:00
Lorn Potter
a4a13949a8 wasm: fix assert in QDateTime
like windows, we dont have historical time data

Change-Id: Iab77c1e2949bc909324f18209e6c52324c80a548
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-19 16:13:54 +00:00
Ivan Solovev
5c4861d312 QCborValue: add asserts to encoding method
This patch is inspired by CodeChecker, that is complaining about
possible nullptr dereferencing.
Currently it is a false-positive, because the codepath suggested by
CodeChecker is impossible with current implementation.
But having asserts can save some time in case of possible refactoring.

Task-number: QTBUG-95727
Pick-to: 6.2
Change-Id: I242a23e8aaa249cce16b867c0884dfc3849977f5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-08-19 16:42:32 +02:00
Eskil Abrahamsen Blomfeldt
43a63901f4 Fix bug with NoFontMerging when font does not support script
When using NoFontMerging, no fallbacks should be resolved. If the
font does not support a specific character in the text, we should
display a box instead of merging it with another font.

But in practice, Qt would still apply the fallback mechanism for
one specific case: If the font itself does not support the script
of the text, we would get no match and do a search for a fallback
instead. Since NoFontMerging is set, we would then force this
as preresolved for *all* scripts in the QFont's private data
(logically, the match should only have a single response for
NoFontMerging).

The end result was that if you set the font family before updating
the text, you would get broken rendering. This can happen e.g. in
Qt Quick, where you could update the font family of a text label
while it contains characters which are not supported by the new
font. Qt would then pick a fallback instead. When you subsequently
update the text, the fallback would already be preresolved for
whatever script this is. If it does not support the updated text,
we would then see boxes, even if the requested font actually would
have supported it.

The fix is simply to do an additional pass if NoFontMerging is set
and we were not able to match with the specified script. Since
the same family might be available in different foundries, with
different writing system support, we still want to do a pass first
to see if we can match the exact script of the text.

Note that QRawFont::fromFont() exploited the bug by using
NoFontMerging for getting the fallback font for a specific
writing system. To keep this working without having to rewrite
fromFont() and risk introducing regressions, we add an argument
to make the findFont() function behave as before. It isn't
super-pretty, but since it is private API it is hopefully fine.

[ChangeLog][QtGui][Text] Fixed an issue with NoFontMerging and
changing font families dynamically, where boxes would be seen in
place of the correct text.

Pick-to: 5.15 6.1 6.2
Done-with: Andy Shaw
Fixes: QTBUG-81770
Change-Id: Ide9a36d7528a1040172c5864fa99e7a82eac4e83
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-19 13:35:40 +02:00
Alexandru Croitor
e7455644a2 CMake: Don't install metatypes files for user projects
Installing extracted metatypes json files for user projects was an
oversight. We shouldn't install anything on behalf of user projects,
but rather give them enough information so they can do it the
themselves.

Make all the install options of qt6_extract_metatypes internal,
change the behavior not to install the files by default, unless
__QT_INTERNAL_INSTALL is passed, which is used for the Qt build only.

__QT_INTERNAL_NO_INSTALL is now a no-op and should be removed from
projects.

This is behavior change for existing public API, but it's better to
fix this now before 6.2.0 release.

Introduce a new OUTPUT_FILES option to allow assigning the extracted
metatype file paths into a variable that the project provides.
The project can then install the files where they need them.

[ChangeLog][CMake] qt6_extract_metatypes does not install metatypes
files anymore. Instead the OUTPUT_FILES option can be provided to get
the list of extracted files for further processing.

Pick-to: 6.2
Task-number: QTBUG-95845
Change-Id: If5dd0255a5fea2b598e15118c29ec2ab2ba4324e
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-08-19 13:35:40 +02:00
Giuseppe D'Angelo
11d1dcc6e2 QString: use the QRegularExpression operations on QStringView
There's no need of duplicating code all over the place; QString can
reuse the implementation of the indexOf/contains/count/lastIndexOf
family of functions already existing for QStringView.

For simplicity, the warning messages (that our autotests actually check)
have been made more generic, rather than introducing some other
parameter (as in, "which class is using this functionality so to emit
a more precise warning"), which would have just complicated things as
the implementation of these functions is exported and used by inline
QStringView member functions.

Change-Id: I85cd94a31c82b00d61341b3058b954749a2d6c6b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-19 08:49:07 +02:00
Giuseppe D'Angelo
f0d1f50e02 QRegularExpression: fix matching over null/empty QString(View)
An empty QString(View) is allowed to have nullptr as its data pointer
(of course, only if its size is 0). This wasn't properly
checked in QRegularExpression, which passed such nullptr to
PCRE, and that resulted in PCRE raising an error (PCRE_ERROR_NULL).
Detect this case and pass a dummy pointer to keep PCRE happy.

Fixing and testing this in turn exposed a problem with QStringView
support in QRegularExpression when used over a null QString: the
code is supposed to use the QStringView(QString) constructor and NOT
qToStringViewIgnoringNull. That's because QRE distinguishes null
and empty subjects; when using qToStringViewIgnoringNull over
a null QString, one gets a non-null QStringView (!). Again, this in
turn exposed a problem with a QRegularExpression autotest that assumed
that a null match could only mean "no match" (instead, it can happen at
position 0 of a null QString(View)).

Change-Id: Ifb3cf14dec42ce76fcdbcb07ea1d80784d52ef65
Pick-to: 6.1 6.2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-19 08:48:52 +02:00
Albert Astals Cid
9e90682def qpnghandler: Only assume we're past the input size if it returns a size
Size 0 is a "valid" answer for QIODevice implementations so we need to
make sure that we only enter the "try to workaround broken files" if we
know there is a size, otherwise the first read of length 4 that libpng
does breaks everything.

Change-Id: I1e396abd206ff90edae4372726f1d82d5d41ccf3
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-08-19 02:27:28 +02:00
Giuseppe D'Angelo
6cee204d56 QS(V)/QBA(V)/QL1S::lastIndexOf: fix the offset calculations
When trying to fix 0-length matches at the end of a QString,
be83ff65c4 actually introduced a
regression due to how lastIndexOf interprets its `from` parameter.

The "established" (=legacy) interpretation of a negative `from` is that
it is supposed to indicate that we want the last match at offset `from +
size()`. With the default from of -1, that means we want a match
starting at most at position `size() - 1` inclusive, i.e. *at* the last
position in the string. The aforementioned commit changed that, by
allowing a match at position `size()` instead, and this behavioral
change broke code.

The problem the commit tried to fix was that empty matches *are* allowed
to happen at position size(): the last match of regexp // inside the
string "test" is indeed at position 4 (the regexp matches 5 times).

Changing the meaning of negative from to include that last position (in
general: to include position `from+size()+1` as the last valid matching
position, in case of a negative `from`) has unfortunately broken client
code. Therefore, we need to revert it. This patch does that, adapting
the tests as necessary (drive-by: a broken #undef is removed).

Reverting the patch however is not sufficient. What we are facing here
is an historical API mistake that forces the default `from` (-1) to
*skip* the truly last possible match; the mistake is that thre is simply
no way to pass a negative `from` and obtain that match. This means that
the revert will now cause code like this:

  str.lastIndexOf(QRE("")); // `from` defaulted to -1

NOT to return str.size(), which is counter-intuitive and wrong. Other
APIs expose this inconsistency: for instance, using
QRegularExpressionIterator would actually yield a last match at position
str.size(). Similarly, using QString::count would return `str.size()+1`.
Note that, in general, it's still possible for clients to call

  str.lastIndexOf(~~~, str.size())

to get the "truly last" match.

This patch also tries to fix this case ("have our cake and eat it").

First and foremost, a couple of bugs in QByteArray and QString code are
fixed (when dealing with 0-length needles).

Second, a lastIndexOf overload is added. One overload is the "legacy"
one, that will honor the pre-existing semantics of negative `from`. The
new overload does NOT take a `from` parameter at all, and will actually
match from the truly end (by simply calling `lastIndexOf(~~~, size())`
internally).

These overloads are offered for all the existing lastIndexOf()
overloads, not only the ones taking QRE.

This means that code simply using `lastIndexOf` without any `from`
parameter get the "correct" behavior for 0-length matches, and code that
specifies one gets the legacy behavior. Matches of length > 0 are not
affected anyways, as they can't match at position size().

[ChangeLog][Important Behavior Changes] A regression in the behavior of
the lastIndexOf() function on text-related containers and views
(QString, QStringView, QByteArray, QByteArrayView, QLatin1String) has
been fixed, and the behavior made consistent and more in line with
user expectations. When lastIndexOf() is invoked with a negative `from`
position, the last match has now to start at the last character in the
container/view (before, it was at the position *past* the last
character). This makes a difference when using lastIndexOf() with a
needle that has 0 length (for instance an empty string, a regular
expression that can match 0 characters, and so on); any other case is
unaffected. To retrieve the "truly last" match, one can pass a
positive `from` offset to lastIndexOf() (basically, pass `size()` as the
`from` parameter). To make calls such as `text.lastIndexOf(~~~);`, that
do not pass any `from` parameter, behave properly, a new lastIndexOf()
overload has been added to all the text containers/views. This overload
does not take a `from` parameter at all, and will search starting from
one character past the end of the text, therefore returning a correct
result when used with needles that may yield 0-length matches. Client
code may need to be recompiled in order to use this new overload.
Conversely, client code that needs to skip the "truly last" match now
needs to pass -1 as the `from` parameter instead of relying on the
default.

Change-Id: I5e92bdcf1a57c2c3cca97b6adccf0883d00a92e5
Fixes: QTBUG-94215
Pick-to: 6.2
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-19 01:55:01 +02:00
Thiago Macieira
6feb289189 MySQL: pedantism: create and destroy the MYSQL_TIME type
This is a no-op. But take the opportunity to make a drive-by update on
the loop, which improves it.

Change-Id: I4a40ccbd3321467a8429fffd169b08590d28c928
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-08-18 15:39:05 -07:00
Thiago Macieira
ddea7e6ce9 MySQL: implement binding output (SELECT) results to MYSQL_TIME
We already do it for inputs but weren't doing it for outputs.

Change-Id: I4a40ccbd3321467a8429fffd169afeb5730ad75e
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-08-18 15:39:04 -07:00
Sona Kurazyan
8aefbe67bf QtConcurrent: fix examples of overloaded methods in docs
Wrap the overloaded methods in qOverload(), to make the examples
compile.

Also remove the extra whitespaces when declaring nested templates.

Pick-to: 6.1 6.2
Change-Id: If438caa6d705d9036dae45278fb26e080918da89
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-18 22:31:17 +02:00
Marc Mutz
96810e3863 QDateTime: port to QStringTokenizer and QVLA
The code isn't easily linearized to work directly with
QStringTokenizer, which is a forward-only range, but we can at least
remove the (non-error) memory allocations by supplying a
suitably-sized QVLA to tokenize into instead of the default QList.

Change-Id: I1aa11a5fbbe66ede4ec2e5b2090044a39052a241
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-18 22:31:17 +02:00
Marc Mutz
93745ef346 QMetaEnum: stop playing ping-pong with *ok
By dropping the clause pointlessly guarding the ranged for loop against
an empty collection, we can reduce the ping-pong being played with the
*ok boolean: Just set it to false at the beginning, and only set it to
true when we reach the success-return.

Pick-to: 6.2
Change-Id: I87365146086aba427b7414e83f077096824ff56f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-18 20:31:17 +00:00
Marc Mutz
d3ece0fcc2 QLibrary: remove dead check
The variable `i` is initially `suffixPos + 1` and is then incremented
further. It therefore can never be equal to `suffixPos` (ints don't
overflow, that would be UB, and suffixPos doesn't change its value),
so don't check for that.

Change-Id: I3870ddf6ee550cad6c24fececf2a0b662a33d750
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-18 22:31:17 +02:00
Alexandru Croitor
175e81ffbd CMake: Fix wasm top-level prefix builds
The wasm support files need to be both copied and installed in a
top-level prefix build, to ensure that leaf repos can find them in the
build dir when they are configured.

Pick-to: 6.2
Fixes: QTBUG-95806
Change-Id: I8c09f04fec51cf850299d535bdf3f26542ec4aac
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2021-08-18 22:15:35 +02:00
Laszlo Agocs
213755a866 rhi: metal: Make base vertex and instance support optional
Like we do for OpenGL. Conveniently enough the QRhi feature flags are
readily available.

This should prevent errors such as:

MTLValidateFeatureSupport:3901: failed assertion `Base Vertex Instance
Drawing is not supported on this device'

on the iOS Simulator. It is not clear since which version or SDK this
became a fatal problem, but the base vertex/instance support is indeed
an optional feature according to the Metal Feature set tables, so not
calling the drawIndexedPrimitives variant taking baseVertex and
baseInstance when the reported iOS GPU family is too low is the right
thing to do regardless.

Pick-to: 6.2 6.1
Fixes: QTBUG-95795
Change-Id: I47c54a77a66a0410b86b8d4e5a1863dc730490f4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-08-18 22:15:35 +02:00
Assam Boudjelthia
90d8a7bed6 Add note on selecting the device which is used to run tests on Android
Pick-to: 6.2 5.15
Change-Id: I9bcff18ca11fbbfdff968e29190cae488de56263
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-18 19:53:38 +00:00
Luca Di Sera
fd86939eaf Doc: Add missing links to methods to QSet documentation page
Some internal links to `QSet` methods were missing from the
documentation. In particular, all methods that were written with one
attribute.

It seems that QDoc might automatically recognize method/function
links only if they have zero parameters, such that the identifier is
followed by `()` directly.

To avoid this problem while keeping the current parameter-containing
form of the text; each function of the form `functioname(\a
parametername)` was changed to `\l {functionname()} {functioname(\a
parametername)}.

Furthermore, one of those text instances was modified to use `\a` for
the parameter name, instead of the previously used `\e`, to enhance
consistency.

An instance of `operator<<()` was not recognized as a link.
To resolve this it was marked with the `\l` command.

Fixes: QTBUG-95389
Pick-to: 6.2 6.1
Change-Id: I16b2a7a2fbaf4785c2c6bfa5017a3db46d9db2f4
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-08-18 20:29:23 +02:00
Tor Arne Vestbø
61d4f7e228 Report ImAbsolutePosition for QLineEdit
ImAbsolutePosition was added in f8dbed1226,
based on requirements on Android, but without an implementation for
QLineEdit. It would seem sensible to fall back to the cursor position
in this case, as QLineEdit doesn't support multiple blocks.

Pick-to: 6.2
Change-Id: Iff1255270ceef069f03ce457df633d7b675f1a28
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-18 20:06:05 +02:00
Volker Hilsheimer
7188e65077 QTabBar: don't overwrite data, fix refactoring error for vertical tabs
Amends 359616066e, which incorrectly
changed

-            tabList[i].minRect = QRect(0, miny, sz.width(), sz.height());
+            tab->data = QRect(0, miny, sz.width(), sz.height());

in the code laying out verticals tabs (correct done for the horizontal
case).

Since QDockWidget uses the user data for tabs to maintain the mapping
between tabs and dock widget, this broke the layout logic.

Fixes: QTBUG-95841
Pick-to: 6.2 6.1
Change-Id: Ie785e1205b426bbc4954b965f619f4c603490f76
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-18 19:27:31 +02:00
Sona Kurazyan
642b9fce81 QtConcurrent::run: support non default-constructible return types
The QtConcurrent::RunFunctionTask class keeps a variable to store the
result of QtConcurrent::run when it becomes available, so that it can be
reported afterwards. This requires the result type to be
default-constructible. However there's no need in storing the result, it
can be reported immediately after it becomes available.

Pick-to: 6.1 6.2
Fixes: QTBUG-95214
Change-Id: I95f3dbff0ab41eaa81b104a8834b37d10a0d193a
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-08-18 09:41:55 +02:00
Paul Wicking
c4ac9e74c7 Doc: Add see also links to operator== and operator!=
Add see also link from operator== and operator!=
to matches() to avoid possible confusion.

Fixes: QTBUG-95820
Pick-to: 6.2 5.15
Change-Id: Ica8112da436b57da0d410f8e1f6b71fc6bf0791f
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
2021-08-18 07:27:57 +00:00
Waqar Ahmed
3c625b7752 QFileDialog: Use static const QRegularExpression
This avoids rebuilding the same pattern. Caught by clazy.

Change-Id: Ibd0f2063617df1a9e975f58e34df556d1983afff
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-08-18 08:50:54 +05:00
Thiago Macieira
74705ae17b MySQL: don't allocate 1-byte buffers for BLOBs
We set the buffer length to 0 for blobs, as we need to do it for each
row, in bindBlobs() (apparently a workaround for MySQL 4.1.8 API). That
function was deleting the buffer and reallocating.

Change-Id: I4a40ccbd3321467a8429fffd169b06422612ca13
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-08-17 17:20:03 -07:00
Thiago Macieira
549ee216fd MySQL: treat the MYSQL_FIELD as read-only
The MariaDB-connector-c version 3.2 and MariaDB server version 10.6
cooperate to avoid re-transferring the query metadata, so the fact that
we were modifying it was causing it to improperly decode the DATETIME
data types into string, as we had asked. We ended up with a 7-byte
string that was actually the date binary-encoded.

References:
 - https://jira.mariadb.org/browse/MDEV-26271
 - https://github.com/MythTV/mythtv/issues/373
 - https://bugs.kde.org/show_bug.cgi?id=440296

Pick-to: 5.12 5.15 6.2
Fixes: QTBUG-95639
Change-Id: I4a40ccbd3321467a8429fffd169afdbb26cf29f6
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-08-17 17:20:03 -07:00
Thiago Macieira
65aca9a223 MySQL: remove left-over charset-setting code
Complements commit 472520afb9. We were
doing it twice.

Change-Id: I4a40ccbd3321467a8429fffd169b05fa5e22f204
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-08-17 17:20:03 -07:00
Jonas Kvinge
4ddbfb68f8 Fix compile with MinGW-W64 9.0.0: Redefinition of 'struct _FILE_ID_INFO'
With MinGW-W64 9.0.0, _WIN32_WINNT is set to Windows 10 by default, so
_FILE_ID_INFO is already defined.

Fixes: QTBUG-94031
Pick-to: 6.2
Change-Id: I0b29a4a1932425e1c4079aba6768fe94460c60af
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-08-18 00:13:22 +02:00
Alexandru Croitor
b5d833730e CMake: Set a placeholder bundle version for iOS apps
Without a bundle version and short version string string, the
iOS simulator will refuse to launch the app.

Set a placeholder "0.0.1" version for both fields if they were not set
by the project. Allow opt-out via a QT_NO_SET_XCODE_BUNDLE_VERSION
variable.

Pick-to: 6.2
Fixes: QTBUG-95836
Task-number: QTBUG-95838
Change-Id: I3e959766c7fa13f23ad12882f8bd14cd45e7096c
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 21:30:34 +02:00
Tor Arne Vestbø
d627d351be macOS: Don't wipe NSWindowStyleMaskFullSizeContentView if set manually
The NSWindow may have style masks set by the user via winId(). We don't
want to wipe those just because we're recomputing the style mask.

Fixes: QTBUG-69975
Pick-to: 6.2 6.1 5.15
Change-Id: Ibca8388d45b623f4cdfaff4b256c4eb012e2ffac
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-08-17 12:20:24 +02:00
Edward Welbourne
bb04478dfc Fix some old copy-and-paste errors in QByteArrayView docs
Various texts copied from QByteArray were still talking about the byte
array, not the byte array view.

Change-Id: Ief46f6053641b7a19f8be7b20562f4b9ed66f6b3
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2021-08-17 12:20:24 +02:00
Wang Peng
6dc9c89919 QStyle: allow styles to control the margin around icons in QLineEdit
The styles can't control the margin of the icon container, and its value
is hardcoded to a quarter of the iconSize, which is very unfriendly.
Add a PixelMetric enum value to allow styles to control the margin.

Change-Id: I21274b68d24150db7be78513fe9125f775aa2b00
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-17 03:29:12 +00:00
Jonas Kvinge
b781fa79c1 Change since for QNativeInterface::QX11Application to 6.2
The documention currently incorrectly lists QNativeInterface::QX11Application
as available since 6.0.

Pick-to: 6.2
Change-Id: I13256a1504b2bd93296434438835791f12353089
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-08-17 04:23:48 +02:00
Tor Arne Vestbø
0f39fc55c9 Forward declare Objective-C classes as class, not typedef objc_object
Forward declaring an Objective-C class in Objective-C/C++ mode is done
by using the `@class` syntax, e.g.:

  @class NSString;

In C/C++ mode however there's no documented approach, so we chose
to flatten the type down to the opaque objc_object "base class":

  typedef struct objc_object NSString;

As it turns out, when Objective-C classes are used as arguments or return
types in C++, the signature they produce is equal to what it would have
been if the type was a normal class. For example:

  void foo(NSString *) -> __Z3fooP8NSString

The is due to @class in Objective-C++ just being just sugar, so an NSString
pointer is not treated as `struct objc_object *` but rather a pointer to a
distinct type, which then gets mangled as such by LLVM's Itanium mangler
in CXXNameMangler::mangleType(const ObjCObjectType *T).

With our current forward declaration however, we are expecting:

  void foo(NSString *) -> __Z3fooP11objc_object

As a consequence exported helper functions such as QString::fromNSString()
are not possible to use from plain C++ right now, as it will give a linker
error for the missing QString::fromNSString(objc_object*) function.

And even if we did define the extra signature, it would not be possible
to declare overloaded functions taking Objective-C classes, as they would
all produce ambiguous overloads in C++ mode.

To fix this we change the forward declaration to a plain old class,
which matches the signature in both Objective-C++ and plain C++ mode,
and allows overloads. This is a binary compatible change, as no client
were using any of these functions from C++ anyways as they would have
produced linker errors. It does have a slight source compatible break,
for clients that manually forward declared classes using the old style,
but that use-case is deemed fringe enough to accept, and clients can
work around this by defining Q_FORWARD_DECLARE_OBJC_CLASS to their
preferred format, which Qt will respect.

Pick-to: 6.2
Change-Id: I04813c60a7da22379dd9de1be56cc12c53a38232
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-17 02:55:12 +02:00
Mårten Nordheim
de9c03dc6e QByteArray: Disentangle number(double) from QLocale
Previously number(double) would go through QLocale which takes a lot of
factors into consideration (which we don't need in this case) and
outputs a QString in the end, which we then have to convert back to
QByteArray. Avoid all that extra work and format it directly into a
QByteArray.

The other number() functions do not use QLocale, so are left alone for now.

Task-number: QTBUG-88484
Change-Id: I4c2eaf101a55ba16e858f95017fb171589a0184e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-17 00:31:26 +02:00
Mårten Nordheim
e5e8e4f59b Make double-formatting code ready for QByteArray
Split off the actual logic in qdtoBasicLatin into a templated function,
qdtoString, which supports both QByteArray and QString. Since it uses
qullToBasicLatin_helper as part of its fallback path make the same
change to it.

Task-number: QTBUG-88484
Change-Id: Icac75ee74ba6a9ddc3aa8d4782a981ef50a88db4
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-17 00:31:26 +02:00
Mårten Nordheim
2696d5a71b QString::number(double): Disentangle from the QLocale path
By writing code to do formatting without considering locale

The code tries to not do any unnecessary (re)allocations, and as such
it reserves at the beginning and only appends.

Cuts execution times of benchmarks by between 30% and 80%:

 PASS   : tst_QString::initTestCase()
 PASS   : tst_QString::number_double(0, format 'f', precision 0)
 RESULT : tst_QString::number_double():"0, format 'f', precision 0":
-     0.0001774 msecs per iteration (total: 2,661, iterations: 15000000)
+     0.0001238 msecs per iteration (total: 1,858, iterations: 15000000)
 PASS   : tst_QString::number_double(0, format 'f', precision 0)
 RESULT : tst_QString::number_double():"0, format 'f', precision 0":
-     0.0002472 msecs per iteration (total: 3,709, iterations: 15000000)
+     0.0001407 msecs per iteration (total: 2,111, iterations: 15000000)
 PASS   : tst_QString::number_double(0.12340, format 'f', precision 5)
 RESULT : tst_QString::number_double():"0.12340, format 'f', precision 5":
-     0.0004769 msecs per iteration (total: 7,155, iterations: 15000000)
+     0.0001638 msecs per iteration (total: 2,458, iterations: 15000000)
 PASS   : tst_QString::number_double(-0.12340, format 'f', precision 5)
 RESULT : tst_QString::number_double():"-0.12340, format 'f', precision 5":
-     0.0005759 msecs per iteration (total: 8,639, iterations: 15000000)
+     0.0001664 msecs per iteration (total: 2,497, iterations: 15000000)
 PASS   : tst_QString::number_double(1.618033988749895, format 'f', precision 15)
 RESULT : tst_QString::number_double():"1.618033988749895, format 'f', precision 15":
-     0.0003644 msecs per iteration (total: 5,467, iterations: 15000000)
+     0.0001869 msecs per iteration (total: 2,804, iterations: 15000000)
 PASS   : tst_QString::number_double(2.220446049e-16, format 'g', precision 10)
 RESULT : tst_QString::number_double():"2.220446049e-16, format 'g', precision 10":
-     0.00070580 msecs per iteration (total: 10,587, iterations: 15000000)
+     0.0002277 msecs per iteration (total: 3,416, iterations: 15000000)
 PASS   : tst_QString::number_double(1.0E-04, format 'E', precision 1)
 RESULT : tst_QString::number_double():"1.0E-04, format 'E', precision 1":
-     0.00082213 msecs per iteration (total: 12,332, iterations: 15000000)
+     0.0002018 msecs per iteration (total: 3,028, iterations: 15000000)
 PASS   : tst_QString::number_double(1.0E+08, format 'E', precision 1)
 RESULT : tst_QString::number_double():"1.0E+08, format 'E', precision 1":
-     0.00082459 msecs per iteration (total: 12,369, iterations: 15000000)
+     0.0002016 msecs per iteration (total: 3,025, iterations: 15000000)
 PASS   : tst_QString::number_double(-1.0E+08, format 'E', precision 1)
 RESULT : tst_QString::number_double():"-1.0E+08, format 'E', precision 1":
-     0.00093840 msecs per iteration (total: 14,076, iterations: 15000000)
+     0.0002074 msecs per iteration (total: 3,111, iterations: 15000000)
 PASS   : tst_QString::cleanupTestCase()
-Totals: 11 passed, 0 failed, 0 skipped, 0 blacklisted, 153777ms
+Totals: 11 passed, 0 failed, 0 skipped, 0 blacklisted, 48753ms

Task-number: QTBUG-88484
Change-Id: I23234467801243b163dff5cccf8a9fe9d90c3e2a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-17 00:31:26 +02:00
Ievgenii Meshcheriakov
fe9ddbe197 QUrl: Improve Punycode overflow handling
Add more overflow checks from the sample code in RFC 3492.
Also check if a code point to be inserted into output is in
the allowable range for Unicode.

Rewrite all overflow checks to use {add,mul}_overflow()
functions.

Do not try to process any inputs that are too long to be
part of a valid domain name label.

This fixes a test in tst_qurlinternal.

Fixes: QTBUG-95689
Pick-to: 6.2
Change-Id: Ice0b3cd640d8a688b63a791192ef2fa2f13444be
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-16 19:47:14 +00:00
Eskil Abrahamsen Blomfeldt
2f5695bed5 Fix printing with unhinted fonts
On high-dpi displays or when you explicitly select an unhinted font,
we pick a DirectWrite font engine. This hit an uncovered code path
on Windows, because we relied on being able to get the HFONT from
the font engine.

To fix this, we introduce an alternative code path which gets the
HFONT based on the DirectWrite font when this font engine is active.

[ChangeLog][Windows] Fixed an issue where the characters in printed
text would look too small.

Pick-to: 6.1 6.2
Fixes: QTBUG-95720
Change-Id: Ifd609e92512e1f25f0ee2aace35cb5ccedf09030
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-16 20:20:26 +02:00
Marc Mutz
874c8c56a4 QVarLengthArray: add missing default-ctor documentation
Was lost when we un-explicit'ed the default ctor in
c34242c679.

Pick-to: 6.2 6.1 5.15
Change-Id: Ifb4943b9e9647ae59c1cc6d5fc5076e8620b73ce
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-16 17:26:30 +00:00
Marc Mutz
0756b6a719 QDateTime: port away from takeFirst() use
Use the std-compatible API subset instead.

This is in preparation of using QVarLengthArray instead of QList here,
which (thankfully, because it's inefficient for arbitray T) doesn't
have pop_front().

As a drive-by, port at(0) to front() and introduce a temporary
variable. The front() call will briefly emit a detach attempt (but the
container isn't shared, so it won't actually detach), but only until
the next patch ports to QVLA.

Change-Id: I38ee123aa6730aee5ba1e14ec46fc71c5d74986e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-08-16 19:26:29 +02:00
Marc Mutz
db8368f535 QMetaEnum: stop parsing when an invalid key is found
The old code obfuscated the algorithm by or'ing -1 into the return
value, which is equivalent to setting it to -1 on two's complement
architectures (which C++ these days requires), and happily continuing
to accumulate potential keys. But nothing that can be or'ed into -1
will ever change the value, so this is rather pointless, as we're not
emitting diagnostics apart from setting a bool to false.

Fix by simply returning -1. That makes it obvious what we're
returning, and we return early on error.

Pick-to: 6.2
Change-Id: I8957f44e03609ad58d6c25d5fa78c57190b14bdd
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-16 17:26:29 +00:00
Marc Mutz
29cfea3e82 QVarLengthArray: add support for emplacement
Take the rvalue insert() function and turn it into the emplace()
function. Reformulate rvalue-insert using emplace(). Lvalue insert()
is using a different code path, so leave that alone. This way, we
don't need to go overboard with testing.

[ChangeLog][QtCore][QVarLengthArray] Added emplace(), emplace_back().

Change-Id: I3e1400820ae0dd1fe87fd4b4c518f7f40be39f8b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-16 17:26:29 +00:00
Marc Mutz
e7ab888700 Short live namespace q20!
As proposed already for Qt 5 (then with q14 and q17), add
reimplementations of C++20 library features into a q20 namespace. The
advantage is that we can later just s/q20::/std::/ and be sure that a)
the q20 functionality works (within reason) like the std counterparts
and b) we don't have to re-indent the code after the replacement.

Start with std::identity in q20functional.h, required by
std::ranges::{any,all,none}_of() (ex ranges[1]) in q20algorithm.h,
which I happen to require in QLibrary next.

[1] We can't provide the nice range-based overloads (any_of(vector,
pred)), yet, because that would require to reimplement all the
range-related concepts, as the overloads are ambiguous if
unconstrained. First, we should check whether we can't just depend on
Nieber's ranges-v3 library instead. The q20 namespace is independent
of this decision, as it's more universally useful (q20::remove_cvref
comes to mind).

Unlike in q14/q17 times, a single header, q20.h, would become unwieldy
very soon, so use separate headers.

Change-Id: I14b98c865e242d2dc9674bc1bff5f7a9e4db9940
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-16 19:26:29 +02:00
Marc Mutz
8948f5cc78 QStandardPaths/Unix: use QStringTokenizer
Avoids having to allocate storage to hold the parts. Since the
startsWith('/') will fail for empty parts, remove the SkipEmptyParts
so we don't check for emptiness twice.

Change-Id: Id33a52d5fbd29f7a9d4ead758729195bb201a369
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-16 19:26:29 +02:00
Marc Mutz
dd3c4b66a1 QDir: use QStringTokenizer
Avoids having to allocate storage to hold the parts.

Change-Id: Ie4d877af959751139f4c098b644e4a57f63d03b9
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-16 19:26:29 +02:00
Marc Mutz
991c471aa5 QLibrary: succeed early for .dylib on Darwin
Drag the cheap check for 'fileName.endsWith(".dylib")' to before the
expensive operations (QFileInfo creation, extraction and splitting of
completeSuffix(), building of suffix candidate list, ...), at the cost
of a duplicated Q_OS_DARWIN check.

Change-Id: I8ed764f18f0beb8ad24c30ab806ecc5452159601
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-16 19:26:29 +02:00
Liang Qi
cfa631e0fb Update bundled Freetype to 2.10.4
Removed everything, imported with help of import_from_tarball.sh script,
and then added a pre-generated builds/unix/ftconfig.h

This also amends 58f5695084 because it is
not a clean update, some old files are still there.

Also redo the fix for wasm like 30f4ca4e4f.

Fixes: QTBUG-82480
Pick-to: 6.2
Change-Id: I45ee3230299908ca0372e035636dd64b6c549a27
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-08-16 17:26:29 +00:00
Tor Arne Vestbø
d4015a21a4 macOS: Add logging for keyboard and complex text input
Pick-to: 6.2
Change-Id: I098829e051d4f63950b2e35ee6dd4def8d70cf01
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-08-16 19:26:29 +02:00
Tor Arne Vestbø
853c350cca macOS: Map dead keys directly to their terminator when building key map
When a key press comes in we may end up in QAppleKeyMapper::possibleKeys()
as part of checking whether the key press should trigger a QShortcut.
The function builds on QAppleKeyMapper::keyMapForKey(), which provides
a map from the given virtual key to all the possible Qt::Keys that can
be produced by applying different modifier key combinations.

The map is built using the Carbon function UCKeyTranslate, that takes
the current keyboard layout, virtual key, and modifiers, and produces
the resulting characters. The function also maintains a running dead
key state via one of the arguments. When mapping a dead key, the state
variable will be updated to the current dead key state, which then
affects the next call to the function (for the next key press).

The problem is that we're not calling UCKeyTranslate for each key press.
We are calling it in a loop, for a single key press, to build up a map
of all the possible characters produced by varying the modifier keys.
And in doing so, we are passing on the dead key state from one call
to the next, even if these are for different modifiers. The result is
that the first call, for the dead key, results in mapping to \0, as
UCKeyTranslate produces no output, it only modifies the dead key state.
And then the next call, for the next modifier key combination, results
in mapping to a character that incorrectly incorporates the dead key
state (resetting it in the process).

What we really want is to directly map the initial modifier combination
to the dead key terminator character, if one is defined. This is the
character produced if the dead key state is cancelled, for example by
pressing a key that's not defined in the dead key state.

To achieve this we pass kUCKeyTranslateNoDeadKeysMask as the translate
options to UCKeyTranslate, and always reset the dead key state before
every call. Another common way to achieve the same result would be to
call UCKeyTranslate a second time when detecting that the first call
produced a dead key state, for example with a synthetic space key, to
trigger the terminator output. But this can potentially fail if the
space key actually has a defined output in the dead key state.

Fixes: QTBUG-95471
Pick-to: 6.2 6.1
Change-Id: Icdae7639fd9a641a86c9d6615679bd93d380ff5c
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-08-16 19:26:29 +02:00
Tor Arne Vestbø
99a4419647 macOS: Don't treat null-key as potential shortcut key
When mapping virtual keys and modifiers to their corresponding characters
via a keyboard layout we may hit combinations that do not produce any
characters. This can happen if there's no <key> element defined for the
virtual key, or if the output attribute of the element is empty (despite
the spec saying there should always be one UTF-16 code point in the output).

 https://developer.apple.com/library/archive/technotes/tn2056/_index.html

When that happens QAppleKeyMapper::keyMapForKey() will map the combination
to a null-QChar, resulting in the "key" being 0. We do not want to propagate
this back to the QShortcutMap machinery, as QShortcutMap does not validate
the keys coming out of QKeyMapper::possibleKeys(). In particular, it doesn't
check the isEmpty() or count() of the QKeySequences it creates. And even if
it did, QKeySequence itself seems to treat Qt::Key(0) + Qt::SomeModifier
as a non-empty sequence, so passing on 0-keys would still give weird bugs.

The user-visible result of passing back 0-keys is that QShortcutMap will
treat it as a partial match for any incoming key combination (as long as
some modifier is pressed that triggers the QShortcutMap machinery), which
resulting in eating the key press. This compounded the issue in QTBUG-95471.

Regression after fab3dfff7d.

Task-number: QTBUG-95471
Pick-to: 6.1 6.2
Change-Id: I2e51ec86f4df2a708e1757be827ab74859be3c8b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-08-16 19:26:29 +02:00
Sona Kurazyan
9009a36c01 Fix some errors in docs of string-related classes
- Fixed various texts in docs for QStringView, QUtf8StringView and
QAnyStringView copied from QString, that are still talking about string
or string reference instead of string view.

- Replaced 'string-view' with 'string view', which is the more commonly
used form.

- Fixed the wrong usage of uppercase 'If' in some places.

- Did minor adjusments, to make the docs consistent with docs of
QByteArray/QByteArrayView.

Change-Id: Ifb905e00957e869a8befad5a36d6b00b6e621a04
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-16 18:53:56 +02:00
Volker Hilsheimer
06235d36ae QGraphicsProxyWidget: fix propagation of high-precision events
In order to fix QTBUG-95552 properly we have to add APIs to
QGraphicsSceneWheelEvent that informs QGraphicsProxyWidget about
whether the event is a high-precision event where Qt grabs the
wheel.

If it is, then the wheel grabber will be the QGraphicsView's viewport,
and any wheel event sent to any widget will be grabbed by it. This
results in infinite recoursion, partly fixed in change
I78400ceae8da7a4e22a988c06ed58f99f1a979f4.

The proper fix is to re-grab the wheel by the embedded widget
if it (or any of its children) accepts the ScrollBegin event (and if
not, return the grab to the QGraphicsView).

This fixes the scenarios that failed in the test case, so now scrolling
through nested widgets and scrolling in nested widgets works as the
user would expect.

Fixes: QTBUG-95552
Pick-to: 6.2
Change-Id: I3e1f31cbff999c70f8c63c034f77cd2ae567d7e3
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-08-16 16:37:26 +00:00
Volker Hilsheimer
4982c872ef Don't crash in high-precision wheel scrolls on a QGraphicsProxyWidget
For high-precision wheel scrolling sequences, the widget that gets
the first (typically ScrollBegin) event grabs the wheel. Qt directs
all future wheel events within the same sequence (i.e. until ScrollEnd)
to that widget.

QGraphicsView passes wheel events through to the item under the mouse,
and QGraphicsProxyWidget implements wheelEvent to forward a synthesized
QWheelEvent to the embedded widget. Since QGraphicsView's viewport has
already grabbed the wheel, any forwarded event would end up back in
QGraphicsView, resulting in infinite recursion (if the assert doesn't
fail first in debug builds).

The correct fix requires that QGraphicsProxyWidget knows that this is
a high-precision wheel event, allowing it to adjust the wheel grabber
temporarily to the embedded widget. However, QGraphicsSceneWheelEvent
doesn't provide this information.

To fix the infinite recursion, mark the generated event as synthesized
by Qt (but still send it spontaneously to enable propagarion within
the proxy widget hierarchy). In QApplication's notification routine,
interpret such events then to override the wheel grabber.

Add a test case for the various scenarios. This 6.1 compatible fix
does not pass all situations. A follow up commit that introduces the
missing APIs to QGraphicsSceneWheelEvent then fixes those as well.

Task-number: QTBUG-95552
Pick-to: 6.1 6.2
Change-Id: I78400ceae8da7a4e22a988c06ed58f99f1a979f4
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-08-16 18:37:26 +02:00
Volker Hilsheimer
1653ae13db Accept the QWheelEvent before each propagation step
Input events in Qt are accepted when constructed, and ignored by the
default event handler (so overriding the event handler is enough to
accept an event).

Since we use the same QWheelEvent instance for each propagation step,
we need to reset the event to be accepted before each delivery so that
an earlier child ignoring the event doesn't result in the event being
ignored without explicit acceptance.

Amends the refactoring of wheel event delivery in
92df790f46.

Task-number: QTBUG-95552
Task-number: QTBUG-79102
Task-number: QTBUG-67032
Pick-to: 6.1 6.2
Change-Id: Ib3f99792518364cf6e635cf4c6fda088051a7848
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-08-16 18:37:26 +02:00
Ievgenii Meshcheriakov
864ecea83b QUrl: Make Punycode encoding code less surprising
Move the code that modifies the encoding loop variables from
appendEncode() back to qt_punycodeEncoder() instead of passing
the variables by reference. This gives better overview of how those
variables change.

Remove comment claiming overflow detection inside appendEncode()
where no overflow detection is done.

Task-number: QTBUG-95689
Pick-to: 6.2
Change-Id: I8830e75370646f0c9b78cae883f778a12e32919d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-16 11:45:14 +02:00
Assam Boudjelthia
dc90755541 Fix Style java code format and warnings
The code had many bad formating and syntax or API usage warnings,
as well as some unused methods or classes which are fixed with this
patch.

Pick-to: 6.2 5.15 6.1
Task-number: QTBUG-71590
Change-Id: Ib113a0dc05703afb5190ec880b27daf75274cb1e
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2021-08-15 14:02:41 +03:00
Eirik Aavitsland
c1643e6547 Remove unused internal flag in QImage
The "locked" flag was only added for a particular use in the Freetype
font engine in 070d9c00c488a5ee6811f04170cf488ead79bf80,but that usage
was refactored away long ago in afb326f071.

Pick-to: 6.2
Change-Id: I7347c91f49ba59041f6ff35bd5a6b537d6c704d4
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-08-13 06:55:20 +00:00
Povilas Kanapickas
de9d486d2f Properly scale gesture positions in hi-DPI case
The local/global positions for gestures should be handled the same as
for other events as they mean effectively the same thing.

Change-Id: Ic5ad995607ecd3daf385a7c7be3b67cbae312e7b
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-08-12 23:14:47 +03:00
Alexandru Croitor
ab2669a9fa CMake: Fix testlib compile definitions not to be overridden
Amends 70464b355e

Pick-to: 6.2
Change-Id: I92424d830afc0aaad9001817be82a06adabd014b
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2021-08-12 15:07:56 +02:00
Alexandru Croitor
e599be12d6 CMake: Fix plugin target names to end in Plugin suffix
Pick-to: 6.2
Task-number: QTBUG-95731
Change-Id: I56a34dd26656613c95fbc8f081d39561cb691852
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-08-12 13:50:14 +02:00
Volker Hilsheimer
adafa5ee1f StyleSheet: Use rule for ComboBox in embedded QLineEdit
An editable combobox uses an embedded QLineEdit as an implementation
detail. That lineedit should use the rules that are set for the combobox
to render itself, similar to what was already implemented for the lineedit
used in a QAbstractSpinBox.

The containerWidget helper function provides the logic for identifying
the container of the rendered widget, returning the QAbstractSpinBox or
the QComboBox for an embedded QLineEdit. Use that method rather than
duplicating the logic.

Pick-to: 6.2 6.1 5.15
Fixes: QTBUG-95631
Change-Id: I50bc92a62715608b11c2c923f8f9215f56bfd15e
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-08-12 13:10:27 +02:00
Tang Haixiang
a7b1aaa98b Close all popup windows when the screen is rotated
Changing the screen orientation will cause the menu position to be
displayed incorrectly. When the screen is rotated, the geometry of
the application changes. We can refer to the handling of the menu
on Android or IOS. Close the popup window when the screen
orientation changes.

Fixes: QTBUG-95607
Pick-to: 6.2
Change-Id: I55e1cd6a8b89e375c6714a9163dfb1902d52f101
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-08-12 19:10:27 +08:00
Assam Boudjelthia
b5b9c264dd Fix hidden API access for Android style
Use public API and attributes to retrieve part of the Android
style values instead of using reflection to access hidden or
private fields. This latter method, was throwing lots of warnings
or exceptions at the start of apps making it big annoyance to deal
with.

This patch doesn't handle drawables though, so the "full" and
"default" Android style will be somehow broken still for now.
For that reason, the default style extraction method is set to
minimal to avoid getting warnings about it, and Fusion style
could be used for Widgets apps, and for QML apps, it's recommended
to use the Material style from Quick Controls 2.

Pick-to: 6.2 5.15 6.1
Task-number: QTBUG-71590
Change-Id: If87895dc66751e23c9f4ea840e9f3e611aaa8833
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2021-08-12 09:46:34 +03:00
Edward Welbourne
54b1ed6798 qlocale_win: return null QVariant on failed look-ups
Various functions were still returning a null QString wrapped as a
QVariant; the caller distinguishes these cases, so should get a null
QVariant so it knows the backend failed to answer the query and can
attempt whatever fall-back it may have at its disposal.

Pick-to: 6.2
Change-Id: I0983b9f3b1026f17c3f13ab92b713bee90be466c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-11 22:32:42 +02:00
Edward Welbourne
6f833eff92 Add QByteArrayView::trimmed()
Unlike simplified(), it just moves the end-points, without needing to
modify contents, so it makes sense (as for QStringView and
QLatin1String) to provide it. Moved QByteArray's trimmed() tests to
tst_QByteArrayApiSymmetry so that QBAV can now share them.

[ChangeLog][QtCore][QByteArrayView] Added trimmed().

Change-Id: Ifd7a752adb5f3d3e2ad0aa8220efa7e7d2d39baa
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2021-08-11 22:32:42 +02:00
Ievgenii Meshcheriakov
2b4ffe914f QUrl: Fix handling of invalid sequences starting with xn--
Return ASCII sequences that start with xn-- but fail Punycode
decoding as is when converting URLs to Unicode. This is consistent
with handling of sequences that do decode successfully but fail other
validity checks.

This fixes one test in tst_qurlinternal.

Task-number: QTBUG-95689
Pick-to: 6.2
Change-Id: I63d7197f25102c96f5dc21d9fecec5e015c531cb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-11 19:12:00 +00:00
Edward Welbourne
dfbb2d6e1d Clarify documentation of QEXPECT_FAIL()'s mode
Present behavior is to continue or abort, according to the mode,
regardless of whether the condition marked does fail.

Change-Id: I2eb5eefbbf173326101d08f3bbb378d214e93e71
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-08-11 21:10:00 +02:00
Edward Welbourne
40bfc2d8a0 Clean up some notes in QtTestLib documentation
Use \note instead of \b{Note:}, don't refer to functions as macros,
and don't lie. The data-table set-up functions can delegate their
calls to addColumn(), addRow() and newRow() to functions not called
directly by the test framework.

Change-Id: I3bef22cf1a45df91dc822ac04f07e7d15053825f
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-08-11 21:10:00 +02:00
Cathy Park
3727683bd5 Fix button type to update coordinates when dragging
A move position (x,y) can be delivered to the MouseArea only if
button is Qt::NoButton during mouse move (dragging). Otherwise
mouse move does not cause positionChanged in MouseArea.

Task-number: QTBUG-95453
Pick-to: 6.1 6.2
Change-Id: I298943dc4f6f30714e940f4029c62dd52c176b93
Reviewed-by: Jaeyoon Jung <jaeyoon.jung@lge.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-08-11 12:38:35 +00:00
Edward Welbourne
bb49d2ec02 Correct QStorageIterator::next()'s use of qstrtoll()
The end-pointer out-parameter of qstrtoll() is set to the start of the
subject string on failure, never to nullptr; and this only happens
when ok gets set false in any case, so there's no need to check for it
as well as checking ok.

Change-Id: I852a77a2398ffdcd5cb0671a586362cd578b6df4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-11 14:01:55 +02:00
Yuhang Zhao
1e085b9e15 d3d11rhi: remove pre-win10 code
CreateDXGIFactory2() is always available from Windows 8.1
No need to load it dynamically.

Pick-to: 6.2
Task-number: QTBUG-84432
Change-Id: I84d82f30327df416e1fdbac256b63512900c07b7
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-08-11 19:35:25 +08:00
Tasuku Suzuki
c2cbd80425 Fix a typo in the comment for TrueType fonts with embedded bitmaps
Change-Id: I1484c32af03070b8c15c90f21a1ed8a8efde7797
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-08-11 18:14:29 +09:00
Andy Shaw
a68e1b96b8 Undeprecate QFont(QString) since this is still useful for many
Fixes: QTBUG-95441
Pick-to: 6.2
Change-Id: Ib1f78a5a797c7b7d7eb252a7bfa11b5c003ce0d3
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-08-11 08:19:45 +02:00
Robert Löhning
76e2409cc9 Fix memory leak if eXIf has incorrect crc
Change eb6767 from upstream repo.

Fixes oss-fuzz issue 23376.

[ChangeLog][Third-Party Code][libpng] Fix for possible memory leak in
libpng was backported.

Change-Id: Id0c2f8b8bd60438ae8b5a61c83b6e50d55c6eb65
Pick-to: 6.2 6.1 5.15
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-10 18:52:41 +00:00
Thiago Macieira
472520afb9 MySQL: properly fix setting the character set
Commit e4bd73dc54 moved the
mysql_set_character_set() call above the mysql_real_connect() but that
doesn't actually work, as there's no connection to send the "SET NAMES"
statement on.

So do it in two steps: first, by setting the charset in the MYSQL
structure, then by asking the server to match.

Pick-to: 6.2
Task-number: QTBUG-55444
Change-Id: I4a40ccbd3321467a8429fffd1699bd829f342124
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-08-10 10:43:03 -07:00
Thiago Macieira
aa93b4835a MySQL: don't format QDateTime with timezones
Neither MySQL nor MariaDB like it. According to the documentation[1],
MySQL now accepts timezones using the [+-]HH:MM format (and -00:00 is
rejected). MariaDB does not accept timezones at all[2].

This has apparently been broken since Qt 5.0 (the "Z" suffix was
introduced in commit 2528f4ffe5), but this
issue was never noticed because the of prepared queries: when they're in
use, we transfer the time using a MYSQL_TIME structure, which does not
support timezone offsets either. We've only noticed this issue when the
code to determine if the MySQL client library supported prepared
statements broke.

[1] https://dev.mysql.com/doc/refman/8.0/en/date-and-time-literals.html
[2] https://mariadb.com/kb/en/date-and-time-literals/

Task-number: QTBUG-95071
Change-Id: I4a40ccbd3321467a8429fffd1699cc4c050ae746
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-08-10 10:43:03 -07:00
Thiago Macieira
211369133c MySQL: remove the version number checks in favor of actual functionality
MariaDB library version 3.2 no longer returns the server version in the
10.x range but the library version itself, which is lower than 4.x. That
meant we concluded the server did not support prepared statements.

And because of the lack of prepared statements, all QDateTime
conversions failed, because of the timezone. I don't know if this was
intended or what, but it's a side issue.

[ChangeLog][QtSql][MySQL] Fixed the detection of whether the client and
server support prepared statements. This was caused by the mariadb
connector library reporting its own version numbers (starting in version
3.2) instead of the server version.

Fixes: QTBUG-95071
Pick-to: 5.15 6.2
Change-Id: I4a40ccbd3321467a8429fffd1699bc089ba706e6
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Fabian Vogt <fabian@ritter-vogt.de>
2021-08-10 10:43:03 -07:00
Edward Welbourne
d055abd195 Assert that special handling of '0' padding does what it should
When formatting numbers, if the fill character used to left-pad to
field widths is '0', the code delegates that padding to the
QLocaleData's ZeroPadded formatting option. Since we want the zeros
before any minus sign, and don't want to subsequently add more zeros
before it, check that this has worked as expected when calling
replaceArgEscapes(), to confirm that it doesn't need to worry about
that.

Add some tests that verify the expected behavior.

In the process, tidy up the code doing this. Rename a local variable
to match our coding style, split a long line.

Pick-to: 6.2
Change-Id: I7cc430c5bceb006cf4e226bca33da16bd2bb1937
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-10 19:43:03 +02:00
Volker Hilsheimer
33f9591e37 Implement missing support for 'em' and 'ex' lengths in style sheet
The Qt style sheet reference claimed that Length properties can be
specified in 'em' or 'ex' units, but that was never implemented.

Add the missing implementation. Since the sizes depend on the size of
the font of the current element, we cannot convert the units in the CSS
parser, but have to do so in the QRenderRule constructor, where we can
make a decision about which font to use if the style sheet itself doesn't
specify a font. Fall back to the widget font if possible; otherwise it
will be the application default font.

The implementation translates em into QFontMetrics.height, identical to
what is already done in the QCssParser. This is in line with the CSS
specification, but contradicts our previous documentation which stated
that 'em' means "width of M". Fix the documentation.

Fixes: QTBUG-8096
Pick-to: 6.2
Change-Id: I145e2504ae3b19101a0d0dd63653466b6c2cec1d
Done-with: Cristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io>
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-08-10 19:43:02 +02:00
Tor Arne Vestbø
41d6a26731 Add default constructor and Q_DISABLE_COPY_MOVE to native interfaces
We currently define a non-default destructor, but without defining a
constructor, copy constructor, copy assignment operator, move constructor,
or a move assignment operator

Pick-to: 6.2
Change-Id: I0dcaef61d86292df5963fac410d22cb3fcf12af3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-08-10 19:31:03 +02:00
Tor Arne Vestbø
f0757d2fcd testlib: Remove unused QTestCoreElement and QTestElementAttribute types
The "documentation" has also been removed for all types, as it didn't
add anything, and maintaining it to be in sync with the values just
adds overhead.

Pick-to: 6.2
Change-Id: Iab1dd7b9804c05559b4674342d6059b68ecf3ecf
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-10 16:06:36 +00:00
Tor Arne Vestbø
d9fd41a1fe testlib: Let loggers know which test function is being left
None of the loggers rely on this at the moment, but one could imagine
one that does. Plus, doing any sort of debug logging in leaveTestFunction
will at the moment be attributed to  UnknownTestFunc().

Pick-to: 6.2
Change-Id: I284b2785a276e028b9f57c26357679fd9e045ca7
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-10 18:06:36 +02:00
Tor Arne Vestbø
072e5d2a8f testlib: Document order of QTestResult completion functions
Pick-to: 6.2
Change-Id: I34adbcc2bd02887a93cd1e86692401e840afe8bd
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-10 18:06:36 +02:00
Tor Arne Vestbø
4632be1b4d testlib: Don't write redundant log message information in JUnit reporter
The separation between <system-out> and <system-err> is sufficient, and
we can't expect consumers to interpret our custom comment format.

The type of the text node has been renamed to more accurately identify
its purpose.

Pick-to: 6.2
Change-Id: I63c8ff17529fc087e1b695698350a6711eb5e68d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-10 18:06:36 +02:00
Tor Arne Vestbø
c08d56be1f testlib: Treat qCritical messages as system-err in JUnit reporter
Pick-to: 6.2
Change-Id: Ia34fbc59dc430b7ef39a94bd6836d9675cde58f5
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-10 18:06:36 +02:00
Tor Arne Vestbø
ca15cc0049 testlib: Rename QAbstractTestLogger::QSystem to QCritical
It's used to handle qCritical() messages, and corresponds to QtMsgType's
QtCriticalMsg, so change its name to reflect what it really is.

In the process, reclassify the -maxwarnings overflow message as a warning,
rather than a critical message.

Pick-to: 6.2
Change-Id: I87626117a547ae4498d5dc352b93bd6db8bfb332
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-10 18:06:36 +02:00
Tor Arne Vestbø
308280e7a9 testlib: Move stdout/stderr reporting into individual <testcase> elements
The original Ant JUnit reporter only writes <system-err> and <system-out>
to the <testsuite>, but more modern reporters such as Maven Surefire
scopes output to each individual <testcase>.

This is also handled by both the Jenkins JUnit and xUnit plugins, e.g.:

 https://github.com/jenkinsci/junit-plugin/commit/145eb5c98

Pick-to: 6.2
Change-Id: I20c87276004a4e0910fc18e05e6ffa0f5e5a7b7c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-10 18:06:36 +02:00
Tor Arne Vestbø
825e4291cd testlib: Produce <error> elements on fatal errors in JUnit reporter
Test errors represents unanticipated problems, e.g., an unhandled
exception, or a problem with the implementation of the test.

Pick-to: 6.2
Change-Id: I87219e7ffdea56862278f005de44526ad97545f0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-10 18:06:36 +02:00
Alexandru Croitor
5161d8d525 CMake: Remove qt6_enable_object_libraries_finalizer_mode
qt6_enable_object_libraries_finalizer_mode is not needed anymore
now that static Qt builds require CMake 3.21 and thus CMake takes
care of placing object library object files at the beginning of
the link line.

Rename qt6_enable_import_plugins_finalizer_mode to a more generic
qt6_set_finalizer_mode that can enable or disable multiple
different modes.

For now the only available mode is "static_plugins" which handles
the behavior of the old function name.

The mode can be enabled by calling

 qt6_set_finalizer_mode(${target} ENABLE MODES "static_plugins")

Note that the function is re-tagged as being in Technical Preview.

Ideally we would not need it at all. But we need to provide some
workaround for the limitations of linking Qt static plugins in CMake
on Linux-y platforms that use bfd ld or ld.gold.

The workaround does not work well with dependencies wrapped in
generator expressions which is why we can't confidently advertise it
as a proper solution.
Our hope is that this can be fixed in future upstream CMake versions
and the function can be removed.
See 6fcc272ac9 for details.

Adjust the tests due to the renamed and removed functions.

Amends 19e789bace
Amends cdbb390c4a
Amends a25027eecb
Amends 6fcc272ac9
Amends a3c430f390

Pick-to: 6.2
Fixes: QTBUG-95169
Task-number: QTBUG-95601
Task-number: QTBUG-95603
Change-Id: I51b85f776ec29fc04fed1a637eba7d1f60609e69
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-10 16:51:53 +02:00
Tor Arne Vestbø
32725806c8 Improve documentation signature for native interface accessor
Pick-to: 6.2
Change-Id: I8fd0633fb993cf1544a1fd5d897fe59f8687705a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-08-10 15:53:03 +02:00
Jeremy Katz
81411cb3a8 Doc: fix QStyleOptionMenuItem::menuHasCheckableItems typo
Change-Id: I2553f3e799e57e688ae98090e34f30122fea1142
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-08-10 05:42:58 -07:00
Tianlu Shao
0ef190fcc4 QCompleter: QCompleter unexpectedly changes QLineEdit text
When qcompleter and qlineedit are used together, the currentcompletion()
of qcompleter is its first item by default. Therefore, when qlineedit
makes the initial value, then selects the text and enters, qcompleter
will modify the default first item to qlineedit text. The judgment that
completionprefix() of the completer is not empty is modified and added
here, because completionprefix() is always empty when there is no match.

Fixes: QTBUG-20894
Pick-to: 6.2 6.1 5.15
Change-Id: Id47f7f4da0a93d03a4e7b056ec731615b0803d13
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Tianlu Shao <shaotianlu@uniontech.com>
2021-08-10 20:21:59 +08:00
Gatis Paeglis
e946e6895a xcb: implement missing bits from ICCCM 4.1.4 WM_STATE handling
ICCCM 4.1.4 says:

Clients that want to re-use a client window (e.g. by mapping it again) after
withdrawing it must wait for the withdrawal to be complete before proceeding.
The preferred method for doing this is for clients to wait for a windown manager
to update or remove the WM_STATE property.

This patch implements the required logic. Qt 4 had something similar. Without
this patch we are calling various setter functions on a native window while it
is in an undefined state.

Fixes: QTBUG-69515
Pick-to: 6.2 5.15
Done-with: Liang Qi <liang.qi@qt.io>
Change-Id: I377a66ad3d5e43f14465d0ea670b2f43f96ed7d3
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-08-10 14:21:59 +02:00
Liang Qi
02248eea55 xcb: add a timeout control when reading INCR property
For the first call of QXcbClipboard::clipboardReadProperty()
inside of clipboardReadIncrementalProperty() in getSelection(),
it will get a XCB_NONE reply before the contents arrived via
property change. Then we give a chance to read more.

Manually tested with following setups:
* examples/widgets/mainwindows/application with gvim(gtk3)
* examples/widgets/widgets/imageviewer with GIMP 2.10.18(based on
gtk2) and GIMP 2.99.6(based on gtk3 via flatpak)

Fixes: QTBUG-56595
Pick-to: 5.12 5.15 6.1 6.2
Done-With: JiDe Zhang <zhangjide@uniontech.com>
Change-Id: Ib45f08464d39ad79137b1da99808c89b7dca2d08
Reviewed-by: JiDe Zhang <zhangjide@uniontech.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-08-10 12:21:58 +00:00
Ievgenii Meshcheriakov
f636a1efa5 QCalendarRegistry: Explicitly disable moving and copying
Add Q_DISABLE_COPY_MOVE to QCalendarRegistry to silence the following
warning produced by QtStaticAnalysisBot:

    class 'QCalendarRegistry' defines a non-default destructor but does
    not define a copy constructor, a copy assignment operator, a move
    constructor or a move assignment operator

QCalendarRegistry is a singleton so it does not need to be moved or
copied.

The warning was introduced by d0ae1ef33a.

Task-number: QTBUG-93004
Pick-to: 6.2
Change-Id: I5e018346415b9d0a1ebc3bbde2ab7c3ad5e6d9d0
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-10 14:21:58 +02:00
Ievgenii Meshcheriakov
9bd2ab85ac QUrl: Fix Punycode handling for non-BMP codepoints
Iterate over Unicode codepoints instead of UTF-16 characters
when converting to/from Punycode as described in the specification.
Additionally reject strings with invalid surrogate pairs when
encoding to Punycode, reject strings with any encoded surrogates
when decoding.

Remove expected failure marking from the test for this issue
in tst_qurlinternal.

Fixes: QTBUG-95577
Pick-to: 6.2
Change-Id: I3dd68f95ada6d652e2fa5c0c3118dcfa0a5f4c4d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-10 14:21:58 +02:00
Sona Kurazyan
d61820e5ab Improve docs for QFuture continuations
Replace phrases like "future has been running", "parent" with more
precise descriptions.

Pick-to: 6.1 6.2
Fixes: QTBUG-95273
Change-Id: Ibd5a464007d41cc437da49ba250b9ea0a46078c6
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-10 13:07:18 +02:00
Edward Welbourne
f5aeb4f970 qlocale_win: Rename a misnamed local variable
Although the function is called get{Dat,Tim}eFormat(), the content
it's filling the buffer with isn't a format, it's a formatted date or
time. So name the variable we transcribe the buffer into text instead
of misleadingly calling it format.

Change-Id: Ia3a51184963109a50dbc41e205bd8c83d83c04d7
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-10 13:07:18 +02:00
Ulf Hermann
6f8ef8c64d QVariant: Tolerate QObject* metatypes without QMetaObject
QMetaType does. QVariant should do the same.

Pick-to: 6.2
Change-Id: I3419276b78b3b5ce8bd144dee92685195797d568
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Daniel Nicoletti <daniel.nicoletti@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-10 13:07:18 +02:00
Volker Hilsheimer
79a219862f Document that hiding/disabling a menu is best done via the menuAction
Task-number: QTBUG-95072
Pick-to: 6.2
Change-Id: I83afe13b129a35b39c62abe553061cc4a390fd65
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-08-10 12:00:13 +02:00
Thorbjørn Lund Martsum
7502598ef5 QListView: fix AdjustToContents (sizeAdjustPolicy)
Unlike an acceptable effect in QTableView + QTreeView
setAdjustPolicy(QAbstractScrollArea::AdjustToContents)
unfortunately didn't work for QListViews (and QListWidget).

This patch corrects QListViews AdjustToContents
behavior.

[ChangeLog][QtWidgets][QListView] A more correct implementation
of QListView::viewportSizeHint has been made. That
implies that setting the sizeAdjustPolicy to AdjustToContent
on QListView and QListWidget will now cause the view to
size after the contents and avoid scrollbars.

Pick-to: 6.2
Task-number: QTBUG-58749
Change-Id: I1675115f2348e2fcf0b2c39b451ef337e10eb872
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-08-10 12:00:13 +02:00
Eirik Aavitsland
84aba80944 Refix for avoiding huge number of tiny dashes
Previous fix hit too widely so some valid horizontal and vertical
lines were affected; the root problem being that such lines have an
empty control point rect (width or height is 0). Fix by caculating in
the pen width.

Pick-to: 6.2 6.1 5.15
Change-Id: I7a436e873f6d485028f6759d0e2c6456f07eebdc
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-08-10 12:00:13 +02:00
Marc Mutz
aa25e8d87e QGuiApplication: move two static variables from DATA to BSS
The {mouse,touch}DoubleXDistance variables were initialized to -1,
which forces them into the DATA segments.

But this value is completely unused, since these variables are also
set in initThemeHints(), called from QGuiApplicationPrivate::init(),
before their only user, QGuiApplicationPrivate::processMouseEvent(),
can possibly execute.

By changing the default value to 0, then, we allow the compiler to
place these variables into the BSS segment.

Change-Id: I86144559ee2410b844f70a4f2499c8d3140d14cf
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-10 08:11:38 +02:00
Marc Mutz
8da891a7f4 QMetaStringTable: disable copy and move
This class is an algorithm, and shouldn't be copied or moved.

Change-Id: I6f517f53a242dbfd61975ef885c358eef139a272
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-10 08:11:13 +02:00
Tor Arne Vestbø
ab70aa362e macOS: Fix leaked NSMutableArray in applicationActivationChanged
The +[NSObject new] method is a combination of alloc and init.

Fixes: QTBUG-95619
Pick-to: 6.2 6.1 5.15
Change-Id: I341f8a3958fb7a016cf4c346750ea6d46eeebe9f
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-08-08 13:54:37 +02:00
Alexandru Croitor
b2f00dfb46 CMake: Rename qt6_add_plugin TYPE option to PLUGIN_TYPE
The intention is to remove TYPE as a keyword completely before 6.2.0
release, but in case if that's not possible due to the large amount
of repositories and examples, just print a deprecation warning for
now and handle both TYPE and PLUGIN_TYPE.

Task-number: QTBUG-95170
Pick-to: 6.2
Change-Id: If0c18345483b9254b0fc21120229fcc2a2fbfbf5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-06 21:08:21 +02:00
Tor Arne Vestbø
eb4fb9fa32 testlib: Don't report blacklisted tests as failures in JUnit reporter
We don't produce <failure> elements for them, so we shouldn't include
them in the total count of failures.

In the future we might produce <skipped> elements instead, but for now
remove the incorrect increment.

Pick-to: 6.2
Change-Id: Ia89a5cdaf79f6aa2f92be53180112c40ad6da2c6
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-06 20:05:15 +02:00
Ievgenii Meshcheriakov
84a93d94ac QCalendar: Delete registered calendar backends on program exit
Add code to check if the calendar registry is destroyed to all
QCalendar methods that dereference QCalendarBackend pointer.

Pick-to: 6.2
Change-Id: I9b562355e2e0579396b52968f6065c6927cc9ca8
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-06 19:46:18 +02:00
Ievgenii Meshcheriakov
d0ae1ef33a QCalendar: Thread-safe calendar backend registration
All calendar backend accounting was moved into QCalendarRegistry class
(renamed from Registry). Calendar backends are no longer registered
inside constructors, because in multithreaded environment
this may lead to incompletely initialized instances becoming visible
via QCalendar API in multithreaded environment. All system backends are
registered by QCalendarRegistry itself when they are needed. New method
QCalendarBackend::registerCustomBackend() is provided to register
any 3rd-party calendar backends.

Registration by names was also simplified. The list of names is now
passed to QCalendarBackend::registerCustomBackend(). The checks are
provided to ensure that all system backends have non-conflicting names.
Name conflicts for custom backends are resolved in favor of earlier
registered backends, as it is already the case in the existing code.
The documentation was updated to reflect that.

Method QCalendarBackend::names() was added to query the list of names
associated with a backend after it is registered.

Calendar backend deregistration was completely removed because it is
not possible to perform it safely without reference counting.

Fixes: QTBUG-93004
Pick-to: 6.2
Change-Id: I0ab1eccc02fdd1e1c66b5e5dd076c93de32d5a49
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-06 19:46:18 +02:00
Marc Mutz
f84adba102 Qt namespace: add a Qt 7 note about enumerator order
LayoutDirectionAuto is the default in qguiapplication.cpp's
layout_direction. Because the numeric value isn't zero, it forces the
variable into the DATA segment instead of the more efficient BSS one.

At a less technical level, LayoutDirection{} should really produce the
default, Auto, instead of LeftToRight. APIs have been changed for
lesser violations of inclusivity :)

Change-Id: I06b42f0bc00ea539805280ef0aa9694e6d739f41
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-06 18:11:37 +02:00
Andrei Golubev
d4e62f2c5a moc: Support BINDABLE for private properties
Hopefully we won't need it but let's have it still at least for
consistency

Change-Id: I72289e65e5e5613174ad4d98cf8d614f9caae8e6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-08-06 17:25:50 +02:00
Marc Mutz
6ba6e7585d QXpmHandler: clean up write_xpm_image: cut out the QBA middle-man
Instead of appending to a QByteArray and then streaming that one, just
stream the components of a line directly. QTextStream's op<<(const
char*) is not subject to QT_NO_CAST_FROM_ASCII, etc., so can be used
unconditionally.

Change-Id: Idd97a75a1b5b939de7176d40880a2f328d01927d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-06 17:08:10 +02:00
Tor Arne Vestbø
1272b60d9e testlib: Fix name of current test case element in JUnit reporter
Pick-to: 6.2
Change-Id: I0bd77e5f1d0540b87568a0c69a4b96442d4000eb
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-06 17:00:22 +02:00
Tor Arne Vestbø
a2026e4116 testlib: Write failure details as <failure> content in JUnit reporter
Pick-to: 6.2
Change-Id: Ica48769e7dfcabdc4bc8f0ed058bc22e29a0b632
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-06 17:00:22 +02:00
Tor Arne Vestbø
0ce70a29b3 testlib: Indent CDATA element in JUnit reporter
The data itself is not indented, as consumers may read it as verbatim
data.

Pick-to: 6.2
Change-Id: Ia934616cea273feadc3a45d7c74726d4f804f0dc
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-06 17:00:22 +02:00
Mårten Nordheim
9b860ece42 QString/QByteArray: Fix setNum docs and add tests
Amends 260168d9d7

Task-number: QTBUG-53706
Pick-to: 6.2
Change-Id: I01c8cdc6a3cb46ec8e49e15ad71b6d707c0d272f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-06 16:49:08 +02:00
Marc Mutz
65512f8505 QInputDeviceManager: make QT_NO_KEYWORDS-clean
Change-Id: I1ba43c4dce82a8488e51c471fa3409fc08be1529
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2021-08-06 16:49:08 +02:00
Tor Arne Vestbø
f5203eeada Add native interface for X11 application, exposing display and connection
The major use-case of the now private QX11Info from Qt X11 Extras was
getting hold of the Xlib display and XCB connection, for example in KDE:

  https://lxr.kde.org/search?%21v=kf5-qt5&_filestring=&_string=QX11Info

A new native interface for QGuiApplication has now been added that
exposes these two properties, e.g.:

  if (auto *x11App = app.nativeInterface<QX11Application>())
      qDebug() << x11App->display() << x11App->connection();

To avoid type clashes one of the enum values of QXcbNativeInterface's
ResourceType had to be renamed.

Pick-to: 6.2
Task-number: QTBUG-93633
Change-Id: I2e366a2bb88bd3965ac6172ad000ae32209f43e7
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-06 15:09:39 +02:00
Edward Welbourne
e158502e33 Turn off feature timezone for emscripten
We don't (yet) have a workable back-end for it.

Pick-to: 6.2 5.15
Task-number: QTBUG-95314
Change-Id: I8cf0fd11f315bc7d6cac351d485f4cbc676ed95d
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2021-08-06 14:31:11 +02:00
Edward Welbourne
57da4a4f76 Tidy up QString's replaceArgEscapes() helper function
Eliminate wasted space, add spaces required by coding style, reflow an
arithmetic expression to read more gracefully.

Change-Id: Id04dfc7710f5cdb560a8d4655608139fb4c36191
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-06 14:29:18 +02:00
Edward Welbourne
d0c7f718ca replaceArgEscapes(): rework nested conditional to avoid repetition
Change-Id: I42306cb38d745bde33b93d3f66e86f19f58a868a
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-06 14:29:18 +02:00
Edward Welbourne
54abc61af1 replaceArgEscapes(): correct a comment and assert what it relies on
Change-Id: I1d0c82b1cac0d59bd1fbda65f6a3e5be346b4c70
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-06 14:29:18 +02:00
Edward Welbourne
2452a7e184 replaceArgEscapes(): rework local variables to make code simpler
Change-Id: I188dc6f7a0d81d8587cc5a750d8773c3d389644f
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-06 14:29:18 +02:00
Edward Welbourne
0dca7afaee replaceArgEscapes(): use qsizetype in place of int ant uint
The uint, particularly, was requiring some contortions to avoid
getting a "negative" value, where using qsizetype makes it harmless,
as the resulting loops are then no-ops. In the process, document the
slightly eccentric semantics of one of the retyped variables.

Change-Id: Idaad4cfde9ed9d24e1bcbf03c2bdb10b62e07916
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2021-08-06 14:29:18 +02:00
Edward Welbourne
47ead6ce2c replaceArgEscapes(): use a local variable to avoid duplication
Two blocks of code branched on the same local variable and, in each
block, one branch acted on a C-locale text, the other a localized
version, but doing the same to each in the two branches. Branch to set
a variable to the selected text so that we only have to write the code
to do each branch's actions to that one text.

Change-Id: I8bbc1210f2c14b19f41a9974c7b6ec2ae612cc70
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2021-08-06 14:29:18 +02:00
Marc Mutz
ccec95fda6 QCoreGlobalData: use QHash, not QMap, for dirSearchPaths
No user of the variable iterates over the container, they only
manipulate or inspect individual entries, so order doesn't matter. If
order doesn't matter, use the more efficient QHash over QMap.

Change-Id: Id28913a57bb14eb328e668624f236f76cad86def
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-06 14:19:52 +02:00
Fabian Kosmale
87973325f1 Handle even more include in enum cases
The solution in d3ed7dac8a was needlessly
complicated, and broke a valid use case.
The issue of no identifier being available to parse after the include
has been processed can instead be solved by moving the test for the
closing brace after the include processing.

Fixes: QTBUG-94790
Pick-to: 6.2 6.1 5.15
Change-Id: Ieec4b89e1d117637f11479e8bddc4060f93da43d
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-06 11:54:11 +00:00
Marc Mutz
71334c324e QXpmHandler: actually limit characters-per-pixel to four
The following code assumed, and all comments indicated, that the cpp
variable was limited to a max of 4. Yet, as coded, cpp could be five,
in which case the XPM would be corrupt, as the header suggested five
characters-per-pixel while the data was formatted in only four.

Add a warning and error out when we encounter this situation.

[ChangeLog][QtGui][QImage] Instead of writing a corrupt file, rejects
to write XPM files with more than 64^4 colors (more than four
characters per pixel) now.

Pick-to: 6.2 6.1 5.15 5.12
Change-Id: I458873cf7d179ab2e2dacd4c17dc837d640591a9
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-06 13:50:39 +02:00
Marc Mutz
066dd1cdc0 QInputDeviceManager: ++explicit, ++out-of-line-dtors
It's private API, but exported, so de-inline the dtor to pin the
vtable in QtCore instead of potentially duplicating it in every plugin
that uses the class.

Change-Id: Ia948985bb94677c8453a8e7be27a14085303aaf5
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2021-08-06 13:02:44 +02:00
Morten Johan Sørvig
6336b5350b Improve WM_DPICHANGED handling
Resize QPlatformWindow on DPI change, so that QWindow
size can stay approximately constant.

For example, a 100x100 QWindow at 100% scaling will
have a 100x100 QPlatformWindow. If the scaling is changed
to 200% then the QPlatformWindow is resized to 200x200,
while the size of the QWindow stays at at 100x100.

In practice the QWindow size will also change slightly,
due to inaccuracies in how we adjust for the size of the
non-client window area. This will be addressed in a later commit.

We can get DPI change independently of screen change,
so no resizing should happen in screen change events.
Disable the resize code in QGuiApplication for Q_OS_WIN,
and remove the WithinDpiChanged flag.

The new flow for handling DPI change is:

  1) Send screen change (if any), so that the correct
     screen will be used when calculating scale factors
     during the following resize.
  2) Resize the native window, which will trigger geometry
     change events, possibly also for the QWindow.
  3) Resize child windows; WM_DPICHANGED is sent to
     top-level windows only.

Fixes: QTBUG-89294
Pick-to: 6.2
Change-Id: I0e2d44bae72d20ebdafc3d410db7be9964ad851b
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-08-06 13:02:44 +02:00
Morten Johan Sørvig
f988386560 Track current window DPI
The WM_DPICHANGED event gives us the new DPI, but we
also need the current DPI in order to determine the
scale factor corresponding to the DPI change.

Pick-to: 6.2
Change-Id: Ia61388415f57aa739397d3125b8751952e8fd392
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-08-06 13:02:44 +02:00
Nico Vertriest
7d7b484429 Doc: Fix link error to qFuzzyIsNull()
Pick-to: 6.1 6.2
Change-Id: I17d890d4d61199dd74598ffa4c670ed65894047c
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-08-06 12:04:28 +02:00
Marc Mutz
726119c431 QXpmHandler: clean up write_xpm_image: use conventional pointer arithmetic
... instead of *(array + index).

Also fix a pointless cast from QRgb to int which the next line
implicitly undoes (because colorMap has QRgb as key, not int) and get
rid of the local variables that facilitated said fallacy in the first
place.

Change-Id: I71a92822ee2404646f6fb5533e40252f38e6b21f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-08-05 11:32:02 +02:00
Marc Mutz
2658f95d3c QXpmHandler: clean up write_xpm_image: scope variables better
... and fix spacing around operators and after flow-control keywords.

Change-Id: Iefaa03074536d13a655c91fb42aef6aa96c2665b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-05 07:35:20 +02:00
Marc Mutz
ec40e50506 QXpmHandler: avoid double-lookup
The code used the if (!contains()) { insert() } anti-pattern,
necessitated by Qt's deviation from the STL of allowing insert() to
overwrite an existing entry, causing two lookups of the same key.

Since QMap these days is a wrapper around std::map, fix by using the
real thing (a std::map) instead, which sports the non-broken insert()
semantics already, avoiding the need to play tricks like detecting a
size increase in order to find whether an insertion took place. It
also simplifies the loop later on, and we can transparently use pmr,
when available.

Change-Id: Iedd8d5691514a7705a55c27376446304b20af071
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-05 05:19:10 +02:00
Thiago Macieira
ae0b080c01 QStringLiteral: suppress the clang-tidy warning about const_cast
We can't add the comment inside the macro, so we solve the problem by
adding an extra level of indirection.

Pick-to: 6.2
Change-Id: Ib8fbfcfeb48a49ca945dfffd169829b3610f6a34
Reviewed-by: Rui Oliveira
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2021-08-04 19:36:01 -07:00
Tor Arne Vestbø
c95d7741b7 testlib: Don't report additional 'pass' test point for blacklisted XFail
Regression after 9906cc57ed.

Pick-to: 6.2
Change-Id: I5566f70c66d248426c7a41b6de1cfb92f104cc64
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-05 03:58:50 +02:00
Tor Arne Vestbø
fb16a66b71 testlib: Report skipped tests in JUnit reporter as <skipped> elements
The Apache Ant and Surefire Maven specs document a <skipped> element that
can be used to signify skipped test, with a corresponding total skipped
test attribute on the <testsuite>.

The element includes an optional message attribute, documented in the
Surefire spec, and in the Ant source code, but not yet documented in
the reverse-engineered Ant spec:

 https://github.com/windyroad/JUnit-Schema/pull/11

Pick-to: 6.2
Task-number: QTBUG-95424
Change-Id: Ib6417a41b9c328836f4017e6ebf7f7e9cd91288d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-05 03:58:50 +02:00
Tor Arne Vestbø
58f1c0c146 testlib: Don't report JUnit errors attribute without any <error> elements
The errors attribute on the <testsuite> element represents the number of
<error> elements, but we do not produce any at the moment.

Pick-to: 6.2
Task-number: QTBUG-95424
Change-Id: I7196d622a9a6bbb7e79ed2c2886984d539abb1da
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-05 03:58:50 +02:00
Tor Arne Vestbø
5a483656bc testlib: Sync up QTest::LogElementType with element names
539553a572 renamed the LET_Error element
enum to LET_Message, without renaming the corresponding "error" element
name. This was not an issue in practice, since we never write the actual
element in QTestJUnitStreamer, but the two should be in sync to avoid
any confusion.

Pick-to: 6.2
Change-Id: I6c29f5303393b5f36b2f9877940bf3f6eaf3b7d2
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-05 03:58:50 +02:00
Tor Arne Vestbø
bb74e72aa9 testlib: Reduce JUnit test duration reporting to millisecond precision
The original Ant JUnit reporter produced test durations via Double.toString(),
supporting arbitrary precisions, and the de-facto schema declared them
as xs:decimal.

Sadly, the now popular Maven Surefire reporter limited the duration to
millisecond precision, and hard-coded this into its schema as SUREFIRE_TIME:

  https://issues.apache.org/jira/browse/SUREFIRE-1533

Unfortunately this definition spread into tools such as the Jenkins xUnit
plugin, which relies on the schema provided by Maven Surefire:

  https://issues.jenkins.io/browse/JENKINS-52152

As a result, anything that produces higher precision results will not
validate in the Jenkins xUnit plugin.

Other test frameworks have bitten the bullet and reduced their precision
correspondingly, e.g.:

 https://github.com/catchorg/Catch2/issues/2221
 https://github.com/catchorg/Catch2/commit/581c46249acf8389e9

We follow suit, and our JUnit XML output now validates against both
the Jenkins JUnit and xUnit plugins, as well as the original Apache
Ant de-facto schema.

Pick-to: 6.2
Task-number: QTBUG-95424
Change-Id: I3097d10c03c2a29709960372301b29055d224e10
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-05 03:58:49 +02:00
Tor Arne Vestbø
973e74399e testlib: Improve JUnit XML conformance
The JUnit test framework did not initially have any XML reporting
facilities built in. Instead, the XML report was generated by the
Apache Ant JUnit task:

 https://github.com/apache/ant/search?q=filename%3AXMLJUnitResultFormatter.java

Many users interacted with these reports via the Jenkins JUnit plugin,
which provided graphical visualization of the test results:

 https://plugins.jenkins.io/junit/

Due to the lack of an official XML schema for the Apache Ant JUnit
report there was some confusion about what the actual format was.
People started documenting the de-facto format, both as produced
by Ant, and as consumed by Jenkins:

 https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd
 https://github.com/junit-team/junit5/search?q=filename%3Ajenkins-junit.xsd

The XML produced by the Qt Test JUnit reporter was far from these
schemas, causing issues when importing results into tools such
as Jenkins, Allure2, or Test Center.

The following changes have been made to improve conformance:

  - The 'timestamp' attribute on <testsuite> is is now in ISO
    8601 local time, without any time zone specified
  - The 'hostname' attribute on <testsuite> is now included
  - The 'classname' attribute on <testcase> is now included
  - The non-standard 'result' attribute on <testcase> has
    been removed
  - The non-standard 'result' attribute on <failure> has
    been renamed to 'type'
  - The <system-out> element on <testsuite> is always included,
    even when empty
  - The non-standard 'tag' attribute on <failure> has been
    removed. Data-driven tests are now represented as individual
    <testcase> elements, e.g.:

      <testcase name="someTest(someData X)" ...>
      <testcase name="someTest(someData Y)" ...>
      <testcase name="someTest(someData Z)" ...>

The resulting XML validates against both the de-facto Apache Ant
'JUnit 4' schema and the Jenkins JUnit plugin schema.

Task-number: QTBUG-95424
Change-Id: I6fc9abedbfb319f2545b99b37d059b18c16776ff
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-05 03:58:49 +02:00
Tor Arne Vestbø
177d259782 testlib: Simplify JUnit test logger
- Use the right name for the attribute (AI_Message),
   rather than fixing it up in QTestJUnitStreamer.
 - Don't pretend that we're adding line and file information,
   only to discard it in QTestJUnitStreamer.
 - Don't pretend to add benchmark information,
   only to discard it in QTestJUnitStreamer.

Pick-to: 6.2
Change-Id: Ib6eadc12300157216fe9c6e8bcfebd7eb8a3ea68
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-05 03:58:49 +02:00
Marc Mutz
f1ab1132ea QXpmHandler: clean up write_xpm_image: make w,h const
... and use one variable definition per line.

Change-Id: Ie8e6d6fb9e570cf715ab0b39c78d677f1e5a19a7
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-05 03:58:49 +02:00
Edward Welbourne
70adce61ad replaceArgEscapes(): rename a local variable and simplify initialization
The name coincided with one used in other functions for a different
meaning and its initialization was clumsy. Rename to a terser name
that communicates the relevant matter more clearly.

Change-Id: I6baf8e5ec695cbbb1cc10f6c4b4cc6512c1aefc4
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-05 02:44:27 +02:00
Kai Köhne
74d0b1b1b9 CMake: Add whitespace to Android error message
Pick-to: 6.2
Change-Id: I9c7729a7bef4a659b10fe69a73b30f101cbba546
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-05 02:44:27 +02:00
Edward Welbourne
5674610d3f Pre-check a pair of string comparisons by length
When checking whether a floating-point value is "inf" or "nan", the
code actually only checked they *started* with those.  Check the
length first and thereby avoid the check when the string is longer in
any case. This incidentally avoids tripping over any string that
merely starts with "inf" or "nan" - such a string should not be able
to arise here; but we still shouldn't give it the special treatment
reserved for these two, were one to arise. Add an assertion to the one
remaining branch that wouldn't have caught such a malformed string.

Change-Id: I63828e3a99a33cf236e4d1a2e247ad832b7a00fd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-05 02:44:27 +02:00
Marc Mutz
73fabadcee QXpmHandler: fix re-entrancy bug in xpm_color_name
The xpm_color_name() function returned a pointer to a function-static
buffer. This is infamously non-reentrant, and an actual problem,
because we explicitly allow QImage operations (incl. saving to an
.xpm) from non-GUI-threads.

Fix by using the CSS pattern (Caller-Supplied Storage; also used in
the QAnyStringView(char32_t) and QAnyStringView(QStringBuilder) ctors)
to force the caller to allocate storage in its own stack frame. As a
consequence, we re-gain re-entrancy, but the returned pointer is now
only valid until the end of the full-expression, which necessitated
simplifying one caller (sorry!).

To see why said simplification is valid, observe that xpm_color_name()
writes a (now-explicit) NUL into returnable[cpp] and the old code read
max(cpp, 4) characters from xpm_color_name()'s result.

NB: cpp can be 5, even though the code comments say otherwise! :(

[ChangeLog][QtGui][QImage] Fixed a race condition when concurrently
writing .xpm files.

Pick-to: 6.2 6.1 5.15 5.12
Change-Id: I36d7173d53839a52f5cdf58324474c1b32c71f33
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-05 01:46:44 +02:00
Edward Welbourne
115f828ae4 QTestEventLoop: stop when the test fails
It makes no sense for the event loop of a test to keep running after a
test has failed. This lets test code simply use the usual testlib
macros to compare and verify values in asynchronous tests that would
otherwise need to hand-test values and send a signal on failure (that
the main test can connect to an event-loops quit() or equivalent).

For example, QLocalSocket's benchmark simply uses the usual macros,
without doing anything to stop its event loop if they fail, with the
sad result that, when a test fails, it does so repeatedly and then
times out, causing the test program to be killed without running later
tests. With this change, that test code (once converted to use
QTestEventLoop) is able to exit gracefully on the first failure.

[ChangeLog][QtTest][QTestEventLoop] The QTestEventLoop new exits its
event loop as soon as the test is known to be failing.

Task-number: QTBUG-91713
Change-Id: If0d455741668722034906763025dda496d2afbb4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-05 01:07:41 +02:00
Marc Mutz
861feef2bf QFsFileEngine (Unix): replace a QPair with a proper struct
The comments in the declaration of the pair screamed "I want to be a
struct with properly-named member variables", and the code that read
it->first and it->second was really misleading to STL-aware readers.

Fix by defining a small struct with member names taken from unmap()'s
use of the pair's fields.

Change-Id: Ie18852a3147f65cf14cfc5a3bb633f7b3e78f5a2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-04 22:50:10 +02:00
Mike Achtelik
c99849d0bc Shift iOS a11y translations into C++ file
lupdate cannot parse .mm files. Therefore tr markup must be inside of
C++ files. This copies the same approach qtconnectivity uses, see
6b2fd04b7be4494767b6092a030607010d91310c

Pick-to: 6.2
Change-Id: I9853864b4b81b48da763a387c78c102857f23047
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-08-04 22:22:20 +02:00
Marc Mutz
02aa236256 QMetaTypeFunctionRegistry: avoid double-lookup in insertIfNotContains()
Because there's no insertIfNotContains()-like functionality in QHash
(unlike std::unordered_map, where insert() doesn't overwrite an
existing entry), the code first called contains(k) and then insert(k,
~~~), causing two lookups in the case where the insertion actually
happens.

Fix by using the pattern QDuplicateTracker's QSet fall-back uses, too:
recording the size before and after the call to the indexing operator
and using a size increase as the criterion that an insertion should
happen. This reduces the number of lookups to one, at the cost of a
mapped_type default construction (which, given mapped_type is
std::function, should be cheap).

Change-Id: I24b31107b3e26f2eea2edce7b46f8cb5e7cb35bf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-08-04 22:22:20 +02:00
Mårten Nordheim
b41d5f6293 QDecompressHelper: Skip double-decompression if download is small
To retain backwards compatibility with some QNetworkReply usage,
namely connecting solely to finished-signal and allocating a buffer to
read into, but without storing the entire decompressed file in memory
until read, we may decompress the file twice.

With this patch users can now avoid this double decompression if the
amount of buffered data stays below 10 MiB. This means any file smaller
than 10 MiB will never need to be decompressed twice to know the size of
it. On top of that, if the data is handled as it arrives (e.g. in
readyRead) and the buffer is kept below 10 MiB it won't need to
decompress twice either.

This is active as long as "countDecompressed" is true, though it
currently always is in QNetworkAccessManger, with a future goal to make
it possible to control with public API. Since it requires the user to
potentially adapt their usage of QNetworkReply.

In this patch we also stop tracking the amount of unhandled uncompressed
bytes (uncompressedBytes) in favor of tracking the total amount of bytes
which has been read() by the user of QDecompressHelper (totalBytesRead),
since we can more intuitively work out the total amount of unread bytes
using this value.

Change-Id: Ie3d8d6e39a18343fcf9b610f45c7fe7e4cd4e474
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-08-04 19:31:52 +02:00
Fabian Kosmale
5889985c8c QProperty: Only try to avoid TLS access if currentThreadId is faster
We will not gain anything if we have to do multiple function calls to
obtain the thread id. Therefore we introduce a macro to signal that we
have a fast implementation of currentThreadId, and only use the function
if it is defined.

Pick-to: 6.2
Change-Id: I3347489ea91992896bb753b796ae26e391c2c99c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-04 19:31:52 +02:00
Fabian Kosmale
3f0a32aeb5 QProperty: Avoid needlessly refetching bindingStatus
If we already have the bindingStatus, we can just pass it along.

Pick-to: 6.2
Change-Id: Iaaea4f4c34e6a786899561293016ece163c26d25
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-04 19:31:52 +02:00
Fabian Kosmale
f7eed15588 QProperty: more micro optimization
- Provide an inline version of evaluateRecursive which does not fetch the
  status.
- Provide an unsafe variant of setBindingToNotify which does not set the
  tag. This can be used in allocateDependencyObserver, as newly
  allocated observers already have the correct tag (this is checked via
  an assert).

Pick-to: 6.2
Change-Id: I31aec6af4aef244efc6d0777e5bfaaa8f82f2046
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-04 19:31:52 +02:00
Fabian Kosmale
77d528f8d3 QProperty: Force inlining of addObserver
The method is only called in two places: observerProperty (which only
takes care of calling unlink, too, if necessary) and in
registerWithCurrentlyEvaluatingBinding_helper. In the first case, the
method most likely gets inlined anyway. In the latter case, we really
want to avoid the overhead of an additional function call to speed up
registration of the property with the binding. Considering that it is an
internal method, there is no need to worry about code explosion.

Pick-to: 6.2
Change-Id: I3f0f0e37108f3859321d3b432e37fc8da3c15dc0
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-04 19:31:52 +02:00
Fabian Kosmale
e5aff7f3d9 Pass QBindingStatus to evaluateBindings
This avoids another round of TLS lookups in evaluateRecursive when we
construct the BindingEvaluationState.

Pick-to: 6.2
Change-Id: Icfa9fd81fc6f54623d384c4d3fce33f4d4d549b9
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-04 19:31:52 +02:00
Fabian Kosmale
5d0095b1c2 QProperty: micro optimizations
- Ensure that the allocateDependencyObserver fast path is inlined.
- Use addObserver instead of observerProperty; we know that a freshly
  allocated observer does not have its prev pointer set. If prev weren't
  a private member, we could simply use Q_ASSUME(ptr->prev == nullptr),
  but making it public or befriending the class seems like a bad idea,
  as it grants too much access to the internals.

Pick-to: 6.2
Change-Id: Ia845f2807c70512563f7b9e1ecb85fe82b66208c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-04 19:31:52 +02:00
Fabian Kosmale
b8e1782b67 Avoid superfluous QBindingStoragePrivate::get call
If we have no currentBinding, then registerWithCurrentlyEvaluatingBinding
will not do anything. Thus we can completely avoid fetching the storage.

Pick-to: 6.2
Change-Id: Ic20142e4c4e09752b5c41b959f66080e6885e6c3
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-04 19:31:52 +02:00
Fabian Kosmale
71fea09e1a Avoid TLS access for groupUpdateData
By putting the groupUpdateData pointer into the same thread local as the
binding status, we avoid having to fetch two thread_local variables.
Moreover, we can reuse the caching mechanism which we have in place for
QBindingStatus to avoid costly TLS lookups.

Pick-to: 6.2
Change-Id: Iaea515763510daab83f89b8e74f35a80965d6965
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-04 19:31:52 +02:00
Fabian Kosmale
460700f773 QProperty: Avoid TLS lookup if we are in the same thread
If the QBindingStatus we receive from the QObject is from the thread
which is currently running, we do not need to refetch the thread local;
the reason we refetched the thread_local was after all only to guard
against the case where a QObject's property gets read in a different
thread.
To determine whether we are in the same thread, we can store the thread
id in the thread_local structure. Currently, it only gets initialized
for the main thread in QCoreApplication (as bindings are mostly used
there).
At a later point, we could either expose initBindingStatusThreadId, or
call the function when a QThread gets started.

Pick-to: 6.2
Change-Id: Id8eb803973bb083abfab83a62bfccc9e88a4e542
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-04 19:31:52 +02:00
Tor Arne Vestbø
fa8cffa4c9 testlib: Pass on file location on failure, but don't assume we have one
We try our best to pass on the file location of a failure, including for
fatal errors, but the reporting or logging machinery should not assume
there is one.

By passing on nullptr for the file location we allow the logging backends
to decide how to handle the situation, e.g. by not emitting extra fields
for failure location.

This effectively reverts c25687fa0b,
in favor of relying on the backends to cope with null filename,
which they already did.

As qFatal uses QMessageLogger, which by default disables file/line
information in release builds, we need to explicitly enable this in
our self-tests, to get uniform test results. Similarly, we disable
file/line info from testlib itself, as reporting Qt internal file
and line information for user diagnostics is less useful. The odd
one out there is qtestdata.cpp, which still ends up in test output
due to using QTEST_ASSERT instead of qFatal for its diagnostics.
Cleaning up that, and unifying how we report testlib issues to the
user, is left for another day.

Pick-to: 6.2
Change-Id: Ib9451b8eed86fe3ade4a4dcaf0037e1a3450321c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-04 17:31:51 +00:00
Tor Arne Vestbø
bef57b317f testlib: Deprecate QWARN() in favor of qWarning()
The QtTest best practices documentations recommends using output
mechanisms such as qDebug() and qWarning() for diagnostic messages,
and this is also what most of our own tests do.

The QWARN() macro and corresponding internal QTest::qWarn() function
was added when QtTest was first implemented, but was likely meant as
an internal implementation detail, like its cousin QTestLog::info(),
which does not have any corresponding macro.

This theory is backed by our own QtTest self-test (tst_silent)
describing the output from QWARN() as "an internal testlib warning".

The only difference between QWARN() and qWarning(), besides the much
richer feature set of the latter, is that qWarning() will not pass
on file and line number information in release mode, but QWARN() will.
This is an acceptable loss of functionality, considering that the user
can override this behavior by defining QT_MESSAGELOGCONTEXT.

[ChangeLog][QtTest] QWARN() has been deprecated in favor of qWarning()

Pick-to: 6.2
Change-Id: I5a2431ce48c47392244560dd520953b9fc735c85
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-04 19:31:51 +02:00
Joerg Bornemann
fe9c705e9a CMake: Make qt6_wasm_add_target_helpers an internal function
This function is called by qt_add_executable.  There is no need to
expose it as public function.

Fixes: QTBUG-95172
Change-Id: I85a1d906ecda42458e226db225e47c1d348a72f1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-04 17:01:11 +02:00
Giuseppe D'Angelo
07057188e3 QFileSystemModel: cache the name filters regexps
In order to filter out file names based on the user's settings,
QFileSystemModel used to have a loop that tested if a given file
name matched one of the filters. The problem is that each filter
(a wildcard) was converted to a QRegularExpression _inside_ the loop.
This causes a quadratic behavior (number of files * number of filters).

Instead, build the regexps once when the filters are set (or the case
sensitivity is changed, as that affects the filtering), and simply
_use_ them in the loop.

Simplify and correct some related code as a drive by.

Done-with: Jean-Michaël Celerier
Fixes: QTBUG-95383
Pick-to: 6.2 6.1 5.15
Change-Id: I6bc336364c145bb05793a8f867545d7715d35832
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-08-04 14:03:21 +02:00
Marc Mutz
fa7f4c5efd QMetaType: auto-unregister converters and mutable views again
The port from hand-rolled function storage to std::function
inadvertently removed the helper variable of static storage duration
whose dtor would unregister the conversion function. This caused
QTBUG-94831, where the cleanup of conversion functions attempts to
call code (via std::function) from a library that has already been
unloaded.

Restore the 5.15 behavior by adding a static-storage-duration scope
guard to unregister the conversion and view functions from Qt upon
library unload (when static objects are destroyed). Unlike 5.15, only
install the scope guard upon successful registration, ensuring that
only the DLL which successfully registered its conversion function
unregisters it again.

Amends 0e4ae4fbf8.

Add some strategic std::move()s as a drive-by.

Pick-to: 6.2
Task-number: QTBUG-94831
Change-Id: I391ca667420cf0d98a166676b9bb363d6e190306
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-04 13:32:40 +02:00
Marc Mutz
e933d71a61 QFsFileEngine: avoid triple(quadruple) lookup of the same key
Instead of contains(), 1-2x operator[](), and remove(), equalling 3-4
separate lookups, use find() + erase(), which does just one
lookup.

Since our erase() function is C++11-compliant these days and takes
const_iterator instead of (mutable) iterator, we can use the const
find() overload to delay a detach (attempt) until we actually erase().

Change-Id: I8e67a48e221e548528049fa093ab7ef2f1802f7e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-04 07:31:23 +02:00
Nico Vertriest
a46d0b480b Doc: Fix warnings about undocumented enum and parameters
- enum 'CaptivePortal' in QNetworkInformation::Feature
- parameter 'debug' in QNetworkAddressEntry::operator<<()
- parameter 'debug' in QNetworkInterface::operator<<()

Pick-to: 6.2
Change-Id: I518bc06edee9fa4955dc6295786ab1a6be989727
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-08-03 16:03:47 +02:00
Edward Welbourne
b61a6e2507 Consolidate documentation of floating-point formatting code
Move the documentation of the format and precision parameters to
QLocale::toString(double, char, int), reference it from various
QString methods (instead of repeating there and referencing one of
those from QLocale). Add brief first lines for various documentation
comments.

Mention the special handling of negative precision in the moved
documentation. Mention QLocale::FloatingPointShortest, add its type to
\sa lines of methods it affects. Change a comment on some code
implementing its special treatment to make clear that it does apply to
'e' and 'f' formats, not only to 'g', even though it has no overt
special handling in that code; and update docs to report the
undocumented behavior the comment previously described.

Document how infinity and NaN are represented. Be somewhat more
consistent about single-quoting the format names where referred to and
applying \c to character constants.

Make clear what things are different between different methods using
these parameters. Reference QString::number() from QByteArray's
relevant methods, since they share its quirks.

In the process, rename the format and precision parameters of relevant
functions so they're consistently named, replacing a mixture of
abbreviated forms.

Pick-to: 6.2
Change-Id: I077521b30346000e4b4f6968a8e750e934f72937
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-03 14:49:57 +02:00
Mårten Nordheim
11476e5403 QLibraryInfo: Add MSVC 2022
Pick-to: 6.2 6.1 5.15
Change-Id: Ie66effde6832152ee2903c467269a2822ded6653
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-08-03 09:34:45 +02:00
Thiago Macieira
94de5f9b25 QString::localeAwareCompare: adapt to QLocale::setDefault() being called
Because we're using a thread-specific global static, we need to recreate
the QCollator type every time setDefault() is called. Since one is
stored per-thread, we simply increment a generational counter and check
that the next time that QString::localeAwareCompare is called in each
thread.

The issue was introduced on f6425da424
(5.12) even though we were supposed to be using QCollator since commit
5279134935 (5.3).

Fixes: QTBUG-95050
Pick-to: 6.2
Change-Id: I7e0b82c2d2fe464082d8fffd1696a8c9f74e5b30
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-02 17:40:12 -07:00
Thiago Macieira
4d2e574fb0 QCollator/Win: Remove WinRT remnants
USE_COMPARESTRINGEX is not defined anywhere. Its definition was removed
by commit 45b0f1be68 ("Remove winrt").

Change-Id: I7e0b82c2d2fe464082d8fffd1696a931fa301986
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-02 15:09:43 -07:00
Edward Welbourne
260168d9d7 QByteArray: don't coerce negative to unsigned for any base
This follows up on commit 98666c8afc,
which did the same for QString. If someone wants to get formatting
suitable to an unsigned value, they can cast the value to that
unsigned type and the correct overload shall pick it up.

[ChangeLog][Important Behavior Changes] QByteArray's formatting of
negative whole numbers to bases other than ten now, like QString's
(since Qt 6.0), formats the absolute value and prepends a minus sign.

Task-number: QTBUG-53706
Pick-to: 6.2
Change-Id: I91fee23d25ac0d5d5bcfcbeccbac1386627c004a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-02 23:40:56 +02:00
Li Xinwei
74083c239d Use correct MSVC runtime library for targets created by qt_add_*()
Use _qt_internal_set_up_static_runtime_library() to set correct MSVC
runtime library for targets created by qt_add_executable(),
qt_add_library(), qt_add_plugin() and qt_add_big_resources(), to bring
convenience to user projects.

Pick-to: 6.2
Change-Id: Ia49f1e90989c464820824be3e1eef3df1351cdcf
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-03 04:18:42 +08:00
Li Xinwei
a251443949 Avoid to call _qt_internal_set_up_static_runtime_library() twice
Pick-to: 6.2
Change-Id: I28985470b3e0b88befbbd2d62a027670d7d6c822
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-03 04:18:42 +08:00
Andy Shaw
ba3e1fe09b Allow dragging of a floating dockwidget on macOS with a custom titlebar
This amends 3224c6d7d1 to account for the
case when the dockwidget is already floating.

Task-number: QTBUG-70137
Pick-to: 6.2 6.1 5.15
Change-Id: If8b345565b11b44beb3fb4b697cfe812c29c6396
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-08-02 14:55:54 +02:00
Laszlo Agocs
b594374ba8 rhi: Be more graceful when one destroys a resource after the QRhi
One is a bad application or library in this case, but nonetheless
we should handle this more gracefully then just crashing due to
the QRhi already having been destroyed. Mainly because in Qt 5 one
could get away with the same: releasing OpenGL objects underneath,
for example, a QSGPlainTexture with no (or wrong) GL context did
not generate any user visible fatal errors. So we should not crash
in Qt 6 either with these code bases.

In debug builds or when QT_RHI_LEAK_CHECK is set, one will get the
unreleased resources warning printed in Qt 6, which is a step
forward compared to Qt 5. So there is still some indication that
something is badly designed, even if the application survives.

Task-number: QTBUG-95394
Pick-to: 6.2
Change-Id: I944f4f425ff126e7363a82aff926b280ccf1dfc3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-08-02 14:35:33 +02:00
Morten Johan Sørvig
ee68257b61 Fix PerMonitorV2 DPI aware NonCLientAreaScaling handling
The value returned from shouldHaveNonClientDpiScaling()
controls two related behaviors:

1) Should Qt call user32dll.enableNonClientDpiScaling()
2) Should Qt code treat NonClientAreaScaling as enabled.

Commit c35643db updated shouldHaveNonClientDpiScaling()
to account for the fact that PerMonitorV2 always enables
NonCLientAreaScaling, with the intent to disable 1)
However this also disables 2), which was not intended.

Instead, make shouldHaveNonClientDpiScaling() always
return true when PerMonitorV2 is enabled, and then also
omit calling the user32dll API in this case.

Change-Id: I1d06f36a3d06becc667351fadcb00ab28af6ec4b
Pick-to: 6.2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-08-02 14:35:33 +02:00
Tor Arne Vestbø
6e25017922 macOS: Stop relying on balanced CGDisplay reconfiguration callbacks
We were using CGDisplay callbacks to determine when a screen reconfiguration
had happened, and when it had propagated to changes in NSScreen.screens,
so that we could update our QScreen view of the world.

Unfortunately the CGDisplay callbacks were not deterministic enough to
use as a signal for when a reconfigure had completed.

Since we can't rely on NSApplicationDidChangeScreenParametersNotification
either (it comes in too late), we're now resorting to updating our QScreens
at every chance we get:

 - On every CGDisplay reconfiguration ending
 - On QCocoaWindow::windowDidChangeScreen() as a result of AppKit
   moving the window.
 - On NSApplicationDidChangeScreenParametersNotification
 - On QCocoaScreen::get() as a last resort

Since the result of these updates are only reflected as QScreen property
updates or QGuiApplication signals if a change actually occurred, it should
be safe to update early and often.

Task-number: QTBUG-77656
Fixes: QTBUG-80193
Pick-to: 6.2 6.1 5.15
Change-Id: I98334a66767736d94ad2fcb169e65f0d8bc71a30
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-08-02 12:16:24 +00:00
Alexandru Croitor
c13b98d9bc CMake: Bump project versions
Fixes: QTBUG-95454
Change-Id: I2467d3ae27b54424e59a7a4ab00d364eaec517d5
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2021-08-02 12:42:29 +02:00
Mårten Nordheim
e3f10a2760 QByteArray::number/setNum(double): Reverse dependency
Currently number(double) creates a QByteArray-instance and calls
setNum(double).
setNum(double) creates a QByteArray-instance and copy-assigns it to
itself.

By making setNum(double) call number(double) we can cut one creation
from numbers(double)'s path, and making setNum no worse than it was.

The other pairs of setNum/number are left alone as they don't have this
issue.

Change-Id: Ib611ebc78db64f74244a56cb8e384e42bc7d1758
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-02 09:39:45 +02:00
Assam Boudjelthia
50f53b9022 Pass QDeadlineTimer by value in runOnAndroidMainThread()
Also change the timer default value to use QDeadlineTimer::Forever.

Pick-to: 6.2
Change-Id: Ia6d0101872a5d01b04e146cd9b2f90315cb8eb2e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-08-01 21:13:07 +00:00
Alex Trotsenko
6f682d4876 QLocalSocket: always open outer QIODevice in unbuffered mode
The actual buffering is performed either in the inner socket (Unix),
or in the pipeReader (Windows). To avoid unnecessary copying of data
between buffers, enforce unbuffered mode for all implementations,
which slightly improves read performance.

Change-Id: Idb2a09f35823b9945c71231710290be12d9930f7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-08-01 21:06:45 +03:00
Alex Trotsenko
3bc976c2bd QIODevice: allow subclasses to enforce unbuffered mode
For subclasses that implement alternative buffering (such as
QLocalSocket), it would be useful to bypass the QIODevice's internal
buffer, even if the QIODeviceBase::Unbuffered flag is not set when
opened.

By setting the readBufferChunkSize member to 0 in their constructors,
these classes now unconditionally switch the base class to unbuffered
mode, while still reporting buffering with openMode() function.

Change-Id: I351bc57ac0ccb45c81f8c6be15f1745131aa26ba
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-08-01 20:20:46 +03:00
Shawn Rutledge
69c833dae9 Register mouse devices on cocoa
It would have been nice to ensure that a device is registered already in
mouseEnteredImpl(); but in that context, NSEvent.deviceID is always 0,
and we can't find out anything else about the device.
QWindowSystemInterface::handleEnterEvent() doesn't currently take a
QPointingDevice either.

In handleMouseEvent() and scrollWheel(), deviceID seems unique for each
trackpad or Magic Mouse, but 0 for any plain USB mouse. There, the first
mouse that the user interacts with becomes primaryPointingDevice():
its deviceID is assigned to systemID (except if deviceID == 0, we use
1 instead, to avoid the auto-incrementing device ID assignment in the
QInputDevicePrivate ctor.) When scrolling occurs, we update the
capabilities to have PixelScroll if theEvent.hasPreciseScrollingDeltas.

So over time, QInputDevice::devices() should build up to a complete
list, with capabilities() also distinguishing plain mice from those that
have the PixelScroll capability. And in the common case that the user
has only one Apple pointing device, it becomes primaryPointingDevice().

Pick-to: 6.2
Task-number: QTBUG-46412
Task-number: QTBUG-63363
Task-number: QTBUG-72167
Change-Id: Id9771b4dfd765e49023bd57d42a2aa4d0635a3b2
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-08-01 15:32:41 +02:00
Tor Arne Vestbø
07d8885ccc Update QAbstractItemModelTester::FailureReportingMode documentation
The key part of FailureReportingMode::QtTest is that it will result
in a test failure (via QTest::qVerify); not that it's using the
QtTest logging machinery.

Pick-to: 6.2
Change-Id: I18472fba173ce1323748f1f87301a4defa87020e
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2021-08-01 12:44:14 +02:00
Alex Trotsenko
9f092c1077 QIODevice: rework validation policy for read() functions
- avoid calls to private and virtual functions, if the device is not
  open;
- avoid repetitive checks in loops;
- add missing checks in readLine() overloads;
- remove check against unsuccessful resize().

Change-Id: I973d5931163b25db1c09c7c3b66f29ea90bb1b29
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-08-01 10:50:32 +03:00
Alex Trotsenko
21f3ff65b8 QLocalSocket: do not emit aboutToClose() twice
This signal is emitted by the QIODevice itself, so we don't have to
forward it from the internal socket.

Pick-to: 6.1 6.2
Change-Id: I85745f36d7a27d92f339a9184de3b6e5d46f6f34
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-08-01 10:50:15 +03:00
Alex Trotsenko
6e3897b9fa QIODevice: fix converting OpenMode flag in debug output
Suppress error:

src\corelib\io\qiodevice.cpp(791): error C2440:
 '<function-style-cast>': cannot convert from 'QIODeviceBase::OpenMode'
  to 'quint32'

Pick-to: 6.1 6.2
Change-Id: I6b6e94790942d3af62bc2f38afad97c0b3c80817
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2021-07-31 15:19:48 +03:00
Marc Mutz
615a9cf991 QUuid: port to QAnyStringView
Remove the QString/QStringView/QLatin1String/const char* overloads
from the API, but not the ABI.

As a drive-by, replace a use of QStringView::left() by truncate(), as
suggested by a comment.

[ChangeLog][QtCore][QUuid] The from-string constructor and the
fromString() function now take QAnyStringView (was: overload set with
a subset of QString, QByteArray, const char*, QLatin1String,
QStringView each).

Change-Id: If7fa26cfbef9280480c78b669d9f5f14118995ed
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-07-30 22:54:28 +02:00
Marc Mutz
09fba5cf36 QWindowsFontDatabase: port local QSets to QDuplicateTracker
Apart from a more fitting, minimal, API, QDuplicateTracker also
transparently uses C++17 pmr::monotonic_buffer_resource to avoid, or
at least reduce, memory allocations.

Change-Id: I155f5518190c5f8f6d21fbec3fcecd6bcc7ff852
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-07-30 15:59:55 +02:00
Assam Boudjelthia
72e5b36e2e Remove app permission API from QCoreApplication
From the API review session, a potential deadlock behavior might
occur when using QFuture's synchronous APIs on the UI thread. Also
the fact that this api currently have an implementation only for
Android. For those reasons we thought this API could be postponed
until Qt 6.3, when the QFuture concern is addressed and other
platforms other than Android are implemented as well.

Pick-to: 6.2
Change-Id: I1aef025488c24791da85d15fb57367d3e5e681be
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-07-30 14:46:55 +03:00
Edward Welbourne
b72fa182b4 Correct a #include in a comment in qglobal.h
The comment indicates how to use QT_BUILD_REMOVED_API, which includes
a #include of qglobal.h; but we have a tool, run somewhere in
configure, that grumbles about this #include (unaware, I suspect, that
it's in a comment), saying we should #include <QtCore/qglobal.h>; so
change the comment to say that. Presumably this is our recommended way
to do includes, so we should follow it when suggesting how to write
code.

This amends commit 0c8b98774c.

Change-Id: I4683ad6f1c0eedec3eaa02ac40c5d017059a49b0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-07-30 12:35:09 +02:00
Oliver Wolff
5f5c342924 Remove Windows 7, 8, and 8.1 codepaths
Pick-to: 6.2
Task-number: QTBUG-84432
Change-Id: I970d7d7e9ebdcf246a5be32d60066b4e5e948c27
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-07-30 08:02:56 +02:00
Yuhang Zhao
2c6bc06267 Windows QPA: Remove DwmIsCompositionEnabled() usages
According to Microsoft Docs [1], DWM composition is always
enabled and can't be disabled since Windows 8. Now that
we are cleaning up pre-Windows 10 code, this apparently
needs to be removed as well.

[1] https://docs.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmiscompositionenabled

Task-number: QTBUG-84432
Change-Id: I64dc049e0741600c8d0ae4db0e9e3bc98a211339
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
2021-07-30 01:08:15 +00:00
Tor Arne Vestbø
7c14223b1e testlib: Update a few remaining instances of the deprecated -xunitxml format
The format was renamed in 27db9e458c.

Pick-to: 6.2
Change-Id: I53975c7467d8768dc9dc9ac2d89c42eefa12e22f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-07-29 18:46:39 +02:00
Alexandru Croitor
3c23317552 CMake: Make WrapVulkanHeaders target optional for QtGui consumers
If Vulkan headers are present on the system when qtbase is configured,
QtGui and QtOpenGL should be compiled with Vulkan support.

If a user project uses a Qt built with Vulkan support, but their system
is missing Vulkan headers, the project configuration needs to succeed.

The project will get compilation errors if it uses Vulkan headers, but
that's intended.

This use case was broken when fixing Vulkan to be found when building
Qt for Android.

Fix the regression with a combination of things
1) Mark the WrapVulkanHeaders package as optional (already the case)
2) Use the include directories directly when compiling Gui and OpenGL
3) Propagate WrapVulkanHeaders::WrapVulkanHeaders link requirement to
   consumers only if the target exists. It won't exist if Vulkan
   include dirs are not found

This also requires some changes in pri and prl file generation.

For prl file generation, we don't want to link to the
WrapVulkanHeaders target, so we filter out all dependencies that
use TARGET_NAME_IF_EXISTS for anything that calls
__qt_internal_walk_libs which includes qt_collect_libs.

For pri files, we make sure to generate a uses=vulkan/nolink clause
by inspecting a new _qt_is_nolink_target property on the target.

We also don't add include dirs to the pri file if the new
_qt_skip_include_dir_for_pri property is set.
This is intended for Vulkan, because there is separate qmake logic to
try and find the include dirs when configuring a user project.

As a drive-by, fix nolink handling for WrapOpenSSLHeaders.

Amends bb25536a3d
Amends 7b9904849f

Pick-to: 6.2
Fixes: QTBUG-95391
Change-Id: I21e2f4be5c386f9e40033e4691f4786a91ba0e2d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-29 16:38:50 +02:00
Ivan Solovev
e150bcfe4d QByteArray: fix indexOf/lastIndexOf
This patch fixed two bugs in indexOf/lastIndexOf:
1. The lastIndexOf(char, qsizetype) overload was crashing with an empty
   QByteArray. It was unconditionally calling lastIndexOfCharHelper()
   which assumes that this QBA is not empty. An explicit check for
   the empty case is added.
2. The indexOf(QByteArray, qsizetype) overload was behaving incorrectly
   while searching for an empty QByteArray. In this case it
   unconditionally returned its second parameter (from). However, from
   can be negative, or even exceed the size of this QByteArray. This
   patch handles this cases properly.

As a drive-by: this patch adjusts the QByteArray::indexOf(char, qsizetype)
and QByteArray::lastIndexOf(char, qsizetype) overloads to match with the
QByteArrayView implementation. This is done to have similar code paths
in both cases and avoid tricky bugs in future.
Ideally we had to adjust the QByteArrayView implementation, but it's
fully inline, so can't be changed without breaking BC.

Task-number: QTBUG-91736
Pick-to: 6.2 6.1
Change-Id: Iaef2fdc5b99cce6aa342cca2d17544a1ad7ca677
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-07-29 15:00:35 +02:00
Marc Mutz
c61d9873e5 QPrivateSlotBase: add empty base class optimization
There are few slots whose lambdas are empty; most will at least
capture [this]. But there are a few in Qt examples that do, e.g. []{
qApp->quit(); }. Logging is also an example. So go the extra mile and
optimize for empty functors by inheriting from them as opposed to
storing them in a member variable.

Change-Id: I3904f10db5ebe904ba889d29c08569edd804df3b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-07-29 15:00:35 +02:00
Marc Mutz
3c683a8a8d QSlotObjectBase: document relation between m_impl and Operation better
Change-Id: I02bfe1857a9c2b781f7ad891e813fd6818fab671
Reviewed-by: Ivan Tkachenko <me@ratijas.tk>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-07-29 13:35:55 +02:00
Alexander Volkov
0a8aa8c23e Doc: Fix typo Ctr -> Ctrl
Pick-to: 6.1 6.2
Change-Id: I89c9526aa74b312dd67a6d194395b3298bbc31fe
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-07-28 21:00:36 +03:00
Marc Mutz
767e00a2d7 QUuid: port fromRfc4122() to QByteArrayView
Remove the QByteArray overload from the API, but not the ABI.

Adapt callers.

Change-Id: I88aa09cbca3b89d0b249ce336ebe49c4b352c9e1
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-07-28 17:50:09 +02:00
Marc Mutz
3a72496b5c tests: fix some -Wvolatile
C++20 deprecated compound volatile statements such as pre- and
post-increments, to stress that they're not atomic. So instead of

    volatile i;
    ~~~~;
    ++i;

you're now supposed to write

    volatile i;
    ~~~~;
    int j = i; // volatile load
    ++j;
    i = j; // volatile store

which matches more closely what hardware does.

Instead of fixing every use of volatile pre- or post-increment in this
fashion individually, and realising that probably a few more Qt
modules will have the same kind of code patterns in them, write
QtPrivate functions to do the job centrally.

Change-Id: I838097bd484ef2118c071726963f103c080d2ba5
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-07-28 17:50:09 +02:00
Nicolas Fella
74a91773af [qgenericunixservices] Consider kde-open5 for opening URLs
When xdg-open is not found the KDE-specific kfmclient is considered.
That however is part of Konqueror and may not be present as well.
Plasma offers another option, kde-open5, which should be considered
before falling back to webbrowsers.
This is particularly for non-http URLs like tel: where opening in a
webbrowser is not wanted.

Pick-to: 6.2 6.1 5.15
Change-Id: I2b606562e21568fbe43f4593de67a1d467918cc4
Reviewed-by: David Faure <david.faure@kdab.com>
2021-07-28 16:37:10 +02:00
Timur Pocheptsov
4c0f81490b Provide new code paths for OpenSSL v3
With OpenSSL v3 it would be possible to compile-out functions,
directly working with entities like RSA, DSA, DH and EC_KEY.
For this you have to define OPENSSL_API_COMPAT >= 0x30000000L.
This would break QSslKey and QSslContext.
To mitigate this potential problem, we switch to the 'generic'
API, that works with EVP_PKEY instead. All functionality
will be preserved, except inability of QSslKey::handle()
to get pointers to RSA, DSA, DH or EC_KEY.

Fixes: QTBUG-95122
Pick-to: 6.2
Change-Id: Ic85b48502421c4330cf4877b52850539c855fa74
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-07-28 16:24:24 +02:00
Marc Mutz
25fff849e8 QDirIterator: add nextFileInfo()
Before this change, next() was the only way to advance the iterator,
whether the caller was ultimately interested in just the filePath()
(good) or not (bad luck, had to call .fileInfo()).

Add a new function, nextFileInfo(), with returns fileInfo() instead.
Incidentally, the returned object has already been constructed as part
of advance()ing the iterator, so the new function is faster than
next() even if the result is ignored, because we're not calculating a
QString result the caller may not be interested in.

Use the new function around the code.

Fix a couple of cases of next(); fileInfo().filePath() (just use
next()'s return value) as a drive-by.

[ChangeLog][QtCore][QDirIterator] Added nextFileInfo(), which is like
next(), but returns fileInfo() instead of filePath().

Change-Id: I601220575961169b44139fc55b9eae6c3197afb4
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-07-28 15:16:42 +02:00
Mårten Nordheim
a3889e1cc4 QSysInfo: Delete pre-windows 10 code
It's not supported.

Change-Id: Id8c6ca7e7ad152620c76b5479ca495e9f64cc354
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-07-28 13:18:50 +02:00
Mårten Nordheim
6a51ff3f0d io: Remove version checks for versions below Win 10
It's not supported.

Change-Id: Ia17fc7e1d5ae785eca0a6ba530f9b9bc960605d4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-07-28 13:18:50 +02:00
Mårten Nordheim
c877e9760b QEventDispatcher: Remove code dealing with Windows < 10
It's not supported.

Change-Id: I650a48f214bc4965b5e28f04e4f095273d7f9e5b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-07-28 13:18:50 +02:00
Marc Mutz
becb3596f0 QtCore: clean up API removals
Use the same new pattern as in QtWidgets.

Amends de18b3ff37.

Change-Id: Ia1cbd40aa7a7efc9a954d22b599e13a19a6a9266
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-07-28 09:43:03 +02:00
Marc Mutz
d3ecc6db29 QMenuBar: remove addAction() functions
They're now in QWidget itself. Remove them from the API, but not the
ABI.

[ChangeLog][QtWidgets][QMenuBar] The addAction() functions have been
moved down into QWidget.

Change-Id: Iaa023ff227686e8e67a2b5594f0fbc31b95177a3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-07-28 02:01:21 +02:00
Marc Mutz
99f0db695a QNetworkReply: hold QAtomicInt in shared_ptr, not QSharedPointer
Ditto QNetworkAccessAuthenticationManager.

QSharedPointer performs twice as many atomic operations per pointer
copy as std::shared_ptr, and this is private API, we're not bound by
BC constraints, so we can port to the more efficient version.

Change-Id: I59dc09ff4eb3b4acf5d7a68695752a9a7110d8d3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-07-28 02:01:21 +02:00
Paul Wicking
017eb5627b Doc: Add missing comma
Fixes: QTBUG-95379
Pick-to: 6.2
Change-Id: Ie66feccff27d055a4ebd4f7b26313910934ad234
Reviewed-by: Nico Vertriest <nico.vertriest@qt.io>
2021-07-28 01:43:09 +02:00
Giuseppe D'Angelo
cc584c59de QMap: add operator+ and - for iterators
We missed the chance of deprecating them in 5.15, so
they'll just add to the pain of porting to 6.0. We
should not keep them around forever, though; QMap isn't
random access and so its iterators should only have
bidirectional APIs.

Pick-to: 6.2
Fixes: QTBUG-95334
Change-Id: I3577f7d25e8ab793722d2f220fd27bc85c622b0d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-07-27 23:48:29 +02:00
Fabio Falsini
7d7f09d556 Add Android service check on quit app
When quitApp() delegates the quit action to runAction(), this
function only checks if an activity exists. If the process is
a service, rather than an activity, it has no activity, so the
action is skipped and the service is not exited.

Check in runAction() for a service as well as an activity.

Pick-to: 6.2
Change-Id: Iec6f0550064506a780892d3d840f7488fc894569
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-07-27 22:45:57 +02:00
Daniel Nicoletti
8f75ab231f Allow to set Local Socket listen(2) backlog
Unix sockets do not suffer from SYN flood, thus the hardcoded value to
50 is size of the only queue to hold connections to be accepted,
resulting in dropped connections when the limit is reached.

On Windows the hardcoded value is 8, this patch changes the default to
50 matching UNIX.

[ChangeLog][QtNetwork][QLocalServer] Added setListenBacklogSize() to
be able to have control over the listen backlog feature.

Change-Id: Iaee6349a46b75b0bd05e40e7ade5948f1cf9f407
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-07-27 16:47:31 -03:00
Ivan Tkachenko
e4fd86d53a Deduplicate offset calculation in QMetaObjectBuilder
Not even an optimization (unless your compiler sucks). Just improves
readability, since offset is already calculated few lines above.

Offset formula used to be somewhat more complicated, but since commit
e58b44d557 it became reusable here.

Change-Id: I4128b2643daf2cb112c9b861342fd0e27c9a1a95
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-07-27 19:21:36 +00:00