70471 Commits

Author SHA1 Message Date
Marc Mutz
8dbd0828e9 sqlbrowser example: use idiomatic Qt [2/3]: use button-box / override accept()
- The old code used two QPushButtons in a QHBoxLayout to provide
  Ok/Cancel buttons. This hard-codes the positions and text (and
  icons) of these buttons, instead of adapting to the platform style.

  The new code simply uses QDialogButtonBox, which is designed for
  this purpose.

- Also, the old code connected the Ok button's clicked() signal to a
  custom slot that then called QDialog::accept(). This means that the
  code in the custom slot is not executed when the dialog is accepted
  by other means (e.g. return press in one of the line edits
  ("auto-default"), though I'm not sure here).

  The new code uses the idiomatic Qt way of overriding
  QDialog::accept() instead, and connects the button-box's accepted()
  signal to it. This is done in the .ui file, so it already works in
  Designer preview.

- Finally, the old code made a manual connection from the Cancel
  button to QDialog::reject().

  The new code uses the Qt idiom of connecting in the .ui file
  directly, using QDialogButtonBox::rejected() as the signal.

Amends 2690822428deec4f0c08f4d118d69a7c6036369e, which, however,
inherited all of the above from even older code.

Pick-to: 6.8
Change-Id: I83afd6156a0811e0c0f99f2480625ea6b69ff78b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 3419c299369ac1da94ba5710aaf5f5f65c38c33c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-02 09:57:23 +00:00
Marc Mutz
f2b88b3225 sqlbrowser example: use idiomatic Qt [1/3]: disabling group-box
The old code connected to the wrong signal and therefore had to write
a custom slot to perform the disabling of the group-box.

The new code simply connects the QCheckBox::toggled(bool) signal to
the directly-compatible QWidget::setDisabled(bool) slot, removing the
need for a custom slot.

Also move the connection into the .ui file, so it works already when
checking the form in QtDesigner.

Amends 2690822428deec4f0c08f4d118d69a7c6036369e, which, however, only
inherited the issues from older code.

Pick-to: 6.8
Change-Id: Ia834f92de270bb7b18981273188f6e5b6cd457a2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 53826d1cde26f825d1983476c6697f72130e351f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-02 09:57:17 +00:00
Thiago Macieira
381dca29ff Replace qgetenv() calls converted to QString with qEnvironmentVariable()
It's slightly more efficient.

Change-Id: Id5ac04fc27eee108c8e5fffd786c3d5f793a0a9d
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit db34e27f7f6ade54bfae59e5eed14c05ac508a49)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-01 19:55:21 +00:00
Thiago Macieira
36d260014f qEnvironmentVariable: avoid a temporary QByteArray
Because we don't need one. I guess I was just lazy.

Amends b12fd1fa9d0b64e3cb66fa68c85392dbde8e175b ("Long live
qEnvironmentVariable()").

Pick-to: 6.8
Change-Id: I5b9141c5a32f9d784e0bfffdc3e4d742790aebdd
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit ce95c26034cc5b3ae8094c1521221e5b2f13ecfa)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2025-01-01 16:46:29 +00:00
Ahmad Samir
01edc916d2 moc: fix GCC -Wextra-semi colon after member function definitions
As pointed out by Thiago the QT_DECLARE_METATYPE calls are redundant, so
remove them.

Task-number: QTBUG-132101
Pick-to: 6.8
Change-Id: I73800e70d3f270fb87941d4e053aa7ac5ed1841c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 3bb4c4949fed9ccf8653151c78d5130b8db00716)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-31 23:59:24 +00:00
Ahmad Samir
5171b7f488 src/plugins/*: fix GCC -Wextra-semi colon after member func definition
Pick-to: 6.8
Task-number: QTBUG-132101
Change-Id: I947fdb66df9b6d86c60139046166395e4ae42127
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 997abb0520cdfbde60e0fe4fdb133e15e24ce871)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-31 23:09:12 +00:00
Ahmad Samir
cc369ad07f QCryptographicHash: hashInto(): check the buffer size earlier
We can use hashLengthInternal() to check if the buffer is big enough.
This matches what the QCH::hash() method does, it also has an assert
that `result.size() == ba.size()`, so we can assume this works with
OpenSSL's EVP_MD_get_size() in EVP::finalizeUnchecked().

Amends c70c81b371993ca865d523bb5f37eac4eb8a972b.

Pick-to: 6.8
Change-Id: I64935f3d590ab243b361a0b764f011c388820e32
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit b83e825fab16f83f86149ead78efb6ec3d2fa16d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-31 23:09:11 +00:00
Marc Mutz
11f485ea68 tst_QImage: fix discarded QFile::open() results
Wrap them in QVERIFY(), as usual.

Found by QFile::open()-turned-nodiscard-come-6.10.

Amends e673e5a257569eaa816c6acd31dd754efd9f8c75 and
25c96d547b4563cbfedcec6093d68116148d8599.

Pick-to: 6.8
Change-Id: Id39e5d9e500b524af8443cb57916a12f98bd7c23
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit cf6ae9a90106a3557a8df1e0d2567b02a4ef6ded)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-31 19:03:28 +00:00
Marc Mutz
c970909437 tst_Q(Gui)EventLoop: Unbreak UBSan build
The tests peek into QEventLoopPrivate, which means that a UBSan build
needs access to QEventLoopPrivate's type_info, for which we need to
export the class.

Amends 3af20bd8eb8c75017c5d6d138d7c42914ee5bee3, which fixed the weak
vtable that, presumably, made this test work before.

Pick-to: 6.8
Change-Id: I4104ba95093fa240c5ef7d9d5bf287c1652333f0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit 8bf54385319df958ea88f9998e7690d4c35e354d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-31 10:13:04 +00:00
Marc Mutz
5cd16659ff Port QtCore from QScoped- to std::unique_ptr [1/2]: private uses
This patch series is in preparation of enabling QT_NO_SCOPED_POINTER
when building QtCore, a prerequisite for enabling this opt-out in leaf
modules.

This first part of the patch series ports objects whose use cannot
"leak" into other modules, e.g. because they are in .cpp files or are
private members and is thus SC (and, as demonstrated by various static
assertions we put into the source code over the years, BC).

The second patch will deal with objects in protected and public APIs,
and thus might be QUIP-6 SiC Type A.

Task-number: QTBUG-132213
Change-Id: If4967f6e563a4e7d74550fad4c6d354fad1beef5
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit 63f1c6fcbab5f36809ffc96ac5ff6cb9e01e70bb)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-31 10:12:58 +00:00
Marc Mutz
3ea877a844 QLibraryInfo: de-pessimize prefixFromAppDirHelper()
The local appDir variable was only used to hold the return value of
another function call. But hardly any compiler will be able to look
through the QString atomic ref-counting to turn the non-Darwin code
paths into the tail-calls that they ought to be.

Remove the variable and return the result immediately. This removes
the move-assignment and dtor calls in the two changed lines and lets
RVO kick in, turning these calls into tail-calls on non-Darwin
platforms.

Amends 4ac872639ed0dd3ae6627e05bdda821f7d128500.

Pick-to: 6.8 6.5
Change-Id: Ieeefbd52fc983ab7aebcff6419965b206f374935
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit e57113feac183abd1f5bfcfb633a33e1387b2d3e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-31 10:12:56 +00:00
Toni Saario
60a264ed50 Coin: Tweak VxWorks testrunner
Add crash handling to avoid waiting until 10min timeout on each crash.
Force restart on each crash by killing emulator.

Make health check more robust to allow it to work even when emulator is
down. This is done via wait in separate process which cannot be done
with normal timeout command, as input to pipe that is not being read
by emulator will block forever.

Change-Id: I86c3c86f936cc96d57b38983da48d1d73162399d
Reviewed-by: Simo Fält <simo.falt@qt.io>
(cherry picked from commit 918cbe7601b07fa6db7973ff9a4f76208dae8f22)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-30 11:31:47 +00:00
Samuli Piippo
884c338355 egldevice: allow DRM device path to be overridden
The backend-provided DRM device might not be the right one,
so allow kms config to override it.

Pick-to: 6.8
Task-number: QTBUG-131887
Change-Id: Ied744ae7015eae64f4556f1528e0dbe8ae69d206
Reviewed-by: Pasi Petäjäjärvi <pasi.petajajarvi@qt.io>
(cherry picked from commit c3bbbb22b8bc920e4937cf640fd1d2df3b0f9205)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-30 11:31:47 +00:00
Friedemann Kleint
b06125aa51 uic: Generate fully qualified enumerations for QFormLayout
This is required for Python.

Task-number: PYSIDE-1735
Change-Id: I92108009dd23565adaa2ee77300059cb197a89c5
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
(cherry picked from commit 11d6200d8ad88459a499550b30f5c22f1657719b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-30 04:04:22 +00:00
Ahmad Samir
bbf78c9636 tst_QCryptographicHash: split 4GiB tests to a separate unit test
With those tests split, tst_QCryptographicHash takes about 4ms.
When FEATURE_openssl_hash is enabled those tests take about 15s on
their own, but when openssl_hash is disabled they take about 2 minutes.
That makes running the tests locally a bit of a hassle when hacking
code ... test ... hack ... test.

This is with a debug build, GCC, `-O0 -g` flags.

Change-Id: I8b8f5d1954feb1f9eb8115e27635610a41b42f47
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit fff217824b532da7306af1ac755581e76e098a27)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-29 23:22:56 +00:00
Christian Ehrlicher
6790d8d716 QCommandLinkButton: fix drawing high-dpi icons
QCommandLinkButton was using QIcon::pixmap() without specifying the
current device pixel ratio. Switch to QIcon::paint() to not have to
fiddle around with the dpr at all here.
As a drive-by remove a useless QPainter::save/restore call.

Pick-to: 6.8
Change-Id: I7e2492a09b28cb8a4f4cc60454733e0054fe1e9b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 785fb89e0aafc25a435d28ff05bf0dc05385b372)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-29 19:35:04 +00:00
Thiago Macieira
d39c493390 3rdparty: patch BLAKE2 sources to not export anything in static builds
This could cause conflicts with other users of these algorithms, notably
libb2 itself. Though if you're using libb2, you shouldn't be using the
un-optimized copy inside QtCore...

I've updated the SHA1 of the last commit in the repository, but there
were no changes to our sources.

[ChangeLog][Third-Party Code] Fixed a bug that caused the BLAKE2 symbols
to be visible from QtCore in a static build. If you need to use the
BLAKE2 hashing algorithm in your own code, either use QCryptographicHash
or import libb2 into your build environment. Using libb2 remains the
recommended solution for all systems, especially those for which it has
optimized (vectorized) implementations.

Fixes: QTBUG-132347
Pick-to: 6.8
Change-Id: I48003b58cef0d8bcc720fffdd89b0f151fd102e3
Reviewed-by: Linus Jahn <lnj@kaidan.im>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit b884fbf10237547e809745f528978942faf0e5f6)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-29 11:40:51 +00:00
Marc Mutz
b79b2edde8 QLibraryInfo: port from manual memory management to unique_ptr
It's safer and clearer.

Also standardize on unique_ptr instead of QScopedPointer, because the
latter is not supposed to be movable, so the assignment in
QLibrarySettings::load() would not compile.

As a drive-by, scope a variable tighter (in an if condition).

Task-number: QTBUG-132213
Pick-to: 6.8
Change-Id: Iecdd910af4d06dbd03d2daf3ccf99dd4822f04ac
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit aa1f2064801b39a26a718703817e197a3e31447e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-29 11:40:51 +00:00
Christian Ehrlicher
e23933e868 QStyleSheetStyle: Honor box settings for QSpinBox
The previous patch to not modify the CT_SpinBox by QStyleSheet when
nothing was added for QStylesheet also removed the additional margins &
paddings handling for the size calculation. This patch re-adds this.

This amends 96adebed606cdbc73c73778917d777dc04c6e93e.

Pick-to: 6.8
Task-number: QTBUG-130642
Fixes: QTBUG-132431
Change-Id: Iff1f0febeca90d3154e61fd80e4b359bc7766b84
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit b2cc8824ec2cdeb6e053a2ff92d7d5b71f8d0ee5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-29 03:54:57 +00:00
Christian Ehrlicher
314c91d94e Widgets: pass dpr to QIcon::pixmap()
Change the remaining calls to QIcon::pixmap() to pass a valid
devicePixelRatio parameter.

Change-Id: I0e71e20c8109e296446e9e13cddba31d53c05df9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit efc318e05a2288f3fe62d9d7b2b892906e9263e0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-29 03:54:57 +00:00
Christian Ehrlicher
fba5f806e6 QCommandLinkButton: reload icon on style change
Different styles provide different icons for SP_CommandLink so reload
the icon on every style change.

Pick-to: 6.8
Change-Id: I2d8bd706d4c1bca89b91c90f1bb90a796b38e0d3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit d4c518b210ad56cb51c17e6e1b4a81b0deb7253c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-29 03:54:57 +00:00
Volker Hilsheimer
843e2e1309 JNI: don't pass jobject by reference
And definitely not by non-const reference.

Discovered during upcoming fixes for native function registration.

Task-number: QTBUG-132410
Pick-to: 6.8
Change-Id: I0ce8519f5a1f9f3caffefc53e6d93b52509bc439
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 1b84970b90c36771bf266f8612dba9585341795a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-28 19:19:03 +00:00
Marc Mutz
5e6fa3dbc5 QTest::toString(QCbor-type): port from const char* to unique_ptr<char[]>
This is more robust and lessens the impedance mismatch as seen by the
old code using std::unique_ptr<char[]>(expr).get().

The new code isn't impedance-mismatch-free, either
(UP{qstrdup(qba.data())}), but short of writing a small string class
whose internal buffer can be release()ed to comply with the archaic
QTest::toString() new[]'ed const char* return value, there's not much
we can do about it atm.

Also separate the internal from the "public" stuff in
QCborValueFormatter by adding private: and public: sections.

Pick-to: 6.8
Change-Id: I09a2ad1a75bb9eab3d01f2b5b60afc2d762da384
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit d9264ee65d6f24e1008b08494b1472a54ac01940)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-26 17:23:30 +00:00
Thiago Macieira
8fdcda4dac Replace qTerminate() with std::terminate() and mark it for removal
It was used by the QT_TERMINATE_ON_EXCEPTION macro, introduced in 2012,
to support pre-C++11 noexcept semantics. That macro was removed for Qt
6.8 in commit 9b2ae564a59656d9cf49b141e70f5958b4fb79a4. This commit
amends that removing the definition of qTerminate() immediately in Qt
6.9 (it was an \internal function).

Change-Id: I9682121c04fafb3676b0fffd9f5ac999e7603c84
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit b8f84fd1e2af38ece89d60619bf93e7af34433ab)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-26 17:23:30 +00:00
Thiago Macieira
09d44fdef3 QSaveFile: make it so flush() errors imply commit() failed
QSaveFile records past write errors in writeData(), but often the
QFileDevice::writeData() calls it places will succeed because the data
is only being buffered. Instead, the failures are noticed only by
flush(), whose actions do not affect QSaveFilePrivate::writeError.

[ChangeLog][QtCore][QSaveFile] Fixed a bug that caused commit() to
return true and overwrite its intended target file even though it failed
to flush buffered data to the storage, which could cause data loss. This
issue can be worked around by calling flush() first and only calling
commit() if that returns success.

[ChangeLog][QtCore][QSaveFile] Fixed a bug that caused commit() to
return true even after a cancelWriting() call had been placed, if
writing directly to the target file (that is, only with
setDirectWriteFallback() set to true). Note that the state of the file
does not change under those conditions, only the value returned by the
function.

Drive-by clarify a comment from 6bf1674f1e51fd8b08783035cda7493ecd63b44
(Qt 4.6 "Don't drop errors from flush on QFile::close") which had me
chasing the wrong lead.

Fixes: QTBUG-132332
Pick-to: 6.8 6.5 5.15
Change-Id: I427df6fd02132d02be91fffd175579c35b9c06cc
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
(cherry picked from commit 92373d353cf090faa03cbc8aca505d1784b10b54)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-26 17:23:29 +00:00
Lars Schmertmann
e6434a71eb Avoid unused variable warning in qfilesystemmodel.cpp
2135:5: warning: unused variable 'q' [-Wunused-variable]
    2135 |     Q_Q(QFileSystemModel);
         |     ^~~~~~~~~~~~~~~~~~~~~

The variable is only required for the feature filesystemwatcher.

Pick-to: 6.8
Change-Id: I5da48f94118179ec20fec7da7169b7f22cec17fe
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit 46dddcb213eb5080b8f759633a1b025d86f55e36)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-26 16:35:11 +00:00
Marc Mutz
353d22756f Fix a performance regression in QDataStream
Commit e176dd78fd2f253eb2625585b2bd90b5713e5984 replaced a `new
char[n]` with a std::make_unique<char[]>(n), probably on this author's
insistence.

But the two are not equivalent: make_unique() value-initializes, even
arrays, even of built-in type, which means that each buffer resize
writes each byte twice: first nulling out the whole buffer as part of
value-initialization, then in the memcpy() and any following read()s.

For buffers of several MiB, or even GiB in size, this is very costly.

Fix by adding and using a backport of C++20
make_unique_for_overwrite(), which performs the equivalent of the old
code (ie. default-, not value-initialization).

Also add q20::is_(un)bounded_array, which are needed for the
implementation of q20::make_unique_for_overwrite().

Amends e176dd78fd2f253eb2625585b2bd90b5713e5984.

Pick-to: 6.8 6.5
Change-Id: I8865c7369e522ec475df122e3d00d6aba3b24561
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 1a9f8cc0df33195df959cee2e355dde4cbacd754)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-24 23:42:09 +00:00
Marc Mutz
aff082764a tst_QSpan: check QList<int> -> QSpan<const int> doesn't detach the former
It does.

While std::span, does, too, and so users should be using
std::as_const(), it's quite simple to avoid for QSpan, so we'll fix it
in QSpan. This patch adds the reproducer.

Task-number: QTBUG-132133
Pick-to: 6.8
Change-Id: I2e416fb7344830cd5e0d945cce61491cd6f4a7a5
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 05b9a4b2deefd586356e1f36d84372b06e74cfe3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-24 22:24:05 +00:00
Mike Chen
b6108318c2 QFactoryLoader: load extraSearchPath first
Since `QT_QPA_PLATFORM_PLUGIN_PATH` or `-platformpluginpath`
 specifies the path to platform plugins, `extraSearchPath`
 should be loaded first.

Pick-to: 6.8
Change-Id: I2e62fbf2021250ca864c669a7bbd7d56acd67d1e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 457580936ddebc73e8a24fc8af0d342084b3a0b5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-23 04:08:12 +00:00
Marc Mutz
7b5dbe165d QDecompressHelper: fix compilation with GCC 9
GCC 9 doesn't accept [[unlikely]] between the (condition) and the
compound-statement of an if, in both C++17 and C++20 modes:

  qdecompresshelper.cpp: In member function ‘qsizetype QDecompressHelper::readZLib(char*, qsizetype)’:
  qcompilerdetection.h:1048:31: error: attributes at the beginning of statement are ignored [-Werror=attributes]
   1048 | #    define Q_UNLIKELY_BRANCH [[unlikely]]
        |                               ^~~~~~~~~~~~
  qdecompresshelper.cpp:597:54: note: in expansion of macro ‘Q_UNLIKELY_BRANCH’
    597 |         if (ret == Z_DATA_ERROR && !triedRawDeflate) Q_UNLIKELY_BRANCH {
        |                                                      ^~~~~~~~~~~~~~~~~

See also https://stackoverflow.com/questions/51797959/how-to-use-c20s-likely-unlikely-attribute-in-if-else-statement

Put it into the compound-statement instead, then GCC 9 accepts it. The
two are equivalent, because [[likely]] marks a path, and there is no
selection statement between the two positions.

Amends 5ae84d0afbd3690a2c003d06d920566a5d56dc8c.

Change-Id: Iac1970219c98a1c26e450dfe6bad6583e4d32c29
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 7a7804d4b454021d68d1d5138d134ef62abfcdb3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-22 16:28:52 +00:00
Marc Mutz
fc29f57a17 q23type_traits.h: use is_scoped_enum_v from std
We don't like surprises in qNN, so use the real is_scoped_enum_v from
std instead of adding the _v version outselves, even in C++20.

Amends 03a7be37806a32e9a8ac963b309812d6b8f125f6 and
63a8f657c2236829f16016602d9c0098b089d35e.

Change-Id: I7f9149678b95f7a59643152abf5a627e226cc058
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 40501ffbb441ce48733b3733b7ab781c7db8cca8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-22 13:50:51 +00:00
Christian Ehrlicher
4354d7797e QDrawUtil: use QPainterStateGuard
Replace the internal PainterStateGuard class with the now public
QPainterStateGuard.

Change-Id: I9c072ce6e45ddfe2d0a8aba789311193788dee5a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 204df603ef43be921e0eecae4d4af0ae6026787f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-22 09:19:05 +00:00
Christian Ehrlicher
6f7b8ada85 QCommonStyle: use QPainterStateGuard
Replace the internal QPainterStateSaver class with the now public
QPainterStateGuard.

Change-Id: I56285cb469cec43071320e87ac378674fd99c06b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 7690b6260eac12958c97d642421e27680ca57496)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-22 09:19:04 +00:00
Wladimir Leuschner
4eaaf89db5 QWindows11Style: Adjust Subline for QLineEdit to fit rounded corners
Reduce the size of the subline for QLineEdit to fit the begin and end of
the rounded frame corner.

Task-number: QTBUG-132261
Pick-to: 6.8
Change-Id: I879f30c2bdc6601fef4738aeec71d7ab7bcee22c
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
(cherry picked from commit 5e656b9ea3c192f389b7e4f7aa2ae6b010cec306)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-22 09:19:03 +00:00
Wladimir Leuschner
4c2f439001 QWindows11Style: Align QSpinBox rect to match QLineEdits rect
The content rects for QSpinBoxes were smaller than QLineEdits rects for
UI elements that should have the same size. This patch increases the
content rect for QSpinBoxes.

Task-number: QTBUG-132261
Pick-to: 6.8
Change-Id: I59e752b719399c5845ab3ef81c6e271deda16273
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
(cherry picked from commit a53e095882551caf3684a1f6a205b6c7d76a8913)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-22 09:19:02 +00:00
Alexey Edelev
8f1438b1a8 Avoid creating Plugin targets if the dependencies are missing
The plugin lookup mechanism doesn't handle the situation, when the
plugin is available but it's private dependency(static plugin case)
is missing. In this case we currently silently bypass the dependency
lookup and create targets. So users see the confusing message about
missing linked target, like:

   Qt6QSQLiteDriverPluginTargets.cmake:61 (set_target_properties):
   The link interface of target "Qt6::QSQLiteDriverPlugin" contains:
     SQLite::SQLite3
   but the target was not found.  Possible reasons include:
     * There is a typo in the target name.
     * A find_package call is missing for an IMPORTED target.
     * An ALIAS target is missing.

This indeed should be handled properly and we should omit creating
targets especially if users don't really use the plugin directly.

Also if dependencies are not satisfied it looks logically to set
the <plugin>_FOUND to false as this will be yet another indicator
for user that the plugin is not found.

Task-number: QTBUG-132244
Pick-to: 6.8 6.5
Change-Id: I8685163df0dee3a728c724901f69780569ffcad5
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 8d0283ad2cae3d8fbd4b1b7ee5c6454f7fcc079c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-21 04:51:58 +00:00
Eskil Abrahamsen Blomfeldt
610ee0c504 Don't include bearing of mid-string characters in max width
When calculating the maximum width of a text layout, we
would add the text width of each substring *after* we had
added the negative right bearing of the last character to it.
But the bearing of the last character in a wrapped substring
does not actually add to the maximum width unless it is the
last character of the *whole* string.

Prior to 250117086ff15bba79df8f0e15ee66192edc9ea9 this was
not noticed, because the last glyph in the substring would
typically be a space and the space does not have any
bearings (when doing wrapping on individual characters it
could still happen). After the change, the previous glyph
for which we get the right bearing will be the last
non-whitespace glyph. If this happened to have a negative
right bearing, we would add this to the max width and
end up with a larger max width than we should.

This caused a test failure in tst_qquicktext.

This test prefers the text width without the bearing (i.e.
the *advance* of the substring) unless the line is manually
wrapped or it is the last line of the layout.

Pick-to: 6.8
Change-Id: Iba1a5ad48d575683672400f0572dfa683a0f2d9c
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
(cherry picked from commit c08a92307d6d9fa9d9d9a1f301e3f2a65374e99a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-21 04:51:43 +00:00
Tor Arne Vestbø
e266949979 Apple: Use automatic rendering mode for icon engine
When requesting symbol icons the OS automatically chooses a rendering
mode per icon. Most icons use the monochrome rendering mode by default,
but some of them use the hierarchical.

We don't want to override this choice by always using hierarchical,
as that doesn't match the look of most icons in the system and may
be surprising to the user.

We still want to support tinted icons, based on the QPalette. For
iOS this is easy via [UIImage withTintColor:] but for macOS we
have to do an extra render pass. Unfortunately we can't use
configurationWithPaletteColors with a single color, as for the
hierarchical icons this will produce a different looking icon
than if we tint the entire icon.

[ChangeLog][macOS/iOS] The Apple icon engine, used for theme
icons on macOS and iOS, will now use the default rendering
mode for icons, typically monochrome, instead of always
using hierarchical icons.

Pick-to: 6.8
Change-Id: I9e66d848222e8ed0f7f20897454f27446bf0fd81
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 9f392c09a1d30e48494b4df0e2f5f531c7e4ec4b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 15:38:18 +00:00
Mårten Nordheim
b91edac40d tst_QHttp2Connection: make settings exchange wait for acknowledgement
Is needed when sending more SETTINGS frames during the test later

Task-number: QTBUG-132277
Pick-to: 6.8
Change-Id: I24b2a5d1b2e7aecd8687db5b24f37233df3b91dd
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit 6e7a15f5c50a94216bcf35241ec008e6c419ba18)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 15:38:18 +00:00
Toni Saario
7ce68e59fd Increase VxWorks stack size
Increases to around 16MB with the format change.
Required by some tests.

Change-Id: Ia41436b4269220f84271b614ea6f2b96ca605c32
Reviewed-by: Simo Fält <simo.falt@qt.io>
(cherry picked from commit 75d87caef70ff79b4db04834d28daa1905f0d5a0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 15:38:18 +00:00
Juha Vuolle
651b515074 Change QImage::mirrored() deprecation from Qt 6.10 to Qt 6.13
The deprecations aren't urgent, and allowing more time for users to
adapt is appropriate. In addition, also suppress the deprecation
warnings when compiling the related autotest.

Resulted from API-review.

Amends: 577946c1f05aaaa2a3f9682001aeb4144386b26b

Task-number: QTBUG-132090
Change-Id: Ia0c07ab510a9a9c8722892fcd94f58f6ec287059
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit 0aa07ce77237dacc58de5939d5a239fb8997da7a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 15:38:17 +00:00
Christian Ehrlicher
1319dcf472 QWindows11Style: Adjust position of MDI subwindow icon
The y position for the MDI subwindow icon was not calculated correctly
so the icon was not painted vertically centered.

Pick-to: 6.8
Task-number: QTBUG-130673
Change-Id: I5f9023820a4e4b4288017869ac4088fe2669ce50
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 6e29a94b547fbafa69e97ac02aeb33edad63f2ae)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 15:38:17 +00:00
Marc Mutz
9cd2e3ffef qtesttostring.h: standardize on unique_ptr<[]>
... instead of QScopedArrayPointer.

Less Qt code (which we're supposed to test with this library) and more
consistent with the tuple implementation.

Also makes the header clean w.r.t. upcoming QT_NO_SCOPED_POINTER.

Pick-to: 6.8
Task-number: QTBUG-132213
Change-Id: I3705b8db89e909e3f1e37ad6a31aaba6f9af899a
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit f405925829ca37af47ecbb291bdb8a95a606e024)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 15:38:17 +00:00
Christian Ehrlicher
ecc31955f1 QWindows11Style: adjust text rect for CC_TitleBar
The adjustment for the textrect was wrong - the bottomRight point must
be moved by -1/-1, not 1/1.

Pick-to: 6.8
Task-number: QTBUG-130673
Change-Id: I6c099fdd9a03188e7a5c7852b1912ed9b2801f7a
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 2c85e5d22215f24bd46d07a1183393e52702493f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 15:38:17 +00:00
Christian Ehrlicher
f349040b39 QDrawUtil: Cleanup qDrawPlainRoundedRect/qDrawPlainRect
Fix the style and use PainterStateGuard instead own save/restore
functionality because PainterStateGuard is already available and used in
those functions.

Pick-to: 6.8
Task-number: QTBUG-132187
Change-Id: Ie454b6cffe03444d88f13d15adb19a7e7783a493
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 1fb86f1f84bb56dab60bc15604c09a14157d6f10)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 15:38:17 +00:00
Volker Hilsheimer
319b31a5a2 QTestLib: Remove logging category declaration from public header
The lcQtGuiTest category is only used in qtestsupport_gui.cpp, so
declare it there as a static logging category.

Addresses header-review comment, amends
5ac4f04325a56d47812f528fe31ceb0d4932f664.

Task-number: QTBUG-132090
Change-Id: I5b2a93822a698f55c52c1be87ebf8a689f49e2a3
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
(cherry picked from commit b957dfc6e06deed64e20e8eee5d2164250b28b95)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 15:38:16 +00:00
Thiago Macieira
1596b5855c QDebug: constrain the new Standard Library op<<
So they be SFINAE-ruled out when either the key or (for associative
containers) value types don't provide their debug-streaming operators
either.

Amends 850d4895be565931d18c92e5e2f9a33b7f26de6d,
0c96528e8d43ad4309bdca14b179a5045984655a,
a9fe57fefaac0cb047e4c02e0b8c8f8327e0a58c.

Fixes: QTBUG-132104
Task-number: QTBUG-130290
Change-Id: I1d6703b1fdf6cfd03799fffd33191d8028ecc123
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 8f958a6e2dcff5bb9b01442a19f5605f357c6e7e)
2024-12-20 08:17:40 -03:00
Christian Ehrlicher
7ab2885594 QSqlQueryModel: add new function to refresh the model data
This function re-executes the query used by QSqlQueryModel and refreshes
the data from the database. The query must not use bound values as these
values are not preserved.

[ChangeLog][QtSql][QSqlQueryModel] Added refresh() to refresh the model
data from the database.

Task-number: QTBUG-123603
Change-Id: I3f1d779e07b88565abe825c31cfc4d7d1b2312c4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 1bd883dbc15c4016f78d421afac2ac9f31ec4874)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 11:17:40 +00:00
Christian Ehrlicher
fc29afbe1a QSqlDriver: return the connection name of the assoicated QSqlDatabase
A QSqlDriver instance is directly bound to a QSqlDatabase object. But
there was no way to get the QSqlDatabase out of a QSqlQuery/QSqlDriver.
Fix it by storing the connection name also in the driver during
creation and add a getter for it.

[ChangeLog][QtSql][QSqlDriver] Added connectionName() which returns the
connection name of the associated QSqlDatabase instance.

Task-number: QTBUG-123603
Change-Id: If78b85413cf6ca965ff6bf9f3600cb54169b5569
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 5b07e3de3fe5335d9338c65ca40cfe656a389167)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 11:17:39 +00:00
Eskil Abrahamsen Blomfeldt
ed1032975e Include right bearing in width of layouts wrapping on spaces
When we're calculating the width of the layout, we include the
right bearing of the last character in the text line if it is
negative (i.e. it exceeds the advance width). We do this by
storing the last glyph that has been verified to fit in the
line, so that we can retrieve its right bearing when we find
a break.

However, when we were wrapping on spaces this previous glyph
would always be a space, and the right bearing would
subsequently be 0. But then the trailing spaces would be
trimmed and the right bearing of the actual last glyph
would not be recorded and never added to the text width.

This caused a failure in tst_qquicktext on Windows with both
DirectWrite and Freetype: This was purely unlucky, because
the metrics of the Tahoma font happened to be such that the
right bearing on the 'k' was enough to cause a line to
overflow. Since we didn't account for it when setting the
width, we ended up with unexpected line breaks, causing the
test to fail.

This did not happen with GDI, since it rounded the right
bearing of the character down to 0 (which was actually
visible in the layout, in that the k was painted a fraction
of a pixel outside the text layout's width).

In addition, QTBUG-130313 was causing us to pick a different
font when resolving the non-existent font requested by the test,
so therefore the bug was not found immediately when moving to
DirectWrite as the default but only when QTBUG-130313 was fixed.

We fix this by
  1. When adding a chunk of whitespace, we record the previous
     non-whitespace glyph that has been verified to fit.
  2. When adding a chunk of non-whitespace, we only record the
     previous glyph verified to fit *if* it is not whitespace.
	 Otherwise we keep whatever we recorded before adding the
	 spaces.

Pick-to: 6.8
Fixes: QTBUG-132075
Change-Id: I8d9a2f3197068f5f93520d217a6bb89633644e95
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
(cherry picked from commit 250117086ff15bba79df8f0e15ee66192edc9ea9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-20 07:24:35 +00:00