Commit Graph

12152 Commits

Author SHA1 Message Date
Thiago Macieira
58bea7f3a2 QCborStreamReader::next: don't allocate too much memory in a QBA
Because CBOR strings are encoded in UTF-8, it's possible that the string
that won't fit a QString in UTF-16 would still fit QByteArray in UTF-8
(e.g., anything US-ASCII and most Latin text).

The previous solution was an improvement because we used to read into a
QByteArray then convert the QByteArray to QString, thus using 3x the
amount of memory (1x in QByteArray, 2x in QString). The previous commit
skipped the middle allocation and made the regular readString() function
do the decoding either directly on source memory or by reading in small
chunks (16 kB).

Future improvement for Qt 6.1: add readStringChunk(char16_t *, qsizetype)
so we can do the validation / skipping at O(1) memory.

Pick-to: 5.15 6.0
Change-Id: I7b9b97ae9b32412abdc6fffd1645458c655cc566
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-12-07 22:54:39 +00:00
Allan Sandfeld Jensen
37bd7b5733 Add SameSite API to QNetworkCookie
Change-Id: I3f8b25418154f74bb55fa978b03465f75771d015
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-12-07 22:38:37 +01:00
Mårten Nordheim
4be6663cf2 tst_qnetworkreply: unblacklist putWithServerClosingConnectionImmediately
Looking at grafana it rarely fails in dev so unblacklisting it.
Though it is a little more flaky after switching to http 2 by default
because then we only have one channel and more requests end up queued in
the same channel, which will get errored out when the server
disconnects.

Task-number: QTBUG-88943
Change-Id: If5d6335864ce6bbc35f519b2c6d7068e4181afd2
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-12-07 15:19:12 +01:00
Mårten Nordheim
a443cbe7cd tst_qnetworkreply: unblacklist various tests
headFromHttp hasn't been flaky since 5.14 times according to grafana,
does not fail locally.

Same situation with ioHttpRedirect as above.

ioHttpRedirectMultipartPost has not failed on Windows since october
2019, assumed stable now.

backgroundRequestInterruption no longer exists.

ioPostToHttpFromSocket would fail in debug MSVC builds but was
fixed in 710886fbdd.

Task-number: QTBUG-88943
Change-Id: Ida640179ef15a3452291745e4e94a71a385f57ae
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-12-07 15:19:10 +01:00
Lars Knoll
cb39ea0581 Make the signal argument in Q_OBJECT_BINDABLE_PROPERTY optional
The intention was always that you can define properties that do
not require a changed signal. But having to explicitly pass
a nullptr as signal parameter into the macro is ugly, so
use the cool QT_OVERLOADED_MACRO to make it optional.

Pick-to: 6.0
Change-Id: I0ce366d043850f983c968d73c544d89933c48df9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-12-07 15:18:44 +01:00
Friedemann Kleint
cb064dee3a uic/rcc: Use QT_VERSION_MAJOR for major version
Amends 539a16a69fa1ef302cf4eb97ff5a7f8afb606d15.

Task-number: QTBUG-89124
Change-Id: I68c9ab2179d464d83c3fd9eefc5609b7a5a58e27
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
2020-12-07 11:37:35 +01:00
Friedemann Kleint
5634bdf9ce Fix qtdiag testing helper on Windows
The windows library user32 is no longer a known library for qmake; add
it explicitly.

Pick-to: 6.0
Change-Id: I61f44e8a2cbccbabbdc5d58bd2615b431097aafd
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-12-07 11:37:35 +01:00
Thiago Macieira
638171eb10 QCborValue: avoid allocating result if data is insufficient
Similar to the previous commit which applied to QCborStreamReader, don't
allocate too much data before checking that the stream actually has that
much.

Pick-to: 5.15 6.0
Fixes: QTBUG-88256
Change-Id: I7b9b97ae9b32412abdc6fffd16454b7568a063ba
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-12-06 07:51:19 +00:00
Thiago Macieira
9a55f40937 QCborStreamReader: avoid allocating result if data is insufficient
By calling the internal readStringChunk() function with a QByteArray
pointer, QCborStreamReader::readByteArray() can now avoid allocating the
resulting buffer until the internals have confirmed that there is
sufficient data in the incoming buffer. As a result, we first detect the
EOF condition before we conclude the payload would have been too big for
QByteArray (validation()) test. Meanwhile, the hugeDeviceValidation()
test ends up with a few conditions where it would have copied 1 GB of
data, so limit that too.

We make a choice of reporting OOM vs DataTooLarge only if QByteArray
fails to allocate in the first place (QByteArray::resize() ->
Q_CHECK_PTR -> qBadAlloc, QtCore is always built with exceptions on).

The QCborValue unit test needed a temporary work around until we apply
the same allocation fix (see next commit).

Pick-to: 5.15 6.0
Fixes: QTBUG-88253
Change-Id: I7b9b97ae9b32412abdc6fffd164523eeae49cdfe
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-12-06 07:50:57 +00:00
Friedemann Kleint
e4395f3f68 Fix uic/rcc generating outdated export for Qt for Python
Bump version to 6.

Fixes: QTBUG-89124
Change-Id: Ifcf60552b5b6efb86f79da34da9c34b8efae9fa4
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
(cherry picked from commit fc9cda5f08ac848e88f63dd4a07c08b2fbc6bf17)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2020-12-04 15:46:04 +00:00
Liang Qi
c48cb33810 tests: add a shortcut to quit app in allcursors
Pick-to: 6.0 5.15
Change-Id: I6b377cacfe05fc13c9f70e37247ed4da72f3f72e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-12-04 16:20:09 +01:00
Ivan Solovev
3d780c0d70 QtConcurrent: filter/map reduction without default ctor
Previously a default constructor was required for the result type
of mappedReduced() and filteredReduced(), even if a default value
was provided.

This patch fixes the problem.

The issue was in the ResultReporter type, that was calling
QList::resize() to adjust the size of expected reported results.
A default-value parameter was added to the class, so that
a corresponding overload of QList::resize could be invoked.

Task-number: QTBUG-88452
Change-Id: I51113753e314d76aa74d201b5a7e327a6ca75f47
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-12-04 15:36:50 +01:00
Allan Sandfeld Jensen
0c19e3f703 Fix QImage::setPixelColor on RGBA64_Premultiplied
QColors were not premultiplied before being set.

Pick-to: 6.0 5.15 5.12
Change-Id: Id3765b6932a72374ddfd788fae4bb628a4edf0b7
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-12-04 15:09:47 +01:00
Giuseppe D'Angelo
9afb3506b3 tst_qmakelib: link to QtCore's private API
Just like it was done in the .pro file.

Pick-to: 6.0
Change-Id: I7def52127f4bab6f0ef490ac7eee2de2da479352
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-12-04 11:22:38 +01:00
Fabian Kosmale
e236faa75f QBindable: Disallow mutation if read-only
If a QBindable is created from a computed property, it is not possible
to actually set a value or a binding. If we try to do it anyway, we'd
get a crash. Thus we now check whether the function pointer is null
before invoking it.

Pick-to: 6.0
Task-number: QTBUG-87153
Change-Id: I5bedb9080ccf79d9b8166b80d5733d095ed76f8d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-12-04 11:22:37 +01:00
Lars Knoll
6012285e7d Fix hashing of QPersistentModelIndex
The hash and equality operators used need to be consistent with
each other. Unfortunately, QPMI::operator==() is not suitable to do
this. So specialize qHashEquals() for QPMI.

Fixes: QTBUG-88966
Change-Id: If5f19a722ae9fc4e78e93537e7ea15726f148768
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 83e95956ed58e88b11e2cc3cb61c5beacb7985db)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2020-12-04 06:00:38 +00:00
Volker Hilsheimer
ec1ac2f1b2 Fix compiler warning from discarded return value
Amend 53b7cb1bd7, match() is only used
to provoke data races.

Change-Id: Id20b11fedf7f20e74baab15bbb60c995c1a0c794
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-04 00:17:46 +01:00
Mårten Nordheim
a7610a0cf7 tst_qstorageinfo: Test the copy ctor
It was previously untested

Task-number: QTBUG-88183
Pick-to: 6.0
Change-Id: Icc59fc632957a75cac8c7f5e2a1aed88a1c9ff9d
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-12-03 23:17:46 +00:00
Mårten Nordheim
0592369df4 tst_qnetworkreply: stabilize and unblacklist getFromHttpIntoBuffer2
The test in general is fine, but it was making an assumption that the
first 5 readyRead emissions would never result in the whole message
being received. In certain scenarios with slowdown however it was still
possible that we would receive the whole message after just a few
readyReady emissions. While I didn't check it's most likely due to a
mechanic in the QNetworkReply machinery where we suppress some
emissions if we know there's more data just about to be available.

Task-number: QTBUG-88943
Change-Id: I0cf06edb34d4e86cc8a42c0f1cd7e8c35765f6ee
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-12-04 00:17:46 +01:00
Mårten Nordheim
27f52942b4 tst_QTcpSocket: stabilize connectToHostError
It's not _wrong_ to time out when connecting to something unreachable
(it's just a different way of handling it) so we shouldn't fail when
this happens either.

In local testing (windows) it times out after 8 seconds, so bump
the timer to 10 seconds. On systems where it's faster there'll be
no difference as long as things don't go wrong.

Pick-to: 6.0
Fixes: QTBUG-89089
Change-Id: I8437cf8e4fbecedea2391ed87fdce1213085b964
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-12-04 00:17:46 +01:00
Karsten Heimrich
a0e04e7d2b Add test for QTranslator::load() translation file lookup algorithm
Pick-to: 5.15 6.0
Change-Id: I70f4b3d7dbc46d21065eab21a5af8a38d4a60589
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-12-03 07:49:58 +01:00
Giuseppe D'Angelo
7a32a2d809 tst_containerapisymmetry: fix typo
Change-Id: I9fd5c982a72cd4483108293667b2ae60f7b82ce7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-03 06:51:29 +01:00
David Skoland
3ca921293a Add test for qRound
Add test for qRound that covers some edge cases for rounding. Note that
as of right now, this test fails and the docs have been updated to warn
that it should not be depended on for strict correctness.

Change-Id: I1a61bca47abd77855fe7c13ded44e913cc7e8722
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-02 21:24:19 +01:00
Timur Pocheptsov
89734289d5 tst_qnetworkreply: cleanup BLACKLIST
Which contains a lot of 'macos'/'osx' black-listed auto-tests. They
mostly fail with SecureTransport (on BigSur) because SecTrustEvaluate()
does not like our old certificate. Instead, since SecureTransport
is deprecated anyway and we are not planning to develop it in future,
skip the related auto-test depending on QT_CONFIG(securetransport).

Task-number: QTBUG-88943
Change-Id: I5f6cb7b2d0ea15c445603c1ff3e1700f123c28d1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-12-02 17:39:06 +01:00
Mårten Nordheim
dcb10dfe81 Unblacklist tst_qnetworkreply getFromHttp
It was blacklisted due to the issue there. The issue is resolved, but
the blacklist stayed.

Task-number: QTBUG-88943
Change-Id: I7d9a660a17c1463dd8b654752ed5787fe5f5af24
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-12-02 17:39:04 +01:00
Eskil Abrahamsen Blomfeldt
34fa01be82 Fix tst_QFontDatabase::aliases failure with ambiguous font
If the first font in the families list happens to have been
disambiguated because of duplicates, two things went wrong:

1. hasFamily() would return false for the font family, because
it does not disambiguate when checking for the family name and
only checks if the families list contains the exact string.

2. Adding aliases to the full disambiguated string is not supported,
only the family name.

The first issue has been reported separately as QTBUG-89068.

The test failure is fixed by just avoiding the fonts that
are ambiguous in the test, as it really doesn't matter which
font we pick.

Fixes: QTBUG-89008
Pick-to: 5.15 6.0
Change-Id: I829778c2e7bb6090475c34dcf9cdce58862729d6
Reviewed-by: Liang Qi <liang.qi@qt.io>
2020-12-02 16:22:27 +00:00
Giuseppe D'Angelo
e12e2b43b7 Associative containers: add erase_if
Use a trick similar to the one we use for their ranged
constructors: support predicates that either take a
container's iterator, or that take a std::pair (for STL
compatibility).

[ChangeLog][QtCore][QMap] Added removeIf() and erase_if().

[ChangeLog][QtCore][QMultiMap] Added removeIf() and erase_if().

[ChangeLog][QtCore][QHash] Added removeIf() and erase_if().

[ChangeLog][QtCore][QMultiHash] Added removeIf() and erase_if().

Change-Id: Ie40aadf6217d7a4126a626c390d530812ebcf020
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-02 10:35:14 +01:00
Mårten Nordheim
65bcac95a7 Http2: Remove errored-out requests from queue
The requests will remove themselves once they get deleted
but since the deletion is done through a _queued_ invokeMethod
to 'deleteLater' we will call
QHttpNetworkConnection::_q_startNextRequest first which may
end up starting a reconnect of the TCP socket which we had the error on.

In this specific instance it manifested as a race condition where we
either don't get a proxyAuthorizationRequired signal at all (it was
emitted while we didn't have any valid replies), or we get the signal
emitted too late and it gets emitted on whatever the next reply was.

Task-number: QTBUG-88417
Pick-to: 5.15 6.0
Change-Id: If3f8ececc5550f1868c90124559cb8e3029646d8
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-12-02 10:17:12 +01:00
Mårten Nordheim
734c8aa9d9 QSet: add insert(T&&)
We already have all we need in QHash to support this, so the addition
is simple enough.

Add test checking how many copies and/or moves are needed for a single
insert.

As a drive-by: remove some unneeded static_cast

Change-Id: Iaf768657644afa45f78f5c81ffcf89ba9607be96
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-02 10:17:11 +01:00
Giuseppe D'Angelo
bec8f9ca92 Add tests for the new erase/erase_if for sequential containers
Change-Id: I3bac5f6f04f3028fbc21f1b4b15b00252a7accb1
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-01 23:03:32 +01:00
Giuseppe D'Angelo
dc091e7443 tst_containerapisymmetry: use an algorithm
In preparation for the next changes.

Change-Id: Ibe0635dfa040842073749aa3e2ae140f27dc983a
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-01 23:03:31 +01:00
Shawn Rutledge
2e0f7117b6 Fix deprecations in manual tests
QEventPoint instead of TouchPoint:  we have source compatibility for that,
but we can use the new type to avoid the deprecation warnings.
Some position accessors have been renamed too.

Change-Id: I5bfe5bc853931127a883d2bd61fab122495fd427
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-12-01 20:20:11 +01:00
Lars Knoll
60ea10e70b Add a way to check whether a metatype has datastream operators
Add QMetaType::hasRegisteredDataStreamOperators() to complement
the method to check whether a data stream operator exists.

Fixes: QTBUG-82916
Change-Id: Ib2f841131b7c401d5a3ae76d49104e41697c4eac
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-12-01 16:01:08 +01:00
Giuseppe D'Angelo
b5b2640a65 QHeaderView: fix spurious sorting
QHeaderView sorting may be triggered when the user performs
some mouse interactions that should really not result in sorting.

Generally speaking, this happens when the user:

* presses on a non-movable section (A)
* moves on another section (B)
* releases on that section

resulting in B becoming sorted / flipping sorting.

(Non-movable is required, otherwise dragging would cause section moving,
not sorting.)

To make the matter worse, QHeaderView doesn't check that the release
happens within its geometry. This makes sense when moving sections: one
is able to drag a section horizontally/vertically even if the mouse
leaves the QHeaderView.

But when not moving sections, this means that one can

* press on section (A),
* move the mouse anywhere vertically (for a horizontal bar, mut.mut
  for a vertical) above or below another section (B), that is,
  outside QHeaderView's geometry
* release the mouse

and cause B to be sorted.

Fix it by

1) remembering which one was the section that the user originally
clicked on; that's the only one that can possibly become sorted
(if we're not moving and other conditions hold). No other variable
seemed to remember this.

2) on release, check that it happens within that section's geometry.
If so, sort.

Pick-to: 6.0 5.15
Change-Id: Icfb67662221efbde019711f933781ee1e7d9ac43
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2020-12-01 15:57:10 +01:00
Fabian Kosmale
b21dba98e3 QProperty: Avoid spurious dependencies by suspending binding state
Avoid spurious bindings by resetting the binding state before calling
the setter of eager properties.

Fixes: QTBUG-88999
Pick-to: 6.0
Change-Id: I1e3b5662307d906598335a21d306be9c606529d4
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-12-01 15:06:35 +01:00
Fabian Kosmale
cea8b5832c QProperty: add test case for spurious dependency issue
Task-number: QTBUG-88999
Pick-to: 6.0
Change-Id: Ifcbf23fedfb795771550762dfed8fc38bce65794
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-12-01 15:06:31 +01:00
Mårten Nordheim
6035fd8f2c tst_qtcpserver: Test pauseAccepting/resumeAccepting
Currently untested

The socks case is odd: after accepting the first connection it shows as
unconnected. Details as for why is unknown, out of scope of adding this
test.

Pick-to: 6.0
Change-Id: I0e7658f23b89f3af8db379b001ee33a844f3bec4
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-12-01 14:42:56 +01:00
Mårten Nordheim
f7d7060b60 QNetworkDatagram: Test copy ctor and clear()
As they were not currently tested

Change-Id: I91bc8dead2c098376001a8502d29bfc746d33f73
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-12-01 14:42:54 +01:00
Mårten Nordheim
1911a4d40a QDuplicateTracker: add tests
It didn't initially have tests. To avoid relying on realizing
breakage implicitly through other classes we'll just add tests instead.

Task-number: QTBUG-88183
Pick-to: 6.0
Change-Id: I7449dc1f9a118d4b7a8158a2c34563dbd9c43c66
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2020-12-01 14:42:52 +01:00
Andreas Buhr
caa632803d Disable some OpenGL and QRhi tests for offscreen backend
This patch disables four failing unit tests when executed with the
offscreen backend.

Change-Id: Ie67341b886984e6de19cd8dd8a8a237a620a1b7a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-12-01 14:14:45 +01:00
Volker Hilsheimer
2885a99c32 Fix compiler warnings from mixing signed/unsigned ints
Change-Id: I146203dd8b6dddabc0a7cf4b3db8a3fd379fc0c6
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-12-01 09:12:10 +01:00
Timur Pocheptsov
fe009bd514 tst_QSslError: improve the code coverage, as pointed at by LCOV
And also, reduce the utter sloppiness, weirdness of the test and
make it more a test and not a joke. Since the test itself depends
on !QT_NO_SSL, why bother building and running its main, to create
a useless tst_QSslError and do nothing then? Exclude test from
no-ssl build.

Pick-to: 5.15
Pick-to: 6.0
Change-Id: I67879b0de036cbc8c2f75a18f4cf94e6c43c5af0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-12-01 09:12:10 +01:00
Lars Knoll
de4a73ebd6 Inline access to the QBindingStorage
And inline the fast checks inside the methods in QBindingStorage.
This allows QObjectBindableProperty and friends to inline all the
fast checks and almost completely eliminates the overhead for property
accesses when no bindings are being used.

Read and write times of QObject based properties when no bindings
are being used:
                                              Read       Write
Old style property:                           3.8ns       7.3ns
QObjectBindableProperty (no notification):    4.5ns       4.3ns
QObjectBindableProperty (with signal):        4.5ns       7.6ns
QObjectBindableProperty (inline accessors):   3.2ns       3.4ns

Numbers without this patch:

Old style property:                           3.8ns       7.9ns
QObjectBindableProperty (no notification):    7.2ns       7.7ns
QObjectBindableProperty (with signal):        7.2ns      16.0ns
QObjectBindableProperty (inline accessors):   6.3ns       6.7ns

Change-Id: Ifd1fa3a489c3be8b1468c0b88af547aac397f412
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 98c82fb445acf45cc4c4bc86a5adda43358127bf)
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-11-30 23:02:27 +00:00
Timur Pocheptsov
1158ff67b4 QSslSocket::verify: do not alter the default configuration
QSslCertificate::verify() has an undocumented and not very desirable property -
on some platorms it updates the default configuration, which can be surprising.
For example, we deprecated QSslSocket::setDefaultCaCertificates() and recommend
using QSslConfiguration::defaultConfiguration(), QSslConfiguration::setDefaultConfiguration(),
and QSslConfiguration::setCaCertificates(). If an application does this to select
CA roots it trusts explicitly, and then for some reason is calling verify, the
application can have its QSslSockets successfully connecting to a host, whose
root was not trusted by the application. Also, on Windows, defaultCaCertificates()
include system roots already, no need to have them twice.

[ChangeLog][QtCore][QtNetwork] QSslSocket::verify - do not change the default configuration

Pick-to: 5.15
Pick-to: 6.0
Pick-to: 6.0.0
Fixes: QTBUG-88639
Change-Id: I1cd40b259d0a6dcd15c78d1e7c027ff10859595c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-11-30 23:11:05 +01:00
Timur Pocheptsov
6a1d9f6fc1 QDtls(cookie verifier): make sure a server can re-use 'Client Hello'
And extend an auto-test for this. When a cookie verification mechanism is
enabled, and verifier, indeed, verifies that some datagram is a 'Client Hello'
message with a proper cookie attached, we start a real DTLS handshake creating a
QDtls object and calling 'doHandshake'. In case cookie verification
was enabled, we need parameters from the verifier (it's a crypto-strong
'number' and hash algorithm) to 'lock and load' the TLS state machine in
a freshly created TLS session object. This code path previously was only
tested manually and was found by LCOV as untested.

Pick-to: 5.15
Pick-to: 6.0
Change-Id: Ieacb8c989997999ea10e15bda6ae106a0338b698
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-11-30 23:11:05 +01:00
Timur Pocheptsov
bf7cec737f tst_QSslKey: remove blacklist
And do not run the test with QSslSocket::supportsSsl() returns false -
this may mean unresolved symbols and thus missing functionality,
like i2d_X509 etc. This also makes cases more like other, that already
had those checks.

Fixes: QTBUG-87386
Change-Id: If4e9a650ca325b6f70956f532891a4c1d50465c0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-11-30 23:11:04 +01:00
Kirill Burtsev
6c442ddbf5 Add widget-based test for TouchCancel event
Follow up for 45a65cbeb2

Pick-to: 6.0
Change-Id: Idb4f4eaaa3ee583462430c530f88a4cc32378d6c
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-11-30 23:11:04 +01:00
Timur Pocheptsov
efd20cafe5 tst_QSslCertificate - improve code coverage
Some code-paths were never executed by auto-test, thus giving us LCOV's
diagnostic. Extend existing tests and add new ones.

Pick-to: 5.15
Change-Id: I648747547f0525a482216b1e1972fcc698c73f65
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-11-30 17:16:22 +01:00
Fabian Kosmale
5082b84b38 QMetaObjectPrivate: Add firstMethod
QMetaObject::indexfOfMethod returns the method corresponding to a
specific signature. In QML, we however only want any of the methods with
a given name (and do overload resolution at a later point).
For this usecase this patch introduces the internal
QMetaObject::firstMethod function.

Change-Id: Ie3820354edffb273c4cbe1399201a955ebe79344
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-11-30 17:16:22 +01:00
Giuseppe D'Angelo
405244fe30 Fix QVariant/QMetaType::compare APIs
std::optional<int> is the wrong datatype to use for compare.

First and foremost, it can't be used in the idiomatic form of

  auto r = a.compare(b);
  if (r < 0) ~~~ // a is less than b
  if (r > 0) ~~~ // a is greater than b

which we *already* feature in Qt (QString, QByteArray).

Also, std::optional<int> (explicitly) converts to bool, which is
a trap, because the result of the comparison can be accidentally
tested as a bool:

  if (a.compare(b)) ~~~ // oops! does NOT mean a<b

Not to mention extending this to algorithms:

  auto lessThan = [](QVariant a, QVariant b) { return a.compare(b); }; // oops!
  std::ranges::sort(vectorOfVariants, lessThan);

which thankfully doesn't compile as is -- std::optional has
an *explicit* operator bool, and the Compare concept requires an
implicit conversion. However, the error the user is going to face
will be "cannot convert to bool because the operator is explicit",
which is deceiving because the fix is NOT supposed to be:

  auto lessThan = [](QVariant a, QVariant b) { return (bool)a.compare(b); }; // big oops!

Instead: backport to Qt the required subset of C++20's <compare>
API, and use that. This commits just adds the necessary parts
for compare() (i.e. partial ordering), the rest of <compare>
(classes, functions, conversions) can be added to 6.1.

Change-Id: I2b5522da47854da39f79993e1207fad033786f00
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 3e59c97c3453926fc66479d9ceca03901df55f90)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2020-11-30 17:16:22 +01:00
Giuseppe D'Angelo
81e893fb2d QHash: support std::hash as hashing function
In addition (and as a fallback) from requiring qHash, add support
for std::hash specializations. This catches two birds with one stone:

1) users of Qt can simply specialize std::hash for their datatypes,
and use them in both QHash and stdlib unordered associative containers;

2) we get QHash support for any (stdlib) datatype that is hashable
without having to overload qHash for them.

[ChangeLog][QtCore][QHash] QHash, QMultiHash and QSet now support
for key types anything that can be hashed via std::hash, instead of
always requiring a qHash() overload.

Change-Id: Ib5ecba86e4b376d318389500bd24883ac6534c5f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2020-11-30 17:16:22 +01:00
Giuseppe D'Angelo
d982fdfca4 QHeaderView: allow un-sorting of models
If one clicks on a QHeaderView's section, the header view will
sort the view by the respective column/row. By clicking multiple
times, one is able to toggle the sorting between ascending
and descending. Something that is NOT possible to do however is to
un-sort the view -- that is, to restore the model's original
sorting. This must be done via code, by asking the header or the
view to sort by section -1.

This commit adds new property to QHeaderView to make it possible
to unsort models. Basically, the sort indicator becomes a tri-state:
sort ascending, sort descending, unsort (sort by column -1).

[ChangeLog][QtWidgets][QHeaderView] Added the sortIndicatorClearable
property. Setting this property allows the user to clear the sort
indicator on a section, resetting the model to its default ordering.

Change-Id: Ibf4e280b2086b75ccd64d619ea4d70816dc3529f
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
2020-11-30 18:16:21 +02:00
Ivan Solovev
3cacf1d1bd QCollator: extend tests
- Add tests for QCollatorSortKey
- Add test for QCollator copy assignment and copy construct
Currently QCollatorSortKey tests are working properly only
with QT_CONFIG(icu)

Task-number: QTBUG-88546
Change-Id: Ic35dfd33038cc736245904b78fe4383a5a11b580
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-30 17:16:21 +01:00
Andreas Buhr
0440614af0 Replace discouraged Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPE
Q_MOVABLE_TYPE was conceived before C++ had move semantics. Now, with
move semantics, its name is misleading. Q_RELOCATABLE_TYPE was
introduced as a synonym to Q_MOVABLE_TYPE. Usage of Q_MOVABLE_TYPE
is discouraged now. This patch replaces all usages of Q_MOVABLE_TYPE
by Q_RELOCATABLE_TYPE in QtBase. As the two are synonymous, this
patch should have no impact on users.

Pick-to: 6.0
Change-Id: Ie653984363198c1aeb1f70f8e0fa189aae38eb5c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2020-11-30 17:16:21 +01:00
Andreas Buhr
5e84023344 Fix warnings about unused variables in benchmarks
This patch removes two unused variables and marks one unused, fixing
three warnings.

Change-Id: I71f59839452590b82ffb5459a968f06bd434fb9a
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-11-30 17:16:21 +01:00
Alexander Volkov
68de00e0d4 QStandardPaths: Don't change permissions of XDG_RUNTIME_DIR
Conform to the XDG Base Directory Specification:
"If, when attempting to write a file, the destination directory
is non-existent an attempt should be made to create it with
permission 0700. If the destination directory exists already
the permissions should not be changed."

At the same time the spec states about XDG_RUNTIME_DIR that
"its Unix access mode MUST be 0700", so don't consider the
directory with wrong permissions correct and use a fallback.

Task-number: QTBUG-68338
Pick-to: 5.15 5.12
Change-Id: I03c6b35b3f7d5ceb8e6326695bfc8207da92ea67
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: David Faure <david.faure@kdab.com>
2020-11-30 19:16:21 +03:00
Fabian Kosmale
d27d2b5d72 QMetaProperty::typeName: use name from metatype
Except for types marked as unresolved, we're doing it anyway - the only
difference is that now we skip looking up the metatype by typeid.

[ChangeLog][QMetaProperty][Important Behavior Change]
QMetaProperty::typeName returns now always the same name as name() of the
corresponding metatype. This can cause a change for enum properties
which were not fully-qualified.

Change-Id: I1f57743948b7262ac06095d3bbc838d620f6e481
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-11-30 17:16:21 +01:00
Fabian Kosmale
26e1a0997e QMetaObjectBuilder: remove relocatable data support
Change-Id: I6f1dc9e81723e9a8af8988a8cb45c63c05214296
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-11-30 17:16:21 +01:00
Fabian Kosmale
2cea05fce9 tst_qmetaobjectbuilder: Clean-up deallocation of dynamic metaobjects
If a testcase failed before we reached free, the QMetaObject would have
leaked.
Moreover, defer freeing until all tests have run: dynamic QMetaObjects
might create dynamic metatypes. If those were shared, we would run into
issues.

Change-Id: I2edfcb2605e58eaba454bfe0446a6b187a5210df
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-11-30 17:16:21 +01:00
Fabian Kosmale
71200ae11d tst_qmetaobjectbuilder: more descriptive error messages
Change-Id: I7e430f5033d18cf3dc804294bbaac16b0d3f348a
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-11-30 17:16:20 +01:00
Fabian Kosmale
465701bb98 QMetaPropertyBuilder: carry metatype
Properties of non-dynamic classes always have the metatype stored, so we
can make use of it. Moreover, when the builder is converted into a
metaobject, we need to resolve the metatype anyway.
As a driveby, add a dedicated metatype test to tst_qmetaobjectbuilder.

Change-Id: I7eea0cd8fc2da5d92c7fc803f05cd81e3a9d4cf4
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-11-30 17:16:20 +01:00
Wang ChunLin
66acca3316 Fix invalid QSortFilterProxyModel::dataChanged parameters
QSortFilterModel shouldn't forward dataChanged() when the source model changes data in columns that the filter model refuses

Fixes: QTBUG-86850
Pick-to: 5.15
Change-Id: I26565d119d2aa36ea07b3de0c15f1b137bc002f8
Reviewed-by: David Faure <david.faure@kdab.com>
2020-11-30 12:39:21 +08:00
Volker Hilsheimer
6b85f4f9fe Fix compiler warning - remove dead code
The function is unused.

Change-Id: Ib2154398981c0db20a2096c83b371d12920e34ea
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: David Skoland <david.skoland@qt.io>
2020-11-27 13:26:54 +01:00
Edward Welbourne
bbe74df26f Use QCOMPARE(,) in preference to QVERIFY(qFuzzyCompare(,))
The former also does fuzzy comparison, but it reports what the values
were, if the test ever fails.

Change-Id: I36ecda1f69bf3f430c904b37cd8c3a23201ab7e2
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2020-11-27 13:26:52 +01:00
Edward Welbourne
4785e39156 QCalendar: increase coverage by tests
Added tests for aliases and various calendar properties, ensured
dateToJulianDay()'s invalid date branch is exercised. Corrected
assertion when constructing from system and asserted calendarSystem()
is as expected.

Pick-to: 5.15
Task-number: QTBUG-88183
Change-Id: I510afcb5d9d115f68148d1f679f3224d712f92f4
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-11-27 13:26:52 +01:00
Volker Hilsheimer
27f78b9da5 Fix compiler warning from comparing signed to unsigned
std::vector::size returns size_t, which is unsigned.
Change-Id: I81ba3d58a1bd3a3c3d90c911263a5c0df0441b16
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
2020-11-27 07:28:25 +00:00
Volker Hilsheimer
c2dbc26893 Fix compiler warnings from deprecated method
QTextCharFormat::fontFamily is deprecated in favor of fontFamilies,
which returns a QStringList wrapped in a QVariant, whereas the setter
expects a QStringList.

Change-Id: I3333eaae4fc5ec3e3bdbec58047d6b3554b4a171
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2020-11-27 07:28:24 +00:00
Volker Hilsheimer
63c5d13885 Fix compiler warning from deprecated function
Change-Id: I34d6788fd5b9ab004b0e337933bea90c8f63717a
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2020-11-27 08:28:24 +01:00
Assam Boudjelthia
97b914b3e7 Android: fix tst_android test
Fixes: QTBUG-88506
Pick-to: 6.0
Change-Id: I938de388fce8ec393b03b2f0f42ddfe9094e6a5e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-25 21:08:10 +00:00
Assam Boudjelthia
c7dec2faca Android: exclude faulty qfilesystemwatcher test
Task-number: QTBUG-88508
Pick-to: 6.0
Change-Id: I11b845e74e599d3bdae4f9490a591893531bc77b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-25 23:08:09 +02:00
Assam Boudjelthia
63934f1338 Android: exclude faulty tst_selftests
This test was failing but was returning a pass because of a bug
in androidtestrunner.

Task-number: QTBUG-88507
Task-number: QTBUG-88508
Pick-to: 6.0
Change-Id: I4fda7c2ddf8cd1e6858617e7bb447078c5768a75
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-25 23:08:09 +02:00
Marc Mutz
3f8896d77e QSet: add missing insert-with-hint
Since QHash is missing the overload, too, just ignore the hint for
now, but provide the STL-compatible signature so generic code can use
QSet as a normal sequential container.

[ChangeLog][QtCore][QSet] Added insert() overload taking an insertion
hint, for STL compatibility.

Change-Id: I9fe41877343ebff721b650fb7b9cd4e06b6608d8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2020-11-25 22:08:09 +01:00
Volker Hilsheimer
cd2f29891f Fix compiler warning from deprecated function
Make the string into a list and call setFontFamilies.

Pick-to: 6.0
Change-Id: I1b70db784fd6e495b48917141d07bacd1e883882
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2020-11-25 22:08:09 +01:00
Giuseppe D'Angelo
bfe77a21fb QVLA: do not include QtTest
The right include is QTest, QtTest drags in all of QtCore.

Change-Id: Icc2964ccdb85fe1bfc9fe8f43351a4605a34329b
Pick-to: 6.0 5.15
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-25 03:48:09 +01:00
Alexey Edelev
2548438e32 CMake: Change generated resources naming
Align generated resources .qrc file naming to qmake naming.
Update tests.

Fixes: QTBUG-88581
Pick-to: 6.0
Change-Id: Id8a2f91f23c257e5b8bd371748c2151ec54a6418
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-24 21:51:29 +01:00
Andreas Buhr
824de3850e Fix tst_qfiledialog2 in case directory ~/foo exists
One test in tst_qfiledialog2 only succeeded if the directory "~/foo"
did not exist. This patch changes the path used to "~/Vugiu1co"
which has hopefully a much lower probability of existing.
The string "Vugiu1co" is taken from a call to "pwgen".

Pick-to: 6.0
Change-Id: Ia82b07902a91eb908a74aa90cdbdf4761d432d9a
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
2020-11-24 21:50:55 +01:00
Andreas Buhr
1dff26dd95 Fix tst_qlibrary after rebuild
tst_qlibrary depends on a library (targets mylib and mylib2) to be
built. They create a library with the same name, in two versions.
This is done in order to test versioned library loading.
However, those two libraries were fighting over the creation of
"libmylib.so". In a fresh build, mylib2 wins, as intended. But after
a rebuild, mylib won, which led to failing unit tests.
This patch changes the situation. With this change, mylib no longer
tries to create "libmylib.so". Thus no fighting and no problem.

Pick-to: 6.0
Change-Id: Id89baa5503c9f078a8737ff0b8616edf09044f72
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-11-24 21:50:46 +01:00
Alexandru Croitor
47435572fb Blacklist authenticationCacheAfterCancel on Ubuntu 20.04
It flaky fails integrations.

Amends 2b49b01aa3

Task-number: QTBUG-88417
Change-Id: I6aad6ee7a70e580da64e75f69e8c9cab1cb78cd7
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 143d619ba33c693fbbf9fbc3587921a44ae87435)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2020-11-24 20:50:42 +00:00
Andy Shaw
8302ca22f4 Return a QString() if the families list is empty
Fixes: QTBUG-88781
Change-Id: Iafed2be29e2e0c3029e832986ba58d19446214eb
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-11-24 21:49:54 +01:00
Andreas Buhr
764fbb1c01 Skip QSystemTrayIcon unit test for offscreen platform
When we are using the offscreen plugin, there might or might not
be a working system tray icon. This patch disables the unit test in
that case as we do not know what to expect.

Change-Id: I34fded516300cc9aab1eb67644dcef8631ecfdf1
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2020-11-24 18:54:45 +01:00
Ivan Solovev
d8579826ed QMessageAuthenticationCode: extend tests
- Add test for static hash() method
- Add tests for addData() overloads
- Add input data for sha384 and sha512

Task-number: QTBUG-88183
Change-Id: I7e16419b3a582468fd1de15613e1157af428bc4c
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-11-24 18:54:44 +01:00
Andreas Buhr
f9d172f5a1 Fix tst_qlibrary by telling CMake about required libraries
tst_qlibraries needs to test libraries to be built in order to run
successfully. However, these libraries were not mentioned as
dependencies in CMake.
This patch fixes that.

Fixes: QTBUG-88445
Pick-to: 6.0
Change-Id: Ic335e46664edd98217bd55a9bca5a58a39cffe66
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-23 21:11:42 +01:00
Timur Pocheptsov
95cbce3e6e QPasswordDigestor - improve code coverage
By extending (a bit) an auto-test to cover paths found by LCOV. All of them
is just to trigger the code that checks input parameters.

Pick-to: 5.15
Pick-to: 6.0
Change-Id: I62f9a9045038ff8d123fd1396f4bfd85e75c6d8f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-11-23 18:38:53 +01:00
Timur Pocheptsov
1157167a5c QSslConfiguration - improve code coverage
By adding auto-tests that were missing/not triggering the paths found
by LCOV.

Pick-to: 5.15
Pick-to: 6.0
Change-Id: I472f59e8e7292786c80d7c8dcebde53a2982e1ec
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-11-23 18:38:53 +01:00
Volker Hilsheimer
e59ab8b590 Fix compiler warning about discarded return value
Not testing the result of the copying, just verifying that it doesn't
assert.

Pick-to: 6.0
Change-Id: Ib51129134b74c17eada7e3819ccfff10bb9affbf
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-11-23 12:51:41 +01:00
Fabian Kosmale
5806ecf5cb QMetaType: Track whether type is QML list type
This information is required in the QML engine to handle list properties
(instances of QQmlListproperty<T> and list<T> types from QML).

Pick-to: 6.0.0 6.0
Change-Id: I1e30572f1c91f58b290cb9b4b07433af99a1db6f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-11-23 09:57:00 +01:00
Ivan Solovev
54875be84d Add convenience functions for QFuture creation
[ChangeLog][QtCore][QFuture] Add convenience functions to create
a ready QFuture and a QFuture with an exception

Task-number: QTBUG-86713
Change-Id: Ic7f9ca590a8ea8a9696b84f35bad074780794461
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-11-23 09:50:21 +01:00
Allan Sandfeld Jensen
f61f8bb966 Replace qt_make_unique with std::make_unique
We can depend on C++14 now.

Change-Id: Iee9796cd22dbfbb70d4bdb25f0eee1662a026d6d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-11-23 09:50:21 +01:00
Alex Trotsenko
ed8b8ffde4 tst_QProcess: fix compilation on Windows
Suppress warning:

..\tst_qprocess.cpp:272:13: warning: 'void childProcessModifier(int)'
    defined but not used ...

Change-Id: Idf601df78be256cfbee0ca80252d1c364c712c8e
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-11-22 23:14:25 +02:00
Giuseppe D'Angelo
8ae9431c79 QMargins(F): add support for structured binding
[ChangeLog][QtCore][QMargins] QMargins is usable in a structured
binding.

[ChangeLog][QtCore][QMarginsF] QMarginsF is usable in a structured
binding.

Change-Id: I0c501847b9377c47bd0e63da3735792075bd0079
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-22 02:22:20 +01:00
Andreas Buhr
ae2c309420 Add unit test for QAnyStringView::compare
Coverage tests revealed that
QAnyStringView::compare(QAnyStringView, QAnyStringView, CaseSensitivity)
was not tested in our unit tests. This patch adds a test for this.

Pick-to: 6.0
Change-Id: Id8e0d8af87e7e7ab192fb7554a278ddbb890fb14
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-21 06:11:55 +01:00
Andreas Buhr
146a2a21b1 Fit tst_qprinterinfo in case there are printers in local network
tst_qprinterinfo compared the output of "lpstat -p" with the
result of a call to "cupsGetDests". "lpstat -p" only returns local
printers, "cupsGetDests" also returns printers on the local network.
This patch fixes the test by using "lpstat -e", which also
shows printers on the local network.

Pick-to: 6.0
Change-Id: Ia70adad8b8467f4c738f769d34757786fc9645b2
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-11-21 06:11:37 +01:00
Eskil Abrahamsen Blomfeldt
1d14067680 Fix weight when reading old serialized QFonts
The QFont::fromString() needs to differ between strings
produced before and after Qt 6.0 when interpreting the
weight value, since in older strings this will be the legacy
scale.

Luckily the number of tokens in the string can be used for this
purpose, since many tokens were added in Qt 6.0.

This broke KDE, where font settings are stored in QSettings
and serialized using QFont::toString() from Qt 5.

Fixes: QTBUG-88589
Pick-to: 6.0.0 6.0
Change-Id: I199737fed61917f8b9d8f86176ead29a89eb8e0c
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2020-11-20 20:29:00 +00:00
Assam Boudjelthia
4713298b98 Android: exclude qarraydata::dataPointerAllocate() from CI tests
Task-number: QTBUG-88705
Task-number: QTBUG-87025
Pick-to: 6.0
Change-Id: If2dc0e650e5104d00a097e6195dd117d6cfd64e6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-20 21:38:02 +02:00
Ivan Solovev
1a0ae4e32d Extend tests for QMargins
- Add check for QT_NO_DATASTREAM macro
- Add tests for QDebug operator<<

Task-number: QTBUG-88183
Change-Id: I346777a3237986f7f950f157e50cae846b077e11
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2020-11-20 15:02:11 +01:00
Giuseppe D'Angelo
fb6b7869e8 QPoint(F): add support for structured binding
QPoint(F) are "naturally" destructurable in their x/y
counterparts (hello Mac/Carbon users, we don't live in 1999
any more, it's x and then y, and not vice versa...).

[ChangeLog][QtCore][QPoint] QPoint is usable in a structured
binding.

[ChangeLog][QtCore][QPointF] QPointF is usable in a structured
binding.

Change-Id: I8718a4e80be4ce03f37f012034f1fba009304b32
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-20 16:01:14 +02:00
Timur Pocheptsov
1d7189f5b3 tst_qocsp: improve code coverage
By simply extending the basic test to trigger qHash, isEqual and
a bunch of getters.

Pick-to: 6.0
Pick-to: 5.15
Change-Id: Ib1d88fc6d2ad623743cea77ac286ae6ac819dfd1
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-11-20 14:46:33 +01:00
Andreas Buhr
b02147788b Add unit test for YearMonthDate
Coverage analysis showed that QCalendar::YearMonthDate was not
rigorously tested. This patch adds a unit test.

Pick-to: 6.0
Change-Id: I0af485d13c4883764b61ea1e35455905cc77b966
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-11-20 14:43:33 +01:00
Andreas Buhr
7b0fd20775 Add unit test for QString::insert(negativeint, QChar)
QString::insert(qsizetype, QChar) can insert at negative positions,
then counting from the end of the string. Coverage analysis revealed we
do not have a unit test for this. This patch adds a unit test.

Pick-to: 6.0
Change-Id: I8d41b38df964c07fe2d2e7be444f8236c9e19b5d
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-11-20 14:42:49 +01:00
Andreas Buhr
756c4faccb Add unit test reproducing integer overflow in QDateTime::fromString
Task-number: QTBUG-88656
Change-Id: I05b9ad1dfa9b3f02480d8e99a523371342bdba9b
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
2020-11-20 14:42:32 +01:00
Timur Pocheptsov
1a2e2921d2 QSslCipher - improve its code coverage and auto-tests
tst_qsslcipher was quite useless - now we test that default constructed
QSslCipher reports expected values. Test the non-default from the
different auto-test,  where we are sure we have really useful
ciphersuites (with different parameters obtained from a TLS backend,
where it's possible).

Pick-to: 6.0
Pick-to: 5.15
Change-Id: Iff14a0580fed889cf9e0873bee01d968773626db
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-11-20 14:38:59 +01:00
Giuseppe D'Angelo
37808ee55a Remove QScopedSharedPointer
It's private and unused since ~2012.

Change-Id: Iea11af27f7eebf3eae2467b22b68cd4c26885edd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-20 14:34:14 +01:00
Timur Pocheptsov
4111d8e8e7 tst_QTcpSocket::connectToHostError - handle possible timeouts
... instead of failing the test. On Ubuntu 20.04 when calling
'connect' with 0.0.0.1 we get EINPROGRESS and nothing else,
since our own internal timer has 30 s. timeout, the event loop
in the test stops before this and no socket error detected yet.
Handle such situation without failing a test.

Fixes: QTBUG-88042
Change-Id: Id6add27fcf9bbbe5fbf83a193652edf08fbad8d6
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-11-20 14:34:04 +01:00
Sona Kurazyan
289f909621 Test conversion of ulonglong variant to JSON
Make sure ulonglong variant converts to a double JSON value when the
value is greater than 2^63.

Change-Id: I4d4392b05de29c220624056d5d0d4664fb2c08b7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-20 14:31:49 +01:00
Andy Shaw
d8602ce58b QFont: Prefer setFamilies() over setFamily()
By depending on setFamilies() then we can be sure that font names with
spaces, commas, quotes and so on are correctly handled without being
misinterpreted. For now it will split on the comma when a string
containing one is passed to setFamily. But from Qt 6.2 this will be
removed to preserve the family string as a convenience function.

[ChangeLog][QtGui][QFont] Indicated that setFamilies/families is
preferred over setFamily/family to ensure that font family names are
preserved when spaces, commas and so on are used in the name.

Change-Id: Id3c1a4e827756a4c928fed461a4aafa5a0f06633
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-11-20 14:30:22 +01:00
Kai Koehne
ce29ce586f Revert "Allow QWindowsPipe{Reader,Writer} to work with foreign event loops"
This reverts commit ee122077b0.

Reason for revert: This causes QProcess::readAll() to sometimes
return nothing after the process has ended.

Fixes: QTBUG-88624
Change-Id: I34fa27ae7fb38cc7c3a1e8eb2fdae2a5775584c2
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
(cherry picked from commit 23100ee61e33680d20f934dcbc96b57e8da29bf9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2020-11-20 13:28:31 +00:00
Shawn Rutledge
5509449daf Add tst_QHighDpi::mouseVelocity()
Ensure the values are reasonable regardless of screen DPI.  Velocity
is supposed to be in logical pixels / second.

Task-number: QTBUG-88252
Task-number: QTBUG-88346
Change-Id: Ic209887f8ed0381c033a9ff04ae48b072c444df4
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2020-11-20 10:45:11 +01:00
Andreas Buhr
06f58a909b Add unit test for QString::replace with out-of-bounds position
QString::replace(pos, len, *unicode, size) can handle positions
which are outside of the this-string. In that case, it is a no-op.
Coverage analysis revealed we do not have a unit test for this.
This patch adds one.

Change-Id: Id4a407e860fff0d5c7c0a200c379e5e3961c86d2
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2020-11-19 23:56:15 +01:00
Andreas Buhr
ebaae45ea1 Fix logic error in QString::replace(ch, after, cs)
Coverage analysis showed that an if-branch marked "Q_LIKELY" was never
taken. It turns out the code was incorrect, but behaved correctly.
This patch fixes the logic and adds a unit test.

Pick-to: 5.15
Change-Id: I9b4ba76392b52f07b8e21188496e23f98dba95a9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-19 20:28:27 +01:00
Edward Welbourne
28e4a8421c Fuzzing: Add a test for QDateTime::fromString
This patch adds a basic fuzzing test for
QDateTime::fromString.

Task-number: QTBUG-87104
Pick-to: 5.15
Change-Id: Icc51386f06f6d4d2a4495734f7fa45de80c6e065
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
2020-11-19 12:28:45 +01:00
Lars Knoll
b4c1747612 Make QMetaTypeInterface constexpr on Windows
This was so far problematic as it gave various link errors. The solution
to that seems to be to make the default constructor of QPairVariantInterfaceImpl
constexpr to get around one set of problems.

The other problem to solve where undefined references to metaobjects. The
reason for that is apparently that QMetaTypeInterface contains a direct
pointer to the meta object, something the linker doesn't like. Adding a
level of indirection by using a function that returns the pointer seems
to solve that problem.

Fixes: QTBUG-88468
Change-Id: I5612ae807ea3b7e49bc40349d8d1fca1be9bd7ee
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-11-19 12:28:45 +01:00
Andreas Buhr
98666c8afc Change QString formatting of negative numbers in non-base-10
For bases other than 10, negative numbers have been converted
to QString by casting them to an unsigned number and
converting that. Thus QString::number(-17, 16) returned
"0xffffffffffffffef", for example.
This patch changes the behavior so that
negative numbers are converted like positive numbers.
Additinally, this patch adds unit tests for QString::number.

[ChangeLog][Important Behavior Changes]
Changed QString::number(integer, base) for negative numbers
and bases other than 10 to return the string corresponding
to the absolute value, prefixed by "-".

Fixes: QTBUG-53706
Change-Id: I0ad3ca3f035d553860b262f5bec17dc81714d8ac
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-19 11:28:44 +00:00
Wang ChunLin
8455bfee76 Fix QSFPM not emitting dataChanged when source model is set
QSortFilterProxyModel did not emit dataChanged when calling
setSourceModel() after modifying the source model.
QSortFilterProxyModel::setSourceModel and
QSortFilterProxyModelPrivate::_q_sourceReset(), _q_clearMapping
is called to delete the source_index_mapping. They also need to
call create_mapping function to re-create it.

Fixes: QTBUG-87781
Pick-to: 5.15
Change-Id: Idbe34696c9d3a2fbf354b653c870bac61378811d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-18 20:57:48 +01:00
Allan Sandfeld Jensen
34304e3100 Get rid of Q_COMPILER_CONSTEXPR checks
Is required now.

Change-Id: I62e95929d1649ea1390392230b619bd56d2a0349
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-11-17 21:28:11 +01:00
Alex Trotsenko
1e9dc3ec2f CMake: fix QLocalSocket benchmark to use new qt_internal_ API
Amends ee122077b.

Change-Id: I9b750eb88ac9c83da26da4e5921cb147716c5eb6
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-11-17 21:34:04 +02:00
Timur Pocheptsov
4f6c5d83d0 Network self-test: make it work with docker/containers
Fixes: QTBUG-87740
Pick-to: 5.15
Change-Id: Idfe73708784774188afd40048f81406aa720a554
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-11-17 19:56:06 +01:00
Edward Welbourne
26e41291bb Test QTimer's isSingleShot() and timerType()
Previously neglected in testing.

Task-number: QTBUG-88183
Change-Id: Iacfca6f8c590af6dccb126cf3e43387ed50dbf06
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-17 19:55:05 +01:00
Edward Welbourne
06c898d7a9 Add some tests for various qmath.h functions
Previously untested.

Task-number: QTBUG-88183
Change-Id: I9e94308471651e447f35a21329e43a363fb23961
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-17 19:55:04 +01:00
Edward Welbourne
c0829d6131 Improve qFloatDistance() test coverage
Four code-paths that weren't tested are simply those with the
parameters swapped from code-paths we did test.  In any case, the
float-distance between values should be symmetric, so test that.

Task-number: QTBUG-88183
Change-Id: I2060eb77b1abada5b0fd5f4557dbb1761c5cfd02
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-17 19:55:04 +01:00
Shawn Rutledge
f5010c49a3 QTest: don't wait before sending mouse event: increment the timestamp
Tests can run faster now, but we still expect calculations based on
the timestamp (such as QEventPoint::velocity()) to be correct.

Change-Id: Ie962604c9ebd139384dcd89a157de66b4b773cc9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-17 19:55:04 +01:00
Ivan Solovev
1d8dd9a02c Track progress range in QFutureInterface::setProgressValue
Previously QFutureInterface::setProgressValue was silently ignoring
the progress range and allowed to set any progress value.
Also no checks were performed in QFutureInterface::setProgressRange,
which allowed the user to set minimum > maximum.

Add checking of the current progress range, when settings the
progress value.
Add checks for minimum and maximum values while setting the progress
range.
The implementation of the checks is mostly based on the logic
that is used in QProgressBar.
- If maximum is smaller than minimum, minimum becomes the only legal
value.
- If the current progress value falls outside the new range, the
progress value is set to be minimum.
- If both progressMinimum() and progressMaximum() return 0, the
current progress range is considered to be unused, and any progress
value can be set.
- When setting the value using setProgressValue(), if the value falls
out of the progress range, the method has no effect.

Task-number: QTBUG-84729
Change-Id: I29cf4f94b8e98e1af30dd46fbdba39c421cf66bf
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-11-17 16:16:31 +01:00
Ivan Solovev
e0248ddc5c Extend tests for QLogging
Add tests for QMessageLogger class to explicitly cover all
overloads of logging methods.

Task-number: QTBUG-88183
Change-Id: I8d551f4b066cc285101646230bd9a17869ada3c1
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
2020-11-17 16:16:10 +01:00
Piotr Mikolajczyk
f92e195369 Android: Ensure windows always have a geometry on creation
A QWindow created without an explicit geometry needs to pick up
a default geometry in the platform plugin. If the window has a
maximized of fullscreen window state, it will fill the entire
available geometry of the parent window (or the screen if there's
not parent window).

Fixes: QTBUG-69159
Fixes: QTBUG-69156
Fixes: QTBUG-69154
Pick-to: 5.15
Change-Id: If8565d92a97bb4b3fa44757e68969d54d0bc7ebe
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-11-17 10:48:05 +00:00
Lars Knoll
7fc302520b Move the iterator from QTypedArrayData to QList
The low level implementation does not use it at all, so there's no
point having the iterator in QTypedArrayData. Having it in QList removes
and indirection and will lead to clearer error messages.

Change-Id: I4af270c3cdb39620e5e52e835eb8fe1aa659e038
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2020-11-17 11:47:53 +01:00
Lars Knoll
a1f3be3e41 Clean up QList(iterator, iterator)
Fold the two overloads into one, and distinguish the cases using
if constexpr. Do not overload QArrayOps::copyAppend(), to make it
clear which one is being used.

Change-Id: If6a894841aacb84ba190fb2209246f5f61034b42
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-11-17 11:47:45 +01:00
Lars Knoll
996255baae Fix signature of QArrayDataOps::erase()
Bring it in line with the other methods that also take a
pointer and a size.

Also use truncate() in removeAll() as that's more efficient
for the use case.

Change-Id: Ib1073b7c048ceb96fb6391b308ef8feb77896866
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-17 11:47:36 +01:00
Lars Knoll
c0e1a38f69 Remove the special code for emplaceFront/Back again
emplace() itself now handles those cases fast enough, so there
should not be a need to add special code paths for those methods.

Change-Id: I3277eb77dd54194e46f96f24de44d7785a6f860a
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-17 11:47:32 +01:00
Lars Knoll
30597cfc0e Clean up emplace implementations
Avoid duplicated code paths for GrowsForward vs
GrowsBackward. Special case emplaceing at the
beginning or end  of the awrray where we can
avoid creating a temporary copy.

Change-Id: I2218ffd8d38cfa22e8faca75ebeadb79a682d3cf
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-11-17 11:47:28 +01:00
Lars Knoll
6431565e0a Simplify QArrayDataOps::insert() for movable types
Avoid ever having to call a destructor and unify the code for
insertion at the front or at the end.

Change-Id: Ie50ae2d4a75477cfdae9d5bd4bddf268426d95b5
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-11-17 11:47:16 +01:00
Lars Knoll
faea8e2661 Remove unused code
Change-Id: I22f377c10a556fbb011ec98094d5a61ee3f63867
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-17 11:47:13 +01:00
Lars Knoll
168772fe8f Remove destructor calls from insert()
QList::insert() should never need to call a destructor. This
requires that we construct the new items in the list in order
and increment the size each time we constructed a new item.

Not having a code path that potentially calls destructors should
avoid the generation of lots of additional code for those
operations. In addition, the forward and backwards code paths
are now unified and only require somewhat different setup of
some variables at the start.

This gives us strong exception safety when appending one item,
weak exception safety in all other cases (in line with std::vector).

Change-Id: I6bf88365a34ea9e55ed1236be01a65499275d150
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-11-17 11:47:02 +01:00
Lars Knoll
f1db4d6e38 Fix moveAppend() implementation
When appending multiple items, we are fine with providing
weak exception safety only. This implies that we can simplify
the moveAppend() code and avoid having to potentiall
call destructors in there.

Change-Id: I31cef0e8589e28f3d3521c54db3f7910628e686f
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-17 11:46:57 +01:00
Lars Knoll
621c05e3b1 Don't allow storing types that throw in the destructor in our containers
Types that throw in their destructors are strongly discouraged in C++,
and even the STL doesn't define what happens if such types are stored
in their containers.

Make this more explicit for Qt and disallow storing those types in our
containers. This will hopefully preempty any potential future bug
reports about us not handling such a case. It also helps simplify
some code in QList and other cases and makes it possible to explicitly
mark more methods as noexcept.

Some care needs to be taken where to add the static asserts, so that
we don't disallow forward declarations of types stored in containers.
Place the static assert into the destructor of the container where
possible or otherwise into the templated d-pointer.

Change-Id: If3aa40888f668d0f1b6c6b3ad4862b169d31280e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-11-17 11:46:28 +01:00
Lars Knoll
fed055790a Simplify code in QExceptionSafetyPrimitives
QExceptionSafetyPrimitives::Destructor doesn't need an additional
template argument, and the freeze() method was unused.

Some methods of the Constructor class could also be simplified.

Change-Id: Iacf35bc8634f402519a8bd875b5efea7841f9db5
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-11-17 11:46:12 +01:00
Lars Knoll
fc172c4313 Simplify the code for QList::emplace()
Unify it with the code in QArrayDataOps and only have one
emplace method there that handles it all.

Adjust autotests to API changes in QArrayDataOps and fix a
wrong test case (that just happened to pass by chance before).

Change-Id: Ia08cadebe2f74b82c31f856b1ff8a3d8dc400a3c
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-17 11:45:52 +01:00
Alex Trotsenko
ee122077b0 Allow QWindowsPipe{Reader,Writer} to work with foreign event loops
When a foreign event loop that does not enter an alertable wait state
is running (which is also the case when a native dialog window is
modal), pipe handlers would freeze temporarily due to their APC
callbacks not being invoked.

We address this problem by moving the I/O callbacks to the Windows
thread pool, and only posting completion events to the main loop
from there. That makes the actual I/O completely independent from
any main loop, while the signal delivery works also with foreign
loops (because Qt event delivery uses Windows messages, which foreign
loops typically handle correctly).

As a nice side effect, performance (and in particular scalability)
is improved.

Several other approaches have been tried:
1) Using QWinEventNotifier was about a quarter slower and scaled much
   worse. Additionally, it also required a rather egregious hack to
   handle the (pathological) case of a single thread talking to both
   ends of a QLocalSocket synchronously.
2) Queuing APCs from the thread pool to the main thread and also
   posting wake-up events to its event loop, and handling I/O on the
   main thread; this performed roughly like this solution , but scaled
   half as well, and the separate wake-up path was still deemed hacky.
3) Only posting wake-up events to the main thread from the thread pool,
   and still handling I/O on the main thread; this still performed
   comparably to 2), and the pathological case was not handled at all.
4) Using this approach for reads and that of 3) for writes was slightly
   faster with big amounts of data, but scaled slightly worse, and the
   diverging implementations were deemed not desirable.

Fixes: QTBUG-64443
Change-Id: I1cd87c07db39f3b46a2683ce236d7eb67b5be549
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-11-17 12:45:50 +02:00
Lars Knoll
6be39809b0 Simplify reallocation handling in QList
Have one generic method for detaching and reallocations.
Use that method throughout QList to avoid duplicated
instantiations of code paths that are rarely used.

Change-Id: I5b9add3be5f17b387e2d34028b72c8f52db68444
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-11-17 11:45:46 +01:00
Tony Sarajärvi
c9420aeeff Conditionally disable tests that depend on cxx11_future flag
Task-number: QTBUG-88392
Change-Id: Ic8451ca4052ec4a94f0d78307e1b32965eb18c4e
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-11-17 05:21:06 +00:00
Assam Boudjelthia
76f866c40a Android: move blocked tests of qapplication to test folder
Android packages the test instead of qapplication folder, thus the
BLACKLIST file for Android tests needs to be in "test" folder
instead.

Task-number: QTBUG-87666
Task-number: QTBUG-87025
Change-Id: I065072fa8a030cf9d15e057869e74a8c736c80ab
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-16 13:35:49 +02:00
Assam Boudjelthia
8904c50d6f Android: exclude failing test tst_android:assetsRead
Task-number: QTBUG-87025
Task-number: QTBUG-88506
Change-Id: I11137fadd1455ae782af5ada1c6d88d65050440d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-16 13:35:48 +02:00
Assam Boudjelthia
87fdad35ca Android: exclude failing tests of tst_qhighdpi
Tests in tst_qhighdpi are crashing on Android.

Task-number: QTBUG-88505
Task-number: QTBUG-87025
Change-Id: Ie1350e06fb30d90f20c550f91555f4023eee56b6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-16 13:35:46 +02:00
Assam Boudjelthia
ac1cbc752f Android: exclude tests crashing at start
These tests are failing with "java.lang.UnsatisfiedLinkError: dlopen
failed: invalid ELF file" at the start, excluding them now to enable
Android testing until they're fixed later.

Task-number: QTBUG-87671
Task-number: QTBUG-87025
Change-Id: Ida7d7158fccdc31df1f9689f77fde832964d732f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-16 13:35:44 +02:00
Friedemann Kleint
c8ae8ddb3a Manual shortcut test: Fix deprecation warnings about key combinations
Change-Id: Ifd85dad8042c98ea3c1402588cd50169dee1f685
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-11-16 12:35:42 +01:00
Assam Boudjelthia
4f0ee5fb37 Android: exclude host tools tests for android and ios
Task-number: QTBUG-87025
Task-number: QTBUG-88538
Change-Id: Id691c8463e9bf83c4538dce93300fb4fd5a99849
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-16 11:35:33 +00:00
Giuseppe D'Angelo
784a290c4b QFileInfo: mark constructors as explicit
These look like leftovers (API flaws).

Construction of QFileInfo from QString (or similar) should be not
implicit, as QFileInfo construction is expensive (might hit the file
system), and this may have users overlook APIs (for instance build a
QFileInfo out of QDirIterator::next(), instead of using ::fileInfo();
using QDir::entryList instead of entryInfoList; etc.).

Leave an opt-out mechanism to ease porting.

Fix a handful of usages around qtbase, with at least a couple of them
likely to be actual "sloppy" code.

[ChangeLog][Potentially Source-Incompatible Changes][QFileInfo] Most
QFileInfo constructors are now explicit. The
QT_IMPLICIT_QFILEINFO_CONSTRUCTION macro is provided to keep old code
working.

Change-Id: Ic580e6316e67edbc840aa0c60d98c7aaabaf1af6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-11-15 18:30:16 +01:00
Giuseppe D'Angelo
1869615fc9 QChar: make construction from integral explicit
QChar should not be convertible from any integral type except from
char16_t, short and possibly char (since it's a direct superset).

David provided the perfect example:

  if (str == 123) { ~~~ }

compiles, with 123 implicitly converted to QChar (str == "123"
was meant instead). But similarly one can construct other
scenarios where QString(123) gets accidentally used (instead of
QString::number(123)), like QString s; s += 123;.

Add a macro to revert to the implicit constructors, for backwards
compatibility.

The breaks are mostly in tests that "abuse" of integers (arithmetic,
etc.). Maybe it's time for user-defined literals for QChar/QString,
but that is left for another commit.

[ChangeLog][Potentially Source-Incompatible Changes][QChar] QChar
constructors from integral types are now by default explicit.
It is recommended to use explicit conversions, QLatin1Char,
QChar::fromUcs4 instead of implicit conversions. The old behavior
can be restored by defining the QT_IMPLICIT_QCHAR_CONSTRUCTION
macro.

Change-Id: I6175f6ab9bcf1956f6f97ab0c9d9d5aaf777296d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-11-15 14:41:05 +01:00
Andreas Buhr
2b49b01aa3 Blacklist authenticationCacheAfterCancel on Ubuntu 20.04
The test authenticationCacheAfterCancel was the only one to fail
in recent COIN runs. This patch blacklists it on Ubuntu 20.04.

Task-number: QTBUG-88417
Change-Id: Idc85499da82336d291d9a90ecb941810a0e6c935
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-11-13 20:56:45 +01:00
Sona Kurazyan
2bce62a318 Conditionally disable code snippets that depend on cxx11_future
Fixes: QTBUG-88392
Change-Id: Ida215253fdcad66a5a67084d3ff6781583101859
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
2020-11-13 20:31:22 +01:00
Timur Pocheptsov
9662ff67ce tst_qsslkey - handle QT_NO_SSL properly
The recent change handling missing elliptic curves introduced a problem
for '-no-ssl' configuration/build. The first version had some protection,
but it was openssl-specific and required a private feature, thus was
removed. Now the real ifdef must be with QT_NO_SSL

Fixes: QTBUG-88238
Pick-to: 5.15
Change-Id: I6fba26d6ab63850e1468e76f8b234703255a026c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-11-13 18:05:08 +01:00
Alexey Edelev
558f5a2d7b CMake: Add support for -binary option for generated resources
Add handling of -binary flag in qt6_add_resources for generated
resource file variant.

If -binary argument is provided in OPTIONS section of
qt6_add_resources function, it will be passed to rcc as argument.
File path to output .rcc could be additionally specified by
DESTINATION argument. Extra target generated_<resource_filename>
will be added to project's 'all' set.

Implement tests for new functionality.

Fixes: QTBUG-87644
Change-Id: Id1313da499d86f82859d1757c3cfae2d84e894d4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-12 22:11:37 +01:00