Commit Graph

61747 Commits

Author SHA1 Message Date
Ievgenii Meshcheriakov
a035e8b768 QDBusMetaObjectGenerator: Use uniform loops to iterate over methods
Use the same structure for iterating over signals and other
methods in 3 places. Introduce MethodMap type alias to make
types shorter.

Change-Id: I732b582fc8c47616037087b77a79eb13ecf17019
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-15 14:02:47 +02:00
Ievgenii Meshcheriakov
0f37c47713 QtDBus: Convert some loops to ranged for loops
Convert some loops that are using Java-style iterators into
ranged for loops for better readability.

Change-Id: I14f6339608d201fe06a753be236db52815cbf5c4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-15 14:02:47 +02:00
Edward Welbourne
4768fcf836 Fix case-sensitivity of exponent separator check in Cyrillic fall-back
When matching the locale's correct exponent separator, QLocale was
doing a case-insensitive match; but the Cyrillic fall-back was
matching case-sensitively, so failed to catch the case of lower-case e
and its Cyrillic equivalent, when used in a Cyrillic font in place of
the upper-case form of the other, where that's the locale's official
separator. So make this comparison case-insensitive.

Added some test-cases for the lower-case exponential separator.

Pick-to: 6.5
Fixes: QTBUG-113443
Change-Id: I18e22d7b3451fbb61e87d5b93661eadff3c7356e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2023-05-15 14:02:47 +02:00
Edward Welbourne
637e1542cf rsslisting example: fix bug in construction of title string
The correct time to clear titleString and linkString is at the start
of the item element, to avoid not only the left-overs from a previous
item but also any stray titles and links that don't belong to any
item. The channel element, that contains the items, may also have
title and link elements. This, indeed, lead to the first entry in the
displayed table having a "Qt Blog" prefix on its blog-post's title.

Fortunately the link was already being set, usually to empty, due to
the lack of rss:about attributes on item elements.

Pick-to: 6.5
Task-number: QTBUG-111228
Change-Id: I16647e2498b58caaafa6e88ef73f0d934a1f8396
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-05-15 14:02:46 +02:00
Edward Welbourne
fb2d4074c1 rsslisting example: shuffle parts of constructor for clarity
Group related things together, improve the logical flow of the code.

Pick-to: 6.5
Task-number: QTBUG-111228
Change-Id: If3eb577b74128b305ca5fb3074168280ec2d4db8
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-05-15 14:02:46 +02:00
Edward Welbourne
233ca06500 rsslisting example: move default URL to main()
It felt more natural that the RSSListing class would be agnostic about
the default URL, so let it be a constructor parameter. In the process,
update the URL to what the old one now redirects to (thanks to Ivan
Solovev for spotting that) and make the constructor explcit (thaks to
Ievgenii Meshcheriakov for suggesting this).

Task-number: QTBUG-111228
Pick-to: 6.5
Change-Id: I9f4c0d126e0872bb4ec6e6bb41add7e9d2a9537f
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2023-05-15 14:02:45 +02:00
Edward Welbourne
3cdc65c2ec rsslisting example: Tidy up #include usage
Replace one #include with a forward-declaration - in rsslisting.h QUrl
is only passed by reference to a function. Shuffle order of existing
forward declarations to be alphabetic, in the process.

Shuffle #include order in sources so that this example's own headers
appear before the Qt ones.

Pick-to: 6.5
Task-number: QTBUG-111228
Change-Id: I69a9e091c77f9d3190c0217c8bd9262e056f66fc
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2023-05-15 14:02:45 +02:00
Edward Welbourne
00ccc56434 rsslisting example (coding style): split a long line, purge stray braces
Pick-to: 6.5
Task-number: QTBUG-111228
Change-Id: Ic919d4dee74823f11c55d286beba447d45111754
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-05-15 14:02:45 +02:00
Edward Welbourne
f8ad9cd23c rsslisting example (coding style): fix horizontal spacing
Remove space after *, insert space after comma.

Pick-to: 6.5
Task-number: QTBUG-111228
Change-Id: I7525715dede20b45241efaf3f9540c896b1455c7
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
2023-05-15 14:02:44 +02:00
Edward Welbourne
d52cc4725f rsslisting example: remove unused include and surplus blank lines
Pick-to: 6.5
Task-number: QTBUG-111228
Change-Id: Ibfa82aef67eaf6ba758dade30a4c9542f2836123
Reviewed-by: Mate Barany <mate.barany@qt.io>
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2023-05-15 14:02:44 +02:00
Edward Welbourne
7337474d04 Convert remaining QT_NO_XMLSTREAM* to use feature system
Replace the check in qxmlstream.h with a QT_REQUIRE_CONFIG since the
code that includes this header does no checking, whether on the define
or the feature, so is better off getting told about the missing
feature at the point of include than complaining about an undefined
type despite its header being overtly included.

For the rest, just do the usual transformation to QT_CONFIG(),
flipping the ones that were #ifdef rather than #ifndef, so the
condition is positive. Shifted a couple of open-braces of classes to
the next line, where they belong, in the process.

Change-Id: If9c496082f0489b0f9f4070364cbf840e603fce1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-15 14:02:43 +02:00
Edward Welbourne
526ce669ed Clean up phrasing of --help-all and other help options
The options included by --help-all, although they are "specific to
Qt", are "specific" to all Qt applications, so - in the present
context, of QCommandLineParser - not specific at all. It's the options
described by -h that are specific, to the present command; the Qt
options are generic (in the present context).

So rework the help string for --help-all itself and the documentation
of the function. It had, in any case, an overly-complex first line,
that descended into too much detail. Updated test to match.

Pick-to: 6.5
Task-number: QTBUG-111228
Change-Id: I06da0af41be60e6e1b7616984001ddb9ca33aad6
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
2023-05-15 14:02:43 +02:00
Edward Welbourne
56df9e5603 savegame example: clarify that CBOR can be read
The documentation talked about using CBOR to keep folk from reading,
where (of course) it merely makes it more obscure (and compact). Make
clear that this just makes it less easy and mention the tool that
makes it easy again.

Task-number: QTBUG-111228
Pick-to: 6.5
Change-Id: I472acda4b7533db41ab0e78b694e0256b34d2b40
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-15 14:02:42 +02:00
Edward Welbourne
1371cd107a Add metadata to serialization examples
There's no separate category for {de,}serialization, so I've put them
in Input/Output; and at least some of them are relevant to
transmission over the network, so include that as a tag, so that
someone writing a network application that wants to use what they
illustrate gets a chance of being lead to it.

Pick-to: 6.5
Task-number: QTBUG-111228
Change-Id: Ie9f6dbaf85aed852e9f64eba05ec8c5fe0a7382d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-05-15 14:02:42 +02:00
Andreas Buhr
ae34a78b24 Don't create a QTimeZonePrivate object for an unsupported time zone ID
The QTzTimeZoneCache created one cache entry for every time zone
which was looked up, even if the code was invalid. This uses some
memory for each time zone code queried and thus allows DOS attacks
if user supplied time zone codes are parsed.
This patch prevents the creation of QTimeZonePrivate objects for
invalid time zone IDs.

Change-Id: I22007f6681bea54fa08639f4f786e1a49d10f920
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-15 14:02:42 +02:00
Edward Welbourne
13e8609fc9 Include all available IANA DB zones for the TZ backend
Previously, QTzTimeZonePrivate::availableTimeZoneIds() only reported
the zones listed in the zone.tab file, which maps territories to
zones. It thus omitted several zones that are provided by the IANA DB,
but not the primary zones for any territory. This meant that it was
possible to pass a zone name to the constructor successfully, despite
isTimeZoneIdAvailable() claiming it isn't available.

Pick-to: 6.5
Change-Id: I9e4eb7f4cfe578204951b995f0ad9ffd7eed5f9c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-15 14:02:41 +02:00
Edward Welbourne
06e2719f73 Add test-cases for QDate::{start,end}OfDay() at QDateTime's bounds
Task-number: QTBUG-68855
Change-Id: Ic91cb5f9947ce5ee533fc77ae24a50376e139ab3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-15 14:02:41 +02:00
Edward Welbourne
eff0ffbd1b Sanitize the handling of limitations of the MS time-zone backend
tst_QDate::startOfDay_endOfDay() and its _data() were in danger of
growing a lot of ugly #if-ery to work round the known limitations of
MS's time-zone API and the backend built on them. Replace the #if-ery
with a flags enum indicating which parts we need to ignore on MS and
limit the #if-ery to how those flags get exercised.

Change-Id: I8657b4fba75f1aef1f3f9374e05f60354dc25e34
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-15 14:02:40 +02:00
Topi Reinio
cb8a71dac6 Doc: Replace mentions of deprecated macro
Q_ENUMS() is deprecated in favor of Q_ENUM().

Pick-to: 6.5
Task-number: QTBUG-113229
Change-Id: I29cc23c87b1d6e8eeb49dd1d3ddaf4ca7d2cf8c2
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2023-05-15 08:57:02 +00:00
Topi Reinio
506d237751 Doc: Make QByteArray(qsizetype size, Qt::Initialization) doc public
The constructor that doesn't explicitly initialize the content of the
array can be useful in some cases.

Pick-to: 6.5
Fixes: QTBUG-111582
Change-Id: Icc4bd753f1944a91be70316a7303bb822f79d472
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-15 08:56:21 +00:00
Yuhang Zhao
b5d874e36f Fix the QT_REQUIRE_VERSION macro
Rewrite the whole macro as a function and use QVersionNumber instead
of manual parsing to make it more modern and more readable.

Change-Id: I25498320ef6cd9f19be9267421e2727cd28cfd7c
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-15 08:47:17 +00:00
Thiago Macieira
9a73bc5f3d QDnsLookup/Windows: use DnsQueryEx so IPv6 servers are supported
Similar test with link-local server on the same network:

$ $objdir/tests/manual/qdnslookup/qdnslookup.exe @fe80::1e1b:dff:fee2:49e6%Ethernet
; <<>> QDnsLookup 6.6.0 <<>> qdnslookup @fe80::1e1b:dff:fee2:49e6%Ethernet
;; status: NoError
;; QUESTION:
;qt-project.org                 IN A

;; ANSWER:
qt-project.org            3532  IN A    52.18.144.254

;; Query time: 17 ms
;; SERVER: fe80::1e1b:dff:fee2:49e6%Ethernet#53

Server's dnsmasq log shows it was queried.

We don't know why we must set the port to 0. It works for me the regular
way, but not for everyone who tested this patch.

[ChangeLog][QtNetwork][QDnsLookup] setNameserver() now supports IPv6
servers with on Apple systems, AIX, FreeBSD, NetBSD, Solaris, and
Windows.

(AIX, NetBSD and Solaris not directly tested, but their docs online show
they have res_setservers())

Change-Id: I3e3bfef633af4130a03afffd175d5bfd4e7922b9
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-14 21:44:21 -07:00
Thiago Macieira
678964b242 QDnsLookup/Unix: add support for res_setservers()
This API is found on FreeBSD, Darwin, Solaris, AIX, and Android Bionic.
That means we complement IPv6 support for most platforms.

Test on macOS:

$ $objdir/tests/manual/qdnslookup/qdnslookup @fe80::1e1b:dff:fee2:49e6%en0
; <<>> QDnsLookup 6.6.0
;; status: NoError
;; QUESTION:
;qt-project.org                 IN A

;; ANSWER:
qt-project.org            3336  IN A    52.18.144.254

;; Query time: 2 ms
;; SERVER: fe80::1e1b:dff:fee2:49e6%en0#53

Dnsmasq log on the server confirms it was queried.

Change-Id: I3e3bfef633af4130a03afffd175d59c67faa463f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-14 21:44:20 -07:00
Thiago Macieira
eb9f88a078 QDnsLookup/Unix: modernize the setting of IPv6 server addresses
Instead of using #if, this now uses SFINAE to detect the presence of the
glibc extensions to set IPv6 nameserver addresses. It's also possible
that this fixes some bugs that have always been there, but never checked
because we don't have a way to unit-test explicit name servers.

To that effect, this commit adds a manual unit test that mimics the BIND
tool "dig". When running:

 ./qdnslookup qt-project.org any @dns.google

it printed for me:

; <<>> QDnsLookup 6.6.0
;; status: NoError
;; QUESTION:
;qt-project.org                 IN ANY

;; ANSWER:
qt-project.org            3600  IN MX   10 mx.qt-project.org
qt-project.org            3600  IN NS   ns14.cloudns.net
qt-project.org            3600  IN NS   ns11.cloudns.net
qt-project.org            3600  IN NS   ns12.cloudns.net
qt-project.org            3600  IN NS   ns13.cloudns.net
qt-project.org            3600  IN A    52.18.144.254
qt-project.org            3600  IN TXT  "v=spf1 mx ip4:193.209.87.4 include:spf.protection.outlook.com ~all"

;; Query time: 241 ms
;; SERVER: 2001:4860:4860::8844#53

strace confirms the DNS queries were sent to the correct address.

Change-Id: I3e3bfef633af4130a03afffd175d56a92371ed16
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-14 21:44:19 -07:00
Thiago Macieira
df2131426e tst_QProcess: move setChildProcessModifier test to a Q_OS_UNIX section
There's no need to say it's getting skipped on Windows. moc *can* parse
the #ifdefs these days.

Pick-to: 6.5
Change-Id: Icfe44ecf285a480fafe4fffd174d95c709ff6a74
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2023-05-15 00:12:43 +02:00
Thiago Macieira
49eb9021e3 QProcess/Unix: use open() + fchdir() to change directories
This means we have more system calls (2 more in the parent), but we
can now detect non-existent or inaccessible directories before fork().

Pick-to: 6.5
Change-Id: Icfe44ecf285a480fafe4fffd174d1003581bff59
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-15 00:12:43 +02:00
Thiago Macieira
6b561ccf44 QProcess/Unix: use pid_t for the pid
Qt 5 and earlier versions used to share this member with Windows, where
we needed to store a pointer. We had the Q_PID public type, which was
removed in commit b73d5a0511 (6.0). That
commit made the QProcess::processId() public API use qint64, which is
fine. But we don't need to store more bits than the OS actually
requires.

This further reduces QProcessPrivate's size to 688 bytes on 64-bit Unix,
with 5 bytes of tail padding.

Pick-to: 6.5
Change-Id: Icfe44ecf285a480fafe4fffd174d3fa9345872c0
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2023-05-15 00:12:41 +02:00
Thiago Macieira
29b2fe40dc Revert commit "don't ever force fork() instead of forkfd()"
This reverts commit d6bf71123d and the
docs from commit 82b75570f0
("QProcess/Linux: fix file descriptor leak in case of failed child
start").

Despite the title of the commit being reverted, the actual consequence
is slightly different: we always use the forkfd() function, but we
change whether we force the use of the fork() library function by use of
the FFD_USE_FORK flag.

Commit 97645478de (5.15) first added the
FFD_USE_FORK flag with a hack to detect whether the setupChild() virtual
might have been overwritten. A configure-time feature to force the flag
was added in commit 2ed99ff5ca (6.0).
Before the 6.0 release, commit d6bf71123d
removed the conditional use of FFD_USE_FORK, with the changelog message
saying "pthread_atfork() callbacks are consistently not invoked".

We've also since added vfork()-like behavior. We tried it for Qt 5.15
and reverted shortly afterwards because we had got the memory semantics
wrong. Commit e1a787a76e (6.5) finally got
it right, for Linux, which revealed another set of problems with
functions used in the child process modifier.

Therefore, we're going to make vfork() and clone() usage opt-in if the
child process modifier is active. This commit is the first part:
disabling their use by default. The flag to opt in will come in Qt 6.6.

[ChangeLog][QtCore][QProcess] Reverted a change from Qt 6.0 that made
the childProcessModifier() callback be run in a child created by means
other than a real fork() library call, a situation in which certain
other library functions would be unusable, unreliable, or cause
deadlocks. A flag to opt in to the solution with better performance will
be added to Qt 6.6.

Task-number: QTBUG-104493
Fixes: QTBUG-111243
Fixes: QTBUG-111964
Pick-to: 6.5
Change-Id: Icfe44ecf285a480fafe4fffd174d3e66843e5a29
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-15 00:12:41 +02:00
Thiago Macieira
2b98dd7645 QProcessPrivate: repack and reorganize the members
Reduce the number of #ifdef blocks and use quint8 for the enums that
don't need more than 8 bits anyway (none of them do). Plus move the
std::function callback to an indirect block, as most users of QProcess
won't set them and this type is 4 pointers with libstdc++ and libc++.

After this, QProcessPrivate on 64-bit Unix is 688 bytes, of which:
- 392 bytes from QIODevicePrivate
- 295 bytes of own data
- 3x56 bytes per Channel (which have 5 bytes of tail padding each)
- 1 byte of tail padding and no middle padding

Pick-to: 6.5
Change-Id: Icfe44ecf285a480fafe4fffd174d188a0821d060
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-15 00:12:39 +02:00
Thiago Macieira
7dba2c8761 QDnsLookup/Unix: make sure we don't overflow the buffer
The DNS Records are variable length and encode their size in 16 bits
before the Record Data (RDATA). Ensure that both the RDATA and the
Record header fields before it fall inside the buffer we have.

Additionally reject any replies containing more than one query records.

[ChangeLog][QtNetwork][QDnsLookup] Fixed a bug that could cause a buffer
overflow in Unix systems while parsing corrupt, malicious, or truncated
replies.

Pick-to: 5.15 6.2 6.5 6.5.1
Change-Id: I3e3bfef633af4130a03afffd175e4b9547654b95
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2023-05-14 19:47:03 +00:00
Thiago Macieira
0fc0e821f1 QDnsLookup: remove the #if QT_CONFIG(thread) check
There's no fallback anywhere, so this class simply doesn't work if
threading isn't supported. Writing it is an exercise left for whoever
cares for that configuration.

Change-Id: I3e3bfef633af4130a03afffd175e6f68a3f4673f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-14 12:47:01 -07:00
Thiago Macieira
471f134cdd QDnsLookup: remove the explicit metatype registration for the Reply type
It's unnecessary in Qt 6 if we use the new-style connect or if the type
was fully defined in the compilation of the unit containing the moc
output.

Change-Id: I3e3bfef633af4130a03afffd175e6f4e87adf5e1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-13 16:15:02 -07:00
Thiago Macieira
d26709cd8c Network: Remove Q_DECL_METATYPE_EXTERN for single-.cpp metatypes
These were added in commit 20e6a049fe as a
massive sweep of all Q_DECLARE_METATYPE, without thought as to whether
they were actually needed or not. If they are used as a metatype in a
single .cpp file, they don't need to be.

Incidentally removes the entirely incorrect Q_NETWORK_EXPORT of
QDnsLookupReply.

Pick-to: 6.5
Change-Id: I3e3bfef633af4130a03afffd175e6f378f09a3aa
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-13 16:15:01 -07:00
Thiago Macieira
c257e518c1 QProcessPrivate: remove the member variable "crashed"
It was only used to later set exitStatus = CrashExit, so simply do it
early.

Drive-by removal of a magic numeric literal in the middle of the source
code. It's still magic, but at least we avoid accidentally making typos.

Pick-to: 6.5
Change-Id: Icfe44ecf285a480fafe4fffd174d4176a5d87641
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-13 20:25:27 +00:00
Thiago Macieira
45a03fc506 QNativeSocketEngine: move some code from the _p_p.h to _p.h file
So I can use it in qdnslookup_unix.cpp.

Change-Id: I3e3bfef633af4130a03afffd175d506949968990
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-13 13:24:24 -07:00
Marc Mutz
3b0536bbe8 tst_ContainerApiSymmetry: make assign_impl() robust w.r.t. overallocation
The parameter passed to reserve() is just a hint. The container
implementation is free to choose a larger capacity, and some do
(e.g. QList in prepend optimization mode).

Fix the test by querying the container for its post-make<>()
capacity() and taking a larger-than-expected initial capacity() into
account when later re-checking the capacity().

Change-Id: Id8f26f14e8df9d685ca2387ec4a52d74fea7cb9d
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-13 16:58:36 +02:00
Marc Mutz
fb58df3260 tst_ContainerApiSymmetry: make a comment more precise
It took me a sec to figure out the relation between the comment and
the code line following it. Make it easier for the next guy and add a
bit more infos.

Amends 7cbdc8abbd.

Change-Id: I4ff2d9a52aef643a92339df32cc86f686a689a9a
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-05-13 16:58:27 +02:00
Marc Mutz
4eea3f857c tst_ContainerApiSymmetry: follow file's style for assign() tests
We use a single line per test slot everywhere else, ignoring even
line-length limitations, to keep the function names aligned for easier
parsing.

Amends 7cbdc8abbd.

Change-Id: Iaf2941aae88392d407d688fc4a7537fcdc0a5851
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-05-13 16:58:19 +02:00
Marc Mutz
edc953948c tst_ContainerApiSymmetry: fix mutable lambda anti-pattern
STL algorithms, in general, don't specify how often the function
objects passed to them are copied during the run of the
algorithm.

While generate_n is above any reasonable suspicion of copying the
function object after the first invocation, passing a mutable lambda
containing the counter is still an anti-pattern we don't want people
to copy.

Fix in the usual way, by keeping the counter external to the lambda.

As a drive-by, replace post- with pre-increment.

Amends dc091e7443.

Pick-to: 6.5 6.2
Change-Id: I9c44e769fd41e5f7157179a2be4c3534424cf913
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-05-13 16:58:10 +02:00
Thiago Macieira
3cc39197f8 tst_QAnyStringView: fix warning of unused variable by using it
Pick-to: 6.5 6.2
Change-Id: Ieab617d69f3b4b54ab30fffd175c78ddb5fb919d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-05-12 20:54:13 +00:00
Alexey Edelev
f71eb4a642 Avoid littering CMake logs with QTP0002 warnings
It doesn't make any sense to setup and get policy when we build either
Qt or standalone tests, since the value will be ignored anyway. So
skip the policy setup for Qt builds to avoid littering the CMake logs
with QTP0002 warnings.

Amends c4debab927

Change-Id: Iacae8f9ecbb6c9da2f3af77b2016454c8d4194e6
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-12 17:55:21 +02:00
Tor Arne Vestbø
798456c0a3 Add QIconLoader debug logging to aid fallback logic investigation
The icon loader machinery is a bit opaque, so let's add some logging
to understand the interactions.

Pick-to: 6.5
Change-Id: Ic400b6043607795ad92771f9d9f189699f185366
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-05-12 16:20:29 +02:00
Alexey Edelev
a3cb388eaa Check if next property in the list is not empty before adding a comma
Property merging genex only checks if previous value is not empty, but
doesn't check if an actual value that we concatenate is not empty too.
Add the check to make sure we don't have trailing comma in the json
lists.

Fixes: QTBUG-112885
Pick-to: 6.5
Change-Id: I1a5265ddf1b12f763650daf3c6e3538ed52a1674
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-05-12 14:20:28 +00:00
Peter Varga
2550568a92 Enable [[noreturn]] attribute for non-MSVC compilers on Windows
Avoids -Wsometimes-uninitialized warnings with clang-cl.

Also do not allow to return qt_message_fatal() if built with other
compiler than MSVC.

Amends 97b32fa0b6

Fixes: QTBUG-113351
Change-Id: I9ce87057e764af1e25de93388ae983891df66d2e
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-12 15:33:52 +02:00
Morten Sørvig
417b61b015 wasm: fix qtloader.js container element regression
As of Qt 6.5 the html document should not create canvas
elements directly, but instead create div container
elements and let Qt create and manage the canvas elements.

However, qtloaders.js has not been updated to match this
and is still creating canvas elements when given div
elements.

Remove the canvas creation code and invert the primary
and fallback case: config.containerElements is now passed
to instance.qtContainerElements. config.canvasElements
is copied to config.containerElements, if set.

Change-Id: I7372db93ee4de5b23a0a5d992597a3fbd9711a33
Pick-to: 6.5 6.5.1
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
2023-05-12 10:15:03 +00:00
Amir Masoud Abdol
305f61a807 Remove the -sysroot option from configure
The `-sysroot` does not have any effect, and it can be removed.
I added a warning in case someone is still using it.

[ChangeLog][configure] The -sysroot option was removed. Use
CMAKE_SYSROOT or CMAKE_TOOLCHAIN_FILE instead.

Task-number: QTBUG-112951
Change-Id: Ib180b891ca8228ef1ebf9be43f2f6b8b5b5b0ee7
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-05-12 09:46:24 +02:00
Thiago Macieira
cdd0e8fa67 QSlotObjectBase: move the which parameter to the 4th position
This places the first through third parameters on the exact positions
that they will be used to perform the operations in the switch, saving
the compiler from generating a few instructions to move data around. All
ABIs Qt supports that pass any function parameters in registers at all
pass at least 4.

We keep the return type as void (instead of returning bool, for the
Compare case) so the compiler can apply tail-call optimizations for
those two typical cases.

PMF case: https://gcc.godbolt.org/z/9oP5boKfj
Function case: https://gcc.godbolt.org/z/e9vEzd5dj
Functor case: https://gcc.godbolt.org/z/s8Ejjra7P

Change-Id: I3e3bfef633af4130a03afffd175d3e3009c56323
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-11 21:53:22 -07:00
Thiago Macieira
05ebf3e54b IPC: QNativeIpcKey: fix big-endian builds
We weren't using the LSB in big-endian builds because the bitfield was in
the wrong order: it was either using the MSB (in 32-bit builds) or
something in the middle for 64-bit. So use quintptr in the bitfield to
ensure proper sizing and correct the order.

Additionally, we now store the d "pointer" as a quintptr, so as to avoid
storing the actual pointer to QNativeIpcKeyPrivate with the LSB set.

Change-Id: Idd5e1bb52be047d7b4fffffd17506adb77d52805
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-11 21:53:21 -07:00
Thiago Macieira
e2a76797e0 QLatin1StringView: un-inline Latin1-UTF8 compare_helper
Commit c630b231ec ("Untangle
QLatin1StringView from qstring.{h,cpp}") moved QLatin1StringView from
qstring.h, causing compilations that included qlatin1stringview.h but
not qstring.h to produce a warning.

By un-inlining, we get an improved comparison functionality without
memory allocation too. So win-win.

 qlatin1stringview.h:325:23: warning: inline function ‘static int QLatin1String::compare_helper(const QLatin1StringView&, const char*)’ used but never defined

This is BC because the actual function that used to be inline continues
to be so, and the old implementation is fine, albeit slower.

Change-Id: Ieab617d69f3b4b54ab30fffd175c4e11d4a3b6dd
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-11 21:53:21 -07:00
Thiago Macieira
4f00e6c8b9 QReadWriteLock: inline the constructor and destructor
Change-Id: Ieab617d69f3b4b54ab30fffd175b2500dd860431
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 19:56:23 -07:00