65025 Commits

Author SHA1 Message Date
Juha Vuolle
0bfec6cd11 QHttpHeaders: reserve memory for headers when creating from a container
To avoid any potential resizes during append looping

Task-number: QTBUG-119002
Change-Id: I8f4c391f05b5c5bd0b48a4f17b11996652006508
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-12-08 15:53:36 +02:00
Juha Vuolle
11b19b3341 Mark REST helper classes as tech preview
Task-number: QTBUG-119002
Change-Id: Icf4d50b0e6f25e4e5f82df0b23a249332bbf55bf
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-12-08 15:53:36 +02:00
Juha Vuolle
8da4156da7 Add PATCH support for QRestAccessManager
It is somewhat common HTTP method with RESTful use cases
(partial updates on resources)

Task-number: QTBUG-114637
Change-Id: Id252d3f4b54c3ebb8df5c93259e64a4af2d0ca2f
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-12-08 15:53:36 +02:00
Juha Vuolle
a80ed49b10 QRestAM custom HTTP 'method' support
This commit adds support for sending custom, non-standard, HTTP
methods / verbs.

Fixes: QTBUG-116262
Change-Id: I77addb389a7e4346b63526176bf8323696a7a337
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-12-08 15:53:36 +02:00
Juha Vuolle
98b240d00a Add username/password support to QNetworkRequestFactory
Task-number: QTBUG-114717
Change-Id: I8d6beb6f81668dcba59cbaee6044606fb874bad2
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-12-08 15:53:35 +02:00
Juha Vuolle
b72701a690 Add QDebug support for QRestAccessManager
Task-number: QTBUG-114705
Change-Id: Id33dbfd6906989dfcde654a4f7d6ab4b5e743c33
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-12-08 15:53:35 +02:00
Juha Vuolle
0f34316fb7 Add QDebug support for QRestReply
Task-number: QTBUG-114705
Change-Id: I6c355d683389b773082c5966434d733bf5aec506
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-12-08 15:53:35 +02:00
Juha Vuolle
6420e8b895 Add QDebug support for QNetworkRequestFactory
Task-number: QTBUG-114705
Change-Id: If3e9d67ee310192debf58771e365f6035d4b2da6
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-12-08 15:53:35 +02:00
Juha Vuolle
669a48e5ae Functions for setting request transfer timeouts
Added to both QNetworkRequestFactory and QRestAccessManager

Task-number: QTBUG-114717
Change-Id: Ibca55bba548a034a0da7ea60550642c150b63dc2
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-12-08 15:53:35 +02:00
Juha Vuolle
090991123d Support for std::chrono as transferTimeout type
Provide users with means to use more modern time/duration type.

Please note that since QTimer does not currently support
timeouts larger than 'int' milliseconds, the limit on how long
durations can be expressed, remains. This should not
be an issue in practice with network requests, as a typical
int32 system can express timeouts of ~24 days.

[ChangeLog][QtNetwork][QNetworkAccessManager] Add std::chrono
support for transfer timeout.

[ChangeLog][QtNetwork][QNetworkRequest] Add std::chrono support
for transfer timeout.

Fixes: QTBUG-118714
Change-Id: If85678a5994c59bac5926e47f98c9cfeb2a07c30
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-12-08 15:53:34 +02:00
Juha Vuolle
298d5a4bbd Add uploadProgress signal for QRestReply
Task-number: QTBUG-114717
Change-Id: I2052e4cc4da90962483f5f1931dc20552e484e34
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-12-08 15:53:34 +02:00
Juha Vuolle
e9f703ed3b Add signals and methods for QRestReply download progress
These include:
- readyRead(), signal for indicating new data availability
- bytesAvailable(), function for checking available data amount
- downloadProgress(), signal for monitoring download progress

Task-number: QTBUG-114717
Change-Id: Id6c49530d7857f5c76bd111eba84525137294ea7
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-12-08 15:53:33 +02:00
Juha Vuolle
e560adef21 Add REST client convenience wrappers
[ChangeLog][QtNetwork][QRestAccessManager] Added new convenience
classes QRestAccessManager and QRestReply for typical RESTful
client application usage

Task-number: QTBUG-114637
Task-number: QTBUG-114701
Change-Id: I65057e56bf27f365b54bfd528565efd5f09386aa
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-12-08 15:53:33 +02:00
Juha Vuolle
f587ba1036 QNetworkRequestFactory convenience class
The class provides a way to represent server-side service endpoints.
With RESTful applications these endpoints typically have a need for
repeating requests fields such as headers, query parameters,
bearer token, base URL, SSL configuration. This class allows setting
of the repeating parts, while allowing the setting of changing parts
on a per-request basis.

[ChangeLog][QtNetwork][QNetworkRequestFactory] Added a new convenience
class to help with the needs of repeating network request details
imposed by the server-side service endpoints, which is common
with RESTful applications.

Task-number: QTBUG-113814
Change-Id: Iabcfaed786949ffbb0ad0c75297d0db6ecc1a3cc
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-12-08 15:53:32 +02:00
Juha Vuolle
925ce9e908 Add QHttpHeaders class
New QHttpHeaders class for use in place of
std::pair<QBA,QBA>, QMap<QBA>, and QMultiMap/Hash<QBA,QBA>
to represent HTTP headers.

[ChangeLog][QtNetwork][QHttpHeaders] New QHttpHeaders class

Task-number: QTBUG-107042
Change-Id: I54766886a491acfc9a813a3414322a75011acb9d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-12-08 15:53:32 +02:00
Assam Boudjelthia
0919f97811 CMake: pass ndk-stack path to androidtestrunner
CMake knows about the ndk path so always pass the ndk-stack path
and not rely on the env var being set.

Change-Id: I2cfd8e0708c6b284964dc3dc85b1f080742b125d
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-12-08 15:53:32 +02:00
Edward Welbourne
d2f15d65c7 Improve week-day-based resolution of two-digit year numbers
Where a date format only gives the last two digits of the year, along
with month and day of month, the day of the week can help settle the
question of which century to use. The date-time parser has used this
for some time, rather crudely, but only considered centuries adjacent
to the default (1900 through 1999).

Refine that by using QCalendar's new matchCenturyToWeekday(). Simplify
the account of parsing now that client code doesn't have to do this
for itself.

Task-number: QTBUG-46843
Change-Id: Id054cc87ec867a2498145932d721c3368210cba0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-12-08 11:40:37 +01:00
Edward Welbourne
4799516de9 Add a section on date ambiguities to QDate::fromString()
There are various pitfalls and reasons to be wary of short formats.
Make clear what the hazards and remedies are. Expand on the existing
paragraph about the base-year for the century of two-digit years.

Task-number: QTBUG-46843
Change-Id: If7c3d13eec826671f8dce686e520a17c11572bc3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-12-08 11:40:37 +01:00
Edward Welbourne
9bf7d2a76a Adapt ASN.1 datetime parsing to use the new century control
It previously had to kludge a 1900-to-1999 date into a 1950-to-2049
range; it can now tell QDTP to do that for it. In particular, this
fixes a problem with 00-02-29, which failed to parse using 1900 as
base year so couldn't be corrected to 2000-02-29, which is now the
date it finds directly.

Task-number: QTBUG-46843
Change-Id: I7ac936bdfb15b78daed5d237c5d921c800af4951
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-12-08 11:40:37 +01:00
Edward Welbourne
41f84f3ddb Give the caller control over the century used for two-digit dates
The twentieth century is now some way behind us, so using its years
when parsing a date-time format that only provides the last two digits
is increasingly likely to produce unwelcome results. Most such formats
are saved by the "redundant" presence of a day-of-week field but, for
those that are not (notably including ASN.1 date fields), there is a
need to provide some way to over-ride the twentieth century default.

Allow the caller to pass a base year to the fromString() methods, of
QDate and QDateTime, and to QLocale's toDate() and toDateTime(), that
indicates the first of 100 consecutive years, among which the two
digits given can select a year. Add some test-cases to exercise the
new API.

[ChangeLog][QtCore][QDate] When fromString() has only a two-digit year
to go on, it is now possible to set the start-year of the century
within which this selects.

[ChangeLog][QtCore][QDateTime] When fromString() has only a two-digit
year to go on, it is now possible to set the start-year of the century
within which this selects.

[ChangeLog][QtCore][QLocale] When toDate() or toDateTime() has only a
two-digit year to go on, it is now possible to set the start-year of
the century within which this selects.

Fixes: QTBUG-46843
Change-Id: Ieb312ee9e0b80557a15edcb0e6d75a57b10d7a62
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-12-08 11:40:36 +01:00
Edward Welbourne
b8fac53803 Add QCalendar::matchCenturyToWeekday()
This takes a YearMonthDay and a day-of-the-week, returning a QDate
that (if possible, else invalid) has the given day of the week and
differs from the YearMonthDay only in the century. This is useful when
resolving dates with only two-digit year information, which can be
disambiguated by the day of the week. Added tests of the new API.

This adds a new virtual method to QCalendarBackend, for which that
base class does provide a brute force implementation, so derived
classes do not need to add implementations. It is, however, a
binary-incompatible change for any backend plugins that may be in use
to implement custom calendars.

Worked out the details for the Gregorian calendar to make it possible
to compute the right century (and whether any century works) without
trial-and-error searching. Coded that up as its implementation of the
new method.

[ChangeLog][QtCore][QCalendar] Added a matchCenturyToWeekday() method
for use when resolving dates given day, month and last two digits of
the year, along with day of the week. Any custom calendar backend
plugins shall need a recompile and may, optionally, implement the new
virtual method behind this.

Change-Id: I6003c8d9423d6bfb833957bb5120f2d423219c7a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-12-08 11:40:36 +01:00
Kai Köhne
c5864a96a6 headersclean: Re-add zero-as-null-pointer-constant warning
Amends 0f985e16ba741695182020f2c6a952f31e44c722, which accidentally
dropped this flag (duh!).

Change-Id: Ie772f9e524625edfcdcda4d73a9a712fcd77f8c8
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-12-08 10:40:33 +00:00
Marianne Yrjänä
65081c67f3 Revert "OpenSSL: remove support for 1.1"
This reverts commit d201c0a2184881a226bce76528047707e9062856.

Reason for revert: QNX have support only for OpenSSL1.1.
QNX will start supporting OpenSSL3 with upcoming QNX8.0 but as long as we want to support QNX7.1 (and even QNX7.0) removing OpenSSL1.1 support from Qt is not an option.

Change-Id: Ia2083eda318779968eb6ee84fff2f56ebe3dadf7
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-12-08 06:10:51 +00:00
Marc Mutz
e240f559e4 QUrlQuery: drop the qpair.h include
[ChangeLog][QtCore][Potentially Source-Incompatible Changes] qurlquery.h
no longer includes qpair.h (for qMakePair).

Change-Id: I593ca3fee5f330992b46170bb660b1b33a663428
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-12-08 03:18:32 +01:00
Volker Hilsheimer
c0b1eaaaaa QFont::Tag: use new comparison helper macros
Task-number: QTBUG-104111
Change-Id: Id57b075d00e657c2606b6c1a8f1215ed0d067cbd
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-12-08 03:18:32 +01:00
Marc Mutz
cd39a469a9 Add tests for CompactStorage
They're too trivial for their own QTestLib-based approach, but we
don't want them in the header, either, reducing the compile times for
all users, so put them into an otherwise empty .cpp file.

Change-Id: Iae7fc4d4a29a0648b91752040854288e02da7045
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-12-08 04:18:32 +02:00
Marc Mutz
b6ff86e556 corelib/CMakeLists.txt: restore lexicographical order of SOURCES
Amends 8d367dec156c1aa63544bd851809caa7e72d307e.

Pick-to: 6.6 6.5
Change-Id: Ia1fd819ebabf6df143c06f56624365d3e37fa1c9
Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-12-08 02:18:32 +00:00
Rym Bouabid
4fa9f13397 Make QAtomicScopedValueRollback public API
Move the private header to public.
Make documentation a part of public interface.

[ChangeLog][QtCore][QAtomicScopedValueRollback] New class.

Task-number: QTBUG-115107
Change-Id: I6c9f5448e74a5b62f4d97ee079944f4b1b731121
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-12-08 02:24:41 +01:00
Lorn Potter
d784c14d10 wasm: prevent native mobile keyboard from popping up always
also fix misspelled 'inputMode' which seems to work.
we need to re focus to the canvas when window is raised
which will automagically close the native keyboard
when user clicks on non edit area.

Fixes: QTBUG-101404
Pick-to: 6.6 6.5
Change-Id: Iced9abc7b23e079b1060d2474a139aa653a8ca01
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
2023-12-08 09:22:33 +10:00
Marc Mutz
a5bcb41678 tst_bench_QImageReader: add a benchmark for raw QFatoryLoader operations
This is Eirik's QtCore-only QTBUG-114253 reproducer added to the
nearest fitting existing benchmark.

Done-with: Eirik Aavitsland <eirik.aavitsland@qt.io>
Pick-to: 6.6 6.5 6.2 5.15
Task-number: QTBUG-114253
Change-Id: Iba68bedebae908af497267860e2b230db269787e
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2023-12-07 22:55:08 +00:00
Marc Mutz
6c60117d01 tst_QString: explain TransientDefaultLocale better
A default-constructed QLocale gets initialized with the
currently-active default locale, and apparently retains that setting
henceforth. That is why the `prior` member is not explicitly
initialized, which is confusing at face value.

Explain the mechanism better, and explicitly default-initialize the
member, so the next reader of the code saves the time to research
this.

Amends 76dfda1ad12cc42cdd832aed1edbe5f76b0cbb2d.

Pick-to: 6.6 6.5 6.2 5.15
Change-Id: I1d1171f8564c70a971938b92b809f63ba5637d3a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-12-07 23:55:08 +01:00
Marc Mutz
f395934419 QTest: Extract Method writePrettyUnicodeChar from toPrettyUnicode
Easier to reason about by separating the concerns into separate
functions.

Pick-to: 6.6 6.5
Change-Id: I34666766ac2879577faea17bbd2b700bcb803f51
Reviewed-by: Jason McDonald <macadder1@gmail.com>
2023-12-07 23:55:08 +01:00
Marc Mutz
0a86a77e5f tst_containerapisymmetry: remove the extra push_back
... and make sure it cannot happen again by using Extract Method to
let the compiler do the counting between the resize and the
sequence-of-push_back alternatives, because this author clearly can't.

Amends 3c0fdd7341ed4bff9b5f041e9f4646265d142303.

Pick-to: 6.6 6.5
Change-Id: If18f30d60f556e5e668876a38423f3e519fb79b0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-12-07 23:55:08 +01:00
Marc Mutz
9dd1953218 QByteArray: bring end() into idiomatic form
For contiguous containers, end() is always begin() + size(), so use
that instead of data() + size().

Centralizes what it means to be an iterator in just begin() now, which
will simplify a follow-up commit of Thiago's.

Pick-to: 6.6 6.5
Change-Id: I53ca1a335910bdea3d46b9496ba39bc1a2d3fd93
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-12-07 23:55:07 +01:00
Marc Mutz
72422d7d1b QString::indexOf(): fix UB (signed integer overflow) in negative from handling
The `from` value is not constrained, so the code must be able to
handle all values, incl. `Min := numeric_limits<qsizetype>::min()`.

But the result of negating `Min` is not representable in qsizetype, so
it's UB to try.

Fix by multiplying both sides by -1 (which flips the relational
operator).

This works because the size() of a string is always non-negative, and
the negation of all such values is representable in the same type. Add
a comment to avoid a "fix back".

Amends f9b867216ba2728ff993020599f5062e2f023de1.

Pick-to: 6.6 6.5
Change-Id: I10d2e400b86f07a6a6c0a61080a27f41a16b3517
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-12-07 23:55:07 +01:00
Marc Mutz
8f44ec2e48 QUrlQuery: s/QPair/std::pair/
They're literally the same, QPair is an alias for std::pair, so this
is both SC and BC.

Also port from qMakePair to std::make_pair, so we can later drop the
qpair.h include (not done here to avoid breaking 6.6/6.5 users
relying on this transitive include for qMakePair().

Pick-to: 6.6 6.5
Change-Id: I593ca3fee5f330992b46170bb660b1b33a663427
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-12-07 23:55:07 +01:00
Marc Mutz
9d54b5c57e QDebug: remove QPair streaming docs
QPair _is_ std::pair. If this wasn't a fake-definition under #ifdef
Q_QDOC, the compiler would have complained long ago.

Pick-to: 6.6 6.5
Change-Id: Idfe589ff13115d3d908572a17b849f634ec86787
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-12-07 23:55:07 +01:00
Thiago Macieira
db991cb4e1 QBitArray: replace the member operator~ with a hidden friend
Which takes the array to be inverted by value, so we get free move
semantics and allowing us to perform the negation in-place.

[ChangeLog][Potentially Source-Incompatible Changes] The bitwise AND,
OR, XOR, and NOT operator functions on QBitArray are now hidden
friends. This may cause source-incompatibility in unusual coding styles
(like 'array.operator~()') or with classes that have a casting 'operator
QBitArray()'.

Change-Id: I85b3fc2dd45c4693be13fffd1795ba1fbaf23769
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-12-07 14:55:07 -08:00
Thiago Macieira
9b176281df QBitArray: refactor operator~() to write to an uninitialized buffer
No functionality change otherwise.

Change-Id: I85b3fc2dd45c4693be13fffd179627b2747c132b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-12-07 14:55:07 -08:00
Thiago Macieira
9323351695 Re-do the namespace fix for the linker scripts
This amends and corrects b63045477ea05c17f9abe9434e6d824453e3935a. The
fix there was incorrect for two reasons:
1) it missed one symbol in QtCore (the QFutureInterfaceBase one
   added in 0f0371c8304bd7354a3c43f9fac6b85bd3e9a3f1.
2) it only worked for namespaces that were 15 characters long

Instead, just use a wildcard where the namespace should be for Qt
symbols (note: an extra wildcard appears for plain types because they go
from <N><type> to N<N><namespace><N><type>E).

Pick-to: 6.6
Change-Id: Iae41eb8991e349ceb836fffd179d6e709d6632f8
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
2023-12-07 14:55:06 -08:00
Marc Mutz
40592d38f8 QSpan: add some C++20 reminder code comments
Change-Id: I1cd698bde290cbd37d13103cd6832a739d9c548b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-12-07 23:38:15 +01:00
Marc Mutz
03e78e5d62 Long live QSpan as public API!
Provide qspan_p.h as backward-compatibility header.

[ChangeLog][QtCore][QSpan] New Qt equivalent of std::span.

Fixes: QTBUG-115022
Change-Id: I1cc27dc0aa1f7406f0a41d7a75f176cd7f858feb
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-12-07 22:38:15 +00:00
Marc Mutz
5885db33e3 QSpan: fix an MSVC warning-turned-error:
qspan_p.h(35): error C2220: the following warning is treated as an error
  qspan_p.h(35): warning C4245: 'initializing': conversion from 'int' to 'const size_t', signed/unsigned mismatch

Add an explicit (functional-style) cast to silence it.

Pick-to: 6.6
Change-Id: Id29fda3def1c60415b3e0fe72eaf82c8bc57d363
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-12-07 23:38:15 +01:00
Ievgenii Meshcheriakov
d3860918ea QDBusConnectionPrivate: Close connection after failed q_dbus_bus_register()
The connection should be closed before executing
q_dbus_connection_unref(). Failing to do so results in an assertion
inside libdbus:

    dbus[1573958]: The last reference on a connection was dropped
    without closing the connection. This is a bug in an application.
    See dbus_connection_unref() documentation for details.
    Most likely, the application was supposed to call
    dbus_connection_close(), since this is a private connection.

The q_dbus_bus_register() may fail if maximum number of active
connections for a bus was reached. This can be tested by creating
a custom bus with "max_completed_connections" parameter set to 0.
Add such a test to tst_qdbusconnection.

Fixes: QTBUG-34613
Change-Id: I6ae7df19bf8b6546c2a504931ba852dc15d35f78
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-12-07 23:36:15 +01:00
Marc Mutz
c39fff0da5 Add missing <=> 0 operator to Qt ordering types
It's required by the standard, see e.g. [1] and the eel.is links in
the code.

[ChangeLog][QtCore][QPartialOrdering] Added three-way comparison
operator (<=>) against literal zero, available when compiling in C++20
mode.

[1] https://en.cppreference.com/w/cpp/utility/compare/partial_ordering#Comparisons

Change-Id: I8a3b76661400930c6e247cf5b138ff52bf784395
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-12-07 23:36:15 +01:00
Marc Mutz
ccd0dc7f6d QPartialOrdering: add lower-case flags for std/Qt:: compatibility
The misspelt flags (Less, etc) make it hard to use QPartialOrdering
interchangably with Qt or std ordering types, e.g. in generic code.

[ChangeLog][QtCore][QPartialOrdering] Added a set of lower-case flags
(::less, ::greater, etc) to improve source-compatibility with
{Qt,std}::partial_ordering.

Change-Id: I160600c01c4a2ab72c7b217a306d08045e363578
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-12-07 23:36:15 +01:00
Marc Mutz
07ed8acdf9 QPartialOrdering: add missing conversions to/from Qt::_ordering types
Since QPartialOrdering is supposed to be a drop-in-replacement for
Qt::partial_ordering, it need to have the same conversions from
Qt::_ordering types that Qt::partial_ordering has.

Fix by adding the necessary conversion and relational operators and
conversion constructors.

Change-Id: Ib8e78c850b43c8bcb3bb15c5f7d25be9d0da7339
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-12-07 23:36:15 +01:00
Marc Mutz
1576d70e44 Qt ordering types: unify the form of the implicit conversion operators
The case statements I used when de-pessimising these functions were
pretty long, bumping against line-length limitations and annoying the
reader with overly long repetitive type names.

Add aliases to fix both issues, and also apply the form to
QPartialOrdering's operator std::partial_ordering for consistency.

I was kinda hoping that this would allow to DRY away some of the
repetition with macros, but it didn't work out in the end. It's still
a lot more pleasant to the eye, so don't let the experiment be for
nothing.

Amends 9c03935c9a22f3f6baa602ec0ea7ce91f4a842f0.

Change-Id: I9786ae5c7be0b8fb30e4df219f1c65b2e8589904
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-12-07 23:36:14 +01:00
Marc Mutz
a0ae96e3e7 QPartialOrdering: add missing conversion from std::{weak,strong}_ordering
QPartialOrdering is suppsed to be a drop-in replacement for
std::partial_ordering, so it has to be convertible from all
std::_ordering types.

It was, however, only convertible from std::partial_ordering, and two
user-defined conversions in a row are not allowed.

Add the missing constructors. They, in turn, can then delegate to the
partial_ordering constructor.

Change-Id: I085d95677b258b4a61aabfd5468c1c43c2212766
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-12-07 23:36:14 +01:00
Marc Mutz
39c7bf4631 qcompare.h: move QPartialOrdering to the end of the header
This makes sure that everything in-between will not accidentally come
to depend on QPartialOrdering. It also makes it much easier to
centralize the conversions to/from Qt::_ordering types in the
QPartialOrdering class, keeping the newfangled clases clean of legacy.

I should have done it this way to begin with... Mea culpa.

Amends 4b6f757020382ed157bf6beb572549f05e881359.

Change-Id: I269bdf0cbde59d317381ccd06001e56d5b3c289a
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-12-07 23:36:14 +01:00