Commit Graph

6893 Commits (05dfd8a0bdf8b8ab3c3347e546e18346ee81dffe)

Author SHA1 Message Date
Jøger Hansegård 8a23001ca6 Replace QWinRegistryKey::dwordValue with QWinRegistryKey::value<T>
QWinRegistryKey::value<T> returns an optional<T> which can make code a
bit more readable than the std::pair<DWORD, bool> return value from
QWinRegistryKey::dwordValue.

This implements part of the "TODO: Remove once all usages are migrated
to new interface." comment in QWinRegistry class because it allows us to
remove the QWinRegistryKey::dwordValue function.

Change-Id: If568de4e31778e91ce7aadadb4aac90e41222826
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 7a63a25ef71fbbe7b3eaa6ecb9a26c3e497e582a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-09 20:00:08 +00:00
Marc Mutz 5a9c513231 QPromise: fix documentation re:setException() after cancel() or finish()
The implementation checks the state and returns without storing the
exception when its canceled or finished.

Add tests for both situations.

Done-with: Ivan Solovev <ivan.solovev@qt.io> (analysis and phrasing)
Pick-to: 6.5 6.2
Fixes: QTBUG-128405
Change-Id: I4610a022ea12e1bc9ce24cb17b972b5b9e051f0a
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 6efec3850da188d3bba075185aa6e5c264c815eb)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-08 21:43:11 +00:00
Marc Mutz 0ac0ca8124 tst_QPromise: QSKIP when !QT_CONFIG(cxx11_future)
Don't just silently succeed.

As a drive-by, keep the skipped code visible to the compiler.
QThread::create() is universally available since
4a5f3c8b93, so the skipped code ought to
compile.

Amends ac6a9f9bfa.

Change-Id: I193ecf802ffbfd103747aa34eb307fb1a814a94e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 4e1b20893aeeb9580bc6b52ac4baea297675bfee)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-08 08:51:05 +00:00
Marc Mutz c7771366e5 [docs] QPromise: don't recommend legacy smart pointers
Use unique_ptr instead of QScopedPointer and shared_ptr instead of
QSharedPointer.

Amends 68de38ded1.

Pick-to: 6.5 6.2
Change-Id: Ic5c4c4962be69aecd4312dbdbfa84deb8a3c1e57
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 076445ec0d888f74498b4beadced58edce434ee9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-08 06:14:45 +00:00
Thiago Macieira 334a3922c0 QThread/Unix: refactor to split QThreadPrivate::finish() in two phases
Commit 1ed0dd88a3 moved the finish()
functionality from immediately after run() returns to the time of
thread-local destruction, to make sure that user destructors didn't run
after our cleaning up. But as a side effect, it made other user code run
too late, after some thread-local statics had been destroyed.

This is a common practice, which causes the destructor for worker to run
too late:

    worker->moveToThread(thread);
...
    QObject::connect(thread, &QThread::finished, thread, &QObject::deleteLater);
    QObject::connect(thread, &QThread::finished, worker, &QObject::deleteLater);

This commit splits the cleanup in two phases: QThreadPrivate::finish(),
which runs immediately after run() and will call back out to user code
(finished() signal and delivery of deleteLater()), and cleanup() that
cleans up the QThread{Private,Data} state and destroys the event
dispatcher. That destruction is the only call out to user code.

I've removed the complex mix of pre-C++11 pthread_setspecific() content
and C++11 thread_local variables in favor of using one or the other, not
both. We prefer the thread-local for future-proofing and simplicity, on
platforms where we can verify this C++11 feature works, and because it
allows us to clean up QThreadData and the event dispatcher as late as
possible. (There's some code that runs even later, such as pthread TLS
destructors, used by Glib's GMainLoop)

Unfortunately, we can't use it everywhere. The commit above had already
noticed QNX has a problem and recent bug reports have shown other
platforms (Solaris, MUSL libc) that, 13 years after the ratification of
the standard, still have broken support, so we use pthread for them and
we call cleanup() from within finish() (that is, no late cleaning-up,
retaining the status quo from Qt 4 and 5). See QTBUG-129846 for an
analysis.

Drive-by moving the resetting of thread priority to after finished() is
emitted.

[ChangeLog][QtCore][QThread] Restored the Qt 6.7 timing of when the
finished() signal is emitted relative to the destruction of thread_local
variables. Qt 6.8.0 contained a change that moved this signal to a later
time on most Unix systems, which has caused problems with the order in
which those variables were accessed. The destruction of the event
dispatcher is kept at this late stage, wherever possible.

Fixes: QTBUG-129927
Fixes: QTBUG-129846
Fixes: QTBUG-130341
Task-number: QTBUG-117996
Change-Id: Ie5e40dd18faa05d8f777fffdf7dc30fc4fe0c7e9
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 4fabde349f16b59f37568da2a4c050c6dd53a34e)
2024-11-07 15:00:11 -07:00
Ivan Solovev 8478831214 tst_QPromise: fix handling of failures from nested functions
The commit 1f22fc995a introduced nested
functions without properly checking their return status with
QTest::currentTestFailed().
Later, commit 855c448469 used the same
pattern.

Fix all the affected tests by wrapping the function calls into the
pre-existing RUN_TEST_FUNC macro.

Both commits were picked to 6.5, so do the same with this patch.

Pick-to: 6.5
Change-Id: I3e11bf5724d9b89c75a4e5c73c96f9566c36b5cd
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 4c00337ccb8e4266fa5a4af4fba40e5b62aba81b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-07 22:00:10 +00:00
Marc Mutz f47c8354b1 tst_QPromise: don't rely on move-only lambdas [2/2]
For some reason, 4d6cf54664a98e01d4caab42431c62d6deb9f86e didn't treat
all lambdas, and no-one noticed.

This patch completes the task by transforming the remaining lambdas to
be non-move-only.

Amends 4d6cf54664a98e01d4caab42431c62d6deb9f86e, whose commit message
is pertinent to this patch, too, but not repeated here.

Pick-to: 6.5 6.2
Change-Id: I6dfe6eb438065e16fcb7ab1f2efcb64c0146bb6c
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 5c3dc2ecb97b69eb12e06c499ddb50666be60be6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-07 22:00:10 +00:00
Lucie Gérard 27ae8dbab4 Add REUSE.toml files
Those files are read by reuse to complement or override the copyright
and licensing information found in file.

The use of REUSE.toml files was introduced in REUSE version 3.1.0a1.
This reuse version is compatible with reuse specification
version 3.2 [1].
With this commit's files,
* The SPDX document generated by reuse spdx conforms to SPDX 2.3,
* The reuse lint command reports that the Qt project is reuse compliant.

[1]: https://reuse.software/spec-3.2/

Task-number: QTBUG-124453
Task-number: QTBUG-125211
Change-Id: I01023e862607777a5e710669ccd28bbf56091097
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 4c83657448f66ac0ee46900aff2e5a230eda49b0)
2024-11-07 08:38:49 +01:00
Thiago Macieira 590ac5b4a1 tst_QObject: don't leak QtDeclarative::theData
Change-Id: I347f7558a3b278590b11fffdc48877791c29ca60
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit ee3933a3ddb032e8d62eb5ac920f9450e7dc2f45)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-07 01:13:51 +00:00
Marc Mutz 44d4d2593c tst_QPromise: don't rely on move-only lambdas
VxWorks, at least as used in the 6.8 CI, has a problem with move-only
lambdas passed to QThread::create(). This might have been the reason
for the resurrection of the cxx11_future feature in
408430a543ef605157963b1a894847c7ba9f9956.

This patch tries to work around the issue by not moving the promise
into the lambda capture, but caputuring it by reference, and then
moving it into a local stack variable. In all cases, the ThreadWrapper
is created after the promise, so, since the ThreadWrapper dtor join()s
(like jthread), the promise out-lives the thread, and the destruction
of the promise happens-after the join() with the thread. So, no data
races. Code mustn't touch the promise object from the main thread once
the ThreadWrapper has started, but that's the case already and the
test functions are small enough for any such future use to be obvious
in review.

Amends 385f0732d9 and
4e1b20893aeeb9580bc6b52ac4baea297675bfee.

It appears that dev no longer has the problem¹, but apply this to dev,
too, to maintain consistency with the test in last three LTS releases.

¹ 4e1b20893aeeb9580bc6b52ac4baea297675bfee passed, but its cherry-pick
  to 6.8 did not

Pick-to: 6.5 6.2
Change-Id: If1feba9d3a7f8677789d45fa9f4990cf44145709
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 4d6cf54664a98e01d4caab42431c62d6deb9f86e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-05 18:53:16 +00:00
Friedemann Kleint cb0ac3d471 Tests: Reduce the number of module includes
They are an unnecessary hit on build time.
Rewrite the tests using the standard Qt conventions.

Change-Id: Iac47e62c58b1805c3b4a0ac4f4b3db206c66cc65
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 6ddf74716d7b2fe0df5dd9c0172f9ecf936d5c5d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-04 19:42:27 +00:00
Thiago Macieira e080017c72 tst_QThread: add a test for multiple threads wait()ing for one
There's nothing in our documentation saying this is permitted, but we
have specific code for it on Windows and it works on Unix because we
just wait on a QWaitCondition.

Change-Id: Id6331fa9aad473cb4f35fffdf8bb04d9a34cd108
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 5b5297fe87859f59a7aaf5e86a8915c00714fefa)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-02 16:25:06 +00:00
Marc Mutz c6e13deab6 tst_QPromise: remove some unneeded mutable from lambdas
Lambdas that only capture by reference never need to be mutable.

Drop the keyword (and the now-superfluous parentheses).

Amends 385f0732d9.

Pick-to: 6.5 6.2
Change-Id: Iaa6451c1c26f1aed198c447ee59198c4e0285b15
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 37daf732d5089c58a6428124263243509d152987)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-01 22:54:18 +00:00
Marc Mutz 7be419bb23 tst_QPromise: DRY the inspection of QFuture's handlers
Not all test cases inspect all of failed, then, and canceled, but it
doesn't hurt to always collect all three.

Avoids having to write the same type of code over and over again.

Amends bf3fc5c95c (but really
1f22fc995a and
855c448469, which each duplicated the
initial pattern without refactoring).

Pick-to: 6.5 6.2
Change-Id: Ifb2a3589f8aed9017fbdff20e4edb64e8c9e2488
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 9d0da873f0ddadb60e61fbd6c96c8b00f026e99f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-01 14:31:31 +00:00
Marc Mutz ab4919f316 tst_QPromise: don't wait() indefinitely
In unit-tests, blocking operations should be timed, whenever possible,
so that a proper failure is logged instead of a watchdog timeout
(which is reported as a crash).

Wait for 60s and wrap the wait() in QVERIFY(). Since this can fail,
mark ThreadWrapper's dtor as non-noexcept.

Amends 385f0732d9.

Pick-to: 6.5 6.2
Change-Id: I3462017cb1a7580c901b98e9b1c3741853f32dc6
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 32d12c2ebace41361c789e5aa58430ebf9f687b1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-01 14:31:31 +00:00
Volker Hilsheimer 8c40e8cf12 QTranslator: work around uiLanguages not including lang_Terr variants
Amends 7a7f2547f3, which added the triplet
including the script before the language_Territory name without it. The
truncate-from-the-end algorithm in QTranslator ended up trying the pure
language first, and - if found - ignored any more specific territory-
variant that might be present.

To fix this, replace the truncate-from-the-end algorithm when we try
to find files, and instead create a comprehensive list of fallbacks,
avoiding duplicates as we go along. Insert those fallbacks right after
their base-entry. We then try to find files for each entry, with and
without the prefix.

This fix is needed only in 6.8 and 6.5; from 6.9 onwards, the change to
QLocale::uiLanguages in 84afaafc9c6968dd76fcadc5392065d340543521 fixes
this on the correct level, making kludges in QTranslator unnecessary.

As a drive-by, replace int indices in for-loops with qsizetype.

Fixes: QTBUG-124898
Pick-to: 6.5
Change-Id: Ia3deceb4ed2c6ef5ca0a815cc7b8878bf29ef088
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-10-31 23:15:29 +02:00
Phil Thompson d61a15d043 Fix QFlag properties built by QMetaObjectBuilder
When Q_PROPERTY is used to define a property with type (for example)
Qt::Alignment the name of the type stored in the meta-object is
"Qt::Alignment".

When QMetaObjectBuilder.addProperty() is used it will instead use the
name of the meta-type (ie. "QFlags<Qt::AlignmentFlag>") which it has
obtained from QMetaType::fromName("Qt::Alignment").name().

In the QMetaProperty ctor it tries to resolve the QMetaEnum for the
property and uses the internal parse_scope() to extract the scope and
qualified key from the name. However it does not handle template names
and so fails with dynamically created properties.

This change to parse_scope() removes the "QFlags<>" so that the
template type can then be parsed.

Another solution would be for addProperty() to always use the type name
it was given rather than use QMetaType::fromName(). That has the
advantage that the layout of the dynamic meta-object would match that
generated by moc.

Change-Id: Iac9e2db2f134029709158b4e500286922396501d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 5624060865e3ccd3c487f10355cb740b7322f93c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-29 20:51:12 +00:00
Thiago Macieira 778c70c84c QMetaMethodBuilder: limit the bits of attribute()/setAttribute()
Change-Id: I2d680563e65be28666f5fffd6aac927fd40c6b5d
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit d0580a231c9b8e2a97fc0ea6a558b593dcb0c3d0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-29 20:51:12 +00:00
Marc Mutz 6535b6d5f3 QList: fix std::to_address(QList::iterator) on older compilers
Need to enable element_type unconditionally, to direct the default
std::pointer_traits::to_address to fall back to operator->().

[ChangeLog][QtCore][QList] Fixed std::to_address() on QList::iterator
on older compilers.

Fixes: QTBUG-130643
Change-Id: I521f327933c51ca87c511a7741b2dce65094032b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
(cherry picked from commit b8c879f273533d87f52dbc8e9d2f9b3b3566cd60)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-29 01:10:27 +00:00
Marc Mutz 21c839636c tst_QList: compile in both strict and normal iterator modes
If a class has an opt-in, the test should test both.

Pick-to: 6.5 6.2
Change-Id: I3b200a2f8e96c62b0c38ae735cb9f7e6786375b3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit c198a67bfb3fea21ec06f72ea08107c4da6e88f7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-29 01:10:26 +00:00
Marc Mutz e46ba4d413 tst_QChar: run it also under QT_RESTRICTED_CAST_FROM_ASCII
Like QString, QChar also changes API when said macro is defined.

So, like tst_QString from 8420d3e0b2
onwards, also compile tst_QChar under it, separately.

Pick-to: 6.5
Change-Id: I81d25d5bfae78b1a11d47e49aa618d079c4b09b7
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 167b04aac89488a5f2005bd1f4dfde354f43c6a6)
2024-10-28 16:30:11 +02:00
Marc Mutz b441f9e5bb tst_QDebug: extend test with pair<references>
The current std::pair streaming code supports this (and why shouldn't
it?), so make sure follow-up refactorings won't change that.

Amends 9b0970ad820c084b0fe73bcbbc72b44f04cae3dd.

Conflict resolution for 6.8:
- adjusted expected output to old-style (COMMMA w/o SP) pair
  formatting

Pick-to: 6.5 6.2
Change-Id: I9fb5fc07169d3fbd4699911853f25ef2ab559027
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit 5e49278ab168dbd31cefcdbdb930abac90d11621)
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-10-28 14:30:11 +00:00
Marc Mutz b6c102b742 tst_QDebug: extend test with optionals of const or optional type
Amends b7657ddccb.

Change-Id: I420f11571629025a9d3b588d4ab124b34ee3811c
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit dd672edd15393378898b518091c3117a91c5bbfd)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-26 00:04:46 +00:00
Marc Mutz 6555c62630 tst_QChar: add comprehensive conversion tests
As usual, when making a change, we find out that test coverage was
poor. Add such tests for QChar ctors.

Amends (should have been a prequel commit of)
9ef4c123c39c642357c9e8530d59f32f220a7824.

Conflict resolution for 6.8:
- adjusted static_asserts to old QChar ctor overload set

Pick-to: 6.5 6.2 5.15
Change-Id: Idcd9ab816ef815ce4a85dba1f7e37201b64c2203
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit 69190a370d1e9f60c78f3096df62a61b6a5d1384)
2024-10-26 02:04:45 +02:00
Marc Mutz 5c4a0a5b26 tst_QDebug: add missing test for std::pair streaming
tst_QPair also doesn't have it.

Pick-to: 6.5 6.2
Change-Id: I7391203a9dcb2d937487ee2f3ba1b6ed21d700db
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 9b0970ad820c084b0fe73bcbbc72b44f04cae3dd)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-24 10:13:22 +00:00
Edward Welbourne 4408d077ac Address problems with date-time parsing near bounds
Document the limited range of datetimes that can be parsed from
strings and the (awkward) consequence of the range bounds being
specified in local time.

Add tests for UTC hitting those bounds and QEXPECT_FAIL() the ones
that (as the new docs say they may) fail. Technically the fact that
the UTC:min one *doesn't* fail is evidence of a bug in the existing
date-time parser. Its replacement should support unbounded parsing.

Pick to 6.8 required removing a QEXPECT_FAIL() specific (on MS) to the
std::chrono::tzdb backend, which isn't present before 6.9.

Fixes: QTBUG-129287
Task-number: QTBUG-77948
Pick-to: 6.5
Change-Id: Ic90558f1a06a62f7d0a947e37802370d1ab4e373
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 3e25203d4d5ba428309e972367dbdf99c4e70327)
2024-10-22 18:53:18 +02:00
Thiago Macieira 76da2f74d4 QUuid: restore sorting order of Qt < 6.8
This brings back and adapted version of the sorting code that was
removed by commit 15f753ca5a60b5273d243f528978e25c28a9b56d. The issue,
as shown in the test, is that we store data1, data2, and data3 as
native-endian integers, so the bitcasts in the new code cause them to
become mangled in little-endian platforms.

Since this is a weird behavior and we'll be changing the sorting order
in Qt 7 anyway, I've left a warning for us to think about it at the
time.

[ChangeLog][QtCore][QUuid] Fixed a regression that caused QUuid sorting
order to change for some UUIDs, compared to Qt 6.7 and earlier versions.

Fixes: QTBUG-130155
Change-Id: I5eeb7b36bfc5ed7218e1fffd6a773c582ad0f6f4
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 222891d0b6b84bbf995bd75420bdfb55292c0901)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-22 13:15:24 +00:00
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