Commit Graph

52802 Commits

Author SHA1 Message Date
Marc Mutz
ccec95fda6 QCoreGlobalData: use QHash, not QMap, for dirSearchPaths
No user of the variable iterates over the container, they only
manipulate or inspect individual entries, so order doesn't matter. If
order doesn't matter, use the more efficient QHash over QMap.

Change-Id: Id28913a57bb14eb328e668624f236f76cad86def
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-06 14:19:52 +02:00
Fabian Kosmale
87973325f1 Handle even more include in enum cases
The solution in d3ed7dac8a was needlessly
complicated, and broke a valid use case.
The issue of no identifier being available to parse after the include
has been processed can instead be solved by moving the test for the
closing brace after the include processing.

Fixes: QTBUG-94790
Pick-to: 6.2 6.1 5.15
Change-Id: Ieec4b89e1d117637f11479e8bddc4060f93da43d
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-06 11:54:11 +00:00
Marc Mutz
71334c324e QXpmHandler: actually limit characters-per-pixel to four
The following code assumed, and all comments indicated, that the cpp
variable was limited to a max of 4. Yet, as coded, cpp could be five,
in which case the XPM would be corrupt, as the header suggested five
characters-per-pixel while the data was formatted in only four.

Add a warning and error out when we encounter this situation.

[ChangeLog][QtGui][QImage] Instead of writing a corrupt file, rejects
to write XPM files with more than 64^4 colors (more than four
characters per pixel) now.

Pick-to: 6.2 6.1 5.15 5.12
Change-Id: I458873cf7d179ab2e2dacd4c17dc837d640591a9
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-06 13:50:39 +02:00
Marc Mutz
066dd1cdc0 QInputDeviceManager: ++explicit, ++out-of-line-dtors
It's private API, but exported, so de-inline the dtor to pin the
vtable in QtCore instead of potentially duplicating it in every plugin
that uses the class.

Change-Id: Ia948985bb94677c8453a8e7be27a14085303aaf5
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2021-08-06 13:02:44 +02:00
Morten Johan Sørvig
6336b5350b Improve WM_DPICHANGED handling
Resize QPlatformWindow on DPI change, so that QWindow
size can stay approximately constant.

For example, a 100x100 QWindow at 100% scaling will
have a 100x100 QPlatformWindow. If the scaling is changed
to 200% then the QPlatformWindow is resized to 200x200,
while the size of the QWindow stays at at 100x100.

In practice the QWindow size will also change slightly,
due to inaccuracies in how we adjust for the size of the
non-client window area. This will be addressed in a later commit.

We can get DPI change independently of screen change,
so no resizing should happen in screen change events.
Disable the resize code in QGuiApplication for Q_OS_WIN,
and remove the WithinDpiChanged flag.

The new flow for handling DPI change is:

  1) Send screen change (if any), so that the correct
     screen will be used when calculating scale factors
     during the following resize.
  2) Resize the native window, which will trigger geometry
     change events, possibly also for the QWindow.
  3) Resize child windows; WM_DPICHANGED is sent to
     top-level windows only.

Fixes: QTBUG-89294
Pick-to: 6.2
Change-Id: I0e2d44bae72d20ebdafc3d410db7be9964ad851b
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-08-06 13:02:44 +02:00
Morten Johan Sørvig
f988386560 Track current window DPI
The WM_DPICHANGED event gives us the new DPI, but we
also need the current DPI in order to determine the
scale factor corresponding to the DPI change.

Pick-to: 6.2
Change-Id: Ia61388415f57aa739397d3125b8751952e8fd392
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-08-06 13:02:44 +02:00
Nico Vertriest
7d7b484429 Doc: Fix link error to qFuzzyIsNull()
Pick-to: 6.1 6.2
Change-Id: I17d890d4d61199dd74598ffa4c670ed65894047c
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-08-06 12:04:28 +02:00
Marc Mutz
726119c431 QXpmHandler: clean up write_xpm_image: use conventional pointer arithmetic
... instead of *(array + index).

Also fix a pointless cast from QRgb to int which the next line
implicitly undoes (because colorMap has QRgb as key, not int) and get
rid of the local variables that facilitated said fallacy in the first
place.

Change-Id: I71a92822ee2404646f6fb5533e40252f38e6b21f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-08-05 11:32:02 +02:00
Marc Mutz
2658f95d3c QXpmHandler: clean up write_xpm_image: scope variables better
... and fix spacing around operators and after flow-control keywords.

Change-Id: Iefaa03074536d13a655c91fb42aef6aa96c2665b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-05 07:35:20 +02:00
Marc Mutz
ec40e50506 QXpmHandler: avoid double-lookup
The code used the if (!contains()) { insert() } anti-pattern,
necessitated by Qt's deviation from the STL of allowing insert() to
overwrite an existing entry, causing two lookups of the same key.

Since QMap these days is a wrapper around std::map, fix by using the
real thing (a std::map) instead, which sports the non-broken insert()
semantics already, avoiding the need to play tricks like detecting a
size increase in order to find whether an insertion took place. It
also simplifies the loop later on, and we can transparently use pmr,
when available.

Change-Id: Iedd8d5691514a7705a55c27376446304b20af071
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-05 05:19:10 +02:00
Thiago Macieira
ae0b080c01 QStringLiteral: suppress the clang-tidy warning about const_cast
We can't add the comment inside the macro, so we solve the problem by
adding an extra level of indirection.

Pick-to: 6.2
Change-Id: Ib8fbfcfeb48a49ca945dfffd169829b3610f6a34
Reviewed-by: Rui Oliveira
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
2021-08-04 19:36:01 -07:00
Tor Arne Vestbø
a71b9c9377 testlib: Clean up tst_blacklist
33d7f76f0e attempted to exercise more
of the blacklisting code, but in doing so didn't account for the
fact that the features it added didn't actually work.

Adding a global blacklisting of * will result in blacklisting
all tests, regardless of any inverse conditions "!*" later on,
such as for the 'pass' test. This would have been evident by
looking at the expectation files, which still showed the test
as a BPASS.

The broken feature should be fixed, but in the meantime let's
clean up the test so it doesn't misrepresent reality.

At the same time we also remove the messages() tests, which was
copied straight out of tst_silent, but doesn't serve any purpose
for the blacklist selftest.

Pick-to: 6.2
Change-Id: I20e4693300aad5e9ff5f17ad22e3dfcb5c49fd0e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-05 03:58:50 +02:00
Tor Arne Vestbø
c95d7741b7 testlib: Don't report additional 'pass' test point for blacklisted XFail
Regression after 9906cc57ed.

Pick-to: 6.2
Change-Id: I5566f70c66d248426c7a41b6de1cfb92f104cc64
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-08-05 03:58:50 +02:00
Tor Arne Vestbø
fb16a66b71 testlib: Report skipped tests in JUnit reporter as <skipped> elements
The Apache Ant and Surefire Maven specs document a <skipped> element that
can be used to signify skipped test, with a corresponding total skipped
test attribute on the <testsuite>.

The element includes an optional message attribute, documented in the
Surefire spec, and in the Ant source code, but not yet documented in
the reverse-engineered Ant spec:

 https://github.com/windyroad/JUnit-Schema/pull/11

Pick-to: 6.2
Task-number: QTBUG-95424
Change-Id: Ib6417a41b9c328836f4017e6ebf7f7e9cd91288d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-05 03:58:50 +02:00
Tor Arne Vestbø
58f1c0c146 testlib: Don't report JUnit errors attribute without any <error> elements
The errors attribute on the <testsuite> element represents the number of
<error> elements, but we do not produce any at the moment.

Pick-to: 6.2
Task-number: QTBUG-95424
Change-Id: I7196d622a9a6bbb7e79ed2c2886984d539abb1da
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-05 03:58:50 +02:00
Tor Arne Vestbø
5a483656bc testlib: Sync up QTest::LogElementType with element names
539553a572 renamed the LET_Error element
enum to LET_Message, without renaming the corresponding "error" element
name. This was not an issue in practice, since we never write the actual
element in QTestJUnitStreamer, but the two should be in sync to avoid
any confusion.

Pick-to: 6.2
Change-Id: I6c29f5303393b5f36b2f9877940bf3f6eaf3b7d2
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-05 03:58:50 +02:00
Tor Arne Vestbø
bb74e72aa9 testlib: Reduce JUnit test duration reporting to millisecond precision
The original Ant JUnit reporter produced test durations via Double.toString(),
supporting arbitrary precisions, and the de-facto schema declared them
as xs:decimal.

Sadly, the now popular Maven Surefire reporter limited the duration to
millisecond precision, and hard-coded this into its schema as SUREFIRE_TIME:

  https://issues.apache.org/jira/browse/SUREFIRE-1533

Unfortunately this definition spread into tools such as the Jenkins xUnit
plugin, which relies on the schema provided by Maven Surefire:

  https://issues.jenkins.io/browse/JENKINS-52152

As a result, anything that produces higher precision results will not
validate in the Jenkins xUnit plugin.

Other test frameworks have bitten the bullet and reduced their precision
correspondingly, e.g.:

 https://github.com/catchorg/Catch2/issues/2221
 https://github.com/catchorg/Catch2/commit/581c46249acf8389e9

We follow suit, and our JUnit XML output now validates against both
the Jenkins JUnit and xUnit plugins, as well as the original Apache
Ant de-facto schema.

Pick-to: 6.2
Task-number: QTBUG-95424
Change-Id: I3097d10c03c2a29709960372301b29055d224e10
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-05 03:58:49 +02:00
Tor Arne Vestbø
973e74399e testlib: Improve JUnit XML conformance
The JUnit test framework did not initially have any XML reporting
facilities built in. Instead, the XML report was generated by the
Apache Ant JUnit task:

 https://github.com/apache/ant/search?q=filename%3AXMLJUnitResultFormatter.java

Many users interacted with these reports via the Jenkins JUnit plugin,
which provided graphical visualization of the test results:

 https://plugins.jenkins.io/junit/

Due to the lack of an official XML schema for the Apache Ant JUnit
report there was some confusion about what the actual format was.
People started documenting the de-facto format, both as produced
by Ant, and as consumed by Jenkins:

 https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd
 https://github.com/junit-team/junit5/search?q=filename%3Ajenkins-junit.xsd

The XML produced by the Qt Test JUnit reporter was far from these
schemas, causing issues when importing results into tools such
as Jenkins, Allure2, or Test Center.

The following changes have been made to improve conformance:

  - The 'timestamp' attribute on <testsuite> is is now in ISO
    8601 local time, without any time zone specified
  - The 'hostname' attribute on <testsuite> is now included
  - The 'classname' attribute on <testcase> is now included
  - The non-standard 'result' attribute on <testcase> has
    been removed
  - The non-standard 'result' attribute on <failure> has
    been renamed to 'type'
  - The <system-out> element on <testsuite> is always included,
    even when empty
  - The non-standard 'tag' attribute on <failure> has been
    removed. Data-driven tests are now represented as individual
    <testcase> elements, e.g.:

      <testcase name="someTest(someData X)" ...>
      <testcase name="someTest(someData Y)" ...>
      <testcase name="someTest(someData Z)" ...>

The resulting XML validates against both the de-facto Apache Ant
'JUnit 4' schema and the Jenkins JUnit plugin schema.

Task-number: QTBUG-95424
Change-Id: I6fc9abedbfb319f2545b99b37d059b18c16776ff
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-05 03:58:49 +02:00
Tor Arne Vestbø
177d259782 testlib: Simplify JUnit test logger
- Use the right name for the attribute (AI_Message),
   rather than fixing it up in QTestJUnitStreamer.
 - Don't pretend that we're adding line and file information,
   only to discard it in QTestJUnitStreamer.
 - Don't pretend to add benchmark information,
   only to discard it in QTestJUnitStreamer.

Pick-to: 6.2
Change-Id: Ib6eadc12300157216fe9c6e8bcfebd7eb8a3ea68
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-05 03:58:49 +02:00
Marc Mutz
f1ab1132ea QXpmHandler: clean up write_xpm_image: make w,h const
... and use one variable definition per line.

Change-Id: Ie8e6d6fb9e570cf715ab0b39c78d677f1e5a19a7
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-05 03:58:49 +02:00
Edward Welbourne
70adce61ad replaceArgEscapes(): rename a local variable and simplify initialization
The name coincided with one used in other functions for a different
meaning and its initialization was clumsy. Rename to a terser name
that communicates the relevant matter more clearly.

Change-Id: I6baf8e5ec695cbbb1cc10f6c4b4cc6512c1aefc4
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-05 02:44:27 +02:00
Kai Köhne
00b7679d7a Remove unsupported, host-related options from configure shell script
This amends commit d9a9eca54d.

Pick-to: 6.2
Change-Id: I762090ac9c7ea15a176efe4eb6d39d5c4b653726
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-08-05 02:44:27 +02:00
Kai Köhne
74d0b1b1b9 CMake: Add whitespace to Android error message
Pick-to: 6.2
Change-Id: I9c7729a7bef4a659b10fe69a73b30f101cbba546
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-05 02:44:27 +02:00
Edward Welbourne
5674610d3f Pre-check a pair of string comparisons by length
When checking whether a floating-point value is "inf" or "nan", the
code actually only checked they *started* with those.  Check the
length first and thereby avoid the check when the string is longer in
any case. This incidentally avoids tripping over any string that
merely starts with "inf" or "nan" - such a string should not be able
to arise here; but we still shouldn't give it the special treatment
reserved for these two, were one to arise. Add an assertion to the one
remaining branch that wouldn't have caught such a malformed string.

Change-Id: I63828e3a99a33cf236e4d1a2e247ad832b7a00fd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-05 02:44:27 +02:00
Marc Mutz
73fabadcee QXpmHandler: fix re-entrancy bug in xpm_color_name
The xpm_color_name() function returned a pointer to a function-static
buffer. This is infamously non-reentrant, and an actual problem,
because we explicitly allow QImage operations (incl. saving to an
.xpm) from non-GUI-threads.

Fix by using the CSS pattern (Caller-Supplied Storage; also used in
the QAnyStringView(char32_t) and QAnyStringView(QStringBuilder) ctors)
to force the caller to allocate storage in its own stack frame. As a
consequence, we re-gain re-entrancy, but the returned pointer is now
only valid until the end of the full-expression, which necessitated
simplifying one caller (sorry!).

To see why said simplification is valid, observe that xpm_color_name()
writes a (now-explicit) NUL into returnable[cpp] and the old code read
max(cpp, 4) characters from xpm_color_name()'s result.

NB: cpp can be 5, even though the code comments say otherwise! :(

[ChangeLog][QtGui][QImage] Fixed a race condition when concurrently
writing .xpm files.

Pick-to: 6.2 6.1 5.15 5.12
Change-Id: I36d7173d53839a52f5cdf58324474c1b32c71f33
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-08-05 01:46:44 +02:00
Edward Welbourne
115f828ae4 QTestEventLoop: stop when the test fails
It makes no sense for the event loop of a test to keep running after a
test has failed. This lets test code simply use the usual testlib
macros to compare and verify values in asynchronous tests that would
otherwise need to hand-test values and send a signal on failure (that
the main test can connect to an event-loops quit() or equivalent).

For example, QLocalSocket's benchmark simply uses the usual macros,
without doing anything to stop its event loop if they fail, with the
sad result that, when a test fails, it does so repeatedly and then
times out, causing the test program to be killed without running later
tests. With this change, that test code (once converted to use
QTestEventLoop) is able to exit gracefully on the first failure.

[ChangeLog][QtTest][QTestEventLoop] The QTestEventLoop new exits its
event loop as soon as the test is known to be failing.

Task-number: QTBUG-91713
Change-Id: If0d455741668722034906763025dda496d2afbb4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-05 01:07:41 +02:00
Edward Welbourne
2f7d4f478e tst_QByteArray::qUncompressCorruptedData(): MS-Win no longer hangs
Oliver Wolff reports that this test no longer hangs on Windows; and
the other plafroms for which it was skipped are no longer supported,
so remove the #if-ery that skips this test for platfroms on which
uncompressing corrupt data used to hang.

Change-Id: I94a3fd4b83338fe6e3a97ab055fe05e2f15b6b45
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-08-05 01:07:41 +02:00
Mårten Nordheim
e00928e48c QByteArray::number(double): Extend the test
Move out and share the test data from the QString::number_double() test
and re-use it for this one.

Task-number: QTBUG-88484
Change-Id: I6502d1d360657f6077e5c46636f537ddfdde3a83
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-04 23:45:47 +02:00
Marc Mutz
861feef2bf QFsFileEngine (Unix): replace a QPair with a proper struct
The comments in the declaration of the pair screamed "I want to be a
struct with properly-named member variables", and the code that read
it->first and it->second was really misleading to STL-aware readers.

Fix by defining a small struct with member names taken from unmap()'s
use of the pair's fields.

Change-Id: Ie18852a3147f65cf14cfc5a3bb633f7b3e78f5a2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-04 22:50:10 +02:00
Mike Achtelik
c99849d0bc Shift iOS a11y translations into C++ file
lupdate cannot parse .mm files. Therefore tr markup must be inside of
C++ files. This copies the same approach qtconnectivity uses, see
6b2fd04b7be4494767b6092a030607010d91310c

Pick-to: 6.2
Change-Id: I9853864b4b81b48da763a387c78c102857f23047
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-08-04 22:22:20 +02:00
Marc Mutz
02aa236256 QMetaTypeFunctionRegistry: avoid double-lookup in insertIfNotContains()
Because there's no insertIfNotContains()-like functionality in QHash
(unlike std::unordered_map, where insert() doesn't overwrite an
existing entry), the code first called contains(k) and then insert(k,
~~~), causing two lookups in the case where the insertion actually
happens.

Fix by using the pattern QDuplicateTracker's QSet fall-back uses, too:
recording the size before and after the call to the indexing operator
and using a size increase as the criterion that an insertion should
happen. This reduces the number of lookups to one, at the cost of a
mapped_type default construction (which, given mapped_type is
std::function, should be cheap).

Change-Id: I24b31107b3e26f2eea2edce7b46f8cb5e7cb35bf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-08-04 22:22:20 +02:00
Edward Welbourne
826e1963e3 Rework tst_QString::remove_regexp() and its data table
The test was producing a warning about the invalid test, for which
replace_regexp() had anticipated that warning; do the same in
remove_regexp(). The two tests shared a date() method, but the remove
test was a no-op on the tests with non-empty replacement text; move
the column set-up and data rows with empty replacement to remove's
data() function, from replace's, and reverse the direction of calling
each other between data() functions, so each test gets the cases that
are relevant to it and no spurious PASSes happen for no-op tests. In
the process, give moved test-cases informative names; relocate the
(entirely re-written) remove data function to beside its test; and
eliminate a pointless local variable from both tests (it used to be
needed when testing both QRegExp and QRegularExpression).

Pick-to: 6.2
Change-Id: I93dcfc444f984edf5c029f99306aff6bc95d554a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-04 22:22:20 +02:00
Edward Welbourne
a13942791d Refine localeAwareCompare() test-case filtering on ICU
The code to work around setlocale() mis-describing en_US as C ensured
that we didn't accept the C test-cases when the locale was really
en_US; but neglected to accept the en_US test-cases when the locale
really was en_US but was misdescribed as C. This lead to no tests
being run when the locale was en_US.

Tweak the logic of the test filtering to compare the wanted locale
against the system locale both when C is wanted and when it isn't.
Make the skip-messages a little more informative.

Pick-to: 6.2 6.1
Change-Id: I4e072e12819144b2941b87a5f486534047d9a579
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-04 22:22:20 +02:00
Mårten Nordheim
b41d5f6293 QDecompressHelper: Skip double-decompression if download is small
To retain backwards compatibility with some QNetworkReply usage,
namely connecting solely to finished-signal and allocating a buffer to
read into, but without storing the entire decompressed file in memory
until read, we may decompress the file twice.

With this patch users can now avoid this double decompression if the
amount of buffered data stays below 10 MiB. This means any file smaller
than 10 MiB will never need to be decompressed twice to know the size of
it. On top of that, if the data is handled as it arrives (e.g. in
readyRead) and the buffer is kept below 10 MiB it won't need to
decompress twice either.

This is active as long as "countDecompressed" is true, though it
currently always is in QNetworkAccessManger, with a future goal to make
it possible to control with public API. Since it requires the user to
potentially adapt their usage of QNetworkReply.

In this patch we also stop tracking the amount of unhandled uncompressed
bytes (uncompressedBytes) in favor of tracking the total amount of bytes
which has been read() by the user of QDecompressHelper (totalBytesRead),
since we can more intuitively work out the total amount of unread bytes
using this value.

Change-Id: Ie3d8d6e39a18343fcf9b610f45c7fe7e4cd4e474
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-08-04 19:31:52 +02:00
Fabian Kosmale
5889985c8c QProperty: Only try to avoid TLS access if currentThreadId is faster
We will not gain anything if we have to do multiple function calls to
obtain the thread id. Therefore we introduce a macro to signal that we
have a fast implementation of currentThreadId, and only use the function
if it is defined.

Pick-to: 6.2
Change-Id: I3347489ea91992896bb753b796ae26e391c2c99c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-04 19:31:52 +02:00
Fabian Kosmale
3f0a32aeb5 QProperty: Avoid needlessly refetching bindingStatus
If we already have the bindingStatus, we can just pass it along.

Pick-to: 6.2
Change-Id: Iaaea4f4c34e6a786899561293016ece163c26d25
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-04 19:31:52 +02:00
Fabian Kosmale
f7eed15588 QProperty: more micro optimization
- Provide an inline version of evaluateRecursive which does not fetch the
  status.
- Provide an unsafe variant of setBindingToNotify which does not set the
  tag. This can be used in allocateDependencyObserver, as newly
  allocated observers already have the correct tag (this is checked via
  an assert).

Pick-to: 6.2
Change-Id: I31aec6af4aef244efc6d0777e5bfaaa8f82f2046
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-04 19:31:52 +02:00
Fabian Kosmale
77d528f8d3 QProperty: Force inlining of addObserver
The method is only called in two places: observerProperty (which only
takes care of calling unlink, too, if necessary) and in
registerWithCurrentlyEvaluatingBinding_helper. In the first case, the
method most likely gets inlined anyway. In the latter case, we really
want to avoid the overhead of an additional function call to speed up
registration of the property with the binding. Considering that it is an
internal method, there is no need to worry about code explosion.

Pick-to: 6.2
Change-Id: I3f0f0e37108f3859321d3b432e37fc8da3c15dc0
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-04 19:31:52 +02:00
Fabian Kosmale
e5aff7f3d9 Pass QBindingStatus to evaluateBindings
This avoids another round of TLS lookups in evaluateRecursive when we
construct the BindingEvaluationState.

Pick-to: 6.2
Change-Id: Icfa9fd81fc6f54623d384c4d3fce33f4d4d549b9
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-04 19:31:52 +02:00
Fabian Kosmale
5d0095b1c2 QProperty: micro optimizations
- Ensure that the allocateDependencyObserver fast path is inlined.
- Use addObserver instead of observerProperty; we know that a freshly
  allocated observer does not have its prev pointer set. If prev weren't
  a private member, we could simply use Q_ASSUME(ptr->prev == nullptr),
  but making it public or befriending the class seems like a bad idea,
  as it grants too much access to the internals.

Pick-to: 6.2
Change-Id: Ia845f2807c70512563f7b9e1ecb85fe82b66208c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-04 19:31:52 +02:00
Fabian Kosmale
b8e1782b67 Avoid superfluous QBindingStoragePrivate::get call
If we have no currentBinding, then registerWithCurrentlyEvaluatingBinding
will not do anything. Thus we can completely avoid fetching the storage.

Pick-to: 6.2
Change-Id: Ic20142e4c4e09752b5c41b959f66080e6885e6c3
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-04 19:31:52 +02:00
Fabian Kosmale
71fea09e1a Avoid TLS access for groupUpdateData
By putting the groupUpdateData pointer into the same thread local as the
binding status, we avoid having to fetch two thread_local variables.
Moreover, we can reuse the caching mechanism which we have in place for
QBindingStatus to avoid costly TLS lookups.

Pick-to: 6.2
Change-Id: Iaea515763510daab83f89b8e74f35a80965d6965
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-04 19:31:52 +02:00
Fabian Kosmale
460700f773 QProperty: Avoid TLS lookup if we are in the same thread
If the QBindingStatus we receive from the QObject is from the thread
which is currently running, we do not need to refetch the thread local;
the reason we refetched the thread_local was after all only to guard
against the case where a QObject's property gets read in a different
thread.
To determine whether we are in the same thread, we can store the thread
id in the thread_local structure. Currently, it only gets initialized
for the main thread in QCoreApplication (as bindings are mostly used
there).
At a later point, we could either expose initBindingStatusThreadId, or
call the function when a QThread gets started.

Pick-to: 6.2
Change-Id: Id8eb803973bb083abfab83a62bfccc9e88a4e542
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-08-04 19:31:52 +02:00
Tor Arne Vestbø
fa8cffa4c9 testlib: Pass on file location on failure, but don't assume we have one
We try our best to pass on the file location of a failure, including for
fatal errors, but the reporting or logging machinery should not assume
there is one.

By passing on nullptr for the file location we allow the logging backends
to decide how to handle the situation, e.g. by not emitting extra fields
for failure location.

This effectively reverts c25687fa0b,
in favor of relying on the backends to cope with null filename,
which they already did.

As qFatal uses QMessageLogger, which by default disables file/line
information in release builds, we need to explicitly enable this in
our self-tests, to get uniform test results. Similarly, we disable
file/line info from testlib itself, as reporting Qt internal file
and line information for user diagnostics is less useful. The odd
one out there is qtestdata.cpp, which still ends up in test output
due to using QTEST_ASSERT instead of qFatal for its diagnostics.
Cleaning up that, and unifying how we report testlib issues to the
user, is left for another day.

Pick-to: 6.2
Change-Id: Ib9451b8eed86fe3ade4a4dcaf0037e1a3450321c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-04 17:31:51 +00:00
Tor Arne Vestbø
bef57b317f testlib: Deprecate QWARN() in favor of qWarning()
The QtTest best practices documentations recommends using output
mechanisms such as qDebug() and qWarning() for diagnostic messages,
and this is also what most of our own tests do.

The QWARN() macro and corresponding internal QTest::qWarn() function
was added when QtTest was first implemented, but was likely meant as
an internal implementation detail, like its cousin QTestLog::info(),
which does not have any corresponding macro.

This theory is backed by our own QtTest self-test (tst_silent)
describing the output from QWARN() as "an internal testlib warning".

The only difference between QWARN() and qWarning(), besides the much
richer feature set of the latter, is that qWarning() will not pass
on file and line number information in release mode, but QWARN() will.
This is an acceptable loss of functionality, considering that the user
can override this behavior by defining QT_MESSAGELOGCONTEXT.

[ChangeLog][QtTest] QWARN() has been deprecated in favor of qWarning()

Pick-to: 6.2
Change-Id: I5a2431ce48c47392244560dd520953b9fc735c85
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-04 19:31:51 +02:00
Joerg Bornemann
fe9c705e9a CMake: Make qt6_wasm_add_target_helpers an internal function
This function is called by qt_add_executable.  There is no need to
expose it as public function.

Fixes: QTBUG-95172
Change-Id: I85a1d906ecda42458e226db225e47c1d348a72f1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-04 17:01:11 +02:00
Alexandru Croitor
6518bcc167 CMake: Enforce minimum CMake version in user projects
This change introduces new behavior to error out when configuring user
projects if the CMake version used is too old for Qt to work with.

The main motivator is the requirement of new CMake features to ensure
object libraries are placed in the proper place on the link line in
static builds.

The minimum CMake version is computed based on whether Qt was
configured as shared or static libraries.

At the moment the required versions for building and using Qt are the
same.

The minimum versions are defined in qtbase/.cmake.conf in the
following variables

QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_BUILDING_QT_SHARED
QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_BUILDING_QT_STATIC
QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_USING_QT_SHARED
QT_SUPPORTED_MIN_CMAKE_VERSION_FOR_USING_QT_STATIC

Qt Packagers can disable the version check when configuring Qt
by setting
QT_FORCE_MIN_CMAKE_VERSION_FOR_BUILDING_QT and
QT_FORCE_MIN_CMAKE_VERSION_FOR_USING_QT.

In this case it is the packagers responsibility to ensure such a Qt
works correctly with the specified CMake version.

User projects can also set QT_FORCE_MIN_CMAKE_VERSION_FOR_USING_QT
to disable the version check. Then it's the project's developer
responsibility to ensure such a Qt works correctly.

No official support is provided for these cases.

Implementation notes.

The versions required to build Qt are stored in
QtBuildInternalsExtra.cmake
whereas the versions required to use Qt are stored in a new
QtConfigExtras.cmake.

Also the policy range variables stored in
QtBuildInternalsExtra.cmake are now regular variables instead of cache
variables, to properly allow overrides per-repository.

Some renaming of functions and variables was done for a bit more
clarity and easier grep-ability.

Pick-to: 6.2
Task-number: QTBUG-95018
Change-Id: I4279f2e10b6d3977319237ba21e2f4ed676aa48b
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-08-04 16:03:08 +02:00
Alexandru Croitor
9aa0d99e66 CMake: Bump min required CMake version for static Qt builds to 3.20
Building a static library Qt configuration will now require a
minimum CMake version of 3.20.

Qt builders and packagers can still opt out of the mentioned minimum
required version by configuring Qt with QT_FORCE_MIN_CMAKE_VERSION.
Such a Qt configuration is /NOT SUPPORTED/.

To facilitate these changes, the minimum version check has been moved
to happen after the BUILD_SHARED_LIBS option is computed by either
QtAutoDetect.cmake or set by a user provided cmake toolchain file.

Introduce a new QT_MIN_SUPPORTED_CMAKE_VERSION_FOR_STATIC_QT variable
in .cmake.conf to mark the minimum version for a static Qt build.

Pick-to: 6.2
Task-number: QTBUG-95018
Change-Id: Idc1875729f26a7c635b6bd26ac0c1be973917c13
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Craig Scott <craig.scott@qt.io>
2021-08-04 16:03:08 +02:00
Giuseppe D'Angelo
07057188e3 QFileSystemModel: cache the name filters regexps
In order to filter out file names based on the user's settings,
QFileSystemModel used to have a loop that tested if a given file
name matched one of the filters. The problem is that each filter
(a wildcard) was converted to a QRegularExpression _inside_ the loop.
This causes a quadratic behavior (number of files * number of filters).

Instead, build the regexps once when the filters are set (or the case
sensitivity is changed, as that affects the filtering), and simply
_use_ them in the loop.

Simplify and correct some related code as a drive by.

Done-with: Jean-Michaël Celerier
Fixes: QTBUG-95383
Pick-to: 6.2 6.1 5.15
Change-Id: I6bc336364c145bb05793a8f867545d7715d35832
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-08-04 14:03:21 +02:00
Marc Mutz
fa7f4c5efd QMetaType: auto-unregister converters and mutable views again
The port from hand-rolled function storage to std::function
inadvertently removed the helper variable of static storage duration
whose dtor would unregister the conversion function. This caused
QTBUG-94831, where the cleanup of conversion functions attempts to
call code (via std::function) from a library that has already been
unloaded.

Restore the 5.15 behavior by adding a static-storage-duration scope
guard to unregister the conversion and view functions from Qt upon
library unload (when static objects are destroyed). Unlike 5.15, only
install the scope guard upon successful registration, ensuring that
only the DLL which successfully registered its conversion function
unregisters it again.

Amends 0e4ae4fbf8.

Add some strategic std::move()s as a drive-by.

Pick-to: 6.2
Task-number: QTBUG-94831
Change-Id: I391ca667420cf0d98a166676b9bb363d6e190306
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-08-04 13:32:40 +02:00