Commit Graph

6866 Commits (152153cb111db1bbd42e94f27712bbc39accf310)

Author SHA1 Message Date
Ahmad Samir ff4252b0b6 QAbstractFileEngine: remove beginEntryList(QDir::Filters)
It was kept so as not to break compilation of user code (overriding a
function that doesn't exist in the base class). But as Marcus Tillmanns
pointed out in a qtcreator code review, it can't work because
QDirListing calls the virutal
engine->beginEntryList(QDirListing::IteratorFlags).

Removing beginEntryList(QDir::Filters) and getting a compile-timer error
is better than the code failing silently in user code (all sub-classes
of QAbstractFileEngine in qtbase have been already ported).

QDir::entryList() isn't affected because it calls
QAbstractFileEngine::entryList() which has an overload that works with
QDir::Filters.

Change-Id: I3cb18402f602ac78a6b29be57e59febb2b9db7c0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 4fecfcc867f8215defaa40b50f0340654a36b4c7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-19 10:09:37 +00:00
Mårten Nordheim 701263379a QFreeList: return timer IDs with the serial included
When a timer gets unregistered there is a chance that a new timer is
registered again immediately and gets the same ID.
On Windows this is a problem because there may be WM_TIMER messages
remaining in the native event loop that have not been processed.
This may result in unexpected timeouts for newly started timers.

By not masking away the serial/generation from the ID we generate
we will no longer return the same ID that was just freed.

While QFreeList mostly was prepared to be used in this way, one function
was not, and the tests were written with the assumption that the serial
was masked out. So this patch also addresses that.

Fixes: QTBUG-124496
Pick-to: 6.7 6.5
Change-Id: If6784815bfa41e497cbc4e00bef51da3ded5f255
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
(cherry picked from commit 21e9875d62414306fde9738ab255e55f22d1c8ed)
2024-10-19 06:50:26 +00:00
Ahmad Samir 55a8050d1e QDirIterator: don't crash with next() after hasNext() returned false
The typical use-case is calling hasNext() first before using next, but
the API docs say that calling next() even when hasNext() is false,
should just return an empty string.

[ChangeLog][QtCore][QDirIterator] Fixed a crash that happened if you
called next() after hasNext() had already returned false. Ideally you
should never call next() without first calling hasNext() as that could
lead to unexpected results (for example, infinite loops).

Fixes: QTBUG-130142
Change-Id: If0a8b1fe7dbd13b45793409a7a241e53c7257f24
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit c7691842f743f568a073582c8f0cacd6ee188f98)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-18 01:52:28 +00:00
Edward Welbourne 3167b157cd Remove untruth from QDateTime::fromString() documentation
Two examples were given, one to show "invalid" usage that would, in
fact, work now - producing a date in 2012 - and the other to show
"correct" code which, while correctly delivering the date in 1912 its
author appears to have meant (albeit, giving a four-digit year would
have made that clearer), uses the string API where code should
normally construct dates - much more efficiently - by just passing the
numbers to suitable constructors.

Add tests verifying that the two date-times from the out-of-date
examples do in fact work, even if you tell them the wrong century as
default for two-digit dates.

Pick-to: 6.7 6.5
Change-Id: I8155af019c80729323ba3958fe3942a72bfefc22
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 82d85c16d912b25bfa5b0a081e515fcecda1f975)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-17 16:18:37 +00:00
Mårten Nordheim d6c592aa2f QThreadPool: fix regression with negative expiryTimeout
It's supposed to indicate a thread never expires, but following
a change where it stores the expiry with chrono we no longer considered
a negative expiry as 'forever', but rather it immediately expires!

More directly it is because we end up calling
QDeadlineTimer::setPreciseRemainingTime(0 secs, X nsecs), and it only
cares about negative seconds to set Forever. There are complications to
consider nsecs for this since several nanoseconds may pass between
initially calling the function and assigning the values...

Amends 1f2a230b89.

Fixes: QTBUG-129898
Change-Id: I9626de31810fb2751ff6d83165d7dce5258a9baf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit c57027199996d0f0d2ac8ebc4505c78afa54ab5a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-15 12:45:00 +00:00
Edward Welbourne ac6f080d16 Remove a duplicate inclusion of qlocale_data_p.h
In tst_qlocale.cpp there was a #include that caused the static data
tables to be duplicated, violating ODR. All it actually needed was the
ability to iterate all rows of the locale_data[] table, so export a
method to do that from QLocaleData and have the test run that instead
of pulling in a second copy of the tables.

Conflict resolution at 6.8 needed the declaration of locale_data_size
moved up qlocale.cpp, which happened after 6.8 as part of other work
that isn't included in 6.8.

Pick-to: 6.5 6.2
Task-number: QTBUG-128930
Change-Id: Ie5ebdf508a622eeca93f8785bc09b086502aa0e2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 96c07655c46afdd3e2da7ef7d339b518d36c83c5)
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2024-10-14 17:15:03 +02:00
Volker Hilsheimer 34a41d83d8 QTranslator: rewrite loadLocale test, include failing cases
Add test coverage for the bug reported in QTBUG-124898 with
QEXPECT_FAIL to document the failure in our truncation logic in
QTranslator.

The attempted fix in 9a11273b745a30cebb5cd648c89eb224e9704492 then
introduced QTBUG-129434, as we ignored the order of languages reported
by the system locale. Add a test case for that, and use a QSystemLocale
subclass inspired by the QLocale unit test to override the system locale
with a specific one that supports multiple languages for this test.

Pick-to: 6.5
Task-number: QTBUG-124898
Task-number: QTBUG-129434
Change-Id: Iaae80d29e267fd3a2d14df0e73db27ba4c58b31a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 1f2ab46745af12e4776695c1b1a2523ac170368e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-10 11:21:41 +00:00
Fabian Kosmale dd5c13d09e QMetaObjectBuilder: Fix construction logic for enums
We need to put metatypes in the correct place; this is especially vital
starting with Qt 6.9, given that we need it to query it to figure out
whether we have a 64bit value or not.

As a drive-by, replace some ugly casting when constructing the meta-type
array with a call to QMetaType::iface.

Change-Id: I4b1f42f974e9f7a21f6aa4c87c3f8919f6965d6e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit d392d3b22c94f86fea50f26284bc9ac8b35f6851)
2024-10-09 08:48:13 +02:00
Santhosh Kumar be974c4855 Avoid referring to invalidated observer during binding evaluation
The property observer reference used during binding evaluation can
become invalidated as the container used to maintain the
the observer would invalidate the existing observers during its
resize, leading to referring to invalid memory.

Recognize that we do not need to store the observer, but only its
binding - the observer itself is not used later.

Therefore, change the PendingBindingObserverList to become a list of
QPropertyBindingPrivatePtr to avoid the issue.

Fixes: QTBUG-127596
Original-patch-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
Pick-to: 6.5 6.2
Change-Id: I8c97721ca563083d6280194175f8a915dac2ff04
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
(cherry picked from commit 275202215376238bf414d5008d3c727085e58a4c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-07 17:26:50 +00:00
Tor Arne Vestbø 42439087eb Darwin: Teach QFileSystemEngine how to resolve case-sensitivity
Both APFS and HFS+ can be both case-sensitive and case-insensitive
(the default), and the mounted file system may be any other file
system than these two as well, so hard-coding to case-sensitive
is not sufficient.

Task-number: QTBUG-28246
Task-number: QTBUG-31103
Change-Id: Ibdb902df3f169b016a519f67ad5a79e6afb6aae3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 3d08816f4c4245f08a53307775fe3c4ed31a7a32)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-02 21:36:48 +00:00
Kai Köhne e5c1d02ac6 Revert "QTranslator: fix loading order when loading from locale"
This reverts commit 9a11273b745a30cebb5cd648c89eb224e9704492.

Reason for revert: The fix tried to find a sensible order if
the same language is listed multiple times in QLocale::uiLanguages().
Anyhow, it breaks for lists where entirely different languages are listed. This needs more thought.

Fixes: QTBUG-129434
Pick-to: 6.7 6.5
Change-Id: I8c074cbf1ddc2ddf223ec09aef38dfc1ef7fc85f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit f3fc7b210f79e5eb427b0ff49c45c5d6d390fb34)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit a30c1bcd3c8b8eb4befeb254840224ca7bb52497)
2024-10-02 04:35:19 +00:00
Tor Arne Vestbø e336111a5d tests: Explicitly check for pathconf(_PC_CASE_SENSITIVE) == 1
We use pathconf in some of our tests to determine if the file system
on Darwin is case sensitive. But pathconf returns -1 if the case
sensitivity can't be determined, with errno set to ENOTSUP.

The convention in this case is to treat the file system as not being
case sensitive (as reported by NSURLVolumeSupportsCaseSensitiveNamesKey
and VOL_CAP_FMT_CASE_SENSITIVE in equivalent APIs), so we need to check
explicitly for a return value of 1.

Change-Id: I1107e849babd8813da3b148c92494e8e35a32d36
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit bd3aabf38454087a96a17ff0130d7f5c2b2b39a9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-23 19:36:53 +00:00
Tim Blechmann c5a27f4cfe QObject: disconnect - document behavior with queued connections
QObject::disconnect does not cancel pending events. This can cause hard
to find bugs in application code, so we explicitly document and unit
test this behavior.

Task-number: QTBUG-127675
Change-Id: I5e94d60c27b9ce2dd2bceb832eb817b7eaa9cdcd
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 0681e720a9851f1873ce5a5f99b5567d2b418261)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-20 01:30:56 +00:00
Soheil Armin bbaeb6a357 Android: Add tests for QtAbstractListModel
Adds test data and conditions for QtAbstractListModel interface

Pick-to: 6.8.0
Task-number: QTBUG-125974
Change-Id: I168a5cfabfc191c7ee50aa917d0fd0f9fabc1703
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit ca102dcddfc549b1c0a4135b4d869491f6ead4f3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-19 17:54:39 +00:00
Ulf Hermann a3df6c36db QUrl: Keep one trailing slash when normalizing "file:///b/."
Removing the slash would be a drastic change in behavior. We can expect
many people to rely on the trailing slash to string-append further path
segments without inserting an extra slash.

Amends commit e7bcf41c0b23d83cfb31f966454945c705589a99.

Pick-to: 6.7 6.5
Fixes: QTBUG-128940
Change-Id: I71dfc957f383e4648b3b47a40aeb796d7237fb00
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 2addfa635d2f666d18ffc818f76eb673a6c787d1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-19 15:09:46 +00:00
Thiago Macieira 4f30a4426c QTypeRevision: fix support for 8-bit signed segments
The logic in the isValidSegment() function was failing for 8-bit signed
because for them Integer(SegmentUnknown) is -1, so
  (std::numeric_limits<Integer>::max)() < Integer(SegmentUnknown)
was always false (127 < -1) and the function would only return true on
the impossible condition of
  segment >= 0 && segment < -1

Fixes: QTBUG-128848
Pick-to: 6.7 6.5
Change-Id: I8d17b93afd6c2982a099fffdcaeccf126b7a9d02
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit ddfcc0734875cdee2c169bf2ecb1546bddba6e98)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-14 16:38:08 +00:00
Thiago Macieira 43003ccbce tst_QTypeRevision: rewrite using if constexpr and direct calls
This removes the specializations, which were hiding the fact that signed
8-bit integers produce assertion failures.

Pick-to: 6.7 6.5
Task-number: QTBUG-128848
Change-Id: Ibb4952b0eb50a8c51e05fffd9e88a137ca95bcd8
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit a572b4b0780dcc5fcac55737fc4153fca93e6c62)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-14 16:38:07 +00:00
Thiago Macieira 23cf29ffdd QFileSystemEngine/Win: only .lnk files that exist can be symlinks
Fortunately, isDirPath() had an extra parameter to tell us whether the
path existed in the first place, making the fix very simple.

Pick-to: 6.7 6.5
Fixes: QTBUG-128800
Change-Id: I81482f87b594933158d0fffdbea0ea2a00494b6c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 329b05739d5d62f37464a5714ad87e7ca05693e2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-14 16:37:55 +00:00
Thiago Macieira 16571ac456 QDir: change qt_{cleanPath,normalizePathSegments} to returning bool
Since qt_normalizePathSegments very often modifies the path, pass that
as pointer, and return a boolean with whether the path is attempting to
go up above the root.

Change-Id: I851fcb94db4606a6bd97fffd81910930dea8222a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit 0314491abac092b20ebefc05e2e9f27fd038fc38)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-14 16:37:12 +00:00
Thiago Macieira 2ce3153b83 QUrl::resolved: switch to using qt_normalizePathSegments
Commit 4b1547adc9b195e6acc90471fc48dec7ee0c429d rewrote
mergePathSegments() but got one thing wrong: that ".." on a "//" should
only remove one slash, not all of them. That behavior was introduced by
commit eaf4438b35 to match what browsers
do.

QUrl will use the local file behavior if the URL scheme is "file",
unlike the browsers.

Task-number: QTBUG-120396
Pick-to: 6.8.0 6.7 6.5
Change-Id: I8a96935cf6c742259c9dfffd17e8fd3cfde46e25
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit e7bcf41c0b23d83cfb31f966454945c705589a99)
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-09-14 09:37:12 -07:00
Thiago Macieira 7359d63209 Replace qt_normalizePathSegments algorithm with QUrl's removeDotsFromPath
Commit 4b1547adc9b195e6acc90471fc48dec7ee0c429d rewrote the latter for
simplicity and performance, so copy it over with intent to merging the
two together. In this copy, however, we keep the behavior introduced by
commit eaf4438b35, which made the
normalization match the behavior found in browsers, but didn't apply to
QUrl::resolved (that's the next commit)

Task-number: QTBUG-120396
Pick-to: 6.8.0 6.7 6.5
Change-Id: I2670423f6c6a5339771ffffdf15ebad46fd25cb4
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit 78e2d24752d8b6652aac89d1e79f245bc88281c6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-14 09:37:11 -07:00
David Faure d53c3809de QConcatenateTablesProxyModel: react to row and column moves
Fixes: QTBUG-128742
Change-Id: I6282c3c9f27c435da5d511c61fbb051da127229c
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
(cherry picked from commit b9ba28315d889d0b87ae048dffe33eac55efcda2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-13 17:44:05 +00:00
Thiago Macieira fee6283b85 QUrl::toString: fix using of NormalizePathSegments and RemoveFilename
We were overwriting the normalization if RemoveFilename was used.

[ChangeLog][QtCore][QUrl] Fixed a bug that caused QUrl::toString(),
QUrl::toEncoded() and QUrl::adjusted() to ignore
QUrl::NormalizePathSegments if QUrl::RemoveFilename was set.

Fixes: QTBUG-127711
Pick-to: 6.7 6.5 6.2 5.15
Change-Id: I8a96935cf6c742259c9dfffd17e8e1f7fec44cb6
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit c9ff625865c355fb57c824b13f3cb4b26e53fbe7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-11 03:20:02 +00:00
Fabian Kosmale 722c7edf03 QHash: Unconceptify heterogeneous search code
That allows the code to run in C++17 mode - at the expense of
significantly worse compile time error messages, potentially worse
compilation speed and harder to read code.

Adjust the test type to actually model
detail::is_equality_comparable_with (which requires all four
relational operators even in C++17).

As a drive-by, fix the return value of remove() from auto to bool.

Done-with: Marc Mutz <marc.mutz@qt.io>
Fixes: QTBUG-128470
Change-Id: I68df26db579c60812a18e09b76dd5712e73ccaa2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 7fe3cee36352c74cbaaff52e863bd0da1170affa)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-06 15:55:07 +00:00
Mårten Nordheim 7eea3acac9 Tests: suppress has_denorm deprecation
Deprecated in C++23:
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2614r2.pdf

Pick-to: 6.7 6.5
Task-number: QTBUG-128584
Change-Id: I43fb045dfa78b1f0ba5bd52886ca1bf89869d91d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit e54ee29862bd97749d547330a739416768088986)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-06 14:38:21 +00:00
Łukasz Matysiak a87db277ce Prevent linker error in tst_qfloat16::ordering on VxWorks
tst_qfloat16::ordering tests that qfloat16 can be compared with a long
double. When on x86_64, conversion from qfloat16 to long double leads to
a linker error due to undefined reference to __extendhfxf2.  This is a
bug in the VxWorks' toolchain. It has been acknowledged by WindRiver and
it's being tracked in ticket 00154117.

Since
- this is a platform problem and Qt has no control over it,
- the conversion won't work for any client code anyway, so not testing it
  is not hiding any issues,
mitigate the problem for now by not compiling the problematic test code
on VxWorks.

Task-number: QTBUG-115777
Change-Id: Icf81da405d1392ae3bcacc61745a54d68b849b89
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 6ef631c7992cc81ead158c5c5801f689b21fc378)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-05 12:29:51 +00:00
Thiago Macieira 02510e11a9 tst_QPluginLoader: use qCpuHasFeature instead of __builtin_cpu_supports
Fixes a build problem on VxWorks because their runtime library isn't
libgcc.a and is thus missing the symbols that the Clang emits into the
test code when the intrinsic is used. This also better aligns the CPU
check with what QtCore does.

Drive-by add a comment explaining what this is and why Darwin is
excluded.

Drive-by clean up of the CMakeLists.txt, especially the no-ops.

Task-number: QTBUG-115777
Change-Id: Ib15e33ce157f7e6d99d0530076de6a1024733ed6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 5f522947878690bf7b99ff4b39a6cbaa259b74b1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-05 12:29:51 +00:00
Milian Wolff ba6ffd99e2 Don't increase the refcount if qobject_cast failed
Follow the dynamicCast/dynamic_pointer_cast implementation for
objectCast/object_pointer_cast since a qobject_cast can fail
just like a dynamic dast.
Also see: https://eel.is/c++draft/util.smartptr.shared.cast#6.2

See commit this commit from 2013 for more historical context:
a094bf5a89

Pick-to: 6.7 6.5
Change-Id: I9a54af55a7a1cf106cace52e9cf3bc103ae0bd42
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 7a65abb50eb638de445e24c2746d7f90c1b89f06)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-05 12:29:51 +00:00
Ivan Solovev ea1a6d3ae0 QLocale: add (in)equality operators with QLocale::Language
We do have an implicit constructor which allows construction of a
QLocale from the QLocale::Language enum values. It will be used when
doing the comparison.
However, do not rely on the implicit conversions, and provide the
operators that explicitly do the right thing. This also allows us to
save an extra allocation of QLocalePrivate.

Found in Qt 6.8 API review.

Amends 71bbc35a37.

As a drive-by: fix the order of the test slots in the unit test.

Change-Id: I37f8f5881469b7734705e06e471746814dd2ddf0
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 403b1abcad5f437c51dfabd7095b814e99e197a1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-04 08:37:48 +00:00
Marc Mutz 089263fd4f QDirListing: make end() return a sentinel
This simplifies the implementation, and is more secure, because you no
longer can compare const_iterator with const_iterator and get a
non-sensical result (unequal, even though copies of each other).

Requires the STL algorithm test to be ported to C++20 ranges, because
classical STL algorithms can't deal with decltype(first) !=
decltype(last).

Found in API-review.

As a drive-by, make the reversed and inverted operators conditional on
!__cpp_impl_three_way_comparison.

Change-Id: Icd0e4dac277bd3b053f7b648f8c3f9d9f3753299
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit 2569ca0f34fe15a2e5c828b708f1406be8d53836)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-03 18:06:32 +00:00
Tatiana Borisova e5d96ae7d4 Revert "Convert a Qt ordering type to the weaker std ordering type"
This reverts commit 521e091bca1764d53ac06bb60707475d1032f5d5.

Reason for revert: The fix doesn't work with MSVC2022 compiler and block windows-11_23H2-msvc2022-developer-build integration. Need time to find proper solution.

Task-number: QTBUG-128498
Change-Id: Id938fa2119c7e4c053398b2a3693f3128e53f734
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 1017a0eaf1f9fd9cc37189f73840d85bf4a5664c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-02 18:10:39 +00:00
Volker Hilsheimer d05438454f JNI: Add test coverage for a jobjectArray in a native function
Make sure this works as it should. The bug report/support request wants
to have a String[] parameter on the Java side, but then the C++ side can
not use jobjectArray (as that has "[Ljava/lang/Object;" as signature),
so use Object[] instead (which is one solution; the other is to use
QList<jstring> or (in 6.8) QStringList on the C++ side.

What's easy to miss is that the jobjectArray that we get is a local ref,
so we have to extend its lifetime by creating a QJniObject holding it as
a global reference. We can then create a QJniArray from that QJniObject
(without any type safety).

Task-number: QTBUG-128456
Change-Id: I1e03b811165f9bc5106324d39fb58114ee8cf398
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
(cherry picked from commit f9fd5870f7379103005839bc03543bb8f6da94c3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-09-02 18:10:38 +00:00
Thiago Macieira 6978951d5e Fix users of static max_size()
Container::max_size() is a _non-static_ member function in the STL, so
we can't call it as C::max_size(). Instead, use the newly-added,
Qt-style camel-case maxSize(), which we will keep static constexpr.

Task-number: QTBUG-128450
Change-Id: I839df90a91cced85f000c7d2744ba547f629ed98
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 6c15f99853c4cecd9285e189a441392a397b0f82)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-31 08:56:31 +00:00
Marc Mutz f8b3c1f0a7 QChronoTimer: remove static singleShot() functions
They match what QTimer already provides these days, and we want to
minimize porting for users come Qt 7, so we don't want users to first
write QChronoTimer::singleShot() (because it exists) and then back to
QTimer::singleShot(); we want them to continue to use QTimer.

The only reason QChronoTimer is a separate class from QTimer is that
the latter has an int interval property and we can't just port it to
milli- or nanoseconds chrono types if we want users to actually access
the extra range or precision afforded by the chrono types. But that's
not an issue for the singleShot() static methods, as they never return
an object that could be asked for its timeout.

(No ChangeLog needed, as QChronoTimer is new in 6.8)

Found in API-review.

Fixes: QTBUG-128426
Change-Id: Ief8b7c8d25380c0e9e9c5c36c90ce34c147557ae
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 6e5eb082c934cb94c45f3e13b3f7c2deb2e7b2e6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-29 20:41:50 +00:00
Ivan Solovev d4d2636e5e QDirListing: extend unit tests
Add the tests for the (move-)constructors and move-assignment.

Change-Id: I795a314a0e6d1795006fe152397eb6d9eeb3c712
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit b6466275c27f9ec4ec8b09641e203f7afef3f7e5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-29 20:41:36 +00:00
Jøger Hansegård 2f7d52a9ba Update tika-mimetypes.xml from upstream
This patch updates the tika-mimetypes.xml MIME types definition file to
version 5ea8bbf1644a593ed22ee5c7608ba33aff949d5d, which is currently the
latest on main.

The reason for the change is to include audio/aac as an alias for the
deprecated audio/x-aac MIME type, which is useful in QtMultimedia to
determine the file extension for AAC media files.

In addition, the update adds the application/x-java-keystore MIME type,
similar to the one in the old freedesktop.org.xml MIME type definition.

[ChangeLog][Third-Party Code] Updated TIKA MIME types definition file to
add the audio/aac and application/x-java-keystore MIME types.

Pick-to: 6.7 6.5
Change-Id: I14fa331c5c57e4fae8f8b31880dc66d6ca559f62
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit 5774aa2560b65a67e72f98cf2f776325b6760950)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-29 04:16:36 +00:00
Ahmad Samir e1f4f2ef47 String Views: add slice() methods
Methods with preconditions can't be noexcept (from Marc in code
review).

[ChangeLog][QtCore][String Views] Added slice() methods to
Q{String,ByteArray,Latin1String,Utf8String,AnyString}View which work
like sliced() but modify the view they are called on.

Found in API review.

Task-number: QTBUG-99218
Change-Id: Ic8ef3085f7cfac86b8404fb28d491ca38ad121eb
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 8f68bd9e6353a42d3b71d893b27fec6bedced501)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-28 17:40:05 +00:00
Edward Welbourne 690cc978ea Rename new QTZ::aliasMatches to hasAlternativeName
Raised in 6.8 API change review. The use of "matches" in a name suggests
pattern-matching, which isn't what happens here.

Task-number: QTBUG-125859
Change-Id: I8aa05b117807b9d1b9b737cd63d44fb4a30f6fa5
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 6b36e5de7656e1d9e23364c596cc82f8068d4452)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-27 16:38:19 +00:00
Thiago Macieira fbfec48c42 tst_QByteArrayView: remove use of std::char_traits
Complements ab05e05f60253b9be615c09aa340ee75f2e5bcaf:
    Strings: get rid of the last std::char_traits use

    LLVM's libc++ became pedantic and insists on only accepting
    instantiations for one of the standard Char types, so remove all uses of
    it with a template parameter.

    Complements dc2ae08e02.

which is:

    QStringView: stop instantiating std::char_traits<QChar> and <uchar>

    It's deprecated and will be removed with LLVM 19.

    Amends b1ee49b465.

Fixes: QTBUG-128325
Task-number: QTBUG-126214
Task-number: QTBUG-122753
Pick-to: 6.7
Change-Id: I2c7fbe3c0f557e98e7edfffdb00b4cc71a6612ca
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
(cherry picked from commit b387537d3e9c35d9f112d4aa32ad71df5e5e9028)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-27 05:22:58 +00:00
Ahmad Samir f1e15832dd String Views: optimize the QByteArray/QString constructors
By using {QString,QByteArray}::begin() instead of data() (for const
objectst); both begin() methods, respectively [1], return nullptr for a
const null {QString,QByteArray}. Whereas data() returns &_empty if
QT5_NULL_STRINGS is defined.

[1] QByteArray::begin() since a116b2ddfc
QString::begin() since 287ace562e

[ChangeLog][QtCore][QLatin1StringView] Creation of QLatin1StringView
from QByteArray or QByteArrayView now preserves the origin's isNull()
status. This matches the behavior of creating a QUtf8StringView from
those types.

Change-Id: Icbdfe282e315c08ca6a17201bcd32c1a3bba8bf5
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 221d8fdfb14c16472267320f859105f1a3834952)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-26 04:18:29 +00:00
Tatiana Borisova eae3d0807a Convert a Qt ordering type to the weaker std ordering type
- Added missing conversion from Qt::strong_ordering to
std::weak_ordering, std::partial_ordering.
- Added missing conversion from Qt::weak_ordering to
std::partial_ordering.

Usage of Q_IMPLICIT specifier in new std::*_ordering conversion functions leads to following ambiguity errors on WIN + MSVC configuration:
C:/Users/qt/work/qt/qtbase/src/corelib/global/qcompare.h(334): error C2440:
'static_cast': cannot convert from 'Qt::weak_ordering' to 'Qt::partial_ordering'
qcompare.h(334): note: 'Qt::partial_ordering::partial_ordering': ambiguous call to overloaded function
qcompare.h(249): note: could be 'Qt::partial_ordering::partial_ordering(Qt::partial_ordering &&)'
qcompare.h(153): note: or 'Qt::partial_ordering::partial_ordering(std::partial_ordering) noexcept'
qcompare.h(334): note: while trying to match the argument list '(Qt::weak_ordering)'

For solving the problem we can exclude the conversion function from the argument list(make it explicit in case of MSVC).
Q_COMPARE_CAST_IMPLICIT is used for setting explicit or implicit specifier depending on the compiler type

[ChangeLog][QtCore][QtCompare] Added missing conversions
from Qt ordering types to std ordering types.

Fixes: QTBUG-127670
Pick-to: 6.7
Change-Id: I32a9a33fa8921c75b0e5a40bd413572f1bd6765a
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 521e091bca1764d53ac06bb60707475d1032f5d5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-25 17:04:38 +00:00
Giuseppe D'Angelo 27dc042712 Rename qt_saturate to q26::saturate_cast
C++26 adds std::saturate_cast, so follow the established pattern of
other similar "backported" APIs. The old name is left around while
we port other submodules.

While at it, move qt_saturate's tests to the qnumeric test.

Change-Id: I653a2e3d936081378298a9c8e51e7c1a2d438d83
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 7447ad503330ed176cf369792ffb33b7e00a58d3)
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-08-25 17:04:32 +00:00
Thiago Macieira 13dbf7542e tst_QStringApiSymmetry: disable for WASM
It's failing to produce output in reasonable time and blocking the CI.
Since this test is basically a syntax checker, it not being present for
WASM is not a great loss.

Task-number: QTBUG-128322
Change-Id: Ic49e7523af63d5819c13fffdd7a752534b77f0ab
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit f414505eaac5c222fc6404b9cda24fec25f68a7a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-25 10:21:14 +00:00
Mårten Nordheim 5caa31cb21 QByteArray: fix lastIndexOf for char values with set sign bit
lastIndexOf will convert the `needle` to unsigned char, which is then
'upcast' to int, before we search. But the string itself was searched
using signed char, meaning any values with the signed bit set would
mismatch.

Add tests for indexOf and lastIndexOf.

Amends 4c12ae7e67

Fixes: QTBUG-128199
Change-Id: I0ce7d7d9741f21650ef6f0f012a94e00d84a0f02
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 7b1f3bdc503ea7aceacc9fa8d388d843f1d7b131)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-20 11:40:56 +00:00
Soheil Armin 9af91d6eca Android: Add Java QtAbstractItemModel auto test
QtAbstractItemModel used to be a part of QtDeclarative
and is being moved to QtCore based on API reviews.

Task-number: QTBUG-126976
Task-number: QTBUG-127089
Change-Id: I28a921a113ec4f3ad298bf55b40aea334e7721cf
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
(cherry picked from commit baed8a24d07de87da61e9d5e3dbffc8d8ca92918)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-20 01:28:03 +00:00
Thiago Macieira f6d69a7575 QHash: adapt to C++20 ranges not offering operator->()
Iterators no longer provide it, because they may need to return a
temporary in some occasions.

Fixes: QTBUG-128102
Change-Id: Ide0a7a84f612fff73afffffd49889321cb70505f
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
(cherry picked from commit cb40a1fa7f4b06acced1d17e8333742084092f9e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-20 01:28:02 +00:00
Jøger Hansegård 471debef07 Test QFileInfo::isWritable when it should return false
Extend existing tests to verify that QFileInfo::isWritable returns
false when file is read-only or non-existent.

Task-number: QTBUG-124011
Pick-to: 6.7 6.5
Change-Id: If41241b500aa76036b39a53590b5e0b6ab2f20ea
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 42004d245e2bf4846520e5e186a5c86aa87a6019)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-20 01:28:02 +00:00
Marc Mutz 7805b3c32f Only define QT_SUPPORTS_INT128 if type_traits work for them
It turns out that libstdc++ in -ansi mode defines __SIZEOF_INT128__,
but not the corresponding specializations of <type_traits> and
<limits>. This has caused numerous pain points over time, esp. since
is_signed doesn't work, so qt_saturate e.g. can't be used on qint128
inputs e.g.

After another such issue (cmp_equal()), we decided to require
<type_traits> and <limits> support for extended integer types in the
stdlib, or we will disable Qt's support for it, too.

So check that if QT_SUPPORTS_INT128 is defined, is_signed_v,
is_integral_v and numeric_limits work, too. Disable QT_SUPPORTS_INT128
when compiling with libstdc++ in __STRICT_ANSI__ mode (-ansi or
-std=c++NN instead of (the default) -std=gnu++NN).

[ChangeLog][Potentially Source-Incompatible Changes] Qt's support for
128-bit integers (qint128/quint128) is now conditional on support for
these types from the Standard Library, in particular <type_traits> and
<limits>. Qt no longer tries to work around missing Standard Library
support. As a consequence, e.g. GCC -ansi and GCC -std=c++NN (instead
of -std=gnu++NN, the default) builds will now no longer support these
types.

Task-number: QTBUG-119901
Change-Id: I8529e72a52a2f5da0f469bae543688e18220255f
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 9bb2ab5978625eee96f703871d5eca8e54b31386)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-16 17:34:29 +00:00
Marc Mutz caf57f0ca3 tst_QGlobal: add a build of this test in strict mode
This is in preparation of adding some static assertions here that we
need to have evaluated in both "normal" and "strict" mode, namely
<type_traits> and <limits> support for qint128.

But this change is more general, so making it a separate change.

Turns out we already have (non-static) assertions here about <limits>
support for qint128. These force us to define precisely when
GCC/libstdc++ has gained <limits> support for __int128_t: the
timestamp of the __GLIBCXX__ macro is the Daily Bump immediately
preceding the gcc commit that fixed <limits>
(gcc/8eb9a45e87bdb81cb44948c651edee846c622a0f).

Let's hope no-one is running the prerelease version of GCC 10.3 from
that particular day, otherwise these might become XPASSes. But just
not testing is also wrong; we want to be informed about True Positives
and Negatives here.

Task-number: QTBUG-119901
Pick-to: 6.7 6.5
Change-Id: I6f9be047f846fff74133c466c5bed40d0039d60f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit e7c54248987d474cff9f49cad502822eb9dcb114)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-16 17:34:29 +00:00
Ivan Solovev c197fefb22 Qt::totally_ordered_wrapper: do not allow operator*() for void*
Disable operator*() for void* type, because it otherwise causes
a compiler error:

  qcomparehelpers.h:1103:18: error: forming reference to void
     constexpr T& operator*() const noexcept { return *get(); }
                  ^~~~~~~~

Use this as an opportunity to add more tests for operator*().

Amends ece36a7394.

Change-Id: I205b9989bd142ca9aa49f8f4d15854e591e3042b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 053b8ff7fedfe5aed29a91a82569c00cac466e9a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-08-13 12:56:19 +00:00