Commit Graph

58651 Commits

Author SHA1 Message Date
Edward Welbourne
bed8663a0b tst_QPainterPath::testNaNandInfinites(): anticipate the warnings
The test used to trigger a lot of QWARN messages; these are clearly
intended, so tell QTest to expect them, so that we get an error here
if those warnings ever don't show up.

Incidentally tidy up a comment and convert a != verify to a
QCOMPARE_NE(), since it's now available to do that job.

Change-Id: I83e225c37abe8446dac06ebe4e75258cb87b71b0
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-10-18 14:13:27 +02:00
Edward Welbourne
4af55438d0 tst_QPainterPath::testArcMoveTo(): include index in some data tags
In the process, clean up the building of the data tags: use a
range-for loop, albeit we do need an index to show in tags; show it
and the angle in the tags using addRow()'s easier formatting. Change
the low angle tests to show the sign of the angle (which is how they
differ)rather than just labeling them 1 and 2.

Change-Id: Ib5aaa3e22d771c530c9343ba368b0fdfceb264ce
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Jason McDonald <macadder1@gmail.com>
2022-10-18 14:13:27 +02:00
Edward Welbourne
119801f70d tst_QPainterPath::contains_QRectF(): rename some data rows
The last three duplicated earlier ones; and their names didn't take
into account the circle that had been added to the path since those
tests. So revise their names to reflect that.

Change-Id: I32d74f21947b4ba0c04eee53daf8efde6b4a6409
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2022-10-18 14:13:27 +02:00
Edward Welbourne
d52abad85d tst_QImage::reinterpretAsFormat(): deduplicate a data tag
Two rows shared a data tag. Prefixed one of them with the color of the
half-transparent image it involves (the other's is fully transparent).

Change-Id: I1bd174008ed29bcf2f460e683fdf6d1f12ba19d0
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-10-18 14:13:27 +02:00
Edward Welbourne
e6fb0e0779 tst_QImage::mirrored(): deduplicate some data row names
Change-Id: Ia10c72c450eed12d29c9608c6a6270dd4dc4ef7c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-10-18 14:13:27 +02:00
Edward Welbourne
c13df5b6ea tst_QImageReader::preserveTexts(): deduplicate data tags
The same data tags were used with two distinct filenames in their
data. Include the basename of each filename in the data tag, to avoid
duplication.

Change-Id: I216fecbd413fab409227ad6f93f8ac3fcc74b059
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-10-18 14:13:27 +02:00
Edward Welbourne
af0c910912 tst_QKeySequence::parseString_data(): drop duplicated rows
The "a" and "A" rows appeared under Valid, then again under Only Keys.
The two copies were identical, in each case, so drop the latter.

Change-Id: Ib3d84710e772171bb4a5e0aefd20022810fb41cd
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2022-10-18 14:13:27 +02:00
Edward Welbourne
ab27c1e2d5 tst_QDBusTypes::isValidFixedType: don't duplicate fixed types
tst_QDBusType::isValidFixedType_data() called addFixedTypes() and then
addBasicTypes(); but the latter calls addFixedTypes(), too; so those
rows got duplicated. Only add the fixed types once.

Change-Id: If0d6f44ec7defb12117dad251878850ca75beb48
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-10-18 14:13:27 +02:00
Edward Welbourne
c74cf23124 tst_QRect::containsPointF_data(): remove duplicate data row
The row 27 that was positioned before row 01, as if it were meant to
be numbered row 00, was identical to the row 27 that appeared after
row 26. Since row 26 was the other case dealing with the null
QRectF(), I kept the one after it instead of renumbering row 00 and
deleting row 27.

Change-Id: I3585839184233f1f1629280ac9e5b25110c155c0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-10-18 14:13:27 +02:00
Edward Welbourne
c10132888e tst_QCryptographicHash: avoid duplicate data tags
Use key(i) rather than valueToKey(value) as the Sha3_* alias Kekkak_*
or RealSha3_*. This way, we still test all members of the enum,
without duplicating row keys (albeit the aliases duplicate values).

Change-Id: I6acba5ffdf5b68294031d609a76b37ca8fad9d94
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-10-18 14:13:26 +02:00
Edward Welbourne
0448d57c07 tst_QBitArray: remove duplicate data rows
Both countBits() and datastream() had two copies of an all-zeros test
with 35 zeros. Removed the second, in each case.

Change-Id: I5dec4765236ae870c30828dae0f04b8902a100f0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-10-18 14:13:26 +02:00
Yuhang Zhao
ade68c9949 MSVC: Disable buggy conformance check
/Zc:lambda seems buggy. Although in my experiments it works well
for 99% Qt repos, it seems some tests will trigger the bug and it
also blocks some new commits. So disable it for now, it's not stable
enough.

Now that this check is disabled, the workaround for tst_qstringapisymmetry
is also not needed anymore, so remove the workaround as well.

Partially reverts commit 8cb832090a

Change-Id: Icf0ecbbaa6262522470e5f5dea05705985ab18f1
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-10-18 19:31:25 +08:00
Axel Spoerl
b1054d45e9 Fix flakiness in tst_QDoubleSpinBox / editingFinished
setFocus() was called on a double spinbox without calling show()
first. That causes flakiness on XCB when checking focus afterwards.
The test can still fail, when focus is acquired by e.g. a system
popup.

This patch adds a show() call before setFocus() to stabilize normal
behavior. In case the double spin box is shown, but cannot acquire
focus, the test is skipped.

Fixes: QTBUG-70088
Change-Id: If02e88800a31b09a1da63dcc074eb8bb1b0df391
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2022-10-18 11:31:25 +00:00
Samuel Mira
2937cf91c7 Android: Stop using getPrimaryClipDescription
The function getPrimaryClipDescription was used to establish if the
clipboard data had text, html and/or uris. Analysing QTBUG-106646 and
tst_qquicktextedit showed inconsistent results, namely the description
hasMimeType failed to find html mimetype on copy&paste.
This patch changes it for searching it by hand instead of using
hasMimeType function.

Task-number: QTBUG-106646
Change-Id: I8918938e7a3fa6953eac95b72959fca85050e52f
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2022-10-18 07:29:51 +00:00
Thiago Macieira
54df3488af QLibrary::setFileNameAndVersion: reset the tag after findOrCreate
If the library we've found is already loaded, set the tag to Loaded.

Pick-to: 6.4
Change-Id: I12a088d1ae424825abd3fffd171ce3831b884eee
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-10-17 15:01:39 -07:00
Friedemann Kleint
ec6b22f67d windeployqt: Deploy Qt Designer plugins for QtUiTools
Make QtUiTools a known module with command line options and
plugin dependencies.

Note: There is no automated dependency checking for those
plugins as this can lead to undesired libraries being pulled.

Pick-to: 6.4
Fixes: QTBUG-104831
Change-Id: I31a0c3620460d6558edcf8245f43502f2bca7748
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-10-18 00:01:38 +02:00
Marc Mutz
2fd990b386 Port qCompress() to zstream/deflate()
The zlib convenience API we've been using so far has two problems:

- On Windows-64, where sizeof(long) == 4, the use of ulong for sizes
  meant that we could not compress data compressable on other 64-bit
  platforms (Unix). While zstream also uses ulong, being a stream API,
  it allows feeding data in chunks. The total_in and total_out members
  are only required for gzip compression and are otherwise just
  informational. They're unsigned, so their overflow does not cause
  UB. In summary, using zstream + deflate() allows us to compress more
  than 4GiB of data even on Windows-64.

- On all platforms, we always allocated the output buffer in such a
  way as to accommodate the pathological case of random, incompressible
  data, so the output buffer was larger than the input. Using zstream
  + deflate(), we can start with a smaller buffer, then let zlib pick
  up where it left off when it ran out of output buffer space, saving
  memory in the common case that compression meaningfully reduces the
  size. To avoid the first few rounds of reallocations, we continue to
  use zlib's compressBound() for input less than 256KiB.

This completely fixes the compression side of QTBUG-106542 and
QTBUG-104972.

Pick-to: 6.4 6.3 6.2
Fixes: QTBUG-104972
Fixes: QTBUG-106542
Change-Id: Ia7e6c38403906b35462480fd611b482f05a5c59c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-10-17 23:33:41 +02:00
Marc Mutz
fdd0a1bc17 QApplicationStatic: avoid use of std::aligned_union
It's deprecated in C++23. Replace with std::aligned_union's
implementation, like done elsewhere in the code base.

Pick-to: 6.4
Fixes: QTBUG-107569
Fixes: QTBUG-99122
Change-Id: I0c06876c03a3c268298fab0f0bae399f26449bed
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-10-17 19:33:36 +02:00
Marc Mutz
f5205bd6a4 tst_Q{BitArray,ContiguousCache}: check not only count(), but size(), too
Add at least a few, so size() isn't completely untested.

Pick-to: 6.4 6.2 5.15
Change-Id: I500d28f7efb30ab578808d8fefb6ea57949edc2e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-10-17 19:33:34 +02:00
Eirik Aavitsland
2742ceb1cd Update bundled libpng to version 1.6.38
With this update, there are no longer any diffs to upstream
libpng. Hence, the qtpatches.diff file is removed. Details:

- #define _CRT_SECURE_NO_DEPRECATE: Done on compiler cmdline instead
- #undef PNG_BUILD_DLL: For our usecase, that only caused PNG_IMPEXP
  to be defined to an empty string. Done on compiler cmdline instead.
- #ifdef for WinCE: dead platform.
- A memory leak fix: Included in upstream 1.6.38.

[ChangeLog][Third-Party Code] libpng was updated to version 1.6.38

Pick-to: 6.4 6.2 5.15
Change-Id: I229db30e1dd54c209dc93e76d11e6fdb1f7adbdb
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-10-17 19:30:50 +02:00
Timur Pocheptsov
46b290dda8 QIosTextResponder: stop using deprecated constants and type
Use NSWritingDirection and corresponding enumerators instead.

Pick-to: 6.4 6.2 5.15
Change-Id: Ie76ec2b8d07ab70288c7071182f215412d3e133c
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-10-17 16:46:03 +00:00
Mårten Nordheim
e48c0a6e7c Revert "QObject: attempt to fix a deadlock introduced by an earlier fix"
This reverts commit 22d4c67234.

Reason for revert: The fix causes crashes
tst_QObjectRace::disconnectRace2 and we don't currently have a
clear resolution on further fixes.

Task-number: QTBUG-107034
Change-Id: I310c27654f125cdb2939940d432724e73c89f485
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-10-17 15:23:54 +00:00
Edward Welbourne
0d915623ec tst_QAlgorithms: fix misleading indent in data table
A violation of coding style (requiring braces on multi-line bodies
of conditionals) was accompanied by a mis-indented else block.
Fix a long line while I'm about it.

Change-Id: Ibe9cf15eadbe9ef58138d7876e5e2c5a14a92fd4
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-10-17 15:53:32 +02:00
Edward Welbourne
ce950bcbf7 Clean up tst_QAlgorithms::count{Trail,Lead}ing_data_impl()
Pull out the arbitrary factor of three as a named constant and
document its arbitrariness once.

Pull out the mask and bit used in each function's loop to the outer
layer of the loop, since they don't depend on the inner loop variable
(or the random value generated in that loop).

Use QTest::addRow() instead of constructing a string to pass to
newRow().

Change-Id: Ifacbcb390e00828fd47f51b0c73d0ad5f6bc8bdb
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-10-17 15:53:32 +02:00
Edward Welbourne
2ffc36c24a tst_QTime: fix two duplicated test data tags
Names for data rows should be distinct.

Change-Id: I2ee1c4f362222d448278a90fc0a1cc9731e30976
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-10-17 15:53:32 +02:00
Edward Welbourne
565a827170 tst_QDateTime: eliminate some duplicate test-cases
Change-Id: I588494f2a79340599cafc48b3f4f4a79e6ca0a19
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-10-17 15:53:32 +02:00
Edward Welbourne
f6e9279ead tst_QAtomicInt:fetchAndAdd(): remove two duplicate data rows
Change-Id: I6568399945f421a18ddb5c52c68f82474de936c5
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-10-17 15:53:32 +02:00
Edward Welbourne
8bb0d2308e tst_QStringApiSymmetry: use startpos to deduplicate indexing data tags
The tests for indexOf() and lastIndexOf() had duplicate data row tags,
due to only using the needle and haystack, although some tests
differed only in start position. Include start position where needed.

Change-Id: I197d415265ab1a805f2d36fb88aec92ea8646f7a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-10-17 15:53:32 +02:00
Edward Welbourne
5b70546c17 tst_QStringApiSymmetry: avoid repetition in trimmed_data()
Enclosing one string in each substring of another does not need to
repeat the empty substring of the latter. Extracting the empty
substring from different positions doesn't get different results.
In the process, tidy up the code a bit.

Change-Id: Ic66febbdadeaac0c466f4f1174d831a991d31e20
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-10-17 15:53:32 +02:00
Edward Welbourne
781bd075a6 tst_QStringApiSymmetry: eliminate one duplicate of a mid_data() row
There were two copies of the same line in mid_data(), leading to
duplicated data row tags.

Change-Id: Ia21e855ff781b13fe18c932cff48cb0aabd12750
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-10-17 15:53:32 +02:00
Robert Griebl
f7e2984a1a Fix QComboBox supressing a QDialogs default button
Commit 64ffe0a broke pressing RETURN aka. the default key in a dialog
to close it, when a read-only QComboBox has the focus.

Before that patch, Enter + Return were actively ignore()d, but this
code path was removed, resulting in those keys to be auto-accepted.

Fixes: QTBUG-107262
Pick-to: 6.4
Change-Id: I3dd8dca7d2f9d94f5172adc92ef508fe81c0df57
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-10-17 15:53:32 +02:00
Marc Mutz
3d6f5e95f0 Update Catch2 to v2.13.10
Two patches applied to upstream release.

Pick-to: 6.4 6.2
Fixes: QTBUG-103321
Task-number: QTBUG-99122
Change-Id: Ief451a21e5f61851cb03a9ca94ffe0f864e4b1f8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-10-17 14:07:43 +02:00
Laszlo Agocs
2d381001da Add missing repaintManager check
This is likely a problem only after the 6.4 changes to move QQuickWidget
composition from OpenGL to QRhi.

Add an extra check to the condition when bailing out.

In QWidgetPrivate (qwidget.cpp) all similar calls into the
repaintManager are guarded by

  if (tlwExtra && tlwExtra->backingStore && tlwExtra->repaintManager)

therefore it makes sense to perform the same check in the other file too.

The assumption is that the check was not added here due to being outside
of qwidget.cpp.

Change-Id: Ic94d4e5153f4a194a997cd669b0f7c48c7932d97
Fixes: QTBUG-107166
Pick-to: 6.4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-10-17 09:03:16 +02:00
Timur Pocheptsov
6e288701e8 QIosMenu - do not check -undo: and -redo: selectors
With the latest Xcode 14 an attempt to 'Archive' and distribute an
app to the App Store Connect ends with a strange warning:
"App Store Connect operation Error The app references non-public
selectors in Payload/appname.app/appname: redo:, undo:". Googling
finds many similar reports and complains (with a bunch of different
selectors suddenly reported as non-public). We filter out undo/redo
instead, the selectors without parameters.

Change-Id: I9667dc61f650f6b6ec42c64a9aa6fbff57fe5049
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-10-17 08:55:33 +02:00
Marc Mutz
bda3628402 Port qUncompress() to zstream/inflate()
The zlib convenience API we've been using so far has two problems:

- On Windows-64, where sizeof(long) == 4, the use of ulong for sizes
  meant that we could not uncompress data compressed on other 64-bit
  platforms (Unix). While zstream also uses ulong, being a stream API,
  it allows feeding data in chunks. The total_in and total_out members
  are only required for gzip compression and are otherwise just
  informational. They're unsigned, so their overflow does not cause
  UB. In summary, using zstream + inflate() allows us to decompress
  more than 4GiB of data even on Windows-64.

- On all platforms, if the size hint in the header was too short, we'd
  double the output buffer size and try again, from scratch. Using
  zstream + inflate(), we still need to reallocate, but we can then
  let zlib pick up where it left off when it ran out of output buffer
  space. In all but the most pathological cases, copying the
  already-decoded data instead of re-decoding it again should be
  faster, esp. if QArrayData uses realloc() instead of malloc() +
  free() to grow the buffer.

We also now directly allocate at least as much output buffer as we
have input, to cut the first few rounds of reallocations when the
expectedSize was created, as qCompress still does, using modulo
arithmetic mod 4GiB instead of saturation arithmethic.

Factor the growing of the output buffer into a wrapper function,
flate(), which can be reused when porting qCompress().

This completely fixes the uncompression side of QTBUG-106542 and
QTBUG-104972.

Pick-to: 6.4 6.3 6.2
Task-number: QTBUG-104972
Task-number: QTBUG-106542
Change-Id: I97f55ea322c24db1ac48b31c16855bc91708e7e2
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-10-16 23:01:36 +02:00
Marc Mutz
e37c0c20bc QHash: simplify HashSeedStorage::initialize()
By not splitting Q_UNREACHABLE() and the following return, we can get
rid of the NOLINT(qt-use-unreachable-return).

Change-Id: I3322843e38dabdadb38eea38a6d91b301257fd23
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-10-16 11:55:34 +02:00
Shawn Rutledge
0f94430a0f testlib: make it possible to test double-clicks with discrete events
The timestamp will no longer be incremented by 500ms after a mouse
release if the delay has been explicitly specified.

The default delay is 1 ms since f5010c49a3
but the running timestamp was unconditionally post-incremented by 500ms
after every mouse release, to prevent double-clicks, which were always
deemed as unintended (because we have a mouseDClick function for that).
Now, we do that 500ms increment only if the user has not provided a
delay value in the function argument at all. We have often found it
useful in our own tests to generate double-clicks "the hard way", by
sending indivdual events, so as to be able to check state in some target
object at each step, as shown in the new snippet.

[ChangeLog][QtTest] QTest::mouseRelease() and mouseClick() can now be
used to test double-clicks, by specifying a realistic timestamp delay.

Fixes: QTBUG-102441
Change-Id: I8e8d242061f79efb4c6e02638645e03661a9cd92
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-10-16 08:36:03 +02:00
Christian Ehrlicher
5caf808750 SQL/tests: fix tst_qsqlquery
Fix two tests which got broken due to the latest changes without
notifying because those tests are not run automatically.

Change-Id: Ibe9d9601f0a2ad4ce8f06ca21e7503e77fa55781
Reviewed-by: Fredrik Ålund <fredrik.alund@mimer.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-10-16 06:05:34 +02:00
Alexey Rochev
1d7e3ef77e QMetaType: explicitly include qobject.h
convertMetaObject() function requires definition of QObject class,
but qobject.h is not included explicitly. Instead it is pulled by
qabstractitemmodel.h.

Include it explicitly to fix builds with -no-feature-itemmodel.

Pick-to: 6.4 6.2
Change-Id: I4386375588c451262923501ab8dd7374c1f729ec
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-10-16 04:05:26 +00:00
Marc Mutz
4af721dec1 QUrl: remove two unneeded Q_ASSERT()s
Q_UNREACHABLE/_RETURN() already contain such an assertion, we don't
need two of them.

Copy additional bits of information, if any, from the manual assertion
into a code comment.

Change-Id: I141b65d1293abf581272b2457015d4e52395d08b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-10-15 22:11:50 +02:00
Marc Mutz
fc76767692 Long live Q_UNREACHABLE_RETURN()!
This is a combination of Q_UNREACHABLE() with a return statement.

ATM, the return statement is unconditionally included. If we notice
that some compilers warn about return after __builtin_unreachable(),
then we can map Q_UNREACHABLE_RETURN(...) to Q_UNREACHABLE() without
having to touch all the code that uses explicit Q_UNREACHABLE() +
return.

The fact that Boost has BOOST_UNREACHABLE_RETURN() indicates that
there are compilers that complain about a lack of return after
Q_UNREACHABLE (we know that MSVC, ICC, and GHS are among them), as
well as compilers that complained about a return being present
(Coverity). Take this opportunity to properly adapt to Coverity, by
leaving out the return statement on this compiler.

Apply the macro around the code base, using a clang-tidy transformer
rule:

    const std::string unr = "unr", val = "val", ret = "ret";
    auto makeUnreachableReturn = cat("Q_UNREACHABLE_RETURN(",
                                    ifBound(val, cat(node(val)), cat("")),
                                    ")");
    auto ignoringSwitchCases = [](auto stmt) {
        return anyOf(stmt, switchCase(subStmt(stmt)));
    };

    makeRule(
       stmt(ignoringSwitchCases(stmt(isExpandedFromMacro("Q_UNREACHABLE")).bind(unr)),
            nextStmt(returnStmt(optionally(hasReturnValue(expr().bind(val)))).bind(ret))),
       {changeTo(node(unr), cat(makeUnreachableReturn,
                                ";")),  // TODO: why is the ; lost w/o this?
        changeTo(node(ret), cat(""))},
       cat("use ", makeUnreachableReturn))
    );

where nextStmt() is copied from some upstream clang-tidy check's
private implementation and subStmt() is a private matcher that gives
access to SwitchCase's SubStmt.

A.k.a. qt-use-unreachable-return.

There were some false positives, suppressed them with NOLINTNEXTLINE.

They're not really false positiives, it's just that Clang sees the
world in one way and if conditonal compilation (#if) differs for other
compilers, Clang doesn't know better. This is an artifact of matching
two consecutive statements.

I haven't figured out how to remove the empty line left by the
deletion of the return statement, if it, indeed, was on a separate
line, so post-processed the patch to remove all the lines matching
^\+ *$ from the diff:

  git commit -am meep
  git reset --hard HEAD^
  git diff HEAD..HEAD@{1} | sed '/^\+ *$/d' | recountdiff - | patch -p1

[ChangeLog][QtCore][QtAssert] Added Q_UNREACHABLE_RETURN() macro.

Change-Id: I9782939f16091c964f25b7826e1c0dbd13a71305
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-10-15 22:11:47 +02:00
Marc Mutz
16dbbc8f8c qcompilerdetection.h: detect Coverity
Just to persist the knowledge of how to detect it for the next guy.

Pick-to: 6.4 6.2 5.15
Change-Id: I16847d02ce60fab0ae14ffb2688f2ee92fa6a9f2
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2022-10-15 20:11:42 +00:00
David Skoland
306f1af145 wasm: change logic for copying batchedtestrunner files to build dir
The previous config did not work for prefix builds (files were not
copied over). To fix this, we simply copy over the files in case
of a prefix build.

Additionally removed batch_test_feature from the condition,
as this is now the de facto wasm test runner, which supports
batched and unbatched tests.

Change-Id: Ib232c7898de0a0d750e4ca5ebf1da8cbcc7da3e0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-10-15 19:50:41 +02:00
David Skoland
e60e8c4ef6 wasm: Add WebAssembly to platform of built tests on module-only build
We need to make a test for wasm run in CI, and have to start small
with qtbase. This lets the tests compile and run.

Additionally, reordered the platforms for full consistency.

Apply the same change to the qtbase config.

Change-Id: If3cedffdd7f1b21215c05b9b9302df8234a47a0c
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Toni Saario <toni.saario@qt.io>
2022-10-15 19:50:41 +02:00
Yuhang Zhao
f8c6151de1 QOperatingSystemVersion: fix newly introduced Android versions
When introducing new entries for QOperatingSystemVersion,
We should follow the new pattern [1], not the old legacy one.

Amends commit 14278bb250

[1] qtbase/3446313c7a5cd6005089866a7b20c9f28e132a0a

Change-Id: Id3444a1fba1384f9b4a410b3878ad25639b69f3d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-10-15 21:34:20 +08:00
Yuhang Zhao
8ba8d1346a QAnyStringView: fix MSVC warning
When use /W4, MSVC warns about the code is not reachable.
It's not reachable indeed, so it's no need to include it
in the final binary, just use the same #ifdef guard to
comment it out.

Pick-to: 6.4
Change-Id: I22a321e2c748bd1c5608475d61ba9a83734c5364
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-10-15 21:34:20 +08:00
Yuhang Zhao
8cb832090a MSVC: Enable all possible conformance checks
For the full list, please refer to [1].

Needed to change the qstringapisymmetry unit test:
In theory we don't need the array to be static and it did compile
without any problems so far, indeed. However, with this patch applied,
MSVC complains that the lambda function below can't access the array.
I don't understand why, because we use [&] in the lambda and it should
capture all the variables in theory, but in reality it failed to
capture this variable in the end. And making the variable static
solves this issue. Maybe it's a MSVC bug.

Already tested locally. Most Qt repos build without any issues,
only very few repos are not tested, as my local environment
can't build them.

[1] https://docs.microsoft.com/en-us/cpp/build/reference/zc-conformance?view=msvc-170

Change-Id: I658427aa171ee1ae26610d0c68640b2f50789f15
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-10-15 13:34:20 +00:00
Joerg Bornemann
0a4d0ac013 CMake: Add filter options to qt_generate_deploy_app_script
Add the options PRE_INCLUDE_REGEXES, PRE_EXCLUDE_REGEXES,
POST_INCLUDE_REGEXES, POST_EXCLUDE_REGEXES, POST_INCLUDE_FILES, and
POST_EXCLUDE_FILES.  These are forwarded to
qt_deploy_runtime_dependencies.

Change-Id: I003814bec7f797a0035e52b17fd0231f9ad7ff0d
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2022-10-15 13:00:17 +02:00
Joerg Bornemann
1407e0fe50 CMake: Deploy runtime dependencies outside of the Qt prefix too
We restricted the runtime dependencies we deployed on Linux to libraries
within the Qt installation prefix.  This restriction was supposed to
prevent the deployment of all kinds of system libraries, which is most
likely not wanted.

However, the user might link against non-system libraries, and those
should be deployed.  The same holds for QML backend libraries that exist
outside the Qt installation prefix in the build directory of the
project.

Now, we restrict deployment to libraries that are not in default system
library directories.  This can be overridden with the new
qt_deploy_runtime_dependencies option POST_EXCLUDE_REGEXES.

We add the following options to qt_deploy_runtime_dependencies, which
are then forwarded to file(GET_RUNTIME_DEPENDENCIES):
PRE_INCLUDE_REGEXES, PRE_EXCLUDE_REGEXES, POST_INCLUDE_REGEXES,
POST_EXCLUDE_REGEXES, and POST_INCLUDE_FILES.

Change-Id: I99a98fd91218abedda270609d0bafbb7f3e0feeb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-10-15 13:00:13 +02:00
Joerg Bornemann
5430fb2243 CMake: Set RPATH of deployed plugins on Linux
When deploying into some directory structure where CMAKE_INSTALL_LIBDIR
is different from Qt's lib dir, we need to set the RPATH of installed
plugins such that Qt libraries are found.

We do this using CMake's undocumented file(RPATH_SET) command and pray
that this command is safe to use across current and future CMake
versions.  For CMake versions < 3.21, we use patchelf, which must be
installed on the host system.

The adjustment of rpaths can be turned on explicitly by setting
QT_DEPLOY_FORCE_ADJUST_RPATHS to ON.

The usage of patchelf can be forced by setting QT_DEPLOY_USE_PATCHELF to
ON regardless of the CMake version.

Change-Id: I62ced496b4c12bf6d46735d2af7ff35130148acb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-10-15 13:00:04 +02:00