Commit Graph

13900 Commits

Author SHA1 Message Date
Jani Heikkinen
0cbb471b1b Bump version to 6.5.0
Change-Id: I83a4f915a914bdc18f6706bb902f3e3b13da074f
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2022-06-06 13:23:59 +03:00
Eirik Aavitsland
f67d89ebde Support cosmetic brush patterns in the pdf and opengl paint engines
This implements the recent functionality extension of painting
cosmetic (untransformed) brush patterns, and the corresponding
NonCosmeticBrushPatterns render hint, in the pdf and opengl paint
engines.

As part of the implementation it also fixes a couple of pre-existing
bugs in the opengl engine, relating to updating the brush after
changes in transformation or brush origin.

As a driveby, it also includes a minor fix for the lance testing tool:
request stencil buffer, as that is needed and not always provided by
default. This echoes a recent fix done to tst_baseline_painting.

Change-Id: Ia8811477e015eebeb40ed138bca96643ce1ab0dc
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-06-04 21:15:42 +02:00
Giuseppe D'Angelo
f8c5f4b7b5 QTest::toString benchmark: do not pass a template type parameter
Let it to be deduced, otherwise it may force instantiations which
are ill-formed.

Change-Id: I3ce674128d96a48ad6883e265734ff330645dd75
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-04 12:40:05 +02:00
Øystein Heskestad
d631e581c0 Unify QSslServer from QtWebSockets and QtHttpServer into QtNetwork
Both QtWeSockets and QtHttpServer has a QSslServer class that is useful
elsewhere. They are different though, so the new class has features
from both versions.

[ChangeLog][QtNetwork] Unify QSslServer from QtWebSockets and QtHttpServer into QtNetwork

Task-number: QTBUG-100823
Change-Id: I523f04db39297ceb9b258f673eb12deecfc6886c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-06-04 02:22:56 +02:00
Øystein Heskestad
782fbe0f63 The new signal pendingConnectionAvailable is added to QTcpServer
The new signal pendingConnnectionAvailable is emitted after a new
connection has been added to the pending connections queue. Connect
to this signal and call nextPendingConnection to handle incoming
connections.

The existing unchanged newConnection signal is emitted after the
overridable function incomingConnection is called, regardless of whether
a new connection is added to the pending connections queue in the
incomingConnection function or not.

If a subclass that overrides incomingConnection either decides to not
add all incoming connections to the pending connections queue, or to
postpone adding the connection until a handshake is successfully
completed, the pendingConnectionAvailable signal should be to used,
because this signal directly corresponds to insertions to the pending
connections queue.

[ChangeLog][QtNetwork][QTcpServer] New signal pendingConnectionAvailable
is emitted when a new connection is added

Task-number: QTBUG-100823
Change-Id: I00c76761389065f68271553e69e6c45c393a2fa8
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-06-04 00:22:55 +00:00
Ivan Solovev
0681a2dd5a QTestLib: rework QTest::compare_helper()
[ChangeLog][QTestLib] QCOMPARE now evaluates toString() on its
arguments lazily, speeding up the general case where the comparison
doesn't fail. This is true for the QCOMPARE functionality provided
by Qt. If you specialized qCompare() for your own types, then you
need to change its implementation in line with Qt's own qCompare()
specializations in order to enable this feature.

[ChangeLog][QTestLib] QCOMPARE calls with nullptr argument(s) will
now print the actual and expected values upon failure.

Previously it was not like that because of the compareHelper()
overload in qtestresult.cpp that treated the presence of
nullptr-arguments as a reason to ignore formatFailMessage() call.
New implementation does not have this check, and correctly
executes formatFailMessage() for all arguments.

Note that the qCompare() overloads that call QTestResult::compare()
internally were not affected by this patch, because they already
defer toString() invocation until the comparison fails.

Some numbers, collected against shared release developer build.
I checked how this change affects the test execution. The idea was
to pick some tests for types that do not have a specific
QTestResult::compare overload, so I picked a couple of QByteArray
tests.
The comparison is done by running a test 10 times and taking the
average execution duration, as reported in the log.

tst_qbytearrayapisymmetry:
 Before: 15.6 ms
 After:  14.2 ms

tst_qbytearray:
 Before: 41 ms
 After:  36 ms

The benefit is around 9% and 12% respectively.

Fixes: QTBUG-98874
Change-Id: I7d59ddc760168b15974e7720930f629fb34efa13
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-03 20:37:51 +00:00
Ivan Solovev
1e36eedb7f tst_QStringApiSymmetry: use QCOMPARE_EQ instead of QCOMPARE
This allows to defer the toString() invocation until it is really
needed, and so allows to speed-up the test execution.

I was testing a release shared developer build, running
tst_QStringApiSymmetry 10 times before the change, and 10 times after
the change, and then taking the average execution duration, as
reported in the log.

Before the change (using QCOMPARE): 51ms
After the change (using QCOMPARE_EQ): 45ms

As we see from the results, the benefit is around 10%.

Task-number: QTBUG-98873
Task-number: QTBUG-98874
Change-Id: Ifcfbcca1f2c1eaf82c7f1a9098fa1512a269cbf8
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-03 20:37:51 +00:00
Ivan Solovev
cc6d984390 Add QTRY_COMPARE_{EQ,NE,LT,LE,GT,GE}_WITH_TIMEOUT()
[ChangeLog][QTestLib] Add QTRY_COMPARE_{EQ,NE,LT,LE,GT,GE}_WITH_TIMEOUT
macros that repeatedly execute QCOMPARE_{EQ,NE,LT,LE,GT,GE} until either
the comparison returns true or the timeout expires. Also add
QTRY_COMPARE_{EQ,NE,LT,LE,GT,GE} macros that simply invoke the
*_WITH_TIMEOUT versions with the usual timeout of five seconds.

Task-number: QTBUG-98873
Change-Id: Ib0d7d1c8c997f442b46acd85da738a8f512cc875
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-03 22:37:50 +02:00
Ivan Solovev
343e0ff485 Add QCOMPARE_{EQ,NE,LT,LE,GT,GE}()
[ChangeLog][QTestLib] Add QCOMPARE_{EQ,NE,LT,LE,GT,GE}()
macros. These new macros behave similarly to QVERIFY(a op b),
where 'op' is ==, !=, <, <=, >, >= respectively, but print
a formatted error message with argument values in case of failure.
The formatting is done lazily, which means that the strings will
be generated only when the comparison fails.

Also add a new test for tst_selftest and generate expected output
for it.

Fixes: QTBUG-98873
Task-number: QTBUG-98874
Change-Id: Ic8074798901d7a469b1f58d5cd28bbf49a3da1db
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-06-03 22:37:50 +02:00
Edward Welbourne
3dcf1779be tst_QUrlQuery: improve formatting of lists of pairs of strings
The compare() implementation made its actual and expected seem to have
different types (using a typedef name for one, when the other was of
the type that expands to) and the formatter it used was needlessly
clunky. Use modern string literals and package a repeated
null-or-quoted representation as a lambda, inline the resulting
simplified prettyElement() into prettyPair(), which can now just take
a pair rather than an iterator. Short-cut the empty list so that the
comma-joined accumulation could initialize with the first entry and
loop over the rest, always joining with a comma.

Undo commit f776595cc10aaafc7162f382a8fa11afffb0e708's mistaken update
to the copyright header and update correctly.

Change-Id: I99258dafa01e79f9ec384d9b375a59376eb7fb53
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-03 21:53:14 +02:00
Ulf Hermann
a248d8daf5 Endian: Allow special bitfield union fields to cover the whole storage
This requires a different computation of the mask since we can't shift
out of the storage type.

Change-Id: Ife85ca3e0c5ca47f06988a397cc2f8a7e28ad0fe
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-02 14:02:44 +02:00
Marc Mutz
29b65c98e7 Short live qxp::function_ref!
This is an implementation of function_ref, which has been proposed for
inclusion into C++23, but has not been accepted, yet, which is why we
place it in namespace qxp (for eXPerimental) instead of q23.

The implementation is based on wg21.link/P0792r9, which, at the time
of writing, is the latest revision of the paper. It will be used in
both QTestLib and qmldom.

Fixes: QTBUG-103739
Change-Id: I52723eca28f7ac02ce7ce51928361d81ae5c92b1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-06-02 12:54:55 +02:00
Allan Sandfeld Jensen
f9df8512c2 Do metadata detach simpler than full detach
Avoid a full data detach when only metadata changes. This paradigm was
already used one place, and made generic.

Fixes: QTBUG-81674
Change-Id: I605253babc6ad9fc130e19e8cef3812690933ac5
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-06-01 15:54:50 +02:00
Allan Sandfeld Jensen
567ffafe7f Add new map methods for QColorTransform
Change-Id: I520fc4f4bd958472c6d6359bf671835796c677fe
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-05-31 22:23:40 +02:00
Allan Sandfeld Jensen
5ea6da55e0 Test prepared qcolortransform
Add test of explicitly prepared qcolortransform, this is a state
a transform can get into if used for an image transform.

Also cleans up the test code.

Change-Id: I9445ed114bed0edc790e14024aaae6a42989220b
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-05-31 22:23:40 +02:00
Eirik Aavitsland
5adaa8d868 Add painter render hint for brush pattern transformation
[ChangeLog][QtGui][QPainter] In Qt 5, the predefined brush patterns
would always be transformed along with the object being painted. In Qt
6.0 onwards, they would or would not, depending on the
SmoothPixmapTransformation render hint. Instead of this somewhat
surprising behavior, make the default be untransformed
(i.e. cosmetic), which makes sense when it comes to dpr scaling. For
the cases where one wants scaling, a new render hint is introduced to
enable that: NonCosmeticPatternBrushes.

Change-Id: I2208c7a28af9056d7ab97a529b66bf2d502c3c4f
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-05-31 21:20:41 +02:00
Marc Mutz
5e48a51608 Long live QAtomicScopedValueRollback (private API)!
QScopedValueRollback has a few users that apply it on QAtomicInt,
which happens to work as QAtomicInt is copy-constructible and its
ctors are implicit.

But that's of course nonsense. We don't need to store the oldValue in
an atomic, nor do we need to pass the new value into the ctor as an
atomic.

So, add a QAtomicScopedValueRollback which works on std::atomic as
well as the Qt atomics, but distinguishes between the reference (which
is atomic) and the value (which isn't), and use it in one of the
users, tst_QList.

Keep it private until we know whether there's an actual need for this.

The test is a copy of tst_qscopedvaluefallback, so the occasional
oddity (like atomic op*=) should be ignored.

Task-number: QTBUG-103835
Change-Id: I3c05b3e51f465698657a02ca5521ed465386e9a6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-05-31 19:25:52 +02:00
Thiago Macieira
23184fb6cd qglobal.h: use the GCC attribute for nothrow in C mode
There's exactly one use in Qt: the qVersion() function.

Change-Id: Ieb9a2aa1ea914b1b956bfffd16eff4b3b9e2119a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-05-27 14:12:07 -07:00
Volker Hilsheimer
31f98957cf Add compile-time generation of JNI class names
As with method signatures, register class names using template function
specialization in the QtJniTypes namespace, and then declare C++ types
as JNI classes with a class name string. Such classes implicitly get
registered as JNI types as well.

Add a QJniObject construct method (since C++ constructors that are
templates cannot be explicitly instantiated with a type), and a
QJniEnvironment::findClass overload.

Add test coverage, also for the recently added macros for native
methods.

As a drive-by, change the name of the Q_JNI_DECLARE_NATIVE_METHOD
macro to Q_DECLARE_JNI_NATIVE_METHOD for consistency.

Change-Id: Ic19562d78da726f202b3bdf4e9354e8ad24d8bd9
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-05-27 22:27:13 +02:00
David Faure
09c7457f4a QTextDocument: add setLayoutEnabled()
This allows to set up everything first - without paying for the layout
calculation at every step - and only then trigger the layout once.

Results:
 0.065 msecs to create a QGraphicsTextItem with some text (layouted)
 0.036 msecs to set everything up in a QGraphicsTextItem with 0 width

Change-Id: I138bd1d58941d029bc0a36d2730216778f1fbd97
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-05-26 16:58:42 +02:00
Allan Sandfeld Jensen
734c9f2df2 Expand QColorTransform
Add comparison operators and an isIdentity() method to detect (1-1)
transforms.

[ChangeLog][QtGui] Added QColorTransform::isIdentity() method. Added QImage::colorTransformed() transitive method.

Change-Id: I5fbcd14e75f2179e43e94e8c5f42cd0a5600790b
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-05-26 09:06:45 +02:00
Allan Sandfeld Jensen
f4b7401cdb Add test of QColorTransform
Before it was only tested indirectly as part of the qcolorspace
tests. This also fixes a rounding for maximum RGB64 values.

Pick-to: 6.3
Change-Id: I6106e662c0f9d00c0b3a0c13213cb051ea39e14e
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-05-26 02:08:38 +02:00
Fabian Kosmale
c46ee7df57 QStringConverter: Do not crash if invalid
Attempting to use an invalid QStringConverter would so far have resulted
in a crash, as we would dereference the null iface pointer.
Fix this by inserting adequate checks, and ensure that hasError returns
true if we attempt to en/decode with an invalid converter.

Pick-to: 6.2 6.3
Change-Id: Icf74bb88cd8c95685481cc0bd512da99b62f33e6
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-05-25 16:38:35 +02:00
Laszlo Papp
d83441340c QKeySequence: Add missing modifier names
The issue is that when someone is trying to use the following code:

QKeySequence keySequence(Qt::Key_Shift);
qDebug() << keySequence.toString();

This will print seemingly gibberish output. It is unicode in practice. For
Qt::Key_Shift, this would be: "�_@\uDC20"

The reason why this is happening is because we have platform-specific ways to
handle this due to Mac glyphs which are not available on Linux or Windows. This
works fine on Mac.

But for the Linux and Windows codepaths, there is not really any mapping like
for other keys. It seems that modifiers were left out.

The solution is to simply amend the list of mapping from these modifier key
codes to raw strings for Linux and Windows like it is done for other key codes.
So, now, modifiers will also be included in the list.

So, the expected output will be generated for the above code, as: "Shift".

[ChangeLog][QtGui][QKeySequence] Added missing modifier names

Fixes: QTBUG-69715
Fixes: QTBUG-40030
Change-Id: I460d54bc8e593b350ff95894f23c5b4a7c819a44
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-05-25 13:00:02 +00:00
Thiago Macieira
121ddac2ed tst_qpainter: change the FP exception block-list to a pass-list
We should prefer to test this unless we know it won't work, but this is
very hardware and implementation-dependent anyway. So I declare that
we'll only guarantee FP exception cleanliness on a best-effort basis for
a few platforms.

The notable difference in this commit is the removal of QNX. I don't
know why it began producing an FP exception with one of my changes, but
since the toolchain isn't public, I can't debug and will not devote any
time to figuring it out. If users of QNX require this, then someone with
interest in that OS will need to spend time after my changes integrate.

Change-Id: Ibcde9b9795ad42ac9978fffd16f1cb9c03a0ff66
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-05-24 23:42:53 -07:00
Ievgenii Meshcheriakov
0e64d97cc1 tst_qtextboundaryfinder: Remove full copies of data files
There are no commented out test cases remaining, so the normal
test vectors are identical to full test vectors.

Fixes: QTBUG-97537
Pick-to: 6.3
Change-Id: I987f178f192e1c8e2d998d36499fdce84f237e77
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-05-24 23:07:43 +02:00
Ievgenii Meshcheriakov
4d4d8dac94 QUnicodeTools: Fix line breaking before open parentheses
UAX #14, revision 45 (Unicode 13) has changed rule LB30 to only
trigger if the open parentheses is non-wide:

    (AL | HL | NU) × [OP-[\p{ea=F}\p{ea=W}\p{ea=H}]]

This fixes the remaining 24 line break tests.

Task-number: QTBUG-97537
Pick-to: 6.3
Change-Id: I9870588c04bf0f6ae0a98289739bef8490f67f69
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-05-24 23:07:43 +02:00
Ievgenii Meshcheriakov
40b4ad1866 QUnicodeTools: Fix line breaking for potential emojis
Implement part of LB30b introduced by UAX #14, revision 47
(Unicode 14.0.0):

    [\p{Extended_Pictographic}&\p{Cn}] × EM

This fixes one line breaking test.

Task-number: QTBUG-97537
Pick-to: 6.3
Change-Id: I3fd2372a057b7391d8846e9c146f69a54686ea61
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-05-24 23:07:42 +02:00
Ievgenii Meshcheriakov
08d2ae411f QUnicodeTools: Fix interactions of WB3d and WB4 rules
Word breaking rule WB3d should not be affected by WB4.

This fixes the remaining word break test.

Task-number: QTBUG-97537
Pick-to: 6.2 6.3
Change-Id: I99aee831d7c54fafcd2a9d526a3e078b12c5bfad
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-05-24 23:07:42 +02:00
Ievgenii Meshcheriakov
c63cdbdc43 QUnicodeTools: Handle WB3c word break rule
Adjust handling of WB3c rule to UAX #29, revision 33 (Unicode 11.0.0).

The rule reads:

    ZWJ × \p{Extended_Pictographic}

This fixes 9 word break tests.

Task-number: QTBUG-97537
Pick-to: 6.2 6.3
Change-Id: I818d4048828e6663d5c090aa372d83f5099fdffe
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-05-24 23:07:42 +02:00
Ievgenii Meshcheriakov
79d26ef3ae QUnicodeTools: Adjust properties of WSegSpace word break class
Disable break between sequences of WSegSpace characters (rule WB3d,
introduced in UAX #29, version 33, Unicode 11.0.0). Also disable breaks
between WSegSpace and (Extend | Format | ZWJ) due to rule WB4.

Adjust "words4" test to take the above changes into account (space
character belongs to WSegSpace).

Mention the full class name in a comment inside the word break table.

This fixes 34 word break tests.

Task-number: QTBUG-97537
Pick-to: 6.2 6.3
Change-Id: I7dfe8367e45c86913bb7d7fe2adb053711978487
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-05-24 23:07:42 +02:00
Ievgenii Meshcheriakov
9a831bdf54 QUnicodeTools: Fix handling of LB22 line break rule
This rule was simplified in version UTS #14 version 45 (Unicode 13.0.0)
to read:

    × IN

Re-enabled 28 fixed line break tests.

Task-number: QTBUG-97537
Pick-to: 6.2 6.3
Change-Id: I1c5565a8c1633428c22379917215d4e424ff0055
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-05-24 23:07:42 +02:00
Ievgenii Meshcheriakov
92d340ed1c QUnicodeTools: Fix handling of ZWJ for line breaks
Adjust implementation of rule LB8a of UAX #14. The rule was changed
in version 41 (corresponding to Unicode 11.0.0):

     ZWJ × (ID | EB | EM) ⇒ ZWJ ×

Fixing this rule fixes 9 line break tests. Those are re-enabled.

Task-number: QTBUG-97537
Pick-to: 6.2 6.3
Change-Id: I1570719590a46ae28c98ed7d5053e72b12915db7
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-05-24 23:07:41 +02:00
Morten Sørvig
e3b3c77d0e wasm: Improve wheel event handling
Always invert scroll deltas. This is what the code did
before, expect for on non-Safari macOS. There is no
need any "smart" code here: correct deltas are provided
by the native API regardless of macOS scroll direction
setting.

Reading webkitDirectionInvertedFromDevice is still useful
for certain use cases, such as 3D scene zooming or spinbox
value change, where upwards motion on the trackpad should
always correspond to "increment" regardless of scroll direction.
Propagate this to Qt using one of the handleWheelEvent()
overloads

Finally, we were sending pixel deltas as angle deltas;
fix by sending pixel deltas as well, but keep existing
angle delta behavior for compatibility.

Change-Id: I7a7104c30da057fefc0377816e551a9e7e2fa0e7
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Reviewed-by: David Skoland <david.skoland@qt.io>
2022-05-24 03:10:10 +02:00
Thiago Macieira
f569acd6ae tst_QStringConverter: roll up independent tests to rows in others
Simplifies the test a little.

Pick-to: 6.3
Change-Id: I77c8221eb2824c369feffffd16f0a7fc44215aaf
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-05-23 14:53:18 -07:00
Thiago Macieira
30721c3d03 tst_QStringConverter: implement the TODO of testing with flags
Pick-to: 6.3
Change-Id: I77c8221eb2824c369feffffd16f0a7e428b23fb6
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-05-23 14:53:18 -07:00
Thiago Macieira
aef27c5aa2 tst_QStringConverter: improve the char-by-char UTF-8 testing
The utf8.txt file was only 21 bytes and contained exactly two non-ASCII
characters. It wasn't very good.

This commit brings back the UTF-8 test rows that existed before commit
18ec53156e deleted tst_Utf8. There's a lot
of overlap with some of the other rows in this test, though.

Pick-to: 6.2 6.3
Change-Id: I77c8221eb2824c369feffffd16f094619b69faef
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-05-23 14:53:18 -07:00
Thiago Macieira
9bad4be214 QStringConverter: use the QUtf8 codec when Windows is using UTF-8
The QLocal8Bit implementation assumes that there's at most one
continuation byte -- that is, that all codecs are either Single or
Double Byte Character Sets (SBCS or DBCS). It appears to be the case for
all Windows default codepages, except for CP_UTF8, which is an opt-in
anyway.

Instead of fixing our codec, let's just use the optimized UTF-8
implementation.

[ChangeLog][Windows] Fixed support for using Qt applications with UTF-8
as the system codepage or by enabling that in the application's
manifest.

Discussed-on: https://lists.qt-project.org/pipermail/interest/2022-May/038241.html
Pick-to: 6.2 6.3
Change-Id: I77c8221eb2824c369feffffd16f0912550a98049
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-05-23 14:53:18 -07:00
Ivan Solovev
e2e0420028 Network: update Public Suffix List
using the description from qtbase/src/network/kernel/qurltlds_p.h.INFO

Task-number: QTBUG-103663
Change-Id: I543fa96d2538f5eb63b114fe6467fb5b0e891e3b
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-05-23 22:28:49 +02:00
Allan Sandfeld Jensen
0d97723ee2 Fix separate delete of window and windowcontainer
The documentation says we can change window parent to avoid the widget
deleting the window. That didn't work as the widget didn't get the
child-removed event as it wasn't the parent.

This patch instead uses an event filter on the set parent.

Pick-to: 6.3 6.2
Change-Id: I1f61d1832fcf3257722f305beeefd8f1abf1f656
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-05-23 21:25:46 +02:00
Volker Hilsheimer
6b02c85f87 Android: Enable building of the QLocale test case
Amends 2a893db480, which changed the
#ifdef'ery but didn't actually enable the building of the test on
Android.

Task-number: QTBUG-87414
Pick-to: 6.3 6.2
Change-Id: Id944dd3023da40ecbf4b8a324784409a63f94aec
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-05-23 19:12:06 +00:00
Volker Hilsheimer
dd8da7ebd9 Compile-time generate a JNINativeMethod from a C function
Add a template function that allows us to get the method signature
string from a free function, which are used as native callbacks methods
from Java.

Provide a macro that defines a signature object, and a JNINativeMethod
object based on it, in an internal namespace so that we don't pollute
the namespace with generated names.

Add another macro to get the generated JNINativeMethod object based on
the free function name.

Lastly, add overloads to QJniEnvironment::registerNativeMethods that
take a std::initializer_list of JNINativeMethods.

We can now declare a free function to be a JNI native method:

static bool callbackFromJava(JNIEnv *e, jobject /*thiz*/, jstring p1)
{
   // ...
}
Q_JNI_DECLARE_NATIVE_METHOD(callbackFromJava);

and register it with the JNI environment like this:

QJniEnvironment jni;
jni.registerNativeMethods(clazz, {
    Q_JNI_NATIVE_METHOD(callbackFromJava)
});

removing a significant amount of boiler plate code.

Change-Id: Ie4007b24125879fed3dae1f4d232b4aa95999b44
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-05-23 21:12:06 +02:00
Volker Hilsheimer
fb56a0f2ce Don't hide a widget that is swapped into a hidden splitter
When replacing a widget in a hidden splitter, then we only need to keep
the new widget hidden if the previous widget was hidden.

If the new widget is not explicitly hidden, and the splitter is already
visible, then we need to explicitly show the new widget.

Augment test case; the existing test cases already cover swapping out a
collapsed or hidden widget.

Fixes: QTBUG-102134
Pick-to: 6.3 6.2
Change-Id: I9b60711a5c1cab79777ce4183783114a16ac3394
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-05-23 21:12:05 +02:00
Giuseppe D'Angelo
c613dd4765 QMetaType: disable conversion from smart pointer<const QObject>
QMetaType can register a converter from a smart pointer class to
QObject *. The code tries to do so even if the smart pointer is
actually holding a pointer to a _const_ QObject
(e.g. shared_ptr<const QObject>), causing a compile error:

  ../src/qt5/qtbase/build/include/QtCore/../../../src/corelib/kernel/qmetatype.h:1208:32: error: invalid conversion from ‘const QObject*’ to ‘QObject*’ [-fpermissive]
   1208 |             return p.operator->();
        |                    ~~~~~~~~~~~~^~
        |                                |
        |                                const QObject*

Disable the conversion if indeed the source is const qualified.

Change-Id: I9e9bc5992f74131e5cfd6ece9b83d4f26d370e92
Fixes: QTBUG-103741
Pick-to: 6.2 6.3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-05-21 11:43:59 +02:00
Sona Kurazyan
bd1023a824 QtConcurrent: prevent conversion of ReduceOption to initial value
QtConcurrent map- and filter-reduce functions take an initial value,
which can be of any type that is convertable to the result type. The
side-effect of this is that the enum values passed as ReduceOptions can
be treated as an initial value (if they are convertable to the result
type) which will result into a wrong overload call. To avoid this, added
additional check to make sure that the initial value type doesn't match
with ReduceOption enum.

Note that this required including the qtconcurrentreducekernel.h header
in qtconcurrentfunctionwrappers.h (which contains compiler checks for
QtConcurrent) for accessing ReduceOption enum, so I had to get rid of
qtconcurrentfunctionwrappers.h include from qtconcurrentreducekernel.h
to avoid circular header includes. This, in turn, required moving the
QtPrivate::SequenceHolder helper type to qtconcurrentreducekernel.h,
which didn't belong to qtconcurrentfunctionwrappers.h anyway.

Pick-to: 6.3 6.2
Fixes: QTBUG-102999
Change-Id: Ieaa8ef2e4bd82ce2ada2e0af9a47b87b51d59e87
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-05-20 17:11:15 +02:00
Eskil Abrahamsen Blomfeldt
4fe9374589 Fix crash in tst_qquicktext::implicitSize
This reverts commit 1e938c348b
and bb2f4d08d9.

bb2f4d08d9 causes the crash, but 1e938c348b amends it, so
this reverts both. When the cause of the crash has been determined
and mitigated, the patches can be recreated.

Fixes: QTBUG-103719
Change-Id: Ifc36b3771a96f6c85387a5306a0402d4c508d006
Reviewed-by: David Faure <david.faure@kdab.com>
2022-05-20 13:14:01 +02:00
Tang Haixiang
efc02f9cc3 xcb: Delete touch points without target windows
When XCB_INPUT_TOUCH_BEGIN closes a popup, we then receive
XCB_INPUT_TOUCH_END, and cannot find a target window (because it's
destroyed). If we don't deliver it, we need to at least clear the
stored point from QPointingDevicePrivate::activePoints. Then when
we deliver the next touch press, m_fakeMouseSourcePointId also
needs to be reset.

It's now even more paramount that autotests (and real-world
touchscreens) must never omit any active touchpoint from a touch event.
If a point doesn't move, it must be included in the QTouchEvent, with
Stationary state. If not, QGuiApp::processTouchEvent() could generate
multiple TouchBegin events in a row, which gets other bits of logic
confused, here and there.

Fixes: QTBUG-94557
Fixes: QTBUG-98519
Fixes: QTBUG-102751
Fixes: QTBUG-103706
Pick-to: 6.2 6.3 5.15
Change-Id: Ia95e410a2bb8bc7784aa5d296fac2b89e53a9f55
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-05-20 10:26:18 +02:00
Shawn Rutledge
ff153d9874 Avoid ending Markdown fenced code blocks with gratuitous blank lines
This caused unnecessary empty <pre> blocks when converting markdown to
HTML, made code blocks too large using QSyntaxHighlighter to highlight
the whole block, and caused assymmetry when rewriting markdown.

Pick-to: 6.3
Fixes: QTBUG-101031
Change-Id: I08016577ccb92edb4afae31d7df3259cb011d5c8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-05-20 00:49:18 +02:00
Shawn Rutledge
04a60bb033 Convert <pre> to Markdown ``` and vice-versa with nonBreakableLines
The HTML parser calls QTextBlockFormat::setNonBreakableLines(true) when
it sees a <pre> tag; so for symmetry, the markdown reader now does the
same when it sees a fenced code block, and the markdown writer honors
the nonBreakableLines property by writing a fenced code block. This
preserves the meaning better when reading HTML and writing markdown or
vice-versa, without modifying HTML reading or writing code.

Added a test tst_QTextMarkdownImporter::fencedCodeBlocks() which
unfortunately also highlights a known bug in the markdown reader: each
fenced code block ends with an extra empty block. That can be fixed
separately.

tst_QTextMarkdownWriter::fromHtml(preformats with embedded backticks)
that we re-enabled in 1abaf9d5d6 was not a
very useful test: ``` with a space and some words but no newline is not
a fence: it's just like a `monospace` span. We have had trouble with
those in CI because of missing monospace fonts, or inconsistency when
a supposedly mono font's QFontInfo::fixedPitch() returns false.
So just test proper <pre>/fence conversion for now.

Pick-to: 6.3
Fixes: QTBUG-100515
Fixes: QTBUG-100981
Task-number: QTBUG-101031
Change-Id: I88f0ede0810d8a9480b30eb0cd780e1af67cc5f2
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-05-19 14:43:39 +02:00
David Faure
1e938c348b QTextDocument: add setLayoutEnabled()
This allows to set up everything first - without paying for layouting
at every step - and only then trigger layouting.

Same performance behavior as setTextWidth(0), but this is a more
explicit/readable API.

Change-Id: I044dbd8b1301b1c97a92f9a29ccde2baf27a7665
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-05-19 12:26:57 +00:00