Commit Graph

52798 Commits

Author SHA1 Message Date
Joerg Bornemann
a477a56d5b Doc: Note that qmake's CONFIG values are case-sensitive
Pick-to: 5.15
Fixes: QTBUG-95827
Change-Id: Ie7b373c547b04a0ebe0b4b93dd0ec0c12e445b2e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-18 14:17:29 +00: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
Joerg Bornemann
b9e8d85fb2 Fix framework dependencies in .la files
"-framework Foo" arguments must be placed in the inherited_linker_flags
variables instead of dependency_libs.

Pick-to: 5.15
Fixes: QTBUG-2390
Change-Id: Idec4115533ed1f86f44db64931fa64cadeeb4572
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-17 23:35:23 +02:00
Alexandru Croitor
ae6a8ddf45 CMake: Remove deprecated CFBundleLongVersionString from Info.plist
The CFBundleLongVersionString Info.plist entry has been deprecated and
removed from Apple documentation for a long time now.

Remove it.

Pick-to: 6.2
Task-number: QTBUG-95838
Change-Id: I4e4f74e00d678fd67875976c8884a80cdbb8cec4
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-08-17 21:30:34 +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
Alexandru Croitor
3d2dc88850 configure: Fix iOS option to be passed for both platform and xplatform
Task-number: QTBUG-95838
Pick-to: 6.2
Change-Id: If0617e1d9c47595d4a350a91ab4f7d47546ebf08
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 21:30:34 +02:00
Alexandru Croitor
67dae9e6ee CMake: Save value of QT_UIKIT_SDK in QtBuildInternalsExtra.cmake
The value of QT_UIKIT_SDK is used in configure tests via
qt_config_compile_test -> qt_get_platform_try_compile_vars.

Up till now QT_UIKIT_SDK was only available in qtbase only.

Save the value in BuildInternals to ensure it's used for other repos
as well.

Change-Id: I46f372267782f1c8e7d48c237fe0264ac72d33bb
Pick-to: 6.2
Task-number: QTBUG-95838
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 21:30:34 +02:00
Alexandru Croitor
fe40e08da4 CMake: Fix building iOS projects with a single-arch Qt build
Automatically set the CMAKE_OSX_SYSROOT and CMAKE_OSX_ARCHITECTURES
values with the ones Qt was configured with, when configuring a user
project with the Xcode generator and a single arch / sdk Qt build.

This ensures that calling xcodebuild from the command line chooses the
correct architecture and SDK when building the project.

Allow to opt out of this behavior by passing
QT_NO_SET_OSX_ARCHITECTURES and QT_NO_SET_OSX_SYSROOT.

Amends 55a15a1c1b
Amends a6a3b82ffb

Pick-to: 6.2
Task-number: QTBUG-95838
Change-Id: Ifab16e9eee3100a9b80a2a14b3ea29ba8d9aa6fc
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 21:30:34 +02:00
Joerg Bornemann
ff00ef6410 Raise cmake_minimum_required to VERSION 3.16 in examples
Pick-to: 6.2
Task-number: QTBUG-95636
Change-Id: I1270b4846d8a23bc3563b6942c0910e095d2be4a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-17 19:18:54 +02:00
Joerg Bornemann
153fd84c8a CMake: Suggest "ninja install" for multi-config builds
The configure summary now suggests "ninja install" for Ninja
Multi-Config builds, because "cmake --install ." does not install all
configurations.  See CMake upstream issue #21475.

Pick-to: 6.2
Change-Id: Ie3129a906945db9d09c6772ce66ec7239797b8fc
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-17 19:18:54 +02:00
Edward Welbourne
4ccbd751f1 Use a scope-guard to take care of process deletion in a test
Doing the deletion at the end of the block only works if the test
passes. Drive-by: remove spurious braces from single-line bodies of
single-line controls. The QTest macros are done properly.

Pick-to: 6.2 6.1 5.15
Change-Id: I83002547dba49ab9792f4db44d73151b1c036900
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2021-08-17 19:18:54 +02:00
Edward Welbourne
2684deaf26 Attempt to unwedge tst_QThread::wait3_slowDestructor()
When the test failed, it never released the blocking slot, so the
tested thread remained blocked indefinitely. Blacklisting doesn't
rescue that: the test run gets killed by Coin's watchdog.

Use a QScopeGuard() to release the clocked slot on failure.
replacing the release that was happening only on success.

As drive-by clean-up, smarten up the code a little and remove an
unused enum.

Pick-to: 6.2 6.1 5.15
Change-Id: Ie035dafe6e4b1d82aea5de38ceb31c0f7fcf81d7
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2021-08-17 19:18:54 +02:00
Edward Welbourne
ebcc8413f2 Expand testing of QEXPECT_FAIL()
Test both Abort and Continue cases. Test more with successive marked
as expected failure. Test cases with a QSKIP after the marked check.
Unify data functions where practical.

Change-Id: I2eade5e4dd0907d23e37137ce3d93cd5ca79f802
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-17 16:28:27 +02:00
Ievgenii Meshcheriakov
a7484002a3 tests: Remove unused SRCDIR defines
Remove SRCDIR defines from tests that don't use them. There is a
standard define called QT_TESTCASE_SOURCEDIR that is available to all
tests and serves the same purpose.

Pick-to: 6.2
Change-Id: I2aa237739c011495e31641cca525dc0eeef3c870
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 12:41:57 +00: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
Joerg Bornemann
eafbda4191 CMake: Fix feature evaluation for feature defines
Passing -DFEATURE_developer_build=TRUE did not add the define
QT_BUILD_INTERNAL to src/corelib/global/qconfig.h like
-DFEATURE_developer_build=ON would.

This happened, because the feature evaluation in
qt_evaluate_feature_definition did a string comparison against "ON".

Normalize both sides of the string comparison, and thus support all
booly values for features.

Pick-to: 6.2
Fixes: QTBUG-95732
Change-Id: Ibf03579c05919b35219438361fc93676b7cca7cc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-17 09:23:40 +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
Mårten Nordheim
4603d7e231 QString/QByteArray::number(double): Test big numbers
Exhausts the entire buffer which double-conversion is left to work with.
Also has a large amount of precision, which apparently we need to store
temporarily.

Task-number: QTBUG-88484
Change-Id: I87e8c323676465f1b8695e086020df1240d0d0d7
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-17 03:53:45 +02:00
Joerg Bornemann
b43afd5315 CMake: Make precompiled headers work for Android on Windows
When building Qt for Android on Windows, the precompile_headers test
failed if the source directory was passed as absolute path without drive
letter.  See CMake upstream issue #22534.

Work around the CMake issue by ensuring that the path is properly
prefixed with a drive letter.

Pick-to: 6.2
Fixes: QTBUG-95652
Change-Id: I3154b6c0bb2f53533306227074b24fbbf5973b05
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-17 01:36:22 +00:00
Alexandru Croitor
6ef3d070a8 CMake: Replace usage of WIN32 with CMAKE_HOST_WIN32 in qconfig.cpp
The workaround of adding a drive letter to
QT_CONFIGURE_PREFIX_PATH_STR should be done when running on any
Windows host, not only when targeting Windows.

Amends 59c3be7117

Pick-to: 6.1 6.2
Task-number: QTBUG-87580
Change-Id: Ic6ca50aa58a4a54fb483e90fe61a907fe86cb002
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 03:36:22 +02:00
Martin Vejdarski
3c148323c0 CMake: Exclude dSYM INSTALL commands for already excluded tools in debug
Debug tools are excluded from the ALL target for debug_and_release
builds. However, when using the -separate-debug-info option, the same
exclusion wasn't being applied for their dSYM INSTALL commands,
resulting in a CMake install error.

Pass any additional install args like

  EXCLUDE_FROM_ALL COMPONENT "ExcludedExecutables"

to the installation rules of qt_enable_separate_debug_info and
install dSYMs for executables per-config in a multi-config build.

All the non-main config executable install rules are optional because
the non-main config executables are excluded from ALL.

Amends 5b136abd21

Pick-to: 6.2
Fixes: QTBUG-93999
Change-Id: I95c3ce28215c3ee535551e4b7a5fa9731f8f1c28
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 02:55:12 +02:00
Alexandru Croitor
48fa7f53cc CMake: Save QT_BUILD_BENCHMARKS and other info in BuildInternalsExtra
So that those values are used when configuring other repos in a
per-repo build arrangement.

Pick-to: 6.2
Change-Id: I5ff86260116c52afc87d7fcd5cbd047fcb9dde22
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-17 02:55:12 +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
01fdc17493 Add benchmark for QMetaEnum
Change-Id: If57f00b14713f2083260a00fd833da62d6f1cd57
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
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