63301 Commits

Author SHA1 Message Date
Jarkko Koivikko
0aaa84b714 pagesize: Fix pixel overflow in QPageSize::sizePixels and rectPixels
This update addresses an issue in converting page size from points to
device pixels. Previously, rounding the result could lead to an
overflow beyond the physical pixel capacity.

Example case: A4 paper size at 600 dpi:

- points to pixels: 842 pt / (72.0 / 600) = 7016.666666666667

However, the physical pixel height for an HP printer:

- GetDeviceCaps(hdc, PHYSICALHEIGHT)) = 7016

This fix prevents pixel size from exceeding the physical print area,
avoiding unprinted pixels.

Change-Id: I66eabc628d3374d9cfb19b0eb5928f83afbc13dc
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit c49fd15a4253a79d70ae2b26ac4cc04454ffd7a0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-09 04:11:18 +00:00
Jarkko Koivikko
b3fdb93ba9 print: QPageLayout: Fix pt unit conversion
This patch corrects the miscalculation in point unit conversion,
ensuring correct margin updates.

Previously, non-pt units were rounded to two decimal places. When
converting back to pt, rounding was to zero decimals, making the result
always less than the original. This could result in margins falling
below the minimum allowed.

Example:
original_points = 8.4
multiplier = 2.83464566929
mm: qRound(8.4 / multiplier * 100) / 100 = 2.96
new_points: qRound(2.96 * multiplier) = 8 // wrong!

The fix rounds back-converted values up to two decimals, ensuring they
are never less than the original and thus stay above minimum margins.

new_points: qCeil(2.96 * multiplier * 100) / 100 = 8.4

Also, remove unused function qt_convertPoint.

Change-Id: I6109f8d381aec96db1ce04cc167f7b73c1c0b9a8
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit d420c1e25a0fb3b25ba4c572f2938701ce8494ec)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-09 04:11:18 +00:00
Thiago Macieira
85e7b700d9 QMetaType: fix typenameHelper() for types in the QtPrivate namespace
GCC at some point decided that it wouldn't include the full namespace
expansion in __PRETTY_FUNCTION__ for any type that is in the same
namespace as the template function being expanded (that is, the
QtPrivate) namespace. I don't know how long this behavior has been in
place, but it can be seen with GCC 13, where the expansion of that macro
inside QtPrivate::typenameHelper<QtPrivate::ModelIndex>() is:

 constexpr auto QtPrivate::typenameHelper() [with T = ModelIndex]

This can be easily worked around by using a different namespace.

Fixes: QTBUG-119650
Pick-to: 6.5 6.2
Change-Id: Ica7a43f6147b49c187ccfffd179df309e43a70cb
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit ead408ca1b0b689bea269543117d89316ab23d0b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-09 04:11:17 +00:00
Marc Mutz
2923a29b59 Rename EINTR_LOOP -> QT_EINTR_LOOP
This non-namespaced macro was defined in a header, and while that
header is private, we shouldn't define non-namespaced macros in our
headers.

The macro also clashed with one of the same name defined in forkfd.c,
which broke unity-builds including the forkfd_qt.cpp TU. This rename
fixes that, too, so we can now remove forkfd_qt.cpp from
NO_UNITY_BUILD_SOURCES.

Pick-to: 6.5
Change-Id: Ic4bb4e4d7a632ca87905e48913db788a7c202314
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit f96a17225f088a5790655c01eaab9578c81a19f2)
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-12-09 02:14:49 +01:00
Thiago Macieira
52cc586a65 Re-do the namespace fix for the linker scripts
This amends and corrects b63045477ea05c17f9abe9434e6d824453e3935a. The
fix there was incorrect for two reasons:
1) it missed one symbol in QtCore (the QFutureInterfaceBase one
   added in 0f0371c8304bd7354a3c43f9fac6b85bd3e9a3f1.
2) it only worked for namespaces that were 15 characters long

Instead, just use a wildcard where the namespace should be for Qt
symbols (note: an extra wildcard appears for plain types because they go
from <N><type> to N<N><namespace><N><type>E).

Change-Id: Iae41eb8991e349ceb836fffd179d6e709d6632f8
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
(cherry picked from commit 93233516957f71054c42ba843cdd57216834acd7)
2023-12-08 15:50:09 -08:00
Alexey Edelev
2ad8e19a03 Make sure that the result variable is empty in _qt_internal_collect_buildsystem_targets
Add the inside-recursion marker to the
_qt_internal_collect_buildsystem_targets function and reset
the result variable only in the top-level function call.

Amends 1c82e92202c8c359872c08095670c121602094b8

Pick-to: 6.5
Change-Id: I34b1e1edbb8a799900b95f67b80151b372073d2c
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit ea3289460b6c9a6c4f17af06871936f105514b66)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-08 19:06:43 +00:00
Friedemann Kleint
c75746a10a Polish the EditableTreeModel example
- Fix/silence most clang-tidy/compiler warnings
  * unsigned/int comparison
  * Avoid repeating return / default parameter types
  * Use auto * for pointers
  * Streamline code, use ternary operators
  * Move constructor parameters
  * Observe rule of 5 by using Q_DISABLE_COPY_MOVE
- Add some bells && whistles, resize properly, expand all

Change-Id: I1721458ff66dcba123ff3a2cf50e7d15387a4e8b
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
(cherry picked from commit d50b56b47544ad2b72811045f64df24eaaf0cf59)
2023-12-08 14:52:37 +01:00
Ahmad Samir
48c78b2a3a examples/: fix compiler (GCC) warnings -Wsign-compare
Change-Id: Ie4965e3ce3113e9c7a5d5d5eba4cab143ef1c806
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 0b3390f33d4f995273289ccc49ce235619c2903d)
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2023-12-08 14:52:33 +01:00
Carl Schwan
2b250954d3 Modernize EditableTreeModel
- Use unique_ptr instead of manual memory management
- Improve consistenty in variable name with the simpletreemodel
  childrenNumber -> row, m_ prefix for member variables

Change-Id: Iface30c2224c2b1db7c623a9e6fcbb449c556f3e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 604b2feca751c5eb43b20e180c175acc2a87099e)
Reviewed-by: <carl@carlschwan.eu>
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2023-12-08 14:52:29 +01:00
Rym Bouabid
280a60ebe9 Add documentation for the private API QAtomicScopedValueRollback
Task-number: QTBUG-115107
Pick-to: 6.5
Change-Id: Icdb09d803f1d789b91ae5c1806470d71adb59067
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit 4b666553b8510fa12d0905cd10d6782e09ac5f56)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-08 07:43:02 +00:00
Christian Ehrlicher
a06b26814d QIconLoader::actualSize(): respect entry.scale on returned size
entryForSize() might return an entry with a scale != 1 (e.g. when
requesting the actual size for 32x32 it might return an entry with
size=16 and scale=2) but the returned size is not multiplied with this
scale so it returns a wrong size and in the case of QTBUG-114849 to a
wrong painting rect.

Pick-to: 6.5
Fixes: QTBUG-114849
Change-Id: I311e7401e61425efb20b37d13cc95c4b22d47e76
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 7cb25eb33c7875c913b4cb0154afd741e602d8aa)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-08 05:12:17 +00:00
Marc Mutz
cb09b3967e corelib/CMakeLists.txt: restore lexicographical order of SOURCES
Amends 8d367dec156c1aa63544bd851809caa7e72d307e.

Pick-to: 6.5
Change-Id: Ia1fd819ebabf6df143c06f56624365d3e37fa1c9
Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit b6ff86e5568d5ce715de4153a1ab34dc2c278fc9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-08 02:18:42 +00:00
Marc Mutz
7270e2ab75 Fix QStringConverter::encodingForName() for trailing -, _
The (internal) docs say that - and _ are ignored, and they're ignored
everywhere, except as suffixes. If the old code only ignored them as
infixes, fine, that would make some sense, but it ignored infixes and
prefixes, so there's no reason for it to not ignore suffixes, too.

Fix by continuing the loop until both input ranges are exhausted, or a
mismatch was found.

[ChangeLog][QtCore][QStringConverter] Fixed a bug where
encodingForName() failed due to trailing characters (`_`, `-`) that
ought to have been ignored.

Pick-to: 6.5
Change-Id: Iec21489d988eda7d33c744c170f88cd665b73f34
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 5f775e671973b1549a48ae8c69c5db7494f6a6d3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-07 20:35:35 +00:00
Marc Mutz
319089dd7f Improve tst_QStringConverter::encodingForName_data()
Add more tests and DRY the code using the usual row() lambda trick.

Pick-to: 6.5
Change-Id: I810fba0ab2a96e740e67392155f9507675fe57ae
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit ddce99989fcc956cb59df722eea0e788a867bd7a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-07 20:35:35 +00:00
Marc Mutz
8d4807da5c qxp::function_ref: try to work around compilation failure on VxWorks
Task-number: QTBUG-115777
Pick-to: 6.5
Change-Id: Icda59c33ae8c92460c7cb06e204c6b1926b82f66
Reviewed-by: Krzysztof Sommerfeld <krzysztof.sommerfeld@siili.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit 062718a7d32b683035055e28864729bc097b1d09)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-07 20:35:35 +00:00
David Faure
525b05599c QMimeDatabase: fix glob-deleteall support for the binary providers
This fixes the recently added QEXPECT_FAIL about glob-deleteall
in a local directory (with a binary cache). Before adding a glob match
we ask the more-local (higher-precedence) directories if they have
a glob-deleteall for that mimetype, and skip it then. This "asking"
is a virtual method, implemented for both XML and binary providers.

Change-Id: I6e4baf0120749f3331fd2d9254bea750a322b72d
(cherry picked from commit 1f0bc1ade316547d01100dcca4f3f7187485f917)
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-12-07 21:35:35 +01:00
David Faure
705118a554 QMimeDatabase: collect glob patterns from all locations
A QMimeTypePrivate used to belong to a single provider, which would
provide the complete data for it.
But since the redesign in commit 7a5644d6481a3c1a741677, each provider
represents is a single mime directory, and the merging happens at the
QMimeDatabase level. So we need a QMimeType[Private] to be just a name
(a "request" for information about this mimetype) and the information
for that mimetype is retrieved on demand by querying the providers
and either stopping at the first one (e.g. for icons) or merging
the data from all of them (e.g. for glob patterns).

The XML provider was using QMimeTypePrivate as data storage,
give it its own struct QMimeTypeXMLData for that purpose instead.

Task-number: QTBUG-116905
Change-Id: Ia0e0d94aa899720dc0b908f40c25317473005af4
(cherry picked from commit 4e9944e6c8a456353d243ab268cb0f01ff006faa)
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-12-07 21:35:35 +01:00
David Faure
37cff48a27 tst_qmimedatabase: move local override to the specific test method
When running tst_qmimedatabase with the full shared-mime-info test suite
(which unfortunately requires local setup so this is easy to overlook),
we need *.webm to still be associated with video/webm.

So to test glob-deleteall, do that in installNewLocalMimeType(), with
other similar tests.

This however unearthed the following bug: the handling of glob-deleteall
is only correct when the local dir has no binary cache. It's broken
when using a binary cache. Added a QEXPECT_FAIL for now because this is
going to be fixed as part of a major redesign, coming up.
I also found out that neither xdgmime nor gio do this correctly...

Change-Id: Ib075fcdb792f60a859f23db8c2d7e1c6524f9050
(cherry picked from commit 994311a66bd31983bec5d75d87f5e03f53f14def)
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-12-07 21:35:35 +01:00
David Faure
6bc35430f9 tst_qmimedatabase: separate xml files for Global and Local tests
For historic reasons, the test had a single list of override xml files
to copy first into the global dir, and then into the local dir.
But glob-deleteall only makes sense in the local dir (as per the MIME
spec). Having two definitions for the same mimetype in the same dir
is undefined behavior, so the test was working by chance only, and
my upcoming refactoring/fixes caught that.

Change-Id: I4717683b4b3f9ba69f1fd815669460789700e877
(cherry picked from commit 251ab925fe8e3dfbc8a8e5f9ed999777d3f6af99)
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-12-07 21:35:34 +01:00
Thiago Macieira
c88e1caf3b qsimd_p.h: fix build with Clang 17 & -Werror,-Wconstant-logical-operand
Amends 39d3af0c29147ff319e89c0be602d99af0af0996

qsimd_p.h:235:18: error: use of logical '&&' with constant operand [-Werror,-Wconstant-logical-operand]
  235 | static_assert((1 && 1 && 1 && 1 && 1 && 1 && 1), "Undeclared identifiers indicate which features are missing.");

Pick-to: 6.5
Change-Id: Ia930b1a2ed1e465a826ffffd179c5c21b4f4e288
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit d677a454b208dfccc16c845d114575a414ca284f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-07 20:35:34 +00:00
Jani Heikkinen
a5c9e10894 Revert "OpenSSL: remove support for 1.1"
This reverts commit 28bdd104fd33acf74a76f7ce74e9382b7ba5faf1.

Reason for revert: Based on discussions this isn't something we can do in patch level releases. We can (and should) keep this in 'dev' but needs to be reverted from '6.6', '6.5', '6.2' and '5.15'

Change-Id: If1fea8557f97e4bae8313b701f974f18853ec0f2
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-12-07 15:21:33 +00:00
Ivan Solovev
9eb1eb10c1 Move the definition of a native float from qfloat16.h to qtypes.h
... and put it into QtPrivate namespace as NativeFloat16Type.

Keep the qfloat16::NativeFloat definition for SC.

This is in preparation of Qt::compareThreeWay() for NativeFloat16Type
(where available and mis-classified as non-is_floating_point).

Amends 99c7f0419e66692260be56c0385badeacb3f6760.

Pick-to: 6.5
Task-number: QTBUG-104113
Change-Id: Ie12c42c86f8dc9e233fe39776b0f0e28088de9e2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit 43d3d037605bac4e13a1282c4eb363cdee98eb74)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-07 12:37:50 +00:00
Tor Arne Vestbø
4f979ec945 iOS: Allow raising and lowering child windows
If the view's superview is not our own QIOSDesktopManagerView
then it's either a child window, or the view of a view controller
that's not our own. In both cases we can skip the logic to include
the window level, as that only applies to Qt top level windows.

Pick-to: 6.5
Change-Id: If8bbf2a79f3be0cbaf6979455b0626b36da71068
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit 09cca9539c0a22ee31f048269a274ba81fdbea8c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-07 09:51:00 +00:00
Axel Spoerl
478ce004af QMainWindowTabBar: make destructor public
Was private by mistake => make it public.

Pick-to: 6.5
Change-Id: I6b07a19687ddf84e8456aa70bc34b1cc714a299e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit d462c7b09c07b366ee5cea00116e32a4b7fedac6)
2023-12-07 10:51:00 +01:00
Marc Mutz
e08534c4b6 QSysInfo: sanitize /etc file parsing [1/N]: properly check endsWith('"') in unquote()
When 3535f46374ccf8ad966e4b266c0dbd919646fded dropped the
Q_ASSERT(end[-1] == '"') by reviewer request from the original
767beb7fff6f08f5574a193967f8f814970ac289 change, it didn't replace it
with some other check, leaving the possibility open that we'd be
passing an invalid range (end < begin) to QString::fromUtf8(), with
unknown consequences.

While technically a security problem, this has very low impact, since
the files being parsed should contain "trusted content", being
supposed to be owned by root, and not writable by mere mortals. I
hasten to add, though, that the code doesn't check permissions of the
files it reads.

The bug existed with the original Q_ASSERT, too. Namely in release
mode. And in debug mode, it would be a DOS.

Port to QByteArrayView to get the more expressive API and as a
prerequestite for follow-up (non-security) patches.

Pick-to: 6.5
Change-Id: Ib79cdad8680861d1f11b6be9234695273d0a97c2
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit c39bd86766ae4e9faa3eda89a486bd5534816b0d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-07 09:51:00 +00:00
Marc Mutz
008072cffd QSpan: ensure interoperability with std::span
We accepted QSpan as a NIH-type instead of waiting for C++20 and
std::span, because we said that there's no impedance mismatch between
the two, as they both implicitly convert into each other.

But we actually never checked that they do.

Fix this omission by adding constructors that treat std::span exactly
the same as QSpan itself, and adding the respective static_assert()s
to tst_QSpan to check that (within the constraints imposed by the
standard on std::span), they actually do convert into each other.

The only two problematic cases are that fixed-size std::span
constructors are explicit, so span is only constructible, not
convertible, from QSpan. Likewise, for an rvalue QSpan to be
acceptable to the std::span constructor, QSpan needs to opt-in to
enable_borrowed_range (while we're at it, do enable_view, too).

We so far have rejected adding these opt-ins for our own container
classes because we wanted to avoid the compile-time overhead of
including the huge <ranges> header into such central headers as those
that define our containers.

But std::span itself has to specialize these traits, and its range
contructor has to use them, so they must be available from <span>,
too, possibly the stdlib puts the definition into a much smaller
header. So just assume we can specialize it after including just
<span>, provided __cpp_lib_concepts is also defined.

Change-Id: I2202869b60c98047256b0fbcb12336f5d8e550ba
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 7f5b795f757ee62af71d8d47ccad19cbf681e0eb)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-07 09:51:00 +00:00
Marc Mutz
010ce12a82 QSpan: don't truncate QSpan::extent
My notes inform me that my intent was for QSpan::extent to be size_t,
for compatibility with both its template argument and
std::span::extent.

So fix it to be size_t instead of qsizetype. While extents that go
beyond numeric_limits<qsizetype>::max() will be unusable in practice,
QSpan doesn't actually allocate memory, so declaring one should be
possible, if only for compatibility with std::span, without getting
into a situation where E != extent.

Change-Id: Ic8ae3a1c03801b4a23b7ba56388372cac64f9e5e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit d6969b76a5281d5dcadc6ef722594d6ba2effd68)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-07 09:51:00 +00:00
Marc Mutz
1945c5f40c QSpan: check conversion from initializer_list
The docs at cppreference.com hint at a corresponding ctor being added
for C++26 (though I don't see it in eel.is/c++draft, yet).

Even so, replacing former initializer_list functions with QSpan ones
is definitely one of the upcoming use-cases, so test it.

Can't use from_container_impl() here as initializer_list<T> is already
immutable, so QSpan<int> is not compatible, only QSpan<const int>.

Change-Id: Iecdf29e629d48313edd5e56d358b9137da76deb6
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit c851fb2456a87d7b19e7fb9a5a61a3b631970026)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-07 09:51:00 +00:00
Marc Mutz
89e8253de5 QSpan: make it a bit more QDoc-friendly
Hide the base class; the documentation isn't supposed to show this
implementation detail.

Don't use auto return types for the begin/end family of member
functions; QDoc doesn't resolve them, but just shows auto, which,
without seeing the implementation, is pretty useless.

Change-Id: If75cc1e7de9c5c1490cb37241739449df4e5d0c2
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 3814174faefef4f0a00a97d980d97312d73d132b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-07 09:51:00 +00:00
Marc Mutz
283ec1055b tst_ContainerApiSymmetry: check value_types with a const member
QVarLengthArray is the only Qt container currently known to be fine.

std::vector is supposed to be fine, too, since C++14. Turns out that
libstdc++ gets resize(n, v) wrong, though, because it never
implemented the resolution to wg21.link/lwg2033. Known issue, linked
in code comment. Worked around for the time being. Keeping std::vector
in, though, because in this test suite we do cross-check with
std::vector, and other platforms, and most of GCC's std::vector
functions, adhere to the standard.

Pick-to: 6.5
Change-Id: I26e11c4a100695c604cebcf7e14a1ae5078d9ec7
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 3c0fdd7341ed4bff9b5f041e9f4646265d142303)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-07 09:50:59 +00:00
Marc Mutz
d4eae78e6b Check that QMulti{Map,Hash} (still) store in reverse insertion order
It's wrong, but let's not break it unconsciously.

Pick-to: 6.5
Change-Id: Ic3daa7df4db2ef34ff5d08fddecf9a932ad92156
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit 2d052b038d5c3e8ec55ca12b3ba531208a6d3cf1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-07 09:50:59 +00:00
Mate Barany
c688fc9f51 Create class documentation for QNtfsPermissionCheckGuard
...and document the related functions as well.

Fixes: QTBUG-116350
Change-Id: I038d59f6af46b29e2123bc8b6c24ff4ffea78bbf
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
(cherry picked from commit fa79b56bd82df6852aab6819dc31b359ee7b24e7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-07 09:50:59 +00:00
Christian Ehrlicher
8fc4a796ba QTabBar: properly calc tab positions when changing tab position
The previous attempt to fix this bug did not work out well since it
tried too hard to avoid double calculations. Therefore restore the old
behavior and fix makeVisible() instead.
This amends 1082038bd89d0bbba4df0d9b3f8af3cd0a2f96f2

Pick-to: 6.5
Fixes: QTBUG-119366
Change-Id: I738a3cd3537ecf0983480d2f961f45f81d101bd9
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit 4e6f7ad26c31fe484421e873cf0de0fad0c878ee)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-07 09:50:59 +00:00
Friedemann Kleint
4e9051417f SimpleTreeModel: Polish TreeModel::setupModelData()
- Use QStringView.
- Use a list of a pair-like struct to represent the state instead
  of 2 lists.
- Use qsizetype.
- Use constLast() to avoid detaching.

Change-Id: Icc3586451f081f6166fece52675d5379160f51da
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
(cherry picked from commit 1c06f86d255d3d92201b1092794a4c1ea403c24d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-07 09:50:59 +00:00
Friedemann Kleint
e19f344460 Polish the SimpleTreeModel example
- Fix/silence most clang-tidy/compiler warnings
  * unsigned/int comparison
  * Avoid repeating return / default parameter types
  * Make functions static/use static invocations
  * Use string literals everywhere
  * Use auto * for pointers
  * Streamline code, use ternary operators
  * Move constructor parameters
  * Observe rule of 5 by using Q_DISABLE_COPY_MOVE
- Add some bells && whistles, resize properly, expand all

Complements 25027444a9b53d61a6257dc5f5ce0ffdb3b06f98.

Change-Id: I78f48d187981ecabf69a5d4d42715bad026fa9e6
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
(cherry picked from commit a3e20df03d522bd1b07ac7a85578401f36f290b9)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-07 09:50:59 +00:00
Christian Ehrlicher
5c8e47d2dd SQLite: Update SQLite to v3.44.2
[ChangeLog][Third-Party Code] Updated SQLite to v3.44.2

Pick-to: 6.5 6.2 5.15
Change-Id: I4da6370cf1e320813b9ba807101ce188d3a09fa0
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 8220173b020fd28fdf9635fbd46c9505b9d9442a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-07 07:05:21 +00:00
Marc Mutz
a0ac17891b Remove unneeded toString(QPair) declaration
It's literally the same as the std::pair one that immediately follows
it, because QPair these days is just a template alias for std::pair.

Wasn't flagged as an error because it's just a declaration, not a
definition.

Pick-to: 6.5
Change-Id: I5b47572f6e2a71edb47cbe224801a719ff1e060d
Reviewed-by: Jason McDonald <macadder1@gmail.com>
(cherry picked from commit 85842da95b5a7821b44d83e5d26922a3d07ef6cf)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-07 00:37:28 +00:00
Axel Spoerl
9557d1ca92 QDockWidget: Fix group unplugging
A floating dock widget could either be a single QDockWidget object,
or a QDockWidgetGroupWindow with a single QDockWidget child.
The former could be dropped on the latter. Dropping the latter on
the former caused a crash.

The existence of QDockWidgetGroupWindows with a single dock widget
child was accepted to be by design.
Previous fixes, such as  9ff40b59da58160dc26c54204a615a2456e07405,
attempted to wrap all single floating dock widgets in
QDockWidgetGroupWindows.

These attempts fell short, because of the manifold programmatic and
manual options to create a floating dock widget:
- drag a single dock widget out of a main window dock area
- drag a dock widget out of a tab bar on the main window
- drag a dock widget out of a floating tab
- call `QDockWidget::setFloating(true)` in any situation
- create a new QDockWidget, that floats from the beginning

Whenever a QDockWidgetGroupWindow with a single QDockWidget child
was hovered and/or dropped on a QDockWidget without a group window,
crashes or screen artifacts were observed. Previous fixes made them
occur less often.

QDockWidgetGroupWindow is not designed to hold a single QDockWidget
child. Such a state is inconsistent and may only exist, while a
QDockWidgetGroupWindow is constructed.

The reason why such invalid QDockWidgetGroupWindows started to exist,
is a bool trap: QDockWidgetPrivate::mouseMoveEvent() starts a drag
operation, when a dock widget is moved by mouse.
It called startDrag() with no argument, which defaulted to
startDrag(true) and caused a group drag.

This assumption is
*correct*, when a tabbed group of dock widgets is dragged out of the
main dock as a whole, to become floating tabs.
*wrong*, when a single dock widget is dragged out of a docked group,
to become a single floating dock widget.

In the second case, the dock widget was wrapped in a new, floating,
invisible QDockWidgetGroupWindow. Looking like a single, floating dock
widget, the group window caused a crash, when attempted to be dropped
on another dock widget.

This patch eliminates all cases, where a QDockWidgetGroupWindow with
a single QDockWidget is created:
(1) Implement QDockWidgetPrivate::isTabbed().
This enables mouseMoveEvent to determine, whether the move relates to a
group of tabbed dock widgets, or to a single dock widget.
startDrag() can therefore be called with the right argument. It will no
longer create a QDockWidgetGroupWindow with a single QDockWidget child.

(2) Change QMainWindowTabBar::mouseReleaseEvent
When a dock widget was dragged out of a tab bar and became a single,
floating dock widget, it was still parented to the group window.
That is wrong, because it has no more relationship with that group
window.
=> Reparent it to the main window, just like any other single floating
dock widget. That enables QDockWidgetGroupWindow to detect, that the
2nd last child has gone and no more group window is needed (see next
point).

(3) React to reparenting, closing and deleting
If the second last dock widget in a floating tab gets closed (manually
or programmatically), reparented or deleted, also unplug the last one
and remove the group window.

(4) Amend 9ff40b59da58160dc26c54204a615a2456e07405
Remove the code path where a QDockWidgetGroupWindow with a single
QDockWidget child was created 'just in case', to make it compatible
others, created by (1), (2) or (3).

(5) Change QMainWindowLayout::hover()
When the hover ends without a successful drop and a temporary group
window with a single dock widget child has been created, remove the
group window.

The patch fixes smaller inconsistencies, which have not become visible
due to assertions and crashes earlier in the chain.

The patch finally extends tst_QDockWidget, to cover all 4 cases.

- Creation of floating tabs
The creation of floating tabs is extracted from floatingTabs() to
the helper function createFloatingTabs(). In addition to creating
floating tabs, the helper verifies that dragging a dock widget out
of the main window doesn't accidently wrap it in a group window.
This covers case (1).

- tst_QDockWidget::floatingTabs()
The test function verifies now, that both test dock widgets have the
same path before plugging them together and after unplugging them from
the floating tab. This covers case(4).

- tst_QDockwidget::deleteFloatingTabWithSingleDockWidget()
This test function is added, to cover cases (2) and (3).

- tst_QDockWidget::hoverWithoutDrop()
This test function hovers two floating dock widgets hover each other,
and returns the moved dock widget to its origin before releasing the
mouse. This covers case(5).

This fixes a lot of long standing bugs, making the author of this patch
modestly happy :-)

Fixes: QTBUG-118223
Fixes: QTBUG-99136
Fixes: QTBUG-118578
Fixes: QTBUG-118579
Fixes: QTBUG-56799
Fixes: QTBUG-35736
Fixes: QTBUG-63448
Fixes: QTBUG-88329
Fixes: QTBUG-88157
Fixes: QTBUG-94097
Fixes: QTBUG-44540
Fixes: QTBUG-53808
Fixes: QTBUG-72915
Fixes: QTBUG-53438
Found-by: Keith Kyzivat <keith.kyzivat@qt.io>
Found-by: Frederic Lefebvre <frederic.lefebvre@qt.io>
Pick-to: 6.5
Change-Id: I51b5f9e40cb2dbe55fb14d769541067730538463
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit e6d85cf28bc4f750b69c33b72c006b067ae1190f)
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2023-12-06 17:52:17 +01:00
Ahmad Samir
10b5590ce0 QFileInfoGatherer: fix narrowing conversion warnings
Found by using -Wshorten-64-to-32 clang compiler flag, or adding that
flag to the flags clangd uses.

Drive-by changes:
- Refactor a small while loop
- Use reverse iterators
- Move instead of copy while constructing a QList
- Replace QPair by std::pair (see QTBUG-115841), and also for its CTAD,
  otherwise I'd have to spill the types out:
  updatedFiles.emplace_back(QPair<QString,QFileInfo>{translateDriveName(driveInfo),
                            std::move(driveInfo)});
  otherwise the clangd complains:
  Alias template 'QPair' requires template arguments; argument deduction
  only allowed for class templates

Task-number: QTBUG-115841
Pick-to: 6.5
Change-Id: I942459f039f6db23f7c1928fe758c6dbf339cd2b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 3cd69050ff3187dad8c3a9b50dcc9ac9d5b60f84)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-06 16:06:05 +00:00
Axel Spoerl
4ec05ee2ad QXcbWindow: protect access to m_mapped with a QMutex
QXcbWindow::requestActivateWindow() is called from the main thread,
while handleMapNotifyEvent() is called from the XCB event thread.
In a data race, handleMapNotifyEvent sets m_mapped to true, before
requestActivateWindow() checks if it is false and sets
m_deferredActivation to true.

If that happens, a window activation is skipped until the next window
systems event is processed.

This is harmless in a normal application environment, where each mouse
move causes window systems events to be processed. In an autotest
environment, it causes flakiness, because an expected window activation
may or may not happen.

As a workaround, QApplicationPrivate::setActiveWindow() is frequently
called after QWidget::activateWindow() or QWindow::requestActivate(),
to set the active window on application level. In essence, this is
setting expected outcome of a skipped deferred activation by force.

This patch protects access to m_mapped and m_deferredActivation with a
QMutex in both methods. That prevents the data race and ensures all
deferred activations processed.

Calling QApplicationPrivate::setActiveWindow() after activation on
window/widget level becomes redundant.

Task-number: QTBUG-119287
Pick-to: 6.5
Change-Id: I2eee69292afe0ef6381880a10d4e8483c2c7cbfa
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 2f6fe3a26843ff68c5d3f9af0a2fc3cce6caac22)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-06 16:06:05 +00:00
Axel Spoerl
36fadb4c13 QMainWindowTabBar: Add destructor
QMainWindowLayout re-uses tab bars. A QSet and a QList member are kept,
to track used and unused tab bars.

Corner cases upon application close down leave dangling pointers in
those containers.

=> Add a destructor to QMainWindowTabBar
=> remove the tab bar from used and unused tab bar containers, if
not directly parented to the main window.

=> No longer reparent unused tab bars of a QDockWidgetGroupWindow
to the main window. Let them be destroyed as a group window child,
and its destructor remove it from the used/unused tab bar container.

Pick-to: 6.5
Change-Id: If2388cf878553dc89583dbc8585748fad65bbab2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit b6b489db6968fbc3b4aab3755d0166ee09712ff0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-06 13:28:25 +00:00
Mårten Nordheim
80925cf84f ASN1: speed up parsing of certificate timestamps
By parsing QDate and QTime separately it will internally parse the
values as-if-by UTC. This means we avoid the overhead of figuring out
what the local timezone is repeatedly for each certificate.

On Windows, with Schannel, this brings QAsn1Element::toDateTime
from consuming more than 97% of the test time to below 10%.
The test being tst_QSslSocket::systemCaCertificates. It also goes
from taking 1 minute in debug, to 1 second.

As a drive-by: add a (currently) failing test for Feb 29 2000, which
fails because we decode the date as 1900 before adjusting it to 2000.
But there is no 1900-02-29, so it returns an invalid date. As spotted
by Eddy.

Pick-to: 6.5
Change-Id: Iefa73a01d710129faf6412c4fa8bc2b5d7c98bbb
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 731b759c00ce17072e3f93fdd7044490e51171ca)
2023-12-06 11:36:45 +01:00
Marc Mutz
23ea13f9d9 QTest::toPrettyUnicode: remove magic numbers
Derive them from the chosen output buffer size instead, itself a
symbolic constant.

Pick-to: 6.5
Change-Id: I33aa351ba358b106b448f886b92e952e53bc75f9
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Jason McDonald <macadder1@gmail.com>
(cherry picked from commit a14d3a49f0abed1d430edb96a272ca05a73f7dc5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-06 09:47:14 +00:00
Marc Mutz
5d2fab5663 tst_tostring: support computed expected values
We need an owning container to keep the data alive when the _data
function computes the expected value instead of passing it as a
literal string, so replace the QByteArrayView we used so far with a
const QByteArray.

If a test failed, print the tail ends of the failing strings. This
is useful when toString() implementations printing the operands of
the failed toString()-under-test result comparison decide to
truncate the output. It works around the fact that we both test
toString() and use toString() to report any failure.

As a drive-by, add a missing blank line between function definitions.

Amends a2551c45d496c23045eb8451e080e75b2f8b42c1.

Change-Id: I0b217aeb1a6d475df8e8b9fb821046f1cceb1a3e
Reviewed-by: Jason McDonald <macadder1@gmail.com>
(cherry picked from commit 3a57885c3766d4ae203650d60881988c374e4148)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-06 09:47:06 +00:00
Marc Mutz
754683dfe9 QTest: simplify toString(tuple)
Use C++14's std::index_sequence instead of our home-brewed
QtPrivate::IndexList. I used make_index_sequence<sizeof...(Types)>
instead of index_sequence_for<Types...> to avoid having to resolve
another type-dependent template alias.

Remove the helper's vacuous \internal qdoc block.

As a drive-by, rename the helper function to prevent it from
participating in QTest::toString() overload resolution, and
fix spaces around &.

Pick-to: 6.5
Change-Id: I5981a9b1a99fbe741e75820a6954d066ced9573d
Reviewed-by: Jason McDonald <macadder1@gmail.com>
(cherry picked from commit ba44a714067468684ffabe0c9f37bf1cb0785c3c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-06 09:47:04 +00:00
Timur Pocheptsov
6834089845 QSslConfiguration: remove example
It uses the ciphersuite name which smart tools one day will mark as
weak (i.e. https://ciphersuite.info/cs/TLS_DHE_DSS_WITH_AES_256_CBC_SHA/
in our example), names in the example are not in the standard notation,
+ it is and always was OpenSSL-specific example.

Pick-to: 6.5 6.2
Fixes: QTBUG-119464
Change-Id: Ic6f095ff2c861582de756bf220e2e74106b88e83
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 66a5f9fdd40485a4e64d447f84046698b7cacae3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-05 19:40:35 +00:00
Orkun Tokdemir
e4c396f254 _qt_internal_create_moc_command: Fix genex parse
The function was replacing the `>` character in generator expressions coming from `add_compile_definitions`. This was creating generator expression syntax errors. Discard generator expressions from character replacing.
Add tests for the three cases.

Amends 5bb745f62ba1aa63e4bbd107b279d96bd06dffda

Fixes: QTBUG-111717
Fixes: QTBUG-119716
Change-Id: I694d2908738085fdf15112834f20183a9f393422
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit bc0c44d4cd634c574307920968f0ab1bf6cd8305)
Reviewed-by: Orkun Tokdemir <orkun.tokdemir@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-12-05 17:32:16 +01:00
Safiyyah Moosa
dc86b61d77 Docs: Add stereoscopic example to OpenGL examples
This fix uses the \ingroup command to add the stereoscopic example to the
examples-widgets-opengl group.

I also elaborated on the hardware requirements.

Fixes: QTBUG-119280
Pick-to: 6.5
Change-Id: I6d5b992e533b897d84100f0f897aae97ef89290f
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
(cherry picked from commit 11c522495d40cca0d76e47cfd1a726d07d3a97ee)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-05 16:29:15 +00:00
Alexandru Croitor
c98a4863dd CMake: Fix Apple max sdk version check
We need to warn only when using a major version that is the next one
after the 'max supported version'.

Add an assertion that the max sdk version specified in .cmake.conf
needs to be just the major sdk version, without a minor or patch
version component, otherwise the '+1' math expression will fail.

Task-number: QTBUG-119490
Change-Id: Ib30abe7157c2ccbe0ad7a98e81fc241685a141a8
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit a0bdd2195f24d8a7d880ba506afc16b41337218e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-05 16:28:32 +00:00
Kai Köhne
68b0fca6eb Doc: Settle on 'function' instead of 'method' in QMAC documentation
Function is the more popular term in the documentation. Method is
also a tad confusing, because QCryptographicHash calls the algorithm
'method'.

Change-Id: I9922f837b04311a4ef45e1c6de6b8e12a32e4f1e
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
(cherry picked from commit b831693365b37cab0c4534776ac2f431283c6b2b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-12-05 16:28:24 +00:00