70431 Commits

Author SHA1 Message Date
Tor Arne Vestbø
c8ae8244b4 QObjCWeakPointer: Clear existing associated object on assignment
If the existing m_object is the same as the incoming object the
call to objc_setAssociatedObject in trackObjectLifetime will
release the existing WeakPointerLifetimeTracker after assigning
a new one, which means we'd clear the QObjCWeakPointer's object.

We now reset the state up front.

Fixes: QTBUG-132256
Pick-to: 6.8
Change-Id: If2c08840d465ae6d190c87a4720a537fe9caa8dc
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit 92012333d112dbdf2926117ec3bb123bd30ed9fc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-17 14:16:22 +00:00
Christian Ehrlicher
9b2e444811 QAbstractItemView: use 'int' as datatype for updateThreshold
... to sync it with the rest of the api.
This amends ff339819925ab550c48b53d9baaba43e5adebfaa.

Task-number: QTBUG-124173
Change-Id: I0ed4681bf7d3717f84a7e888affb0c8cae877c35
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 15a1ae90f5b6da3ffd50acda63ddd33ca14227f4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-17 10:52:59 +00:00
Marc Mutz
ee69826054 qthreadstorage.h: fix position of namespace macros
The file contains two implementations of the class template, one for
QT_CONFIG(thread) and one for without. Both are in the QT_NAMESPACE,
but each provided their own QT_{BEGIN,END}_NAMESPACE macro pair.

This is unneeded and may throw off scripts which use the macros as
insertion positions (like includemocs, which, however, operates on
.cpp files, not headers).

To fix, move the namespace macro pair to be around the #if
QT_CONFIG(thread) block.

Pick-to: 6.8 6.5
Change-Id: I56c1f9a4ef7df0fba54c72d8a213fa92573b826c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 8553ffd8d147ecf6a713d12a360027b477dd59c8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-17 10:08:46 +00:00
Yuhang Zhao
3c0986a34c Windows: Fix title bar size calculation
The title bar calculation is terribly wrong and was
missed during review.

Change-Id: I0c7a860e747465e6a5e4d8aa5415a9701cf170fd
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
(cherry picked from commit f6af3a581642170f0f4fe0d0563851715e045391)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-17 07:58:48 +00:00
Marc Mutz
9e86f73f82 QStringView: refuse construction from QStringRef
When QStringRef was moved out of QtCore, it was also incorrectly
removed from the if_compatible_container constraint, causing
QStringView{sr} to still match the general container QStringView ctor
overload, which doesn't preserve null'ness if data() doesn't return
null. By refusing to provide a constructor from QStringRef, we force
the compiler to use QStringRef's implicit conversion operators
instead.

This transitively affects QAnyStringView in the same way.

The tests can, naturally, only be in qt5compat, so define a macro to
communicate to tst_QStringRef whether it compiles against a fixed
QtCore or not.

Fixes: QTBUG-122797
Fixes: QTBUG-122798
Pick-to: 6.8 6.5
Change-Id: I64b75a8e421d2b6185615e3288ce3ad7fd8f15f9
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit a0e65398483729259cf58781949133c6055fdc7c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-16 20:44:29 +00:00
Volker Hilsheimer
cdfd686714 QSqlQueryModel test: don't copy a QSqlQuery
Move the query into the model, and use a local scope to make sure that
we don't use the moved-from query later.

Change-Id: I9d216e770733af8b0771280276dba0775209a802
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Dheerendra Purohit <dheerendra@pthinks.com>
(cherry picked from commit af760da54190d96b315ea8edeec00c86871af0d8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-16 20:18:13 +00:00
Tor Arne Vestbø
78051d03ca Document that QPlatformTheme::standardPixmap should always be a 1x pixmap
This reverts 59bbfb17db563d7e62b9f3158dab3cc6e7e68acd and
c853054910552f5fef04797222dde0d29a0c340d, as that approach
was causing issues for QCommonStyle::iconFromWindowsTheme,
for example in situations where the system has a 1x and 2.5x
screen, and the user requests a 16x16 pixmap or icon via
QStyle::standardPixmap or QStyle::standardIcon. In that
situation our smallest pixmap is 40x40, and we need to
downscale, causing blurred results on a 1x screen.

Change-Id: Ifa6e15d37d15954df689253c32eaa779885c567b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit d884abaf8bdc1be74ee52306948c0be1986d738d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-16 20:13:30 +00:00
Christian Ehrlicher
eab71ff6b0 Windows11Style: adjust subline color in editable widgets in dark mode
The color of the subline in editable widgets was black in light and dark
mode. Fix it to use white in dark mode to make it visible. Move it out
into own helper function since it's used in at least three places.

Pick-to: 6.8
Task-nubmer: QTBUG-131585
Fixes: QTBUG-131586
Change-Id: Icca2b142a1ce0c3d7f722baa6d3635bae5950e1c
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 66d42b62b6f01205cf1db72e56ecb5166554e373)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-16 20:13:28 +00:00
Christian Ehrlicher
07ad8c8444 QStyleOptionViewItem: document 'widget' and 'locale' member
These two members were added during Qt4 times but never documented.

Pick-to: 6.8 6.5
Change-Id: Ife4abfc6d8883f4c26ce5b95d5c0cfd3adcbd6bf
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
(cherry picked from commit a90d9f4823bd6baf4cb660a942c2b1695441dbbd)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-16 19:37:58 +00:00
Eskil Abrahamsen Blomfeldt
501f78855e Fix DirectWrite subpixel antialiasing on BGR screens
On monitors where the subpixel arrangement is blue, green, red,
our DirectWrite rendering would give the wrong subppixel
antialiasing, causing color fringes on text.

Like we do with Freetype, we determine subpixel arrangement of the
primary screen and use this as the default.

Pick-to: 6.8
Change-Id: I9ce7025449106a2376bd0ed02ce07b59c79438bd
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
(cherry picked from commit d5cef74d8d71458500f979c0d31a7241b3fef9db)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-16 19:37:56 +00:00
Eskil Abrahamsen Blomfeldt
bfb80b7b45 Support variation selector when emoji segmenter is disabled
This amends cb2633468413d8c2a9e28d4c4a10b25e90dd3116.

The patch excluded the ad hoc parsing of variation selector
except when Qt was built without the emoji segmenter. The
reasoning being that the emoji parsing handles this correctly
now.

However, when setting the QT_DISABLE_EMOJI_SEGMENTER variable
in the environment, this is supposed to work as a fail safe
which gives you the original behavior, in case there are
regressions. Therefore, the variation selector handling needs
to be run also when this environment variable is set.

Change-Id: I2669d29016a552775461aad13e50459baecdc26f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit aaf7437db3a520ab14220a46cf9427cb9a8d915c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-16 19:37:55 +00:00
Eskil Abrahamsen Blomfeldt
f5e2166bbd DirectWrite: Remove ad hoc font resolution through GDI
In b8612eaa2a17e12e31ee28141cff1fb43e54c00e, we added a fail safe
where failure to find the font name through DirectWrite would
try loading it through GDI instead and if that was successful we
would register the family with the database after all.

However, the code assumed that CreateFontIndirect() would return
NULL if the font did not exist. It does not do this, but instead
selecting the HFONT on the HDC will give us a suitable alternative
instead. The result would be that any missing font family would
be registered with the font database through this mechanism, even
if it really didn't exist.

This code was added in an early version of the patch, however,
and it should not actually be needed anymore, since we in later
versions of the same patch also added logic to populate the
GDI-compatible family names
(DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES etc.). This should
take care of backwards compatibility with the GDI names for fonts.

Since the code has been reported to cause problems on some systems,
it's safest to just remove this hack.

Pick-to: 6.8
Task-number: QTBUG-130313
Change-Id: I7eca893d17796d9cac07391b7b947d28dd7cd920
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 355f54f7d5dd300c73bf203f12e24305d0e227c1)
2024-12-16 15:24:24 +01:00
Andy Shaw
9988cd2469 SQLite: Fix attrition file to have right version number
Pick-to: 6.8 6.5 5.15
Change-Id: I9fea5c8d19209c44b16916645e600735de929d80
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
(cherry picked from commit 311ac55f118dc88add297853318cd0cfd7c1c0d5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-16 07:13:13 +00:00
Assam Boudjelthia
440dcaca27 Android: handle quotes in hard-coded namespace in build.gradle
Remove quotes from the namespace values if they're set
directly to build.gradle.

Fixes: QTBUG-132150
Pick-to: 6.8
Change-Id: I7f5e132c2600bf5079850c99dc500b1dff7e6a96
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 60f78212379ba2b4a7a9bfadc5088a60309e923c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 18:29:03 +00:00
Magdalena Stojek
7ab145a9ef Output both global and local data tags in benchmark result header
Modified QPlainTestLogger::printBenchmarkResultsHeader() to
concatenate and display both global and local data tags, in
the benchmark result header, in the format `global:local`.
If only one tag is available, it is printed alone.

Pick-to: 6.8 6.5
Fixes: QTBUG-127522
Change-Id: Ic9f3c712ef3f6858aad2546b80d8867ce860b644
Reviewed-by: Matthias Rauter <matthias.rauter@qt.io>
(cherry picked from commit 95f02adf756d1ae485f39a060c6f23a5af3f64ee)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 18:04:39 +00:00
Michael Weghorn
b5ba125fa0 QMenu: Accept accelerators typed on keypad
Add Qt::KeypadModifier (and the combination with Qt::AltModifier) to the
modifiers that may be set in a key event in order to trigger a menu
action via its accelerator.

Otherwise, an action that has a number set as the accelerator (e.g.
using text "&1 Exit"), cannot be triggered by typing the corresponding
number on the keypad.

Fixes: QTBUG-73390
Pick-to: 6.8
Change-Id: I0fa63b0c5f23823c61e159fcc72f7245215f8aae
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit ca4334bc966c7e5f9997f98b83afe37eb8b1d3ba)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 17:20:11 +00:00
Christian Ehrlicher
c437c6a4f6 Style: pass widget to styleHint() where appropriate
QStyle::styleHint() take the QWidget as optional third parameter. Add
this to calls to styleHint() where appropriate.

Fixes: QTBUG-2501
Pick-to: 6.8
Change-Id: Id4e4158cc889236064f2f618495608736607d457
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit aa341ecca816e3503a834ffde0ec6cb817139427)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 16:46:27 +00:00
Thiago Macieira
ff303c5cd9 QMutex/FreeBSD: mark the functions as noexcept as it always has futex
See qfutex_freebsd_p.h.

Pick-to: 6.8
Change-Id: I7e7bbb8387ae2e7b0c39fffd65c7b03e3a65a853
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit c1bc98da02f0f9335e10f45cc5df4c7e3afcee31)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 16:40:35 +00:00
Fabian Kosmale
510f8005bc moc: Always indentify as moc
External tools might rely on the output of "moc --version" to identify
moc, and, depending on how robust their parsing is, could break if the
reported name does not equal "moc".

Explicitly set the application name to moc, so that even if the moc
binary gets renamed and invoked via a symlink, it will still correctly
identify itself.

This might help with both binaries from the Qt Company's installer, as
well as with distros which rename moc to moc6.

Pick-to: 6.8 6.5
Task-number: QLS-1605
Change-Id: Id85e2ffa17d445213da0b37e7bd038d7b68e2c2a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit 47be32b761ea6e1f2c1bfa9dd9eb38846ce2fd45)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 16:40:35 +00:00
Thiago Macieira
e9509291ae QSharedMemorySystemV: fix shm vs sem typo
Fixes: QTBUG-132053
Pick-to: 6.8
Change-Id: Ia4f2bdc8edff91020f13fffd79261a9feaf2f496
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 902058e750e67bbfb166db576c538b7add9be08f)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 16:40:35 +00:00
Thiago Macieira
7664b826db QMetaType: remove the temporary QMetaTypeTypeFlags compatibility
Amends 44876fb45e702c2554fca98ed19af57feb1c0511.

Change-Id: I5ea354bcb6847e996081fffd012130562999d5c4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit e48fe10e541c6dec9db4226f8ad02728de7b0e02)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 16:40:34 +00:00
Ivan Solovev
8bd0625f54 [docs] Add QSpan details to overview of C++20 features
Document that QSpan exists because we cannot use std::span, and
explicitly point to the differences between QSpan and std::span.

Task-number: QTBUG-128837
Pick-to: 6.8
Change-Id: I54f406e3306ee1da136107323887f0c87f94ff9b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 083ebfa1a5cb16b0b62ae5b5855a602b2f9ba818)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 16:40:34 +00:00
Eirik Aavitsland
4d009678ce Fix in-place conversion of certain QImage formats
In the copying/transcription of the generic converter to the generic
in-place converter, a test for Format_RGB32 destination format was
mistakenly replaced with test of source format. The result was that a
suboptimal pixel store function was selected, and the resulting image
data could end up with non-0xff in the unused alpha field.

Task-number: QTBUG-132051
Pick-to: 6.8
Change-Id: If3ebf5fdd7ab6e377c8ad479ea38ce665f922b7c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
(cherry picked from commit 0ace5ba0357b1614b47cb38a16f4afb2fe8e62db)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 16:40:34 +00:00
Edward Welbourne
e2a0ef30da Fix assertion failure on parsing Feb 29 in a non-leap year
If there's no way to resolve an actual date with the data parsed, then
the date-text given is invalid, so don't try to fix it up.

Pick-to: 6.8 6.5
Fixes: QTBUG-132115
Change-Id: Ic6821bd01394d4dba1be1d25806c372800f8176b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 72519aeb237a4085aeb6290b0b4088c690fad106)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 16:40:34 +00:00
Mårten Nordheim
d53feb3da2 QHash: fix small performance regression when detaching with resize
There are two QHashPrivate::Data constructors (and two overloads of
::detached()). Initially the Data ctor that takes a new size always
assumed a resize was happening, and any place where there _may_ be a
resize we would usually detach then rehash.

In an effort to avoid the detach+rehash and instead call detach(d, size)
without the performance overhead of rehashing the call to
reallocationHelper() in this overload of the ctor was changed to verify
that a rehash was actually needed. This had the unfortunate side-effect
of making the compiler no longer inline the reallocationHelper()
function, and it no longer expanded the if-expression with the constant
so it was doing a tight copy-loop with a potential branch in the middle.

In this patch we revert that and make the bool a template argument to
highlight that it should be a constant for better performance (but also
leaving a comment.) Also mark it Q_ALWAYS_INLINE, it has two uses and
they both take advantage of the inlining + expanding the expression.

In theory this might have had an impact on QHash::reserve() calls,
though this code is only relevant when reserve() would cause growth so
the performance regression would hopefully be small compared to all the
other work that would also be needed.

Reverts 45c137d797a85c694897e8b1c5099abacc16e2f5

Pick-to: 6.8
Change-Id: I0d2076a9ded8ca816c54d6ce42d472a23bcbc9fd
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 6c8b6acc894e47a37c4fb443316d9c40d35a144c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 16:40:33 +00:00
Edward Welbourne
7baf9d06b5 Fix typos in qstring.cpp (noticed while reviewing other changes)
Pick-to: 6.8
Change-Id: Ief8a9c429b5cdf424e0c3a57d15b1fcb4fdc963c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 5d5c8d277af77cba069b805074551254c0f0d9c7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 16:40:33 +00:00
Mårten Nordheim
9d7fabb6c2 QHash: call the different detached() overloads depending on resize
Instead of using just the detached() overload taking a new size, call
the two un-sized one when not resizing. The unsized overload is faster
because it is inlining the reallocationHelper() function and expanding
a branch by way of a constant.

And drop the call to rehash in the !isDetached case, if we enter this
branch we willfully 'attach' the detach guard to keep the key and values
alive.

Follow-up change will fix the sized detach() to use a constant again.

Amends d9ad2251d9fff85a18ce5afc62bcb1230cd2820d

Change-Id: Ia1640766b898610d12b5df20d83cefe5ca2d4c36
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit ac2b0b958e97c41b38c42c0789d91de724d567ce)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 16:40:33 +00:00
Marc Mutz
51bfc9da41 Q{Any,Utf8}StringView: fix construction from arrays of unknown size
Like QStringView's, these classes' documentation promised
is_constructible<View,Char[]>, but failed to deliver, because neither
the (const Pointer&) nor the (const Container &) compile for arrays of
unkonwn bounds, and the (const Char*) one is just a QDoc fake.

Apply the same fix as for QStringView: Add a ctor specifically for
arrays of unknown bound, delegating to the (ptr) overload.

The GHS compiler doesn't like the CanConvert static_asserts, so
comment them out for it. The functionality itself is tested by
the from*ArrayWithUnknownSize tests.

[ChangeLog][QtCore][QUtf8StringView/QAnyStringView] Made construction
from arrays of unknown size compile. Such arrays will use the const
Char* constructor, determining the size of the array at runtime.

Pick-to: 6.8 6.5
Fixes: QTBUG-112746
Change-Id: I7acdcae3c5bdf80a0bed673e621d53ef34a92a1e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 734bd05d0a6d37d6488cf8d1b2b9f79b9329d966)
2024-12-13 14:31:08 +01:00
Marc Mutz
1f0dc7635e QLatin1StringView: put qstringfwd.h in control of Q_L1S_VIEW_IS_PRIMARY
Less duplication, matches what we do for q_no_char8_t namespaces, too.

Amends 94addad4dd1c89df9c6820d34b9a90424456c492.

Pick-to: 6.8 6.5
Change-Id: I5d98babcb66d1196d3aed31c33289a1b11212a3d
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 2d2ee569421338dbc07a479a7df2531bd37f0ebe)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 11:27:53 +00:00
Marc Mutz
137da0326a QStringView: use qstringfwd.h
... instead of fwd-declaring a bunch of stuff manually.

Also move the fake QDoc decalaration of a "class QUtf8StringView"
over.

Pick-to: 6.8 6.5
Change-Id: I80bc3240d69f69602c127fc0e8fe694dd46765f1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 8404c21152ed3e28f8e00d683a494a8e1e25a69a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 11:27:47 +00:00
Ulf Hermann
60d28c8c7c Android: Fix some warnings
Use a static logging category where possible, and check the return value
of QFile::open.

Change-Id: Ieda9f7874d1b88d9bfeb593243eb867d0c274e9f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit e0ef713a2c6a74fe574481e98f0a582819418ed0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 11:27:42 +00:00
Marc Mutz
e076767bfd qstringfwd.h: don't include qglobal.h
qstringfwd.h is supposed to be a lean header, dragging in all of
qglobal.h perverts the purpose.

This also helps with certain circular-dependency issues that
appeared when attempting to use this header in other low-level
headers.

Amends abe3b4c9b947de5e55085b37840e0d1d6f3aae42.

[ChangeLog][Potentially Source-Incompatible Changes][QtCore] The
qstringfwd.h header no longer includes qglobal.h. A
backwards-compatible fix is to include qglobal.h yourself instead of
relying on the transitive include.

Pick-to: 6.8 6.5
Change-Id: I1726fccfd13b3a058abaf800c1bbf02c320143a4
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit 5def8ff180c67f288bdc6e3c05b96940aeae37c0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 11:27:41 +00:00
Kai Köhne
c76b845d90 Doc: Fix links to QIODeviceBase:: flags
Pick-to: 6.8
Task-number: QTBUG-131484
Change-Id: Iee545986d4fb4765086fecce6532092d4b691ae8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit d3dad28a51743bb408dee1cf997646a89eb6693b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 09:10:52 +00:00
Kai Köhne
604dcc714a Doc: Improve QTemporaryFile::open() descriptions
Explain the behavior of open() in detail, including the edge
cases (reopening a file). Fix links to QIODeviceBase::OpenMode
flags. Use explicit links to make linking more robust. Use
the same parameter name 'mode' as in the base class.

Pick-to: 6.8
Task-number: QTBUG-131484
Change-Id: I5d01b3bb48a7a439b93c144e6d38482607de8d33
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit adaf1fb107ceb7003313ceb67605f986b74763b1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 09:10:46 +00:00
Kai Köhne
b70e61788f Doc: Improve QProcess setStandardOutputFile description
Fix links to OpenMode flags. While at it, make links explicit so
that future changes breaking implicit linking will cause errors.

Pick-to: 6.8
Task-number: QTBUG-131484
Change-Id: I20b80014eadcbcba6ebebab1ff4db4c345dd434a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 4e85a4f401118f2f7330b673e45b4a0399825ef3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 09:10:39 +00:00
Kai Köhne
5d2f40a14b Doc: Improve QBuffer::open description
Explain the method, instead of just linking to the base method.

Call the argument 'mode' instead of 'flags', like it is done in
the base class.

Force the mentioned QIODeviceBase flags to be links. Use fully
qualified name for the first flag mentioned, but use the short form
for the rest to improve readability.

Pick-to: 6.8
Task-number: QTBUG-131484
Change-Id: I8e9668ffc095ec261e2be54a2dcf16a32e4cb441
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 334460407b7cde1cdab5cfe5abe00175893749c3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 09:10:33 +00:00
Kai Köhne
eb44663eaa Doc: Improve QFile::open description
Force the mentioned QIODeviceBase flags to be links. Use fully
qualified name for the first flag mentioned, but use the short form for
the rest to improve readability.

Mark true and false to be written in code style.

Task-number: QTBUG-131484
Pick-to: 6.8
Change-Id: Iebb0f9c6df382327bc5980e9e06c11deb6658291
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 647bee67150dedbd2a9fd2ddcd265d535e8fd8cf)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-13 09:10:27 +00:00
Marc Mutz
83e18b6540 qstringfwd.h: add missing QString fwd decl
qstringfwd.h should probably fwd declare QString, too :o

Amends abe3b4c9b947de5e55085b37840e0d1d6f3aae42.

Pick-to: 6.8 6.5
Change-Id: I80558c92d1144ead0aade410a8b1810713fed701
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit bc4105c843f666eaeaaa44b5a1f897ffa5824ec7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 20:10:54 +00:00
Marc Mutz
df2f31b9bf qsocketnotifier.cpp: un-break -unity-build
qsocketnotifier.cpp is using a #define to activate a second overload
of QSocketNotifier's activated() signal.

In unity-builds, this overload becomes visible to other TUs and breaks
new-style connect()s¹. In PCH builds, the define comes too late (the
qsocketnotifier.h header was already included by the pch header,
without the define).

Fix by adding qsocketnotifier.cpp to NO_PCH_SOURCES (thereby to
NO_UNITY_BUILD_SOURCES, too).

¹ and the signal's use of QPrivateSignal makes disambiguation by
  qOverload(), or assignment to a function pointer, impossible.

Amends 487dd80bce9c6006f349ccb09222e1c308200f0a(!).

Pick-to: 6.8 6.5 5.15
Change-Id: I40ca3b90f7ecc3116ae78dc952583efa299bcedb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit a38cebfe23674bb459eed6bbbcac965ebf2b6075)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 20:07:29 +00:00
Marc Mutz
e8605372ba qsettings.cpp: really un-break -unity-build
The use of Space was still ambiguous. Says GCC 14:

  qsettings.cpp: In static member function ‘static bool QConfFileSettingsPrivate::readIniLine(QByteArrayView, qsizetype&, qsizetype&, qsizetype&, qsizetype&)’:
  qsettings.cpp:1564:82: error: reference to ‘Space’ is ambiguous
   1564 |     while (lineStart < dataLen && (charTraits[uint(uchar(data.at(lineStart)))] & Space))
        |                                                                                  ^~~~~
  In file included from unity_0_cxx.cxx:277:
  qjsonparser.cpp:217:5: note: candidates are: ‘<unnamed enum> Space’
    217 |     Space = 0x20,
        |     ^~~~~
  qsettings.cpp:1523:8: note:                 ‘SettingsImpl::<unnamed enum> SettingsImpl::Space’
   1523 | enum { Space = 0x1, Special = 0x2 };
        |        ^~~~~
  qsettings.cpp:1605:71: error: reference to ‘Space’ is ambiguous
   1605 |                 while (i < dataLen && charTraits[uchar(data.at(i))] & Space)
        |                                                                       ^~~~~
  qjsonparser.cpp:217:5: note: candidates are: ‘<unnamed enum> Space’
    217 |     Space = 0x20,
        |     ^~~~~
  qsettings.cpp:1523:8: note:                 ‘SettingsImpl::<unnamed enum> SettingsImpl::Space’
   1523 | enum { Space = 0x1, Special = 0x2 };
        |        ^~~~~

Fix by making Space and Special local aliases (contexpr variables)
instead of importing the whole SettingsImpl namespace.

Amends 4ff65f0e5615b1132ec13c6eeba3647162d8dd0f.

Pick-to: 6.8 6.5
Change-Id: I9e8f2422885121fb02938261fbae6231e62ae46d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit 057defe283f1db5fa9dfb1d8183b94d441c3707b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 20:07:22 +00:00
Marc Mutz
00f6df326f qresource.cpp: fix -unity-build
GCC 14 complains:

  In file included from unity_0_cxx.cxx:121:
  qresource.cpp:283:7: error: ‘QResourcePrivate’ has a field ‘QList<{anonymous}::QResourceRoot*> QResourcePrivate::related’ whose type has internal linkage [-Werror=subobject-linkage]
    283 | class QResourcePrivate {
        |       ^~~~~~~~~~~~~~~~

(Hot-)fix by adding qresource.cpp to NO_UNITY_BUILD_SOURCES.

Amends fe6dda9bb9310878b408b2421f60acb7135bd8ba.

Pick-to: 6.8
Task-number: QTBUG-132114
Change-Id: Ic414d1cf9e4dad94d4263b3657d31df896c4e417
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 57fab6a1c2df8f52b25f6db4017bb3acfa8e0526)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 20:07:16 +00:00
Marc Mutz
06a209384a tst_QString: extend arg() tests with enums w/o explicit underlying_type
The QtDeclarative code causing QTBUG-131906 hits UB, because it tries
to store -666 in an enum {A, B}, which has a valid range of [0,1],
therefore its underlying_type is uint, yet, as per [conv.prom]/3¹,
integer-promotes to _int_ instead, so in Qt 6.8 would cause the
arg(int) overload to be called, outputting -666, while in Qt 6.9, it's
treated (correctly) as an unsigned value, outputting -666's two's
complement, a positive value.

Add a version of the scenario that does not cause UB.

¹ Thanks to Ahmad Samir for digging up the pertinent legalese.

Task-number: QTBUG-131906
Pick-to: 6.8 6.5
Change-Id: Iba1a04de523a0b4cd1c87deea40c643cf16df14f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit e64fd05fecae291c9d7358d2e47d7170995af256)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 20:07:12 +00:00
Thiago Macieira
b143215c54 QString: update docs to prefer "UTF-32" over "UCS-4"
They are now the same, but the name UTF-32 is preferred over UCS-4.

The original ISO-10646 UCS-4 encoding was allowed to use all 31-bit code
units, from 0 to 0x7FFFFFFF[1] including those above 0x10FFFF, which
correspond to UTF-8's five- and six-byte sequences. Unicode doesn't
allow that and restricts the UTF to the range possible in UTF-16.

Renaming the functions is left as an exercise for the reader.

[1] https://en.wikipedia.org/wiki/UTF-32#History

Pick-to: 6.8
Change-Id: I2f29db62b974cb689585fffd9a6434ae252a7651
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit 973d0c4c5160200c188f81da5df064510315f22d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 19:38:25 +00:00
Marc Mutz
31e3012296 tst_QStringView: verify that char16_t[] args aren't ambiguous for QS/QSV overloads
They are not.

Pick-to: 6.8
Task-number: QTBUG-112746
Change-Id: I2a20d68543f5914690acbcb4f214b1d98681de6a
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
(cherry picked from commit 67990c16a6b631c1d809d1ad656fc941293b3f83)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 19:38:23 +00:00
Thiago Macieira
bb91219b26 QString::fromUcs4: use std::char_traits or wcslen() to find the size
... when the user passes size = -1. std::char_traits<char32_t>::length()
doesn't appear to be an any better implementation than our simple loop,
but maybe some compiler will optimize it.

wcslen() is usually optimized in the C libraries, even for Unix
platforms that hardly ever use it (it's used as a fallback in qustrlen()
for non-x86 Windows systems).

Pick-to: 6.8
Change-Id: Ia143270869a3a7cf5754fffdc17e500fc454397b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
(cherry picked from commit b98cf4fc4afaf55145c34ba06d61fec38fadc25d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 19:38:19 +00:00
Marc Mutz
2dfc0cb6f6 QStringView: fix construction from arrays of unknown size
The original idea (8b5aa7b6c40d70a7ec15b3ea485f28a142fb247c) of the
separation of array and pointer ctors was to determine string literal
sizes at compile-time in C++11's limited constexpr semantics.

But when the scanning for NUL characters was added to the array ctor
in 107ff4c1d6b5da2cb11c65b2bd9106817f7fdb02, the distinction between
the two ctors became meaningless, because we were able to assume
post-C++11 constexpr to make the Char(0) scan a compile-time action.

Finally, 9e1dc1e8a9fda1a7576cc6377c8a36decff631eb removed the array
ctor in favor of the generic Container ctor. I didn't check whether
the old code handled arrays of unknown size, as in

    extern const char16_t str[];
    QStringView sv = str;
    ~~~
    const char16_t str[] = "str";

but std::size() (and therefore if_compatible_container) surely bails
on such arrays, and if_compatible_pointer also SFINAEs out. As a
consequence, such arrays cannot be used to construct QStringViews atm.

Fix by adding a new constructor for arrays of unknown size, delegating
to the existing pointer overload.

The GHS compiler doesn't like the CanConvert static_asserts, so
comment them out for it. The functionality itself is tested by
the from*ArrayWithUnknownSize tests.

[ChangeLog][QtCore][QStringView] Made construction from arrays of
unknown size compile. Such arrays will use the const Char*
constructor, determining the size of the array at runtime.

Pick-to: 6.8 6.5
Task-number: QTBUG-112746
Change-Id: Ifdb217350d93d38f081c99f14661975491d32076
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 56faffd92bf0ac459a921ec043a6f3b3dba51acc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 19:38:16 +00:00
Ulf Hermann
2a512fd901 Use inline namespaces rather than "using" for logging categories
Amends commit fa4bd30caa079a3b1e5eac1bb4f17365f456b8f9.

Fixes: QTBUG-132111
Change-Id: Iad7969a1841b8cea162e4b0e6624d02313618ef1
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 529ebb31702e8465a9ba42f4c56c749cb7bf7b75)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 19:38:16 +00:00
Marc Mutz
443bdb9620 tst_QAnyStringView: complete Char[] CanConvert sets
Other view tests test Char[N] and const Char[N] separately. Do the
same here.

For many Char types, the array CanConvert test was missing
completely. Add them.

Pick-to: 6.8 6.5
Change-Id: I1d0b6de394d548554a547f190e74cb8cead6ecd4
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 0bbbbfc78beb2393ceea0de0fa85942f71d0a2ed)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 18:21:54 +00:00
Ahmad Samir
149150ab47 QtSql: fix GCC -Wextra-semi warnings after member function definitions
Pick-to: 6.8
Change-Id: I5b65f543d7a36386181e493d8b9ce0267132d686
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
(cherry picked from commit 291c762802a2f5e1edb6bd9a842663ca5689323a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 18:21:51 +00:00
Marc Mutz
29e2695676 tst_QStringApiSymmetry: test QByteArray(weak)/QByteArrayView overloading
Adding it here since this test case already has all the infrastructure
for the overload test.

Pick-to: 6.8 6.5
Change-Id: I2d7fff9d2d82fed3db2446690a354f939c9a37fc
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 140dac92f2a8ee1f54843f69be4026900a049ee7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2024-12-12 18:21:48 +00:00