Commit Graph

49466 Commits

Author SHA1 Message Date
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
Topi Reinio
ca8e9ff2ef Doc: Make \youtube macro work with litehtml help backend
Unlike the QTextBrowser backend, litehtml does not render elements
inside <iframe> correctly. This prevented external links to
YouTube from working in offline documentation.

Move the <iframe> to a macro override specific to online doc builds.

Pick-to: 6.0 6.0.0
Fixes: QTBUG-88975
Change-Id: Iff7828ddeed353620eaa9ac669a3e0c03749daa2
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-12-01 08:12:09 +00:00
Toni Saario
7fd89ed63b Add instructions to build documentation
This enables documentation building in add-ons and other modules that
need to build docs.

Task-number: QTQAINFRA-3972
Change-Id: Ic2763d6d36d26e5a1267b312727c3c268ad6d114
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit e84e85dd4c59f2c79f81ba4d8d7f04397eb0003c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2020-12-01 08:12:09 +00:00
Ole-Morten Duesund
3c3737f88b Discourage the foreach keyword
Stop endorsing the foreach keyword, suggest C++11 range-based loops
instead.

Task-number: QTBUG-86584
Pick-to: 6.0
Change-Id: Icaf537aded6557b7864d731217e967ac56a84928
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-12-01 08:12:09 +00:00
Sona Kurazyan
bc46c7b8ea Fix perfect forwarding of callables in QFuture's continuations
Use universal references instead of rvalue references for passing
callables in the implementations of QFuture's continuations.

Change-Id: I1288c78f78f84f30c6607e505e7f9807a9272071
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
(cherry picked from commit b002722dabef794da0e80010b115b2c6cd6dc6b8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2020-12-01 08:12:09 +00:00
Fabian Kosmale
a9ba5fe7aa QMetaProperty: Enable constructing only Data
Constructing a QMetaProperty can be unnecessarily expensive due to the
QMetaEnum resolution. Add a private method to construct only
QMetaProperty::Data. Make us of it in indexOfProperty.

Task-number: QTBUG-82931
Change-Id: If954538106bcfaa7d088db26591f6bd6eeaf3731
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-12-01 09:12:09 +01:00
Lars Knoll
1f1a322373 Simplify the safeguarding logic in notify()
The logic in notify() was doing quite a bit more work than
it needed to. By inserting a dummy node after the current one instead of
replacing it, we can avoid half of the data shuffling that has been
happening and also don't need a back pointer when executing the
notification.

Also avoid calling a semi expensive destructor of QPropertyObserver.

Reduces the overhead of notify() by ~30%.

Change-Id: I7ce16bcf9cd9c4368c18bf875fc959223452fd4f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit e8ef871e3522f340b4efe32382af7e35ef908665)
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-11-30 23:02:31 +00:00
Lars Knoll
d555425ff8 Inline the fast path for removeBinding()
Save a function call in the common case where we don't have a binding
This makes a rather large performance difference for setters that do
not have a binding.

Change-Id: I140f29790f6fe868721a33b9fad37205e547b8e9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit c63901c5f3195596eb81e5f5ae5483ca5a0b6d35)
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-11-30 23:02:30 +00:00
Lars Knoll
e095bebaf5 Smaller cleanup in QBindingStorage
Unify code paths and avoid excessive code generation.

Change-Id: I4a54234dd322bba380cc45d4f9c97d97a0c93303
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 65759c9867321d978c1f98f5cf66bef11c8f5c15)
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-11-30 23:02:30 +00:00
Lars Knoll
ba0e012902 Inline the fast path of a few methods
No need to do function calls for the case where we return immediately
after checking a boolean.

Change-Id: I3e449850a10fcf82acb843cce6da6dfd98de32ad
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit e165f416a752398079590161a18255f9a0058a3e)
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-11-30 23:02:29 +00:00
Lars Knoll
76743374e7 Remove ExtraBit and FlagMask from QPropertyBindingData
They are not needed and removing it can simplify the code in some places
and avoid a couple of masking operations.

Change-Id: I0e4241a2784026aa89deed35f408b094e89a11a0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit b1be6e6e6f355bfcb0c3814516f6009c91d2de89)
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-11-30 23:02:29 +00:00
Lars Knoll
f538ce920e Inline the QPropertyBindingPrivatePtr destructor
In many cases, it only derefs and does nothing else. Inline the fast
code path.

Change-Id: Ib605c385c1683f7833f7189c84d6cf4eb5b0e59e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit eda4c29eb26dab32e22040bdda0b9b9109b1408b)
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-11-30 23:02:28 +00:00
Lars Knoll
1181286d43 Optimize code in QTaggedPointer
Don't execute instructions that will never do anything.

Directly add the tag to the pointer in the constructor to avoid
additional masking operations, and avoid a masking op that is in
practice a no-op in setTag().

Do the same optimization in QTagPreservingPointerToPointer.

Change-Id: Ia364f89cbe6ccc876ec9bda0c239fc4f57c10501
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 2721728c9056b442c0281f20792f19eb6a491aa0)
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-11-30 23:02:28 +00: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
Joerg Bornemann
92d60ae589 CMake: Fill QT.<module-name>.uses entries in module .pri files
Those entries were always empty. The INTERFACE_QT_MODULE_USES property
was never set.

Map each public dependency to its qmake lib name and place this value
into the module's QT.<module-name>.uses variable.

Take into account the "_nolink" target modifier and translate it to
qmake's "/nolink".

Pick-to: 6.0
Fixes: QTBUG-88951
Change-Id: Ib6ef65b842a1fe1da3ade55867583343b4ee76ee
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-30 23:17:55 +01:00
Joerg Bornemann
bf483ca979 CMake: Rename internal variable
Rename QT_QMAKE_LIB_TARGETS_foo to QT_TARGETS_OF_QMAKE_LIB_foo, because
we want to introduce the counterpart QT_QMAKE_LIB_OF_TARGET_bar in a
subsequent commit.

Pick-to: 6.0
Task-number: QTBUG-88951
Change-Id: I33f00f4fe65c5977da6e74c632ebeab3b891c89a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-30 23:17:53 +01:00
Joerg Bornemann
bd98ba0d17 CMake: Do not discard empty QMAKE_LIBS_FOO entries
Consider a qmake lib 'foo' that doesn't have entries in
QMAKE_LIBS_FOO. Then we must not discard this entry in the generated
module pri file, because otherwise any attempt to QMAKE_USE 'foo' will
fail with the error message "Library 'foo' is not defined.".

Pick-to: 6.0
Task-number: QTBUG-88951
Change-Id: Ibed283857f5f66b1b79459fe7b7cf06c7ce0691d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-30 23:17:52 +01:00
Joerg Bornemann
5592204b19 CMake: Fix QMAKE_LIB of WrapOpenSSLHeaders library
The correct entry for this lib is 'openssl/nolink', not
'openssl_headers'.

In configurejson2cmake's helper.py we already have
this information encoded such that the no_link_so_name field of
'openssl' points to 'openssl_headers'. Extend configurejson2cmake to
take this into account, and re-generate src/network/configure.cmake.

Pick-to: 6.0
Change-Id: I9817ea7722503a373d309b7e6fa201448d403e8d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-30 23:17:50 +01:00
Joerg Bornemann
b71c04353d CMake: Work around building dbus 'controller' example with qmake
Similar to what has been done in 5138a970f3, we need to adjust the
remotecontrolledcar/controller dbus example to be built with qmake.

In the CI we first build the examples with CMake in the source
directory. That creates some generated source files in the dbus example
dir.

Then, the examples are (will be) built ouf of source with qmake, and
those generated source files will be placed in the build directory.

When building with MSVC, there's a peculiarity with nmake/jom's
inference rules that lead to picking up the generated car_interface.cpp
from the source directory, instead of the build directory.
See QTBUG-13496 for details.

car_interface.cpp, built with CMake is generated to include
car_interface.moc.
car_interface.cpp, built with qmake does not have this include, but the
build system calls moc on car_interface.h.

All this leads to duplication of the meta object for
OrgExampleExamplesCarInterfaceInterface, preventing successful linking.

Work around this issue by turning off the generation of nmake/jom
inference rules.

Task-number: QTBUG-85986
Change-Id: I0a6ca9f880b63f05a4e9f2032e44d3b391d8a756
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-30 23:17:48 +01:00
Joerg Bornemann
d4e9f0e633 CMake: Re-generate project files in src
Pick-to: 6.0
Change-Id: I1f5f822d68129490f1a7c495f718aead0b520ca9
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-30 23:17:47 +01:00
Joerg Bornemann
1a1d3a9a44 pro2cmake: Fix is_public_module calculation
write_library_section traverses the parent/child hierarchy of scopes to
determine whether the scope belongs to a public Qt module. This doesn't
work for scopes that stem from included .pri files, because each
included file has its own parent/child hierarchy.

We already have an include scope hierarchy in the form of
Scope._included_children, but lack a way to get to the including
scope.

Add Scope._including_scope and adjust the is_public_module calculation
to take that into account after hitting the top of the parent/child
hierarchy.

Pick-to: 6.0
Change-Id: I8fee1cfbf048e7afc6783b0a52eaca75be17072f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-30 23:17:40 +01:00
Alexey Edelev
c140b26959 CMake: Add debug information for 'qt_evaluate_config_expression'
Add '_qt_internal_dump_expression_values' function that dumps all
values evaluated by 'qt_evaluate_config_expression'.
'_qt_internal_dump_expression_values' doesn't evaluate undefined
features, only collect actual values.

Fixes: QTBUG-88476
Pick-to: 6.0
Change-Id: I9d09ffbd9f9fa91bc4f36536c58e7f118b06f9b9
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-30 22:17:12 +00:00
Timur Pocheptsov
abee4cdd59 QMacStyle - remove vertical adjustment for inactive tab
While it worked as expected with beta, with final release this thing
looks wrong again, especially in the dark mode.

Pick-to: 5.15
Pick-to: 5.12
Change-Id: I6857344de897e0f39d9d8e66431635dbe2f4d077
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-11-30 23:11:05 +01: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
Sheng Mao
dbd1c8b047 Let QXcbConnection::getTimestamp properly exit when X server quits
QXcbConnection::getTimestamp uses dummy events to get timestamp from
X server. However, in some cases, X server shuts down while client tries
to get timestamp. In this case, QXcbConnection::getTimestamp keeps
getting null event and thus falls into indefinite loop.

This fix checks if xcb connection is still valid and use a special
xcb_timestamp_t value, CurrentTime (0L), as returned value.
CurrentTime should not be generated by X server and if getTimestamp
returns this value, it means an "exception" case is triggered.

This fix is introduced because in kwin_x11 (KDE project), X server can
exit on logout. kwin_x11 should handle disconnection from X server.
But the indefinite loop prevents kwin_x11 to process disconnection
event and therefore kwin_x11 cannot quit properly.

Fixes: QTBUG-88435
Pick-to: 5.12 5.15 6.0
Change-Id: Iaf7ef3f8a35fa8389d22a608e3c49041bf90e1b9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-11-30 23:11:04 +01:00
Liang Qi
92a57e0b01 Revert "xcb: add xcb-util dependency for xcb-image"
This reverts commit 39b1dea2ec.

39b1dea2 is wrong, the bug is for static build of qt with static
xcb. It adds the explicit dependency of xcb-util 0.3.9, which is
not available on Debian yet.

Task-number: QTBUG-86287
Fixes: QTBUG-88688
Pick-to: 5.15 6.0
Change-Id: Iffc821f49bdfcad3f2556951d3677c35a7682266
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-11-30 22:11:04 +00: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
Andreas Buhr
d545fbb61b Extend container overview documentation, mention Q_DECLARE_TYPEINFO
The container overview documentation did not mention
Q_DECLARE_TYPEINFO and the related optimizations. This patch
adds a short paragraph about it.

Task-number: QTBUG-86584
Pick-to: 6.0
Change-Id: I5b0b8ce92a47da5f0398cc413fbf3e07b0921e59
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@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
Topi Reinio
99abdd180b Doc: Fix various documentation warnings
- QList iterators are now nested classes inside QList.
- Drop reference to Qt OpenGL Widgets landing page, there is no such
  page.
- Fix typos and linking issues.

Fixes: QTBUG-86295
Pick-to: 6.0
Change-Id: I964843deb81aa55ff8ddb9a1c2b004cb72e68de9
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-11-30 16:16:22 +00:00
Topi Reinio
3789ca6c99 Doc: Fix QVector[2|3|4]D documentation
The \fn commands for friend functions need to include the class
scope for QDoc to find the declarations.

Pick-to: 6.0 6.0.0
Fixes: QTBUG-88932
Change-Id: Icbb45c12d7d657d95243231148483c00baf07c36
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-11-30 17:16:22 +01:00
Topi Reinio
af7f7732cb Doc: Document BINDABLE attribute for Q_PROPERTY macro
Pick-to: 6.0
Fixes: QTBUG-87036
Change-Id: Ia6067d887b9b697dbcb8e02bce5a560a8ac5eaf3
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-11-30 17:16:22 +01:00
Topi Reinio
9aa34f3bf2 Doc: Add thumbnail for Widgets Gallery Example
The example won't show up in Qt Creator's Welcome mode without either
an \image or a generic thumbnail. Add the latter for now.

Pick-to: 6.0
Fixes: QTBUG-88970
Change-Id: Id5ec236ef4760e678921bc2a90608d66ac35394d
Reviewed-by: Paul Wicking <paul.wicking@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
5dab710b90 Seedless qHash catch-all: make it SFINAE-friendly
To support qHash overloads without a seed we have a qHash(T, size_t)
catch-all that calls qHash(T) and XORs the seed. The problem is
that this catch-all is not SFINAE friendly. For a type Foo which
does not have any qHash overload, we can't ask if qHash(Foo, size_t)
is callable because it would instantiate the catch-all and fail
to compile.

Add a suitable trait and enable_if.

Pick-to: 6.0
Change-Id: Idffd48a537eebaf77cee7030b8d91a302643ffde
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:21 +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
Christophe Giboudeaux
687bd03d09 CMake: strip the executable bit from qt-cmake-private-install.cmake
Despite being installed in the the binary directory, this
CMake snippet cannot be executed.

Pick-to: 6.0
Change-Id: Ibfd31e51184f0688d19ac063804cc200c95555a7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-11-30 16:16:21 +00:00
Alexandru Croitor
908ee750ed CMake: Fix resource object file paths in prl files for prefix builds
Before this change, the prl files always assumed that resource object
files are installed into $qt_prefix/lib when doing a prefix build.
That was true for qt_internal_add_resource calls, but not for
qt6_add_qml_module and qt6_target_qml_files.

Change qt_internal_record_rcc_object_files to take a new required
INSTALL_LOCATION argument. The argument takes a path relative
to CMAKE_INSTALL_PREFIX.

Modify __qt_propagate_generated_resource to save the relative path of
the generated resource source file, which will be used in the
computation of the final resource object file location.
This is needed because the Qml resource functions place the source
files in a different directory layout, e.g. .rcc vs .qmlcache

Modify qt_generate_prl_file to prepend $$[QT_INSTALL_PREFIX]/
instead of $$[QT_INSTALL_LIBS]/ for the resource install paths.

A follow up patch is done in qtdeclarative to pass the new
INSTALL_LOCATION argument from the Qml CMake functions.

Amends f9dcade5e7

Task-number: QTBUG-87702
Task-number: QTBUG-88425
Change-Id: Id17bb517b4cb5d00911bfd10a728ba4e0d44871b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 54d0ca93bca78f8fd31b6761f078e7a96283f183)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2020-11-30 16:16:21 +00: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