Commit Graph

52850 Commits

Author SHA1 Message Date
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
Ievgenii Meshcheriakov
5b01399781 tst_qurl: Make an invalid URL test compatible with UTS #46
Use U+1F100 DIGIT ZERO FULL STOP instead of U+1F4D9 ORANGE BOOK.
The latter is not allowed according to IDNA 2003 rules but is allowed
according to UTS #46 rules. The former is disallowed in either case.

Task-number: QTBUG-85371
Change-Id: Idc8afef68c26ae0b702a475e5a53592182998a08
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
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
Joerg Bornemann
d9f8b68963 Revive tst_qresourceengine
This test was not ported to CMake yet.

Pick-to: 6.2
Fixes: QTBUG-88601
Change-Id: Ied3b1a0e2ddfbcf003cb0d8d01d5f64cb83cf4e7
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-24 23:27:30 +02:00
Robert Löhning
8694104809 Fuzzing: Remove .pro-files of libfuzzer tests
They were replaced by CMake files and oss-fuzz was updated to use the
latter. No need to still maintain qmake based builds.

Change-Id: If38f39c23ef3a58c33c428341486b62fd0a81888
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-24 22:04:38 +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
Alexey Edelev
abb19da572 Add missing PRIVATE_MODULE_INTERFACEs to INTERNAL_MODULEs
To detect the internal module ouside the qt_internal_add_module
function need to mark it with the property.
This adds _qt_is_internal_module property to the Qt internal modules.
Since PRIVATE_MODULE_INTERFACE only was applicable to pure Private
modules, INTERNAL_MODULEs is missing those dependencies if they were
specified. Add extra condition to qt_internal_extend_target to link
PRIVATE_MODULE_INTERFACE libraries to internal modules as well.

Pick-to: 6.2 6.1
Change-Id: I9c32fa5bad3aff365f5d7663349e5365d5f1d72d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-24 20:58:39 +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
Joerg Bornemann
278368b523 CMake: Fix excessive size of precompiled header files
Do not add catch-all header files like QtCore, QtGui, etc. to
precompiled headers for targets that already define their own set of
precompiled header files.

This reduces the size of the precompiled headers and brings the pch file
sizes down into the region of the qmake build.

Pick-to: 6.2
Task-number: QTBUG-89122
Change-Id: I8e4d17aa6829c7d7b1aa01a01a61b6677e22c460
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-24 14:50:12 +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
Tor Arne Vestbø
7d45f2d0b9 macOS: Add debug keyboard layout for manual testing
Pick-to: 6.2
Change-Id: Ie35f7a57c6d54c1cc0a7b79d8fd25d0b056bf5e6
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
Edward Welbourne
3878a17137 Use constexpr for constants and ranged-based for loops
In the process, actually use the constants as the size of some arrays,
instead of making [1024] arrays and then only using a few entries.

Change-Id: I9f36b322840393b8680788190cf8b40a828f4957
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2021-08-23 15:11:49 +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
Edward Welbourne
eec25c7807 Fix the (currently unbuilt) qdir/tree/ benchmark
It tried to find its test-data-directory locally, instead of asking
FileSystem where it was keeping its files, relative to a temporary
directory. Its expected counts didn't match the arcane results of its
data file; since this is a benchmark, not a regression test, I'm
assuming that's just because it was never right or the rules for
QDirIterator's filtering have changed.

Tidied up somewhat in the process.

Change-Id: Ib2dcd314b11cb0f1a6fc425633afd0e9c39bd036
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2021-08-23 14:39:44 +02: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
Martin Storsjö
70df6052d8 tst_QPluginLoader: Simplify creating a fake pointer in fakeplugin.cpp
When assigning multiple variables to a specific section, both GCC
and Clang legitimately error out if those variables wouldn't end
up in the same section (e.g. if one of them is going to a read-only
section while the other one is going to a read-write section).

In C++, when a seemingly const variable needs dynamic initialization,
it needs to be stored in a read-write section.

Clang 13 changed internals for how some constants are materialized.
Now, when a variable is initialized with an expression containing
plain old fashioned casts, it is considered to be potentially
runtime initialized (at the point when section assignment conflicts
is evaluated). Therefore, Clang 13 errors out on fakeplugin.cpp
with errors like:

    fakeplugin.cpp:36:39: error: 'message' causes a section type conflict with 'pluginSection'
    QT_PLUGIN_METADATA_SECTION const char message[] = "QTMETADATA";
                                          ^
    fakeplugin.cpp:32:40: note: declared here
    QT_PLUGIN_METADATA_SECTION void *const pluginSection = (void*)(0xc0ffeec0ffeeL);
                                           ^

See https://bugs.llvm.org/show_bug.cgi?id=51442 for discussion
on the matter in Clang.

To simplify things, just initialize the fake pointers as regular
uintptr_t instead, avoiding the whole matter. This produces the
exact same contents in the section as before.

For what it's worth, the actual manually constructed metadata in
fakeplugin.cpp doesn't seem to have any effect on running the
QPluginLoader tests on either ELF or MachO right now.

Change-Id: Ib84a2ceb20cb8e3a1bb5132a5715538e08049616
Pick-to: 6.2 6.1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-20 22:19:58 +03:00
Joerg Bornemann
1ac947e3af Add missing -help argument to qt-configure-module
Now it's possible to display a configure help screen per module with
  qt-configure-module <module-source-dir> -help

Pick-to: 6.2
Fixes: QTBUG-95943
Change-Id: I7d26006246af4b38b5a2ec6deca3f45c5313afec
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-20 19:44:43 +02:00
Joerg Bornemann
57ad532e75 Fix our usage of CMake script mode in Windows configure
This is a preparation for adding the -help argument to
qt-configure-module.bat.

Consider the call
  qt-configure-module.bat path/to/qt-module -help
Internally, we called
  cmake ... -P .../QtWriteArgsFile.cmake path/to/qt-module -help
which was supposed to separate the arguments and write them into
config.opt.

However, passing arbitrary arguments after "-P script.cmake" only worked
by accident and is not supported.  As soon as arguments are passed that
are valid CMake arguments, like -help or -G, the CMake call would fail.

Now, we let configure.bat and qt-configure-module.bat write the
arguments as is into config.opt.in and let QtWriteArgsFile.cmake read
this file, separate the arguments and write config.opt.

Pick-to: 6.2
Task-number: QTBUG-95943
Change-Id: I80f298a2aaf55b0f79fed86320a055eb2d2b6faa
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-20 19:44:43 +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
Joerg Bornemann
6e48d654d7 Don't force lld for Android when clang is used
This reverts commit 64c111e10f.

The claim of the commit message, that we cannot use the gold linker,
does not seem to be true (anymore?).  This is underlined by the fact
that CMake *forces* the gold linker for Android, whenever LTCG is
enabled (see Modules/Compiler/Clang.cmake as of CMake 3.21.1).

Change-Id: I90edac8555be4abdd44cd367228aeffb0d66b895
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-08-20 17:19:20 +02:00