Commit Graph

13279 Commits

Author SHA1 Message Date
Dimitrios Apostolou
df0351836e Fix helper script to run successfully on X11
Without the fix, some tests from tst_selftests were failing with:

Invalid MIT-MAGIC-COOKIE-1 key

Change-Id: I2d07f28d9b2c69fe8575fdf10b362d962f456970
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-12-17 07:03:25 +01:00
Marc Mutz
572b55baa4 tst_QIODevice: fix UB (precondition violation) in SequentialReadBuffer::readData()
memcpy() mustn't be called with a nullptr, even if the size is zero.

Fixes ubsan error:

   tst_qiodevice.cpp:561:15: runtime error: null pointer passed as argument 1, which is declared to never be null

Even though ubsan only complained about one of them, fix all three
occurrences of the pattern in the test.

Pick-to: 6.3 6.2 5.15
Change-Id: I5c06ab4a20a9e9f8831392c46c6969c05248fdac
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-16 23:25:47 +01:00
Marc Mutz
b1938e5787 tst_QByteArray: fix UB (signed overflow)
The first case is simple, as it's a static overflow. Theoretically,
the compiler would be allowed to just remove the complete function as
dead code. This is an error left from the port from int to qsizetype:
Qt 5.15 there has uint(MaxAllocSize) + 1, so use quint here again,
qint64 is wrong.

In the second case, we _may_ reach alloc == MaxAllocSize. Check that,
if we do, we don't then add 1 to it.

Pick-to: 6.3 6.2
Change-Id: I93044ed6f1b77559642fa1e4e8f313cf59eeeb79
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-16 23:25:47 +01:00
Tatiana Borisova
4aea86f5e8 Fix autotest runtime failures on INTEGRITY
- add test resources to binaries
- link Qt::Gui to tst_qpointer for static build case

Task-number: QTBUG-99123
Pick-to: 6.2 6.3
Change-Id: I311827b9c641eaf9537091b051c15f9fcbcb9f0c
Reviewed-by: Kimmo Ollila <kimmo.ollila@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-16 19:45:08 +02:00
Marc Mutz
0d91ad44a7 tst_qmetatype: remove traces of compiler workarounds again
Now that all platforms can deal with the full tst_QMetaType again,
remove the last traces of the workaround.

Pick-to: 6.3
Change-Id: I530cab8413f8b68903991b30a1f29b5871877a88
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-16 18:45:08 +01:00
Lars Knoll
d1626ca6b0 Fix hash lookup using the value of a key iterator
QHash::operator[] could grow the hash even if the key being
looked up already existed. This in turn invalidated all iterators.
Avoid this by refactoring findOrInsert() to not grow if the key
already exists.

Added advantage is that this should make lookups of existing keys
slightly faster.

Fixes: QTBUG-97752
Pick-to: 6.3 6.2
Change-Id: I9df30459797b42c434ba0ee299fd1d55af8d2313
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2021-12-16 18:44:01 +01:00
Marc Mutz
82d90fbb9e tst_qmetatype: remove the previous MingW workaround
Let's see whether splitting the TUs has made the test amenable to be
compiled with MinGW again.

Pick-to: 6.3
Change-Id: Icde1bad20943c7648dbb119ca879bce62325bd6c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-12-16 12:47:39 +01:00
Marc Mutz
81bf3e68b9 Make QRingBuffer a move-only type
There's no sense in copying a ring buffer. Moving is enough. This
marks an important step on the way to preventing accidental copies of
ring buffer content, because the 'QList buffers' member can now no
longer be implicitly shared. While the compiler will still emit the
code for detach()ing, it will now never be executed.

Pick-to: 6.3
Change-Id: I968bfe3e50c46720ed4baca55c99c1f9c518f653
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-16 00:01:41 +01:00
Marc Mutz
63a35898f4 QIODevice: use QVLA to hold the ring buffers, not QList
The only users of more than one read- or write channel are the SCTP
code and QProcess. SCTP being pretty rare, optimize for the common
case of at most two QRingBuffers for reading (QProcess) and one for
writing.  Even with more channels, QVLA shouldn't be slower than QList
- on the contrary.

Need to adjust tst_toolsupport and TypeInformationVersion, as
QFilePrivate::fileName has changed.

Pick-to: 6.3
Change-Id: I3baf982ba1f4dc51463be8730e414f6164072d8b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-15 17:35:13 +00:00
Morten Johan Sørvig
292bdac4cf wasm: add rasterwindow manual test
Simplest possible graphical app, with event logging.

Change-Id: I6b1eb88c270a190becb23cc63d6d755ffbafcf52
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-15 18:06:11 +02:00
Marc Mutz
eb4206ba23 tst_qmetatype: remove the previous clang-arm workaround
Let's see whether splitting the TUs has made the test amenable to be
compiled on Clang for ARM again.

Pick-to: 6.3
Change-Id: I6bf1e31189f5058dc393adefabaf3014dce4bcf2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-15 15:11:17 +01:00
Ralf Habacker
2e2f1e2af7 Add css media rule support for QTextDocument::setHtml()
CSS styles can contain '@media <rule> {...}' blocks, which were
previously ignored for all values except "screen".

To use a media rule other than the default "screen" rule,
specify it before calling setHtml() with setMetaInformation()
and the new info value 'CssMedia'.

[ChangeLog][Gui][QTextDocument] Add css media rule support
for QTextDocument::setHtml()

Pick-to: 6.3
Fixes: QTBUG-98408
Change-Id: Ie05f815a6dedbd970210f467e26b116f6ee3b9ca
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-12-15 11:36:37 +00:00
Marc Mutz
9440c1a1fc Revert "tst_qmetatype: Temporarily disable expensive tests on QNX"
This reverts commit 925ad78024.

Reason for revert: Meanwhile, the QNX VM has been assigned more
resources, and the offending test function been split. Re-enable the
test on QNX, to get back to previous test coverage.

Fixes: QTQAINFRA-4669
Pick-to: 6.3
Change-Id: Ib085fbfa7e0d8445f007d1a9346cee3113620720
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-12-15 01:33:05 +01:00
Marc Mutz
daaa3088ec QVarLengthArray: don't allow syncqt to export base classes
Check, in tst_qvarlengtharray, that the forwarding header still works.

Pick-to: 6.3
Change-Id: Ia03cf48457f538287880bb676aea3fa44aeb255f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-15 00:04:45 +01:00
Andreas Buhr
72e802f3b0 Use QAbstractItemModelTester in all QSortFilterProxyModel tests
This patch installs a QAbstractItemModelTester in the
QSortFilterProxyModel tests.

Change-Id: I9bdcc21ba12f919c91c5b9514a5f4362437318c2
Reviewed-by: David Faure <david.faure@kdab.com>
2021-12-14 14:11:26 +01:00
Tor Arne Vestbø
ae6dc7d6df Fix qt_scrollRectInImage when scrolling outside of the image
We were clipping the source rect to the image, both pre and post
scrolling, but did not apply the same logic to the target position.
By computing the target position based on the already clipped source
rect we ensure that the target position is also correct.

This was causing valgrind warnings on Linux, and crashes on Windows,
when trying to test the lower level QBackingStore::scroll() function.
The reason we were not seeing this in practice was that QWidget does
its own sanitation and clipping of the arguments before passing them
on.

As a drive-by, fix the access of image to use constBits instead of a
manual cast, and rename variables to better reflect their use.

Pick-to: 6.3 6.2 5.15
Change-Id: Ibc190c2ef825e634956758f612a018f642f4202b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-12-14 14:11:26 +01:00
Lars Knoll
9836dbd6ee QHash: increase minimum buckets to a full span
Change the minimum amount of buckets to be at least
128, ie. one full Span. This will simplify some assumptions
in the code.

Regeneration of rcc test-data needed because the extra buckets
causes the order of the keys to change.

Task-number: QTBUG-91739
Task-number: QTBUG-98436
Change-Id: Ic0c7da03570cc4c4e6aacc9645e536aec3667a98
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-13 18:58:36 +01:00
Mårten Nordheim
e508c4c094 QCache: Adapt to upcoming QHash changes
QHash changes some of its preconditions, so we must not call
findNode without verifying !isEmpty()

Task-number: QTBUG-91739
Task-number: QTBUG-98436
Change-Id: I2701b9a01187530f541a7c9a12db56c92f856d87
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-12-13 18:58:36 +01:00
Kai Köhne
9ca7429dff Tests: Use REQUIRED COMPONENTS in find_package(Qt6...)
Make sure configure fails early if a component cannot be found.

Task-number: QTBUG-98867
Pick-to: 6.2 6.3
Change-Id: I4baa35a84342df58ce8932601fb602be92ed5ab9
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-12-13 14:16:26 +00:00
Thiago Macieira
81a31beeb2 Rewrite Q_{GLOBAL,APPLICATION}_STATIC with C++17 goodies
Especially static inline variables. This greatly reduces the amount of
code that existed in macros, moving them to templates.

Additionally, this removes one level of indirection from
Q_APPLICATION_STATIC by removing the std::unique_ptr. We now directly
manage the object's storage.

Change-Id: I2cffe62afda945079b63fffd16bcc825cc04334e
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2021-12-12 14:25:42 -08:00
Pasi Petäjäjärvi
fbbcd109f5 QNX: Cannot handle threads in given time
Large amount of threads is unstable and do not finish in given time

Pick-to: 6.2
Change-Id: I0ce4c8cd278d6611c9e9da7326048279ccc458fd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-12 13:12:39 +02:00
Pasi Petäjäjärvi
6fbb02add5 QNX: inotify is supported, so enable tests
Also change usage of QDir::currentPath to QDir::tempPath
instead as QNX tests are run on CI at qemu over NFS.

Pick-to: 6.2
Change-Id: I2e1d6629299acd125117bcce90320c70eeb4a1a5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-12 11:12:31 +00:00
Pasi Petäjäjärvi
d214c5a09a QNX: Skip failing test
Seems to be bug in QNX itself

Task-number: QTBUG-98561
Pick-to: 6.2
Change-Id: I525bd269b674e9e2b8c994bf778ab14b727df33f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-12 11:12:19 +00:00
Pasi Petäjäjärvi
697cb6eead QNX: Remove not supported testcase
Still not implemented

Task-number: QTBUG-40785
Pick-to: 6.2
Change-Id: I9bb89ccaff30a3d906bf5665bc6ef981717aa054
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-12 11:12:11 +00:00
Pasi Petäjäjärvi
d500fc5580 QNX: Limit maximum largefile size
Pick-to: 6.2
Change-Id: I4e43eaea98e893453c8c1356da63edb0c059f896
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-12 13:12:01 +02:00
Pasi Petäjäjärvi
578f7d56eb QNX: Remove expected fail
Works with QCC 8.3.0 (Based GCC 8.3.0 20190222 (stable))

Pick-to: 6.2
Change-Id: I130847627a4b77ced83d196a7a1674963c5cd3e1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-12 13:11:52 +02:00
Pasi Petäjäjärvi
ac8ce18522 QNX: Successful check depends on user running test
Modify similar like is used for Windows

Pick-to: 6.2
Change-Id: I133a8dde2e78cc66aa9544246cd750a6543b4883
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-12 11:11:36 +00:00
Sona Kurazyan
ed546ff216 QtFuture::connect: exclude QPrivateSignal from the resulting future type
Filter out the last argument of type QPrivateSignal from the signal's
arguments passed to QtFuture::connect().

Pick-to: 6.2
Fixes: QTBUG-92501
Change-Id: Idcd6baba1f01fcc94fa64b1c7030a629d01ed7a1
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-12-11 21:47:17 +00:00
Marc Mutz
85e92f2e5f QVarLengthArray: deprecate prepend()
All Qt 6 containers have "fast" prepend these days. Except
QVLA. Instead of enabling "fast" prepend for QVLA, slowing down
idiomatic QVLA use, simply deprecate prepend().

There appear to be no users of this function in qtbase outside tests.

[ChangeLog][QtCore][Deprecation Notices][QVarLengthArray] Deprecated
prepend() because QVarLengthArray is the only Qt container without a
"fast" prepend. If you require that functionality, even though it's a
linear operation, then use insert(cbegin(), ~~~) instead.

Change-Id: I39ff1dd7d4de7fc08d5380a5a7450dd8c8996fe2
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-11 03:15:11 +00:00
Volker Hilsheimer
9da1f6b608 Fix widget gesture grabbing
After 7369c31ca1f446e81eda1c93ba13767ffcd83efe, unaccepted touch points
were not grabbed anymore in calls to activateImplicitTouchGrab. However,
gesture recognition relies that widgets for which a gesture has been
partially recognized grab also unaccepted touch points.

Add a parameter to allow the implicit grabbing to take place also for
unaccepted event points.

Add test case that replays touch events similar to what Squish is doing,
and fails without this fix.

Pick-to: 6.2
Change-Id: Idb0b20301b1827be57a03013a59043d97c2ee7b6
Reviewed-by: Stefan Gehn <stefan.gehn@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-11 00:51:10 +01:00
Laszlo Agocs
bc4570ed24 rhi: Auto-rebuild rt by tracking attachment id and generation
Unlike the shader resource binding lists that automatically recognize
in setShaderResources() when a referenced QRhiResource has been rebuilt
in the meantime (create() was called i.e. there may be completely
different native objects underneath), QRhiTextureRenderTarget has no
such thing. This leads to an asymmetric API and requires also rebuilding
the rt whenever an attachment is rebuilt:

rt = rhi->newTextureRenderTarget({ { texture } })
rt->create()
cb->beginPass(rt, ...)
texture->setPixelSize(...)
texture->create()
rt->create() // this should not be needed
cb->beginPass(rt, ...)

Avoid having to do that second rt->create().

Change-Id: If14eaa7aac3530950498bbdf834324d0741a7c4d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-12-10 15:08:51 +01:00
Marc Mutz
48b75def5d QList: fix typo in QList(It, It)
Remove scaffolding in the test again.

[ChangeLog][QtCore][QList] Fixed a regression that caused the range
constructor to fail for pure input_iterator's.

Pick-to: 6.2
Fixes: QTBUG-99036
Change-Id: I72d01a9c44c3862c335d96538f26a453b4c7c554
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-10 13:48:37 +00:00
Marc Mutz
2e07d045ff tst_containerapisymmetry: test ranged ctors with pure input_iterator types
Fails in Qt 6, succeeds in Qt 5.15, therefore needed to add the
version check.

Pick-to: 6.2 5.15
Task-number: QTBUG-99036
Change-Id: I9da1b2511d844b5fdcb63fdc58c8bc34d0f65736
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-09 22:49:45 +01:00
Edward Welbourne
6729a4b29c TAP test logger: avoid dangling space on TODO and SKIP lines
If an incident has an empty description we produced output with a
dangling space. Avoid triggering the inanity 'bot with those.
Reorganise the code to save some duplication.

Change-Id: I1dc29fa8ad4449a4584f11dddcf002e405cd9238
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-09 20:54:26 +01:00
Edward Welbourne
8d0b5270fa TAP test logger: skip XFail results as well as pass after an XFail
The rationale for skipping pass after XFail is "to emit a single test
point for" the test; emitting several XFails violates that aim.

Task-number: QTBUG-96844
Change-Id: Ia8626dfc2dded234b3aa530fc2dc2324f1e28400
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-09 20:54:26 +01:00
Edward Welbourne
77a93e6df3 Make Skip an incident in test logging
Skip ends the test (albeit inconclusively).  Rearrange the enums in
the abstract logger, move code to handle skip between relevant
function and tidy up various things that became simpler as a result.

Also reorder the message enum, and its switches, to separate testlib's
internals from the usual Qt messages, and put each group in ascending
order of severity.

Task-number: QTBUG-96844
Change-Id: I2c7a634b9f849830d64eafa750155e66e244b729
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-09 20:54:26 +01:00
Edward Welbourne
1c24b4b8d9 Match up testlib selftest's lists of generated files
The actual files present for expected data, the test function that
selected which tests to skip and the python function to select which
to not generate data for weren't in sync with one another.

The test-code's reason for omitting three tests was that we lacked
data files for them. So generate those and skip that exception. The
generator script's code to decide which to generate didn't exclude
anything like as many, so update it to match the test-code. In the
process, save repeating a startswith test that was used both
positively and negatively, unifying two conditions.

Extend the generator script's handling of its --skip-callgrind option
by auto-setting that option if valgrind isn't available, to match the
driver program's similar skipping.

The generated data included many files for tests we skip and, as
mentioned already, lacked files for some tests we only skipped because
we lacked them. Remove the unused files, add the lacking ones.

Change-Id: If91696cdd95b7b0d5f3d686bff839f1bf15e121b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-09 20:54:25 +01:00
Edward Welbourne
37bc11e707 Refactor QTEST*_MAIN() implementations
The various variants duplicated some rather complex code around
varying setup in the middle. Rework in terms of a macro that defines
main() and takes the setup code as a parameter. That setup code also
had some common structure, so package that in a setup macro that takes
the class to be used.

Reworked various testlib selftests that were using QTEST_MAIN_IMPL();
change to use the new QTEST_MAIN_WRAPPER() and TEST_MAIN_SETUP().
These might be better dealt with by supporting a second form of the
initMain() test-setup function in the test classes, that takes
references for argc and argv, to let a test massage its command-line
options.

Change-Id: I7fb16b38d51c80ba2f5c9c82f3b7a37ffc636795
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-09 20:54:25 +01:00
Edward Welbourne
93830d9ed3 Fix x86 preprocessor check in testlib selftests
When deciding whether to run benchlibcallbrind, the code only tested
_i386; it now tests __x86_64 as well, to match a recent change in the
test itself. As there, reverse the test to reduce negations, flipping
the stanzas it selects between. Also tidy up the code that tests for
valgrind being present - and actually return true, to skip the test,
when it claims to be skipping the test.

Updated test results, now that the test can actually be run and
produce sensible output. Added an _2.txt that matches the results
presently seen in Coin on RHEL 8.4 (despite the fact that a local
build on such a VM produces output matching the _1.txt results).

Change-Id: Ibce09dca06a1eeb73e90fb1345834998683df9d8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-09 20:54:25 +01:00
Edward Welbourne
e42fe5c775 Fix argv hacking in tst_benchlibcallgrind.cpp
It unconditionally added -callgrind to its own command-line options,
but the way testlib handles this argument is, in QTest::qRun(), to
re-run the program under the control of valgrind --tool=callgrind,
removing the -callgrind command-line option from the test and adding
-callgrindchild to its command-line options. So we shouldn't re-add
the -callgrind option in the resulting recursive call.

The test now runs quickly, producing sensible output, where previously
it took a very long time. Revised the drivers to reflect this
speed-up, but continue skipping the non-.txt formats to save the need
for variant-output files for many formats. To match that, removed the
unused non-.txt results files.

Change-Id: Iaa99c1b5964d50bccfc6076a21896791b6bbf289
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-09 20:54:25 +01:00
Edward Welbourne
4eb2dcd4b9 Replace a random define with a __has_include() check
The given reason for needing to define it was that there was no way to
test whether <valgrind/valgrind.h> is available to #include; but we
now require C++17 hence __has_include(). However, moc doesn't seem to
grok that, so move the test's #if-ery inside the test, since otherwise
it gets omitted because the test's metatype doesn't know it's there.

Change-Id: I75a100787b98a52fad4cfb0b047318a115c998e2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-12-09 20:54:25 +01:00
Marc Mutz
e297e80fd0 QVarLengthArray: make reallocation strongly exception safe
The old code had several bugs:

- it immediately clobbered *this with new state, before having copied
  over the elements from the old to the new buffer

- when buffer relocation threw, it would keep the new (partially-filled)
  buffer and throw away the old

- it unconditionally used std::move() for non-relocatable types, making
  it impossible to restore the original buffer when a move throws

Instead of clobbering *this with new state, do all the work on the
side and change *this only once the reallocation has happened
successfully.

Also use q_uninitialized_relocate_n() and unique_ptr in the
implementation to simplify the code. The former got the necessary
update to use std::move_if_noexcept() instead of an unconditional
std::move() for the non-relocatable case.

[ChangeLog][QtCore][QVarLengthArray] The append()-like functions are
now strongly exception safe. This means reallocation will now use
copies instead of moves, unless the value_type has a noexcept move
constructor.

Fixes: QTBUG-99039
Change-Id: I031251b8d14ac045592d01caed59d4638c3d9892
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-09 18:59:55 +00:00
Ievgenii Meshcheriakov
4f53c703e4 QLocale: Extend support for language codes
This commit extends functionality for QLocale::codeToLanguage()
and QLocale::languageToCode() by adding an additional argument
that allows selection of the ISO 639 code-set to consider for
those operations.

The following ISO 639 codes are supported:
    * Part 1
    * Part 2 bibliographic
    * Part 2 terminological
    * Part 3

As a result of this change the codeToLanguage() overload without
the additional argument now returns a Language value if it matches
any know code. Previously a valid language was returned only if
the function argument matched the first code defined for that
language from the above list.

[ChangeLog][QtCore][QLocale] Added overloads for codeToLanguage()
and languageToCode() that support specifying which ISO 639 codes
to consider.

Fixes: QTBUG-98129
Change-Id: I4da8a89e2e68a673cf63a621359cded609873fa2
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-12-09 03:45:08 +01:00
Sona Kurazyan
0fbeac0115 Fix the benchmark for QList::removeAll()
The benchmark was making assumptions about number of
constructor/assignment operator calls, which are not valid in Qt 6,
after the implementation of QList has changed. Considering that we
already check number of constructions, copy constructions, etc., in
tst_qlist.cpp, remove the checks from the benchmark.

As a driveby, fix the following warning:
"warning: parameter 'i' shadows member inherited from type 'MyBase'"

Pick-to: 6.2
Fixes: QTBUG-95096
Change-Id: Ida68fa5803641c8fa84f8309c0093986ed4c0a2b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-12-09 03:45:08 +01:00
Volker Hilsheimer
b886a7ca65 Add unit test for moving of opaque widgets
Expose QWidgetRepaintManager's data structures so that we can write
unit tests, and verify that they are correct after moving opaque
widgets (which triggers the accelerated move code path).

Improve the compareWidget logic to not rely on screen grabbing
(which requires permissions), but instead use QPlatformBackingStore's
toImage function, which is faster and more reliable, and also doesn't
require us to show the UI we want to grab full screen in order to
avoid issues with overlapping windows etc.

Change-Id: Iff2ea419f03a390ab6baca26814fef6ff45f7470
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-08 23:06:42 +00:00
Liang Qi
c8609d1e7a tests: add a capability check for QWindow::requestActivate() call
This amends b65159a5ea.

Pick-to: 6.2
Change-Id: I6055004375b440997ea41b3e4538854780202e10
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-08 21:08:04 +01:00
Marc Mutz
d4a88e4ea4 QVarLengthArray: fix size update on failed append()
If the in-place constructor throws, the old code had already updated
the container's size(). Fix by delaying the update to after the
in-place construction.

[ChangeLog][QtCore][QVarLengthArray] Fixed a bug whereby a failed
append() would leave the container with an inconsistent size().

Pick-to: 6.2 5.15
Change-Id: Ief1e668d945149bd8ba96c8af1398baaa7876880
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-08 16:39:27 +00:00
Liang Qi
493a85a9e4 Widgets: setTransientParent() when a QMenu is a window
On some platforms, such as X11 and Wayland with some compositors,
QMenu could be a popup window, which should be set a transient parent
to get relative position, which is requested by Wayland.

Added transientParentWindow() for QMenuPrivate like QDialogPrivate.

Fixes: QTBUG-68636
Pick-to: 6.2
Change-Id: I6d8880cb008ecf61a4c005898b38e3953379a13d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-12-08 13:45:36 +01:00
Lorn Potter
f0be152896 wasm: improve clipboard support
Add support for Clipboard API
Add clipboard manual test

Also includes these fixes:

- improve clipboard use for chrome browser
- make QClipboard::setText work
- html copy and paste
- image copy/paste

Chrome browser supports text, html and png

To use the Clipboard API, apps need to be served from
a secure context (https). There is a fallback in the
case of non secure context (http)

- Firefox requires dom.events.asyncClipboard.read,
dom.events.asyncClipboard.clipboardItem and
dom.events.asyncClipboard.dataTransfer to be
set from about:config, in order to support the
Clipboard API.

Change-Id: Ie4cb1bbb1dfc77e9655090a30967632780d15dd9
Fixes: QTBUG-74504
Fixes: QTBUG-93619
Fixes: QTBUG-79365
Fixes: QTBUG-86169
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-12-08 13:39:58 +10:00
Volker Hilsheimer
ec267a4c7c Add unit test for QWidgetPrivate::overlappedRegion
Added to QWidgetRepaintManager test case, which is the only place where
the function is used.

Includes a helper that creates a complex scene with opaque children,
which will be used in additional unit tests.

Change-Id: I0e0188dd560923a552a8967d8e992dc17cc849d6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-08 00:40:21 +01:00