Commit Graph

66055 Commits (a14bba6803f674edede596eaeb5a46feed0f889e)

Author SHA1 Message Date
Thiago Macieira a14bba6803 Move QLocaleData::convertDoubleToFloat to qnumeric_p.h
So others can use it too.

Change-Id: I01ec3c774d9943adb903fffd17b86236d06a948c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2024-03-04 11:31:48 -08:00
Richard Moe Gustavsen 26f307ddb1 CMake/Windows: add quotes around the whole path, not just the dir
The quotes should be around the whole file path, and not
just around the directory. Otherwise it can cause the
build to fail if Qt lives inside a directory that is
symlinked from a different drive.

Pick-to: 6.5 6.6 6.7
Change-Id: I46e23d4a78c807e6617224ce7faff96e6985f449
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-03-04 20:31:48 +01:00
Richard Moe Gustavsen 458be44aeb CMake/Windows: add setlocal to the Windows bat files
Several of the cmake bat files sets "script_dir_path". The problem
is that those assignments are not local to the script files. E.g
when qt-configure-module.bat gives it a value, and then call
qt-cmake.bat, qt-cmake.bat will assign it a different value. And
this value will overwrite the original value in
qt-configure-module.bat. So when the call returns, that script can
sometimes fail.

This happens (for unknown reasons) if the Qt source code path
contains a link to a different drive, created with mklink /d.
This is typical if Windows is running in a virtual machine, and
the Qt source code is shared with the host on e.g drive Q:.
In that case you might want to a folder on C: be a symlink to Q:, in
order to build Qt.

This patch will make sure we add "setlocal" in all the affected
bat files, so that any changes done to e.g "script_dir_path"
stays local to each file.

Pick-to: 6.5 6.6 6.7
Change-Id: Iee18e06eb0beece0c85c4345d9bfc0194e466e56
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-03-04 20:31:48 +01:00
Tor Arne Vestbø 5736e0b655 cmake: Allow silencing CMake generator warning from environment
Pick-to: 6.7 6.6 6.5
Change-Id: I13d3000121be39f204b4374118690fe27702dd12
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-03-04 20:31:47 +01:00
Alexandru Croitor 7684814b8b Coin: Set COIN_CROSS_PLATFORM_VERSION_TEST environment variable
We have certain platforms where we build on one OS version (the
latest) and then test on an older version.
macOS is an example of such a platform.

Set the COIN_CROSS_PLATFORM_VERSION_TEST environment variable to true
for such platforms. They usually have a dependency on the main OS
version and are marked with the TestOnly feature.

This is useful information that can be used by CMake build tests in
order to skip those that do not account for the difference in OS
versions.

Change-Id: I6eeeac98abe6beb00ce431e17589f8e093ed23e4
Reviewed-by: Toni Saario <toni.saario@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-03-04 20:14:36 +01:00
Matthias Rauter 3f26fdebbc Implement ping reply in QHttp2Connection and add test
Fixes: QTBUG-122338
Change-Id: I1e8dfa8a93c45dbe12a628d4d5e79d494d8f6032
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-04 20:14:36 +01:00
Volker Hilsheimer 302823d73b Icon: work around compile optimization bug
We are observing that the strings become sequences of zeros in
release builds, possibly triggered by qOffsetStringArray being used
in a static constexpr function to initialize a constexpr array.

Pull the array out of the function as a static on translation unit level,
which is a pattern we use regularly elsewhere in Qt.

Pick-to: 6.7
Change-Id: I69c8cfe4e2d6d7d4659edda621ba1afe9768035b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2024-03-04 20:14:36 +01:00
Giuseppe D'Angelo f7194435f3 Remove qbytearray_p.h
It's unused now.

Change-Id: I948650abdbcc0dc0f7925c56e326762ba66e8ee9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-04 14:42:32 +01:00
André Klitzing 3d31b19538 Do not add PDF-related files to the resources if PDF is disabled
This avoids added resources:

  ":/qpdf/qpdfa_metadata.xml"
  ":/qpdf/sRGB2014.icc"

Pick-to: 6.7
Change-Id: I89a130bd281c5550f1c3dcead8336e0c3de6bc84
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2024-03-04 14:42:01 +01:00
Tinja Paavoseppä 15132530ee Android: Fix inverted equals condition on QtAccessibilityDelegate
Got inverted during child window refactoring, leading to broken
accessibility.
Amends commit 0a92d881bb.

Task-number: QTBUG-122827
Pick-to: 6.7
Change-Id: Icbde94097eb0b33171f18f8a30c935d0b950c545
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2024-03-04 12:31:19 +00:00
Liang Qi 4dca61cbda Revert "tests: blacklist tst_QWidget::render() on Wayland"
This reverts commit c41733b06b.

Based on the Grafana data, last flaky was August 14, 2023, and
the test works fine on local vm with stressed cpu.

Fixes: QTBUG-115598
Pick-to: 6.7 6.6 6.5
Change-Id: I634598d20a581d4d1443a3fd81e1e9481bfa2545
Reviewed-by: Inho Lee <inho.lee@qt.io>
2024-03-04 10:04:31 +00:00
Christian Ehrlicher 3dc755a0ae QCoreApplication: work around gcc 11.3 compiler bug
Fix the amiguity in the comparison of a QByteArray and a char*

Task-number: QTBUG-117661
Change-Id: Ic5142b7bc2a8220d244312414618028e8cc50d09
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-04 06:13:54 +01:00
Tim Blechmann 376ff95e93 Compiler detection - __attribute__((fallthrough)) for clang
Clang supports `__attribute__((fallthrough))`. While C++ sources use
[[attribute]], the C codepath still requires a fallback.

Pick-to: 6.7
Change-Id: Iaa93d2debc21fdd34e414ddb024b95942ae9191f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-04 02:14:13 +00:00
Thiago Macieira 75254e1d35 QProcess/Doc: remove the note that about FailedToStart after started()
It was added in commit 75a2c81b0041df4ca59178cf52d9e5a8815f3524:

 Handle posix_spawn using exit code 127 to indicate fail-to-start

 Most posix_spawn implementations are done using fork(), so the only way
 to report errors afer fork() is via a special exit code.

Support for posix_spawn was removed when we dropped QNX 6.5 support in
Qt 5.7 (commit 005a8bfbf0). Also
complements commit d012e953bf.

Pick-to: 6.6 6.7
Change-Id: I76ffba14ece04f24b43efffd17aadead7c30146b
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-03-03 13:06:33 -08:00
Ahmad Samir 269919fa1e QAbstractFileEngine: remove redundant endEntryList() overrides
QAFE sub-classes endEntryList() overrides returned nullptr, which is
exactly what the base class implementation does.

Change-Id: I2e901647cd087c3b8ba674db6e7b371e620af340
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-03 20:28:54 +02:00
Ahmad Samir d89c32140a QAbstractFileEngineIterator: ensure `m_path` ends with '/'
... when it's first assigned, instead of in currentFilePath(), muck like
what QFileSystemIterator does.

Change-Id: Id58ddcd6df5ad911fd5a62f1ca386e25626cb781
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-03 20:28:54 +02:00
Ahmad Samir e9126fd3ab QAbstractFileEngineIterator: general code cleanup
- This is private API, no point having the d-pointer indirection; store
  the members in QAbstractFileEngineIterator directly. In subsequent
  commits sub-classes can use m_fileInfo from the base class, saving
  some space in e.g. QFSFileEngineIterator

- Make setPath() public, it's a setter called by some QAFEI sub-classes

- Remove EntryInfoType enum, nothing uses it

This is a step towards remodeling QAFEIterator, and its subclasses,
after QFileSystemIterator, i.e. adding a `virtual bool advance()`
method, and dropping next()/hasNext(). This also is more inline with the
QDirListing class (which uses STL-style iterators).

Change-Id: I8ad774b854231e3cdce4935f04c8bf24031001dd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-03 20:28:54 +02:00
Ahmad Samir 94dfcaac8a QDirIterator: port to QDirListing internally
De-duplicates the code between the two classes.

[ChangeLog][Core][QDirIterator] This class has been deprecated and may
be removed in a future Qt release. Use QDirListing instead.

Change-Id: Iceba5091e72ea462dc9c5145a474bf312ee78043
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-03 20:28:54 +02:00
Ahmad Samir c610cfe328 Mention QChronoTimer in API docs
Change-Id: Iaf9fb31994f1580b2051dbd0b1b8eef2a218aa39
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-03 19:56:55 +02:00
Ahmad Samir 4bc0834bc1 Timers: add Qt::TimerId enum class
Which will be used to represent timer IDs. Thanks to Marc for the idea
to use "a strongly typed int".

QTimer got a new id() method that returns Qt::TimerId (can't overload
timerId()). Various classes in qtbase have a member named timerId(), but
a new method is needed anyway in QTimer so id() it is (this is the
reason QChronoTimer only has id() and no timerId()). Besides
timer.timerId() has an extra "timer".

This commit fixes the inconsistency between QObject using `0` timer id
to indicate "failed to start", while QTimer::timerId() returned `-1` to
indicate "timer is inactive". QTimer::id(), being a new method and all,
now returns Qt::TimerId::Invalid, which has value `0`, so that the
values match between the two classes. Extend the unittests to ensure
QTimer::timerId()'s behavior is preserved.

[ChangeLog][Core][QObject] Added Qt::TimerId enum class, that is used to
represent timer IDs.

Change-Id: I0e8564c1461884106d8a797cc980a669035d480a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-03 19:56:55 +02:00
Ahmad Samir 577a3dba52 Q{Chrono}Timer: de-duplicate some code
Q{Chrono}Timer::isActive() has to use isActiveData so that the bindable
property is correctly queried. However in other places in the code we
can take a shortcut by checking id > 0.

So rename QTimerPrivate::isActiveActualCalculation() to make it more
palatable and use it throughout the code.

Change-Id: I3378233e553fd860d9f105bba013dc9ffc31a2ba
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-03 19:56:55 +02:00
Ahmad Samir bd764cc1ca Add QChronoTimer, a timer with nanoseconds precision
The interval in QTimer is a QProperty of type int, which means it's
limited to the number of milliseconds that would fit in an int (~24
days), this could cause overflow if a user constructs a QTimer with an
interval > INT_MAX milliseconds. And it can't be easily changed to use
qint64/std::chrono::nanoseconds:
  - changing the getters to return qint64 means user code would have
    narrowing conversions
  - the bindable QProperty interval can't be changed to qint64 during
    Qt6's lifetime without the risk of breaking user code
  - adding a new bindable QProperty that is qint64/nanoseconds is an
    option, but it has the complication of what to do with the int
    interval; set it when setInterval(milliseconds) is used by using
    saturation arithmetic? and what about notifying observers of the
    changed interval?

Thus the idea of creating a new stop-gap class, QChronoTimer, as a
cleaner solution. Both classes use QTimerPrivate.

During the lifetime of Qt6, QTimer's interval range is about 24 days,
whereas QChronoTimer's interval range is about 292 years
(duration_cast<years>nanoseconds::max()).

Currently the plan is to fold QChronotTimer back into QTimer in Qt7.

Mark all QPropertyS in the new class as FINAL since they aren't
intended to be overridden; this offers a performance boost for QML[1].

[1] https://lists.qt-project.org/pipermail/development/2024-February/044977.html

[ChangeLog][QtCore] Added QChronoTimer, which uses a
std::chrono::nanoseconds intervals, as a replacement for QTimer.

Fixes: QTBUG-113544
Change-Id: I71697f4a8b35452c6b5604b1322ee7f0b4453f04
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-03-03 19:56:55 +02:00
Ahmad Samir 4fa9034d0c Copy QTimer source files to QChronoTimer
Ultimately this is the best way to keep the log history of the code.

Change-Id: I3413deffdb093a3239d65b6ca939e744224e722a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-03 19:56:55 +02:00
Tor Arne Vestbø 7ff1285e7a Disconnect QWindowContainer::focusWindowChanged on destruction
Regression after 9e78256579.

Apparently the string based connection syntax is more lenient,
as with PMF-style connects, we (correctly) get:

 ASSERT failure in QWindowContainer: "Called object is not of the
 correct type (class destructor may have already run)"

when the QWidget destructor closes the QWindow and we get a
synchronous callback from the platform that we've lost the
focus window.

Pick-to: 6.7
Change-Id: I8f25b3b050e11913ec0f0941eaf831c88b4249f9
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2024-03-03 17:07:55 +01:00
Ahmad Samir 7cf39bd785 Port to QDirListing
Use QDirListing in the Bootstrap build instead of QDirIterator.

Drive-by changes:
- more const variables
- use emplace_back() instead of append() where appropriate

Change-Id: Ie1f0d03856e557c4bfabfff38a87edc7da86d091
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-03 14:02:07 +02:00
Mårten Nordheim d5eb5d2f8d QLocal8Bit::convertToUnicode[win]: rewrite remainingChars handling as recursive
Then we will automatically handle invalid leading characters instead
of throwing away the whole sequence when it cannot be converted.
Added a test that was failing before.

Drive-by change: add a comment explaining why we
have the stack allocated buffer.

Task-number: QTBUG-118834
Change-Id: I647a58f2ba95e2e7ed4ea6a964d99ecc0c91fad3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-02 22:57:09 +01:00
Mårten Nordheim 8d6d7428f4 tst_QMutex: use the new QCOMPARE_* macros
Some machine in CI is failing some of these sometimes and
I would like to know by how much.

Pick-to: 6.7
Change-Id: I88b41d5cde81419f7c11f7038101962630eb31ef
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-03-02 21:57:09 +00:00
Mårten Nordheim b2ff0c2dc2 UDP: don't disable read notification unless we have a datagram
The current logic that we will disable the read notification if we
have any data at all doesn't make sense for users who use the
receiveDatagram functionality, since they will not make any calls
that trigger the read notifier to be re-enabled unless there is a
datagram ready for us to hand back.

Fixes: QTBUG-105871
Pick-to: 6.7 6.6 6.5
Change-Id: I0a1f1f8babb037d923d1124c2603b1cb466cfe18
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-02 22:57:09 +01:00
Christian Ehrlicher de0230467c QtXml: fix leak in QDomText::splitText
QDomText::splitText() needs to unref() the newly created QDomText
instance as it does not use it by itself

Pick-to: 6.7 6.6 6.5 6.2 5.15
Fixes: QTBUG-40561
Change-Id: I593011b63c39f2310204d97ec61da7cf78a0fc14
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2024-03-02 21:22:53 +01:00
Thiago Macieira 398a51686e qfloat16: use std::numeric_limits<std::float16> if available
Instead of going through the bit casts. Also solves the violation of
constexpr requirements from the previous commit.

Pick-to: 6.7
Change-Id: I01ec3c774d9943adb903fffd17b8b6ee93d3c031
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2024-03-02 07:29:19 -08:00
Thiago Macieira 48cd686757 qfloat16: make native std::numeric_limits<qfloat16> constexpr
In C++23 with std::float16_t present (QFLOAT16_IS_NATIVE), the
_limit_xxxx() methods in qfloat16 need to set the native type, not rely
on the union trick because that isn't allowed in constexpr mode.

                    in ‘constexpr’ expansion of ‘operator<=>(Max, std::numeric_limits<double>::max())’
qfloat16.h:209:5:   in ‘constexpr’ expansion of ‘compareThreeWay((* & lhs), ((double)rhs))’
qfloat16.h:209:5:   in ‘constexpr’ expansion of ‘(& lhs)->qfloat16::operator NativeType()’
    error: accessing ‘qfloat16::<unnamed union>::nf’ member instead of initialized ‘qfloat16::<unnamed union>::b16’ member in constant expression

Pick-to: 6.7
Change-Id: I01ec3c774d9943adb903fffd17b8b6ceed6ef9e2
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2024-03-02 07:29:15 -08:00
Axel Spoerl 89fc58127d QDockWidget: Use resizer without native window decoration
975c0bdf73 has disabled usage of a resizer
on Windows. This has caused a regression, when a dock widget was
rendered frameless.

Use a resizer in that case.

Fixes: QTBUG-120694
Task-number: QTBUG-102196
Pick-to: 6.7 6.6 6.5 6.2
Change-Id: I9fbcb1a8b1d8869995093bc1da7524ec81e9f02d
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2024-03-02 04:00:14 +01:00
Friedemann Kleint af814d7d9d SQL/SQLite: Silence warning "Unsupported option ''"
It shows for example when starting assistant.
Amends 3379fd2322.

Pick-to: 6.7
Change-Id: I85196c62ff9d9caaa46a5279c3b965dc28266ba8
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2024-03-02 02:51:53 +01:00
Aurélien Brooke 179c664c31 rhi: add labels to OpenGL objects to make debugging easier in RenderDoc
Change-Id: Ide7d16f56ba8a0a23d5c2e29da4dccedfb12ef1b
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2024-03-02 02:31:40 +01:00
Ahmad Samir a4a679ee79 QTimer: delegate more to the chrono overloads
singleShot() (static) methods:
QSingleShotTimer's interval isn't limited by the `int` interval in
QTimer, so this is OK, no narrowing.

start(int)/setInterval(int):
Techincally it makes no difference which overloads delegate to which,
because QTimer stores the interval in an `int` (QProperty); so any
{int interval,chrono::milliseconds.count()} > INT_MAX is narrowing
anyway. But it's less confusing and matches what has been done in other
classes when porting them to chrono, int overload delegates to chrono
overload.

Change-Id: I5ae0888f16130ae28a74be4498a180485fa34550
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-02 03:31:40 +02:00
Ahmad Samir 56e151663e androiddeployqt: fix QDirIterator::next() usage
The code inside the loop body uses it.next() twice, however hasNext() is
called only once; each call to next() advances the iterator.

Amends 4041610cb2.

Pick-to: 6.7 6.6 6.5 6.2 5.15
Change-Id: Idb96cfbddc56e0d7ed38ab1b0279f40592c75175
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2024-03-01 23:12:56 +00:00
Marc Mutz 4b806d678e Rename qIsConstantEvaluated() to q20::is_constant_evaluated()
We should really try to avoid another
almost-std-compatible-but-not-quite idiom. When qIsConstantEvaluated()
was added, the rationale was given that this cannot be q20, because we
can't implement it in all compilers. But we can: returning false is a
perfectly legal implementation, and makes most users actually simpler
because the #ifdef'ery can be dropped.

There are only two users that still require the macro, because either
they do different fallbacks depending on whether the implementation is
trivial, or because they direct expected test outcomes.

The INTEGRITY compiler complains "calling __has_builtin() in a
constant expression", which we currently don't understand. To unblock
this patch, and therefore the 6.7 release, hard-code INTEGRITY to
return false.

Amends 95e6fac0a5.

Pick-to: 6.7
Change-Id: If6cae902ff434f2ccceb6057cb053b7f304a604c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-03-02 00:12:55 +01:00
Christian Ehrlicher 97bbf37f42 SQL/ODBC: cache return value of SQLGetInfo(SQL_IDENTIFIER_CASE)
This value does not change over time so no need to retrieve it from the
driver for every call. As a drive-by change the enum to an enum class.

Change-Id: I25292d724f5173fef7054bb5e7e82e82992e41c6
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-03-02 00:12:55 +01:00
Christian Ehrlicher 000d462bf9 SQL/ODBC: escape values in connection string
Values in connection strings must be escaped when they
 - contain a ; -> escape with "
 - start with ' -> escape with "
 - start with " -> escape with '

Fixes: QTBUG-122642
Pick-to: 6.7
Change-Id: I1df638194067af5df94a34009e1547886fdf928c
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-02 00:12:55 +01:00
Christian Ehrlicher 3b7013f9b7 SQL/ODBC: use SQL_SUCCEEDED(r)
Use SQL_SUCCEEDED(r) instead checking for SQL_SUCCESS and
SQL_SUCCESS_WITH_INFO separately on every return.

Change-Id: Ic5c0e7d13b4ce117a23bbee9311980146b13ba4d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-03-02 00:12:55 +01:00
Christian Ehrlicher 4f4ac705f0 SQL/ODBC: Add helper class SqlStmtHandle
Add RAII SqlStmtHandle helper class to make sure the statement handle is
properly cleaned up also on early exit.

Pick-to: 6.7
Change-Id: I7aba4472be1e2991f395eeb7e43f8dd272336694
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2024-03-02 00:12:55 +01:00
Ivan Solovev 2bc9ad0e5d QAnyStringView: use new comparison helper macros
Also extend unit-test to use new test helper functions.
Remove the now-redundant test for three-way comparison, because it is
covered by the test helper functions.

Task-number: QTBUG-117661
Change-Id: I242b560c281245e04e34353c80000a20998fc677
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-03-02 00:12:55 +01:00
Ivan Solovev 868a5342bb QUtf8StringView: use more comparison helper macros
Convert the last relational operators to using the macros.

Task-number: QTBUG-117661
Change-Id: I5c4c890527d1a3c9500e98f47881d2e17b101ca9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-02 00:12:54 +01:00
Ivan Solovev 7068418a13 QByteArray: use comparison helper macros
Replace the existing friend relational operators with the macros.
Add the previously-missing relational opertors with QChar and char16_t.

This allows to remove the last dummy relational operators and the
macros to generate them in tst_qstringapisymmetry.

Because of a bug in libstdc++[0], we have to explicitly keep the
QBA vs QBA relational operators even in C++20 mode. This problem is
specific to QByteArray, because it is convertible to const void *.

[0]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114153

Task-number: QTBUG-117661
Change-Id: Iac7f81cd3274331b7c7695a51803321b511361c0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-02 00:12:54 +01:00
Ivan Solovev ee612626f9 Q(Latin1)Char: use comparison helper macros
Replace the existing friend relational operators with the macros.

Add the previously-missing QChar vs `const char *` relational operators.
These require out-of-line helper methods, because we need to interpret
the `const char *` array as utf-8.
The `const char *` relational operators cause ambiguities when
comparing QChar with 0 (previously it was only handled by the nullptr_t
overloads). As we have it in several places in our tests, I'd assume
that the users can also do it. To resolve the ambiguities, mark the
new relational operators as Q_WEAK_OVERLOADs.

This allows to remove the dummy QChar vs `const char *` relational
operators from tst_qstringapisymmetry, but at the same time requires
that we introduce new dummy operators for QByteArray vs char16_t
comparison. These will be fixed in a follow-up patch.

For QLatin1Char - convert to uchar before doing the comparison, to
match the behavior of QLatin1StringView and QChar. Extend QChar's
unit tests.

Task-number: QTBUG-117661
Change-Id: I9213fe05a5efdb96d48688f07bec9519f9887a77
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-02 00:12:54 +01:00
Ivan Solovev a08bafc920 Add QByteArrayView vs QChar and vs char16_t relational operators
This allows to remove the dummy relational operators from
tst_qstringapisymmetry.

Task-number: QTBUG-108805
Change-Id: I7cb3154d6fcb571cafab6b318806f74bc8300448
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-02 00:12:54 +01:00
Ivan Solovev 34372af708 QLatin1StringView: consistently use comparison helper macros
Replace all friend relational operators with comparison helper macros.
This allows to enable operator<=>() in C++20 builds.

Use new \compares and \compareswith qdoc commands in the documentation.

Task-number: QTBUG-117661
Change-Id: I0445d7af3c2d692c810e15e83041de2a19f946a9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-02 00:12:54 +01:00
Ivan Solovev 3d0eaf863e Add missing QUtf8StringView relational operators
Add QU8SV vs QSV, QU8SV vs QChar, and QU8SV vs char16_t relational
operators.

This allows to get rid of the dummy relational operators in
tst_qstringapisymmetry.

Task-number: QTBUG-117661
Change-Id: If95d7418efd13c505ed0e3bef748b86ff55e623a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-02 00:12:53 +01:00
Ivan Solovev e2e21bcb2d QString: use comparison helper macros - missing string views [3/3]
The comparison with QStringView works as is, there is no need to add
explicit operators.
Add the missing relational operators with QUtf8StringView. Once it
is added, comparison of QString with u8"string literal" becomes
ambiguous, so explicitly add operators for `const char8_t*` as well.
This also makes the comparison with u8 string literals faster,
because it now uses a view instead of constructing a QString.

Adding QUtf8StringView overloads also makes comparison with
`const char *` ambiguous if QT_RESTRICTED_CAST_FROM_ASCII is defined.
To fix that, mark the overload as Q_WEAK_OVERLOAD. Luckily, we can
just use the third Attributes parameter of the macro for that.

Provide more unit-tests to cover the new relational operators.

Task-number: QTBUG-117661
Change-Id: I60d1f4ad7ea607472deeb5c250e62f2bb7019268
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-02 00:12:53 +01:00
Ivan Solovev 42b6fdfb52 QString: use comparison helper macros - comparison with byte arrays [2/3]
Use the comparison helper macros to replace the member relational
operators for comparison with QByteArray and const char *.

As QString and QByteArray are exported, we cannot simply remove the
inline methods, so wrap them into QT_CORE_REMOVED_SINCE.

Add relational operators with QByteArrayView.

Provide more unit-tests for the comparison with the byte array types.

This enables operator<=> for QString vs byte arrays in C++20 builds.

Task-number: QTBUG-117661
Change-Id: I305343e1b6c5d78b10f2976573db4e904ba6b44b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-02 00:12:53 +01:00