Commit Graph

17259 Commits (05dfd8a0bdf8b8ab3c3347e546e18346ee81dffe)

Author SHA1 Message Date
Axel Spoerl 05dfd8a0bd tst_Gestures::conflictingGesturesInGraphicsView(): use dynamic size
The test function assigns a hard coded rectangle to gestures and uses
the default size of a graphics view at the same time.
The leads to flakiness, where the gestures can't be delivered when their
size is out of bounds of the view's geometry.

Assign size size dynamically, according to the view's geometry.

Task-number: QTBUG-130811
Pick-to: 6.5
Change-Id: If75f59d15f84e610b4ec987daa2a06ce62539228
Reviewed-by: Frederic Lefebvre <frederic.lefebvre@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 6995709992344ac608f2b2a19b2c3883019bfaeb)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-11 18:34:20 +00:00
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
Timur Pocheptsov 1171144f48 tst_QSslServer: check if SecureTransport will block the test
which happens when we build with SDK 14 (where there is not property
for importing PKCS12 in memory only) and then run on macOS 15
(where our trick with a temporary keychain is not working anymore).

Task-number: QTBUG-130500
Change-Id: I05845fa23dec70d48251f5e4d93084a574d67d92
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit c9d1f18d0b88f3a4c60bf9a1342459fd67f42dbe)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-09 09:26:40 +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
Morteza Jamshidi d610103126 QDoubleSpinBox: Use QLocale to omit group separators
Instead of removing group separators after conversion, we can omit them
using QLocale. The decimal point and group separators can be the
same character, if the user configures the system locale accordingly.

Add a test that compares the text shown by the spinbox with what the
locale would do. Since the C locale sets the OmitGroupSeperator number
option by default, cover several cases to verify that we explicitly
set the correct number options based on the QDoubleSpinBox property,
and implement a customized system locale that returns the same
character for group separator and decimal point.

Fixes: QTBUG-77939
Change-Id: I257ea44ed988c70cb4fc0cfc81c3b366c0a431eb
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 34b5e43e6259c6362c642a244ceb26d482f35b82)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-08 12:32:26 +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
Timur Pocheptsov 3502790551 tst_QNetworkReply: add more checks for blocking keychain
There are more tests that create TLS server and can potentially
fail in case SecureTransport backend is in use.

Task-number: QTBUG-130500
Change-Id: Iaf2071c19f3cc0d3617bfc8c484b464c1a212d5a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 81e7d3f95a1646d91d126596d0d7d6acf106298a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-07 01:13:50 +00:00
Volker Hilsheimer cd48b781d1 StyleSheet baseline test for TreeView: include one with empty area
So far, the entire tree view was filled with items, so we didn't see how
the empty area below the last item was rendered. Take a screen shot of
the tree after giving it twice the space it originally has to get some
empty area included as well, without breaking existing baseline images.

Task-number: QTBUG-123632
Change-Id: I50714c0b3b04f4b1844e52063d0c0c77ff2d7154
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
(cherry picked from commit 4be99b1900f3ba7414a9acbc4777a669fcbd8e3a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-06 15:06:19 +00:00
Volker Hilsheimer d4948d354f StyleSheet/QTreeView: draw empty area and background of semi-transparent items
After 3ca615d9735f7ddb8e2ae5c13e5effd419a56300, the style sheet style
will not draw rows unless the item has a border. Otherwise, it will
assume that the item drawing later on will fill the background anyway.
We also never painted the background for empty rows.

However, if the item's background is semi-transparent, then the row
needs to be drawn first, so that the correct background shows through.
And for empty rows, we need to draw just the background. This is
especially important for trees with alternate background colors.

Add baseline test case for this particular combination. This will result
in a minor change to the results of the existing
transparentBackgroundNoBorderForBranchIndicator test case, where now the
background is drawn behind the indicator area when the item's background
is semi-transparent. I don't think this is a bug though.

Fixes: QTBUG-123632
Change-Id: I2cd4efb748aaefc03a3b576458b750ee47479e97
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
(cherry picked from commit b780eaf6a063a7efe03417cf6b7008a188e222a4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-06 15:06:13 +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
Volker Hilsheimer 945c8bf54d Cocoa: Use sheetParent to close sheet instead of transientParent
If the window that the sheet (as created for a modal dialog) lives in
has already been destroyed by the time the sheet is hidden, then we used
to trip an assertion. Instead, always use the sheetParent, which is
still alive.

Add a test case that asserts without the fix.

Fixes: QTBUG-128302
Change-Id: I4c399b73e2552bab79358c5505f403efa8e4f80b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 332f49f2d8c5675bab8bde6acfb377d567961d4a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-04 17:48:56 +00:00
Tor Arne Vestbø 076f89744e Blacklist tst_QNetworkReply::ioHttpRedirectPolicy on macOS 15
Task-number: QTBUG-130500
Change-Id: I92785306f2ecde357c6f4c54419f76643f69e1da
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 57eabffbc9543a1ff1b163a7108d8fbbc8b29878)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-04 16:53:32 +00:00
Eirik Aavitsland 075b3f16e2 Fix QImageIOHandler autotest for static builds
Some of the new imageIO plugin tests recently added would fail in
static builds, since the search order is different then.

Fixes: QTBUG-130739
Change-Id: I074bb1bd314e8ff9a6ea90ba0cd27985aca5ad75
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit 8f5ee7acbdf957ecb4568927df24bd5076da3262)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-02 22:17:25 +00:00
Eskil Abrahamsen Blomfeldt 3b9f202539 Freetype: Fix artificial oblique combined with other transforms
When applying an "obliquen" transformation with Freetype, this
applies a 12 degree horizontal shear on the control points of the
glyph you have loaded.

However, any other transformation we set on the glyph will be
applied when loading it. So if you have e.g. a rotation on
the glyph as well, then this will be applied first and the
rotated glyph would be obliquened instead, now along the wrong
arbitrary axis in the rotated coordinate system.

To fix this, we detect the case where a transform is applied and
multiply in the obliquen in advance. It means we have to duplicate
some code from FT_GlyphSlot_Oblique() which might get out of
sync (if the slant angle changes in a newer version for instance).

We limit this to the cases that are currently broken so that we
avoid messing with any working use cases.

[ChangeLog][Text] Fixed an issue where artificially obliquened
text would look incorrect when other transformations were also
applied and the Freetype backend was in use.

Pick-to: 6.5
Fixes: QTBUG-97436
Change-Id: I61c5d007e9ea9be2beb283a8b8abbed7723bab38
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit db8230715aa115dc2da5177bb1824fb40c5f2569)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-02 16:25:07 +00:00
Timur Pocheptsov d990f697b5 network-helpers.h: add a missing include
For QOperatingSystemVersion

Change-Id: Ie8a7e632b9485111469a2bf1a6407491e29d7229
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit 2ab35ca62faf8a12e8ededa77e028c585363c3cf)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-02 16:25:06 +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
Thiago Macieira 44bf5566cb moc: handle nested structs with meta content
We already disallow them for classes; this was a mistake in not handling
the "struct" keyword. The C++ syntax is valid, but moc is unable to
parse two classes at the same time. Users can define the inner outside
of the body of the outer class and that works.

[ChangeLog][moc] Fixed a bug that caused moc to attempt to parse a
nested struct (not class) with meta keywords and this produced code that
wouldn't compile. Nested classes and structures are permitted, but must
be defined outside of the declaration of the outer class.

The fix for this revealed a bug in the presence of Q_DECLARE_FLAGS for
inner classes. This can be easily fixed by moving the token for
Q_DECLARE_FLAGS value outside of the [Q_META_TOKEN_BEGIN,
Q_META_TOKEN_END] range.

[ChangeLog][moc] Fixed a bug that caused moc to reject a class (not
struct) containing Q_DECLARE_FLAGS that was defined inside the body of
an outer class containing Q_OBJECT or Q_GADGET.

Fixes: QTBUG-130498
Pick-to: 6.5
Change-Id: I2a3f148f70280e87302afffd3e7617e5861bb338
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 4e4eef175bc0d0e2a34875ae98f2ddf9eee73b35)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-02 02:02:09 +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
Volker Hilsheimer 9e99f2a977 QStyle: block future changes that result in QPainter warnings
Amends ff9818135db28e287e7818defd9c1a9acdebacdc and follow-up changes,
which shouldn't have passed CI as they resulted in runtime warnings
until ca8ca216dbd5d374aa05d96db8052c2411baae7c.

Change-Id: Ib3688779d5bcba06ce992453e62fb841251f6a62
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
(cherry picked from commit 3662be51935827e2fdb384bc407e055470e831c0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-01 22:54:06 +00:00
Volker Hilsheimer 20fbd34400 QHeaderView: update the view correctly in resetDefaultSectionSize
Changing the default section size requires that we inform the parent
view of the header about size changes, and that we update the header
so that we repaint with the new section sizes. This didn't happen.

The private setDefaultSectionSize implementation does all that. However,
QHeaderView only remembers if the default section size was explicitly
overridden; it doesn't care if individual sections were resized, and
overwrites explicitly resized sections. This breaks QTreeView, where
calls to setColumnWidth resizes individual sections, but a style change
(e.g. when setting a style sheet, which results in posted events) would
then overwrite all section sizes with a new default.

To fix that, only resize those sections to the new default that had the
old default before.

This still breaks tests that assume that changing the default section
size will affect sections that have been explicitly resized. To make
those tests pass, and to minimize behavior changes, also resize sections
to the new default section size if they don't have a valid size before,
and adjust the problematic test to resize all sections to 0.

[ChangeLog][QtWidgets][QHeaderView] Changing the defaultSectionSize no
longer affects sections that don't have the old default size.

Fixes: QTBUG-116013
Change-Id: I02fee3f7fda66f4d982bacea1b4a8b14c896bb65
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 32578a088db5769e919a4ec5ebf33346479e7a68)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-01 23:53:56 +01:00
Volker Hilsheimer 800d7138a3 QHeaderView: add test for not overwriting resized sections
If we change, reset or update the default section size, e.g. in response
to style changes or programmatically, then we don't want to override
explicitly specified column widths in e.g. a tree view.

Add a test that verifies that we don't overwrite.

Task-number: QTBUG-116013
Task-number: QTBUG-122109
Task-number: QTBUG-123154
Change-Id: I3d9a6ac685da39a59436b91f56e86b0f705e645c
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 3ca0288aa927108de4c57119d9767998021a6089)
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-11-01 23:53:52 +01:00
Volker Hilsheimer 9f79ffe8f0 QHeaderView: modernize calculateAndCheck helper function
Use QCOMPARE_* macros to compare results, and use a qScopeGuard to emit
diagnostic output in case of failure.

Task-number: QTBUG-116013
Change-Id: Id13ba70244d5c58c14c088619dbf0ee835492eb7
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit d9098760134bad9c1d18837a204ea7fb26d30e43)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-01 23:53:48 +01:00
Friedemann Kleint 607ac728ed Brush up the qgraphicsproxywidget test
- Reduce clang-tidy warning from 789->591
  (Use auto, nullptr, member initialization, etc).
- Introduce string literals, replacing deprecated QLatin1String
- Streamline/rearrange layout code
- Fix QCOMPARE(.., bool)
- User per-class includes following Qt conventions

Task-number: QTBUG-128913
Change-Id: I787f39b5ddfe34ba18e33f469b68ccbcfc2709a3
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 25e16e20cc434f484380dfa59c1b8a3d6f772920)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-01 22:53:24 +00:00
Friedemann Kleint 5d612a72ad QWidget::mapTo/FromGlobal(): Fix transformation in case of QGraphicsItem::ItemIgnoresTransformations
Extract a helper returning the transform from
QGraphicsViewPrivate::mapToViewRect() and use that.

Fixes: QTBUG-128913
Change-Id: Idc31f653c23cd7d0e5bbb8af560f010f01ac4d4b
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit deb4e08c1212aa3d43f62f9e7211bf69d3be0ada)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-11-01 22:53:19 +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
Christian Ehrlicher 26774ee8f5 Tests/QSqlQuery: fix tst_QSqlQuery::lastInsertId() for PostgreSQL
Fix tst_QSqlQuery::lastInsertId() for PostgreSQL - there must be no
other query inbetween insert and lastval() to acutally receive the
correct last inserted id.

Change-Id: I6c5bda4b1e54ec89b80caa6abf7afcc9cfe1e28b
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 4b9631359bd3c1cae7344846193e3d10c3a54725)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-31 19:46:55 +00:00
Mårten Nordheim bbfc7b2ca9 Http: fix how we treat must-revalidate
We calculated the expiry at time of download by looking at Max-Age, but
as long as must-revalidate was true we would just perform the network
request anyway.

One issue this, further, highlights is our PreferNetwork and PreferCache
options having no behavioral differences while being documented to
do different things. They both consult the cache first and returns any
non-stale data from there.

Fixes: QTBUG-128484
Change-Id: I24b62e2bb072446e463482a778da7cfbd82a6835
Reviewed-by: Mate Barany <mate.barany@qt.io>
(cherry picked from commit e4a35df2afc306e566884f3d917daa08e41761f8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-31 15:35:47 +00:00
Alexandru Croitor 0bc3457257 CMake: Fix PUBLIC_LIBRARIES option is deprecated in tests warning
Rename it to just LIBRARIES, as PUBLIC_LIBRARIES is not meant to be
used in tests.

Change-Id: Idcf35e2834de44b2dd8d11cdef0205b11e89d377
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit 492deefc17435bef03964382e0abadb16d86669c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-30 10:57:15 +01:00
Thiago Macieira 53835c957b tst_selftests: disable Valgrind tests with AVX512/AVX10
Valgrind does not support those instructions yet so these tests always
fail. Skip them.

When it gets support for them, we can do a version check.

See https://bugs.kde.org/show_bug.cgi?id=383010

Change-Id: I954b2b6a9bbef1a31833fffd1cc4bc33dce353ed
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit 0b41b81b9febc8f0dafd0a6a8e6571333e5415d3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-29 23:52:25 +00: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
Volker Hilsheimer 351b5b3e94 QFileSystemModel on Windows: consistently trim spaces and dots
On Windows, file- and directory-names that end with a space (or a dot)
are invalid, even though it's possible to create them. Same for names
that start with a space (but starting with dots is ok). Even Explorer
chokes when trying to then delete or rename such a file or directory,
and often the only way out of the mess is to operate on the 8.3 path.

In Qt, we only sometimes fixed such paths by removing trailing spaces
and dots. This still made it possible to create a "bad " directory in a
non-native file dialog, which could then not be deleted. The node tree
even ended up with both "bad " and "bad", neither of which was handled
correctly.

Fix this by always chopping trailing space and dots when adding or
modifying a node, amending 3693d3d2a1e76f6e6d41db340505e00c6ddaeda1.

Fortunately, this can be reproduced with QFileSystemModel, so add a test
that exercises it in the same way as QFileDialog does, e.g. both by
creating the misnamed directory directly, and by renaming a directory to
an invalid name.

Given that this is very broken on Windows Explorer as well, don't
cherry-pick this back into branches under strict change management.

Fixes: QTBUG-129028
Change-Id: Iec1edf9fd2548dda4567134a9b5cf3e298589c19
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
(cherry picked from commit 53df22b42d73dbb48bc25ad05500993df56b928c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-29 17:42: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
Timur Pocheptsov a48d7f0c73 Fix prior change: no need for check when OpenSSL is active backend
It's not using keychains and not triggering a blocking system dialog.

Change-Id: Id2a3b74ab3647890747fba9b8d261ab3e60fb3bc
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit 07a0e4496ddf15ef469c3b244270300b9c855d44)
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
Eirik Aavitsland 5de95d3aba Add autotest for QImageIO format handler plugins
To confirm the functionality of custom imageformats plugins in Qt
image reading, both for supporting new formats and for overriding Qt's
builtin formats.

Change-Id: I6abafdb47301ad1f35b19951e42b1f3b61fe6ec3
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit 6eefe0ca59dc25f7953b93e8b80c62c78a6ccfde)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-26 00:04:44 +00:00
Mårten Nordheim 582eaaaa68 tst_bench_qobject: Fix stdAllocator case for Windows
The total stack space available is 1MB, but each pointer is 8 bytes.
So we have to limit the amount of pointers we allocate on the stack to
somewhere below 128K.

Pick-to: 6.7 6.5
Change-Id: I1d1262a4048cf4b3fed8df813decc3e142430a32
Reviewed-by: Mate Barany <mate.barany@qt.io>
(cherry picked from commit b2e0ff4bca5d81205c8425cdc528e5c2a2988172)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-10-25 20:52:12 +00:00