Commit Graph

41081 Commits

Author SHA1 Message Date
Marc Mutz
80b6bcc385 Short live Q_CONSTINIT!
It expands to the first available of

- constinit (C++20)
- [[clang::require_constant_initialization]] (Clang)
- __constinit (GCC >= 10)

Use it around the code (on and near static QBasicAtomic; this patch
makes no attempt to find all statics in qtbase).

[ChangeLog][QtCore][QtGlobal] Added macro Q_CONSTINIT.

Fixes: QTBUG-100484
Change-Id: I11e0363a7acb3464476859d12ec7f94319d82be7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-26 17:15:02 +01:00
Marc Mutz
edb64351cd QDom: preserve empty CDATA sections
Restores Qt 5 behavior.

Fixes: QTBUG-101992
Pick-to: 6.3 6.2
Change-Id: I3b9fc077c0a0fd30f4fcce7bfa342dbe96b2c582
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-26 12:01:14 +01:00
Marc Mutz
64db79f856 QDom: remove uneeded toString()
The trimmed() function is available on QStringView, too.

Pick-to: 6.3 6.2
Change-Id: I0cfde56d910da5abbebfb57396b22a1d21bdf763
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-03-26 12:01:03 +01:00
Sona Kurazyan
b625195893 QtCore: Replace remaining uses of QLatin1String with QLatin1StringView
Task-number: QTBUG-98434
Change-Id: Ib7c5fc0aaca6ef33b93c7486e99502c555bf20bc
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-26 01:44:05 +01:00
Sona Kurazyan
73a03a0c29 QSettings: fix formatting to match our coding style
Change-Id: I5cde2498e6423284f8abec7e717f262b6ea9eed8
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-03-26 00:46:04 +01:00
Sona Kurazyan
753a08ae0e QtCore: replace QLatin1String/QLatin1Char with _L1/u'' where applicable
As a drive-by, did also minor refactorings/improvements.

Task-number: QTBUG-98434
Change-Id: I81964176ae2f07ea63674c96f47f9c6aa046854f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
2022-03-25 19:16:29 +01:00
Jarkko Koivikko
1fefff6d1f Android: Keep the ParcelFileDescriptor open for content uris
Detaching fd and closing the ParcelFileDescriptor prevents IO with the
services like Google Drive on Android.

Instead, the file system should keep the ParcelFileDescriptor open while
the IO operations take place and close it manually. Also, prevent Qt
from closing the handle for us.

Pick-to: 6.2 6.3
Fixes: QTBUG-101996
Change-Id: Ie54c04ad5aa1e7ee5444a04c30ac1323f73047bb
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-03-25 19:06:53 +02:00
Edward Welbourne
eda8b7b4da Enable QIcuTimeZonePrivate's support for transitions
The support was previously limited to ICU version 50, with an == check
rather than a >= one, accompanied by a TODO comment to check whether
the API was stable at 51. Nine years have passed since ICU 51 was
released, we're now up to release 70, and now I've finally verified
that the API is stable (and fixed a few bugs in how we use it). So
change the check so that we now do use the transition API.

Fixes: QTBUG-99747
Pick-to: 6.3 6.2
Change-Id: Ica024b6c28a213e0de0a37f196839e8ded193889
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-25 17:04:38 +01:00
Edward Welbourne
934b528715 Fix QIcuTimeZonePrivate::data() before the first transition
Provide valid data, since ICU can, by the means we used before the
transition API was introduced.

Task-number: QTBUG-99747
Pick-to: 6.3 6.2
Change-Id: I4d4a1201db2255b98901dacb83169ae4ae25ef05
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-25 17:04:38 +01:00
Edward Welbourne
d9602efe88 Fix QIcuTimeZonePrivate::hasDaylightTime() to catch historical DST
QTimeZone::hasDaylightTime() is documented to return true if a zone
has ever dabbled in DST, but the ICU implementation was only detecting
whether the zone currently engages in it. When the transitions API is
available (currently for version == 50; will soon change to >= 50),
use it to find out whether DST was ever in effect.

Task-number: QTBUG-99747
Pick-to: 6.3 6.2
Change-Id: I4576de2e074dc57b54450b1e40a23358ccf0ef49
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-25 17:04:37 +01:00
Edward Welbourne
845eabb314 Fix ICU's handling of last representable transition
ICU's search for next transition, when the result would lie later than
is representable by qint64, returns the last transition before the
bound, even if this is at the time it was meant to exclude from the
range searched. This lead to infinite looping when we tried to
traverse transitions forward. Recognize when this happens and return
the invalid data object that indicates falling off the end of time
instead.

Task-number: QTBUG-99747
Pick-to: 6.3 6.2
Change-Id: I1a210fb7a4086b2fdb052b2260c800bfc29f965a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-25 17:04:37 +01:00
Edward Welbourne
9e01a9a5d1 Apply the East-Saskatchewan exception to zone-fragment lengths to ICU
The exception was previously limited to Android, but I now find that
ICU has the same over-long names; it seems likely that's where Android
gets them. Also update the link to the theory page from the TZ DB, as
it now has an official home on www.iana.org.

Task-number: QTBUG-99747
Pick-to: 6.3 6.2
Change-Id: I9af67426d15609dfaf5f335405ceb1218fcf40ff
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-25 17:04:37 +01:00
Edward Welbourne
460d7c8780 Avoid overflow in some more qdatetime.cpp functions
One multiplied TIME_T_MAX * MSECS_PER_SEC despite knowing this to be
too close for comfort to the bounds of qint64; but the comment
indicated it should have been using a 32-bit signed max in place of
TIME_T_MAX. Two others simply neglected to check for overflow.

Also use QRoundingDown::qMod() in one place to avoid needlessly
complicating arithmetic; and assert, in another, that we were never in
danger of overflowing anyway (thanks to an earlier isValid() check).
Restructured QDateTimePrivate::zoneMSecsToEpochMSecs() in the process
of catching its potential overflow.

Change-Id: I429321d90246ba922cccf09a4f028f03a514cb6b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-25 17:04:37 +01:00
Edward Welbourne
131c7009fa Fix char/uchar comparison warning in toPercentEncoding
This amends commit 5291dc7dcf

Change-Id: Icdd9562f74a4de0323ba8fef558958af41eeb5a1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-25 17:04:37 +01:00
Volker Hilsheimer
71b3d18ea7 Notify about focus object changes upon widget destruction
If the active QWidget gets destroyed, then QWidgetWindow::focusObject
will return nullptr. If then no other object takes focus, then we'd
never emit change signals, and QGuiApplication's _q_updateFocusObject
(which then informs the input context and emits signals) didn't get
called. This left the input context with a dangling focus object
pointer, which resulted in crashes.

If the QWidget clears its focus, but the corresponding window doesn't
know that it had focus, then fall back to the widget's focus widget
to see if we have a change in focus, so that signals get emitted.

Add a test case that shows that we didn't call _q_updateFocusObject
by counting emissions of the QGuiApplication::focusObjectChanged
signal, which we emit in this function. The signal is emitted more
than once both when showing a widget, and now also when destroying
a widget that has a focus child. The former is a previous issue,
the latter is an improvement to not emitting the signal at all.

Pick-to: 6.3 6.2
Fixes: QTBUG-101423
Fixes: QTBUG-101321
Change-Id: Ib96a397211d442f52ce795a3eebd055a0ef51b0d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-25 17:04:37 +01:00
Alexey Edelev
d6919b073a Pass ANDROID_SDK_ROOT and ANDROID_NDK_ROOT variables to external projects
The path to an Android toolchain is set to the one is used on CI by
default. To rewrite it user need to set ANDROID_SDK_ROOT and
ANDROID_NDK_ROOT variables. But these variables are not propagated to
the per-ABI external project, so they cannot locate the Android
toolchain file correctly.

Fixes: QTBUG-102041
Pick-to: 6.3.0 6.3
Change-Id: Ic30a3298518af93718f5422402edd5e0715ea135
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-25 16:19:20 +01:00
Topi Reinio
62a26df2ff Doc: Add \relates command for documented global functions/macros
Global functions need an associated header file/class/namespace to make
the documentation visible.

Remove QDoc comment tag (/*!) for an internal function.

Pick-to: 6.3
Task-number: QTBUG-99578
Change-Id: Id390d433d7e081fc90fa57a02097b6c37fa13bee
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2022-03-25 16:19:20 +01:00
Tor Arne Vestbø
27f6c4106c Remove mention of Q_GLOBAL_STATIC being more thread safe than local statics
As of C++11 local statics are guaranteed to be thread safe, so this
advantage doesn't hold anymore.

Pick-to: 6.2 6.3
Change-Id: I9ac34b8af30e44ff8134e5f81f45c8aa0f8ddcc9
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2022-03-25 16:19:20 +01:00
Allan Sandfeld Jensen
328ab29c25 Avoid fetching destination when not used
Previously this optimization would only trigger if all spans were opaque,
with this change it can also trigger with singular spans.

Change-Id: I79f362072ece7b6082463d32fc91000d5ff319b5
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-03-25 12:52:59 +01:00
Mike Achtelik
5677d79bf2 iOS A11Y: Set more accessibilityTraits
Set traits for roles that have a direct mapping between QAccessible::Role
and UIAccessibilityTraits. This allows the screen reader to pick up on
them and give additional info e.g. for links.

Pick-to: 6.3 6.2 5.15
Change-Id: I0f85e525fef390dcdf1ea664a0d325ce54f5b25b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-25 11:53:54 +01:00
Sona Kurazyan
76a1c060ac Always cancel unfinished QPromises on destruction
If the QPromise is being destroyed, we should signal the associated
futures to stop waiting. No matter in which state the promise is, if
it's not finished, we should always cancel to avoid infinite waits.
This is also what docs state:

"The promise implicitly transitions to a canceled state on destruction
unless finish() is called beforehand by the user."

Fixes: QTBUG-101284
Pick-to: 6.3 6.2
Change-Id: I65ebfefe03b79b41afacda78a4f49938c54d8b37
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-25 08:05:12 +01:00
Tim Blechmann
837bfd6f14 cmake: skip unity build inclusion of generated resources
generated resource files contain static variables like
`qt_resource_data`. if multiple resources are included in unity builds,
we end up with name clashes, so we should exclude them

Change-Id: I8cbe73a9e3ce3808a142b7cb6315355a7d4161db
Pick-to: 6.2 6.3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-25 12:02:14 +08:00
Giuseppe D'Angelo
7d8150da4c QVariant: disable building from arbitrary pointers
The QVariant(bool) is an extremely dangerous catch-all for all sorts of
things that may convert to bool, including arbitrary pointers. Delete
the corresponding constructor, in order to force users to use the
(correct) construction using fromValue, and/or to prevent bugs
altogether. This is technically speaking a SiC, but one of type A -- if
pointer to bool was intented, just do the conversion explicitly.

[ChangeLog][QtCore][QVariant] QVariant used to be constructible by raw
pointers through a conversion towards bool. This is now illegal. If such
a conversion is needed, users are advised to insert manual casts to
bool.

Change-Id: I1b1f81962259514e57d841246740e0f7050104e0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-25 04:02:26 +01:00
Eirik Aavitsland
7dd454e1b9 Improve style drawing under DPR scaling
Line painting code originally designed for unscaled, aliased, pre-Qt4
drawing generally behaves better with a half pixel offset
applied. This fixes a heap of glitches when this code is run with a
device pixel ratio > 1.

Fixes: QTBUG-88934
Task-number: QTBUG-96223
Pick-to: 6.3
Change-Id: I617b0ecc0be2593b34bf78349043f72b9ea4b20c
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-03-25 01:15:18 +01:00
Alexandru Croitor
70c3dd4a54 CMake: Enable verbose autogen for cmake auto tests and EP examples
So we can see the exact moc invocations when debugging issues in the
CI.

For ExternalProject examples, it is conditional on whether Qt is
configured with QT_INTERNAL_VERBOSE_EXAMPLES set to ON, otherwise
calling the main ninja without -v will end up cluttering the output
with AUTOGEN output.

Pick-to: 6.2 6.3
Change-Id: I6468ab0e461b3be283e2428e3515cae4d5986242
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-03-24 21:50:50 +01:00
Alexandru Croitor
64d5708458 CMake: Enable debug verbosity for cmake auto tests and EP examples
Since e2a0ddbb69 , if Qt is configured
as a non-developer-build, some of the CMake tests that include QtSetup
would have their CMAKE_MESSAGE_LOG_LEVEL set to the reduced NOTICE
value.
Make sure that tests always have a DEBUG level, so that if they fail
in the CI, we have more info on what goes wrong.

For ExternalProject examples, it is conditional on whether Qt is
configured with QT_INTERNAL_VERBOSE_EXAMPLES set to ON, otherwise
calling the main ninja without -v will end up cluttering the
output a non default log level.

Amends e2a0ddbb69

Pick-to: 6.2 6.3
Change-Id: Icd3b6e0fcc6c73e4b53b6c4a6d8354c96077a050
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-03-24 21:50:50 +01:00
Laszlo Agocs
e25fc5a197 rhi: d3d11/vulkan: Allow passing in an array range override
Only (straightforwardly) implementable with modern APIs, and
only really exists to handle special platform cases, such as
when a video framework gives us a D3D texture array with
D3D11_BIND_DECODER | D3D11_BIND_SHADER_RESOURCE
which is only possible to use as a shader resource if the SRV
selects a single array layer.

Has no effect on the normal usage of texture arrays, where all
array layers are exposed, and it is the shader that selects the
layer when sampling or loading via the sampler2DArray. That
continues to be the standard way to work with texture arrays.

Change-Id: I0a656b605da21f50239b38abb83067e0208c1dbe
Reviewed-by: Piotr Srebrny <piotr.srebrny@qt.io>
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2022-03-24 19:19:35 +01:00
Giuseppe D'Angelo
5f8e11981c QStandardItemModel: use the right datatype for text alignment
Now that views can deal with Qt::Alignment returned by a model,
use the right type.

Change-Id: Ib6de5f7acbc76e9529451ddb494e808a41c59021
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-03-24 07:20:12 +01:00
Giuseppe D'Angelo
56f2407dc0 QAbstractItemModelTester: use the right types for some roles
Models are expected to return Qt::Alignment and Qt::CheckState
when asked for the text alignment / check state roles, respectively.
However, for legacy reasons, models may return `int` for either
possibility. Extend the tester to cover this.

Task-number: QTBUG-75172
Change-Id: I64bfc898466e8bb4d4a8a35726986ae610a8ffbe
Pick-to: 6.2 6.3
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-03-24 07:19:54 +01:00
Aleix Pol
3ec95f943a qdbusxml2cpp: Improve error message
Instead of saying:
You should add <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="<type>"/> to the XML description
It now says
You should add <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="<type>"/> to the XML description for 'Bind'

So you get an idea of which type it's asking to annotate.

Change-Id: Ia0842d3b54681825201813fe0875014cd35d8192
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
2022-03-24 05:24:13 +01:00
Fan PengCheng
897845ca7f widgets: Disable "Pick color" in QColorDialog when unavailable
On Wayland, you can't read screen content, so the "pick color"
feature does not do anything. In cases such as these, we should
detect that the platform does not support the feature and hide
or disable the button.

Fixes: QTBUG-101145
Change-Id: I192ca2aac78b3df5352b4dc71100b93f69dc5efb
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-03-24 12:24:13 +08:00
Rafael Roquetto
e555069151 QNX: remove mmrenderer overlay window support
QtMultimedia no longer supports overlay windows. The QNX multimedia
plugin now relies on the canonical rendering codepath via QVideoWindow.

Change-Id: Ic3bb14865f147a47200554e4791c191540e5bb75
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: James McDonnell <jmcdonnell@blackberry.com>
2022-03-24 09:42:03 +10:00
Volker Hilsheimer
dfb4697e4a QAbstractItemView: with single selection, deselect on Ctrl+Release
After cbf1b4bc60bca3994b8f8685ee922e53a6b4eed2 the selected item got
deselected on Ctrl+Press, which made Ctrl+dragging a selected item
impossible.

Only deselect on Ctrl+Release. Add scenario to existing test case,
and update the documentation to clarify the properties involved, and
to point out that the event parameter might be nullptr.

Fixes: QTBUG-101647
Pick-to: 6.3 6.2
Change-Id: I749b1cb1a0a311f5c1d4c333984716f05f2c90b5
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Volker Enderlein <volker.enderlein@ifm-chemnitz.de>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-03-24 00:42:00 +01:00
Giuseppe D'Angelo
6880b7c39b Itemviews: start fixing mixups of int/enum for Qt's item roles
A model is supposed to return a Qt::CheckState for a CheckStateRole,
and a Qt::Alignment for a Qt::TextAlignmentRole. This is what the
documentation says (and what makes sense), but unfortunately
Qt's default delegate expected a plain `int` instead.
This sometimes worked (via QVariant conversions, e.g. when using a plain
enum) and sometimes didn't (e.g. when using a flag type).

This is confusing for end-users (and type unsafe, killing the whole
point of using enums and flags in the first place).

Adding some automatic flags<->int conversions through QVariant is
frowned upon, so I don't want to go there. Instead, add some private
convenience functions that extract either the right type from a variant,
or try to extract an `int` and convert it to the expected type.

Use these from within itemviews code.

Change-Id: I44bee98c4a26a1ef6c3b2fa1b8de2edfee7aef32
Pick-to: 6.2 6.3
Fixes: QTBUG-75172
Task-number: QTBUG-74639
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-03-23 23:06:23 +01:00
Niklas Wenzel
af875e88f4 FreeType: Load multiple font faces from the same file on macOS
Previously, if a font file contained multiple font faces, only the first
could ever be loaded. This could lead to Qt loading different font
styles than requested by the application.

[ChangeLog][Text][Freetype] Fixed a bug where the macOS FreeType backend
would fail to load font faces from font files containing multiple faces.

Fixes: QTBUG-100666
Pick-to: 6.2 6.3
Change-Id: I6a126266a2e15f843dd578ab25c11748881bb932
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-03-23 23:05:18 +01:00
Alexey Edelev
de582a26c3 Use the CMake path format when passing the CMAKE_PREFIX_PATH to ctest
The generated 'CTestTestfile.cmake' file contains unescaped '\' symbols
in --build-options argument that causes an issue if the Windows path
format is used in CMAKE_PREFIX_PATH.

Change-Id: Ic03934fcb7bc6230cef72584fef81b01026d5f3b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-23 20:14:18 +01:00
Tor Arne Vestbø
ee15aa7482 CoreText: Maintain theme fonts in the font database instead of themes
The ownership of the fonts were handled in the iOS and macOS themes,
but the CoreText font database also kept a reference to these fonts.

As there was no way for the themes to reset the font database
references we could potentially end up in a situation where the
font database had stale references. And as the font database
would not rebuild the theme fonts once populated the themes
then would not be able to build a new list of theme fonts.

Moving the ownership to the font database makes semantics
and management of the fonts clearer.

Pick-to: 6.3 6.2
Change-Id: I61756abaf5487f28d520dfa1cf7a8ee2d716cce6
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-03-23 20:14:18 +01:00
Sona Kurazyan
76db8a0b1b Use QLatin1StringView in QString/QLatin1String APIs and docs
- Replaced QLatin1String with QLatin1StringView in QString/QLatin1String
  APIs and docs (except for QLatin1String class declaration and ctor
  names).

- Made the docs look like QLatin1StringView is "The Real Thing".

[ChangeLog][QtCore] Made QLatin1StringView the recommended name for
referring to a Latin-1 string view (instead of QLatin1String).

Task-number: QTBUG-98434
Change-Id: I6d9a85cc956c6da0c910ad7d23be7956e4bd94ac
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-03-23 18:06:51 +01:00
Marc Mutz
4167a920ed QDateTime: enable larger ShortData for bootstrapped build
Ensures we get a modicum of testing of the Qt7 32-bit code in.

Change-Id: I0838e4340265e19ab2b17a1a91a11ef5f9948893
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-03-23 13:46:33 +00:00
Marc Mutz
4cf299eb5b QSettings: port API from QString to QAnyStringView keys
With the public interface ported to QAnyStringView, we can now
internally optimize memory allocations _in a central place_ (e.g. by
returning std::u16string or QVarLengthArray<QChar> from normalizeKey()
instead of QString). But first we needed to get rid of all the
unwarranted allocations in user code.

Effects on Linux AMD64 stripped C++20 release builds:

GCC 11.2 libstdc++ (TEXT -= 6.5%):

     text    data     bss     dec     hex filename
   635148   10992    2824  648964   9e704 tst_qsettings-01-baseline
   593691   10992    2824  607507   94513 tst_qsettings-02-qanystringview

Clang 10.0.0 libc++ (TEXT -= 11.6%(!)):

     text    data     bss     dec     hex filename
   790336   10640    2832  803808   c43e0 tst_qsettings-01-baseline
   698572   10640    2832  712044   add6c tst_qsettings-02-qanystringview

That's the beauty of QAnyStringView: transparently reducing temporary
QString creation; and the simplest code is also the most efficient.

[ChangeLog][QtCore][QSettings] Keys can now be passed as
QAnyStringView (was: QString). The most efficient way to pass literal
keys is now "key"_L1, the backwards-compatible way is
QStringLiteral("key").

Fixes: QTBUG-101390
Change-Id: I510fb4ce17ef109dac7c9cdc5d90ede0d1a9db5f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-23 14:46:33 +01:00
Fabian Kosmale
a9cef86b8f Remove qipaddress from boostrap lib
Change-Id: I31a883404f34d0933fe8b316d05b0f28103e48ae
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-23 08:17:44 +01:00
Fabian Kosmale
c25a5b4e1f Remove QTemporary(file|dir) from boostrap lib
Change-Id: I851f0fd8150592784a7b38d3d30d69d8346de112
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-23 08:16:49 +01:00
Volker Hilsheimer
49a5512f0b Document that native file dialogs might not show a title
Native dialogs on macOS haven't shown a title bar since macOS 10.11.
The caption string passed in might not be visible to the end user, which
can be problematic for certain applications that use the title text to
provide context to the user.

Pick-to: 6.3 6.2 5.15
Task-number: QTBUG-59805
Change-Id: I3a1cea8f11a62c0927a9ba00159a118e2b078956
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-03-23 03:31:45 +01:00
Fabian Kosmale
aa29de37a7 Remove QUrl* from boostrap lib
Change-Id: I669ad12588adfd6fb409525616e145120e5a7c76
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-23 03:13:02 +01:00
Eirik Aavitsland
d0a299869b Jpeg handler: Detangle error reporting from the abort handling
If libjpeg has detected a fatal error, wait until after the longjmp to
report the error using qCWarning(), as some compilers don't like that
happening before the stack has been restored.
Also avoids code duplication.

Fixes: QTBUG-100821
Pick-to: 6.3 6.2
Change-Id: I8d0e6e1bcc4f2a85dae06b3879453ee9077288c0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Heikki Halmet <heikki.halmet@qt.io>
2022-03-22 18:52:23 +01:00
Edward Welbourne
5a4106748c Document some details of TAP's use of YAMLish
... along with how QtTest soon shall be using it.

Change-Id: I9c723ebdb8ee5be1c4152aa911ae7c846ea61b5c
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-22 17:43:13 +01:00
Edward Welbourne
90406af31a Use a cheaper is-empty test for a C-string
We only need to look at the first byte to determine whether the length
is > 0; no need to count how many more bytes after it aren't '\0'.

Change-Id: Id2db2a9a993086c0aee02c99396fcb346b1a348e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-22 17:43:13 +01:00
Edward Welbourne
02d130db7e Avoid duplicate descriptions in TAP's incident YAML
When a B?Fail's description doesn't match the QVERIFY/QCOMPARE
regexes, it got output as a comment in the YAML block after the test
line had already reported it as a TODO comment. An empty description
would also have lead to an empty comment in the YAML block. Condition
this fallback output case on there being a description that hasn't yet
been reported in the test line.

Task-number: QTBUG-96844
Change-Id: Id7fe81d26ddb01da3d8003ada8fa590a5e1a166f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-22 17:43:13 +01:00
Edward Welbourne
d52fbfe924 Fix indentation of some continuation lines in qtaptestlogger{.cpp,_p.h}
Change-Id: I33dc05b61b07f077edc7c4816d43d0b53f5f4b43
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-22 17:43:13 +01:00
Edward Welbourne
58b0d72f8d TAP test logger: treat blacklisted XFail the same as XFail
In all places but one they were treated the same; fix that last one to
match the rest. This removes one line from the YAML block for each
blacklisted XFail test; in each case, this message duplicates the one
on its "not ok ... # TODO..." test line.

Change-Id: Iff2028afccd979db7f2c84e85d1b78541900008e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-22 17:43:13 +01:00
Edward Welbourne
44d0cbc7b1 Match QtTest command-line output options to the help output
Reorder the different formats to match the order in the help output
and include missing entries from the list of formats supported by the
-o filename,format variant.

Change-Id: I884f9facc7cfde7cec0bee75944efdd72d66a83e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-22 17:43:13 +01:00
Edward Welbourne
0e5c39ee13 Document what QtTest's various loggers do
Provide basic (internal) documentation of each logging class and link
the command-line documentation to pages relevant to the formats not
defined by Qt.

Change-Id: I3251dd1304203c6ab87dfe1f2dec0e9787ab69f8
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-22 17:43:13 +01:00
Sona Kurazyan
401349af26 QFuture: fix a codechecker warning
Codechecker complains about passing a forwarding reference to std::move,
which may unexpectedly cause lvalues to be moved. We should use
std::forward instead.

This amends cbf8fc0ac4

Change-Id: Ieba9e960b5dfb448e9cebabe9541967698995b8f
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-03-22 17:43:12 +01:00
Andreas Eliasson
c1dc32185b Doc: Reorganize sections structure in Qt Widgets landing page
Also, use the global include snippets for the 'Using the Module'
section.

Task-number: QTBUG-100369
Pick-to: 6.3
Change-Id: Ib9e32dd48689879c91c7c307f8cf0f01dc478efe
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2022-03-22 16:49:05 +01:00
Pasi Petäjäjärvi
7cb047128c QNX: Fix compiler warning by when FEATURE_clipboard is not enabled
warning: unused parameter 'selectionClipboard' [-Wunused-parameter]

Pick-to: 6.2 6.3 5.15
Task-number: QTBUG-101382
Change-Id: I4f42a6f41c8f8a8b3edd3a042c89b7a2a49a96fe
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-03-22 08:26:22 +00:00
Thiago Macieira
32e24e011e qversiontagging.h: remove the attempt to use the "retain" attribute
GCC 11 knows about it, meaning __has_attribute(retain) = 1 regardless of
whether GCC can emit code for it. Clang has a similar limitation.

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99587

Fixes: QTBUG-101753
Change-Id: Ic30914a4448d4bc28974fffd16dce9a78cdefe5b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-21 18:06:13 -07:00
Shawn Rutledge
f0254ef50c qsql_ibase: fix includes
QMap was a transitive include, apparently; and we have mostly
standardized on specifying the module where each include comes from.

Change-Id: I1a54db879e744120f5b10eb0b16f8ba36cde8300
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-21 20:41:23 +01:00
Ulf Hermann
908ee8aab1 QProperty: Allow manual scheduling of binding notification
In some situation we want to notify even if the value didn't change.

Task-number: QTBUG-101771
Pick-to: 6.2 6.3
Change-Id: I7d82a9f6e0f7d5eb48065e3f428b814939181ea8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-21 20:41:23 +01:00
Volker Hilsheimer
cbf8fc0ac4 Fix warning in tst_qfuture
Explicitly move the argument into the return value to silence:

qfuture_impl.h:153:20: warning: local variable 'arg' will be copied
despite being returned by name [-Wreturn-std-move]
            return arg;
                   ^~~

[...]
qfuture_impl.h:153:20: note: call 'std::move' explicitly to avoid copying

Change-Id: I49fab7c31efb7d809182c8d56e6a5ed8f05a5622
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-03-21 20:41:23 +01:00
Volker Hilsheimer
c924c05ae2 Replace deprecated QColor::fromString in tests and documentation
Don't use deprecated methods in tests, and don't refer to them in
documentation.

Change-Id: I110480742d9a7b9b0a2e194e3fe610208c1e07da
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-21 20:41:23 +01:00
Volker Hilsheimer
4ac00ca901 QTabBar: let styles draw tab text with foreground role
QTabBar::setTabTextColor's documentation and implementation suggests
that the set color will always be used unless invalid, and that the
foreground role is used otherwise. QTabBar then sets the foregroundRole
palette entry to the specified color before calling the style. The intent
is evidently that the tabTextColor is used no matter the foregroundRole
(which by default is the role that contrasts with the background role).

If the styles always paint the text with WindowText, then the tabTextColor
gets ignored if the foregroundRole is not WindowText (perhaps because
the backgroundRole is set to Base).

Fix this by respecting the widget's foregroundRole when painting the tab
label in the common style (which is the only style that implements
drawControl for CE_TabBarTabLabel). QMacStyle and QStyleSheetStyle
need to be adjusted to prepare the palette consistently with the logic
in QTabBar.

Pick-to: 6.3 6.2
Fixes: QTBUG-101456
Change-Id: I077a2034eebfe3f56cea28917494f4db01e48747
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-03-21 19:41:23 +00:00
Øystein Heskestad
eaabd0c545 QAnyStringView: constexpr detect 8-bit ASCII as Latin 1
This has performance benefits when doing comparisons.
The check is only performed at compile time.

Task-number: QTBUG-101014
Change-Id: I55694b045fe5e75d9671d0a3a70c80d998cf98c8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-21 20:36:23 +01:00
Kai Köhne
5428c06958 Doc: Remove mentionings of overflows from QElapsedTimer
The last 32 timer that could overflow was not used anymore since Qt 5.9,
see also commit aaa3184f8d. This appends commit aaa3184f8d.

Pick-to: 6.3 6.2 5.15
Change-Id: If033a5fa7a58427bcbc643cc19fc73a8dd36a169
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-21 20:36:23 +01:00
Alexey Edelev
68c0e932a5 Unify DEPFILE support check
Add common function that unifies the check for the DEPFILE support.
Update the check according to the recent CMake version.

Task-number: QTBUG-99354
Change-Id: Ia2abf46fe3a9a3d17ea7a37eaf6c9c6a697c5b84
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-21 12:39:49 +01:00
Volker Hilsheimer
83e11b5fc4 Fix build with latest Apple clang version
Building with Apple clang 13.1.6.13160021 (from command line tools 13.3)
results in

qhash.cpp:754:39: error: passing 16-byte aligned argument to 32-byte
aligned parameter 3 of 'operator()' may result in an unaligned pointer
access [-Werror,-Walign-mismatch]

        hash2x32bytes(state0, state1, src, src + 1);
                                      ^

Help the compiler with deducing the right type for 'src' and 'srcend'.
Also makes 'src' const explicitly.

Change-Id: Id14a034f0fa4c2a002d9b37729d803a50a0e5e9c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-21 06:34:25 +01:00
Rafael Roquetto
d15ef5bc3a QNX: always create buffers for child windows
The QNX raster backend worked on the assumption that child windows were
sharing their parent toplevel window buffer instead, and thus did not
have a buffer of their own. This piece of code dates back from the
BlackBerry days, and I am guessing the motivation was to tackle
mmrenderer/foreign windows.

In fact, not having buffers causes QWindow to malfunction, as
independent buffers are required.

This patch makes sure every QQnxWindow has a backing buffer, as
expected. Foreign widnows shall be dealt with via different means.

Change-Id: I059ac4f8ac684b3577048f874f82b866f21326b1
Reviewed-by: James McDonnell <jmcdonnell@blackberry.com>
2022-03-21 12:12:54 +10:00
Volker Hilsheimer
9d12f6adbc Fix warning from deprecated QMouseEvent constructor on macOS
Pass global position explicitly.

Pick-to: 6.3
Change-Id: I4b9bf735635528c4a289be7db6026162d5a7aff6
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-03-21 02:33:27 +01:00
Volker Hilsheimer
75ea5a0335 Fix build on macOS without warning after QString::count deprecation
Pick-to: 6.3
Change-Id: Ie043289c258fadbfafaf4a88b9695f0e65699de8
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-20 23:18:56 +01:00
Laszlo Agocs
b96c212360 Remove a now-unneeded QT_NO_OPENGL ifdef
This is from a fix unrelated to the recent rhi-based composition
work, which means it still had to enclose the block in an ifdef
due to the variables being only present in OpenGL-enabled builds.
Now with the other patches in place, the variables are no longer
conditional, and the similar ifndef QT_NO_OPENGL checks are already
gone pretty much everywhere so the ifdef is not needed here either.

Change-Id: I497c7a4fad7cd7d8fc1a479e7032de3e2cbb3b32
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-03-20 19:12:11 +01:00
Sona Kurazyan
94addad4dd Add QLatin1StringView as an alias for QLatin1String
And switch to using QLatin1StringView for bootstrap builds and Qt 7.

[ChangeLog][QtCore] Added QLatin1StringView as an alias for
QLatin1String.

Task-number: QTBUG-98434
Change-Id: Iefb860b63eb05ef4755b2e26de265e6e6e4420b3
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-03-19 18:51:00 +01:00
Marc Mutz
c839efb07a QtGui: compile-optimize inline swap functions
Instead of using the overly-generic qSwap() monster, use

- qt_ptr_swap() for swapping raw pointers
- member-swap for swapping smart pointers
- std::swap() for swapping scalars

In QtCore, this has proven to give a nice reduction in compile time
for Qt users, cf. b1b0c2970e.

Pick-to: 6.3 6.2
Task-number: QTBUG-97601
Change-Id: I987ff95e8751a22a4f283655d8225dd16de21178
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-03-19 16:56:08 +01:00
Martin Storsjö
81fb9c5b14 qversiontagging: Fix the imp prefix for 32 bit arm
The underscore symbol prefix is only used on 32 bit x86, not on
other 32 bit architectures such as arm.

Change-Id: Iac82f2d70c8b0c811faa7af5b59805b388b0a00c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-19 16:12:57 +02:00
Marc Mutz
c52ebb3aba QRect: add toRectF()
For symmetry with QRectF::toRect().

[ChangeLog][QtCore][QRect] Added toRectF().

Fixes: QTBUG-73160
Change-Id: If2bda64b8fe4bc113191dda927e9bb86ebcb4c69
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-19 12:02:24 +01:00
Marc Mutz
5dc570f8b1 QLine/QMargins: add toLineF/toMarginsF()
For symmetry with QLineF::toLine().

[ChangeLog][QtCore][QLine] Added toLineF().

[ChangeLog][QtCore][QMargins] Added toMarginsF().

Task-number: QTBUG-73160
Change-Id: I69051cdd2fe4a3c0a000ab86e363a2918a7aea7c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-19 12:02:24 +01:00
Marc Mutz
2fb0135efa QSize/QPoint: add toSizeF/toPointF()
For symmetry with QSizeF::toSize().

[ChangeLog][QtCore][QSize] Added toSizeF().

[ChangeLog][QtCore][QPoint] Added toPointF().

Task-number: QTBUG-73160
Change-Id: I65b088b4f7365ab671ef2f0c75821b707f5ac26d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-19 12:02:24 +01:00
Marc Mutz
98cbdae527 QMargins: fix a missing "full stop" in the docs
Pick-to: 6.3 6.2 5.15
Change-Id: Ic8012ce12ef8d2fee2dc785e373e9c9d8f658ff5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-19 12:02:24 +01:00
Marc Mutz
f97daab7a6 QObject: restore flags printing in dumpObjectTree()
This was lost when QtCore, QtGui and QtWidgets were split up. Restored
now via a virtual function on QObjectPrivate.

Chose to return std::string instead of QString or QByteArray because
its SSO is usually sufficient to hold these flag strings.

[ChangeLog][QtCore][QObject] Restored printing of Qt3-style
information from dumpObjectTree().

[ChangeLog][QtWidgets][QWidget] Restored printing of Qt3-style
information from QWidget::dumpObjectTree().

Fixes: QTBUG-101732
Change-Id: I39ff5728ea5f5abbdbf81b5d7e13b8d16b6ee8b7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-19 12:02:24 +01:00
Marc Mutz
6ec1dc904d QSettings: port key processing to QAnyStringView
... in preparation for replacing the QString keys in the public API
with QAnyStringView ones.

This removes the "important optimization" that avoids a detach in the
common case where the input is the same as the output of
normalization. But that optimization is beside the point, because it
trades a memory allocation avoided in the library for O(N) allocations
inserted into user code for each call to QSettings::value(), the vast
majority of which are calls with string literals.

With the public interface ported to QAnyStringView in the follow-up
patch, we can then internally optimize memory allocations _in a central
place_ (e.g. by returning std::u16string or QVarLengthArray<QChar> from
normalizeKey() instead of QString). But first we need to get rid of all
the unwarranted allocations in user code.

Change-Id: I45fc83d972c552a220c9c29508001d3f172e1162
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-03-19 07:09:55 +00:00
Thiago Macieira
03de9ff7ee QJsonValueConstRef: fix null pointer dereferences
Introduced in commit 705ea62f9e, but
apparently these constructors aren't used anywhere yet.

Change-Id: Ic30914a4448d4bc28974fffd16dc521ab49d3be4
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-03-18 15:14:27 -07:00
Volker Hilsheimer
6492a9c877 Refactor: use lambdas for visitor pattern in QGraphicsSceneBspTree
This way, the visitor implementations are directly where they are used,
without the need for a virtual function call. The allocation of the
visitors on the heap was anyway overkill (they could just have been
allocated on the stack where they were used).

Change-Id: Ic41fd285e3a45daaf2e17aa5aeee07e754127a00
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-03-18 21:56:19 +01:00
Volker Hilsheimer
5e566ab373 When clearing selected items, iterate over a copy of the QSet
Selection change handlers of the items might call a method that
implicitly recreates the selectedItems QSet, which then invalidates
the iterators of the ranged for loop, resulting in crashes.

Iterate over a copy of the set instead.

Add a test case that crashen without the fix.

Fixes: QTBUG-101651
Pick-to: 6.3 6.2
Change-Id: I6da6f4043fe1906b0186931a37283f635cb5a404
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-03-18 21:56:19 +01:00
Luca Di Sera
33d62de7c8 Enable move semantics for QTemporaryDir
Add move constructor and move assignment operator.

To allow for the the change to be implemented QTemporaryDir, the
internal d_ptr was modified from a QScopedPointer, which is not movable,
to a raw pointer.

Add member + free swap implementations.

Add tests.

[ChangeLog][QtCore][QTemporaryDir] Enabled move semantics.

Change-Id: I9f196a77c70b4ca0b7f0c06505d00fdd87a9785c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-18 20:56:19 +00:00
Tor Arne Vestbø
e14466aa66 Fix -Wunused-but-set-variable in QTcpSocket documentation snippet
Pick-to: 6.2 6.3 5.15
Task-number: QTBUG-101883
Change-Id: I54dc7229565cef199f306a0ac837a932aeb00ec6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-18 19:47:59 +01:00
Tor Arne Vestbø
bdb9a254c2 macOS: Remove dead code for focus ring handling in Mac style
It was added in 375dd7ad34
but never used.

Pick-to: 6.2 6.3 5.15
Task-number: QTBUG-101883
Change-Id: Ibad7e0b1c371bdee63bcdbea0c5280091107408a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-18 19:47:59 +01:00
Mårten Nordheim
82296d3193 Add missing includes for some of our _win.cpp files
Change-Id: I74067f5d50bea6fbc16576c26bf84f91e449e497
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-18 17:35:03 +00:00
Ivan Solovev
30830e0cba Android: use empty Intent to clear clipboard data on API < 28
ClipboardManager didn't have any APIs to clear clipboard data before
API level 28.
As a workaround an empty Intent with MIMETYPE_UNKNOWN is created and
inserted into the clipboard for lower API levels.
This makes the QApplication::clipboard()->clear() method work more or
less as expected.
This allows to unblacklist tst_QPlainTextEdit::copyAvailable().

Task-number: QTBUG-87423
Task-number: QTBUG-89402
Pick-to: 6.3 6.2
Change-Id: I454376199cf3b8eed0fa2ecf2f85b87f40892280
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-03-18 18:35:03 +01:00
Marc Mutz
9985cc330a uic: use C string literals for setObjectName()
Because setObjectName() now takes a QAnyStringView, passing C string
literals is much more efficient than using QString::fromUtf8().

This patch only deals with setObjectName() as a known property,
probably from a name attribute. If the objectName property is set by a
<property> element (or so I assume), we still emit a
QString::fromUtf8(). Detecting objectName there would be too much
magic.

Besides, I haven't been able to find why sometimes there's a second
setObjectName call right after the first, when in the XML it seems all
kosher (name attribute and objectName <property> agreeing on the
content).

Change-Id: Icf07bad841ac735a9c744bbd955428ba15758089
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-18 18:35:03 +01:00
Giuseppe D'Angelo
fb7e9bef8d QMutexLocker: code tidies
Improve the docs for the recently added move operations.

Change-Id: Iae17f5289d30faab4aaaec14a27036f7a03129ab
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-18 12:32:28 +01:00
Marc Mutz
7ed5b52e80 QMetaType: remove an unused static pointer variable
Unlike the Gui and Widgets pointers, the Core one wasn't needed,
because the only user can inline the variables contents.

Saves one relocation.

Pick-to: 6.3
Change-Id: Ib7535e1a29c5125eea55c66dad6d2d1de72f6bc1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-18 06:57:10 +01:00
Giuseppe D'Angelo
1b14569753 QMutexLocker: strenghten the locking operations
There is no reason to allow relock() on a locked locker, or unlock()
or an unlocked one, just like we don't allow that on a plain mutex
to begin with. The docs already said that e.g. relock() locks an
_unlocked_ locker.

[ChangeLog][QtCore][QMutexLocker] QMutexLocker allowed relock() and
unlock() on an already closed (resp. open) locker object. These
semantics have always been undocumented and are now unsupported
(in both cases they yield undefined behavior.)

Change-Id: Id5f67beb5dc30d6435dae88a3085fba93ec7d96e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-18 05:18:28 +01:00
Albert Astals Cid
6e23fc8580 QImage::operator==: Also compare the image colorspace
Pick-to: 6.3 6.2
Change-Id: I4cb86d32492876791fe852f8c3123b7d4a69a5bd
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-03-18 01:32:57 +01:00
Edward Welbourne
e10d613509 Add QByteArray::percentDecoded() as an instance method
Percent-decoding was previously only present as a static method taking
a QBA parameter; it might as well be an instance method of that
parameter. Change most QBA tests to use it rather the static method.

[ChangeLog][QtCore][QByteArray] percentDecoded() is now available as
an instance method of the byte array to be decoded, equivalent to the
static QByteArray::fromPercentEncoding().

Change-Id: I982101c44bdac5cc4041e85598d52ac101d38fa1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-18 01:22:54 +01:00
Edward Welbourne
e0206fe9d4 Get rid of QByteArray::nulTerminated()
It is private and was not called by anything inline, even in 5.15, so
can safely be removed without causing binary incompatibilities, now
that it is no longer used even out-of-line.

Task-number: QTBUG-74286
Change-Id: Iaec3877079746bd9ba7d1a39efbfb2711e7c00a5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-18 01:22:54 +01:00
Edward Welbourne
0cee66048d Tidy up QByteArray::toPercentEncoding()
After inlining the local static void to which it used to delegate most
of the work, the main loop can access *this and we have no need for
yet another copy of it or the variables to iterate it. We can also
access the result array directly, rather than via a (poorly-named)
pointer.

It turns out that wrapping QBA in QBAV each time we call a lambda on
it costs enough to cause a 50% slowdown, so change the lambda to now
take the const refs we have. (Constructing the views only once is as
good, for reference.)

Change-Id: I81c5996d91415d8a933de714177a89462555ff03
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-18 01:22:54 +01:00
Sona Kurazyan
73e7fc2d8e Fix a few more {QString, QByteArray}::count() deprecation warnings
Change-Id: I0be2d5e7a8f6af3bc1077ae6d1f20cc5da8f2266
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-17 21:03:08 +01:00
Alexey Edelev
aec6b00758 Disable init prioritization in QNX
This fixes issue with non working QHash when loading QML plugins in QNX.

Change-Id: I55c9edc58aa27cff694603e6281c980e1fedbeba
Taks-number: QTBUG-101341
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-17 19:43:29 +01:00
Tor Arne Vestbø
69d525a6fa Avoid populating font family aliases if family matched
When trying to match a font request to fonts in the database we might
end up with a mismatch due to the style not being available, but the
font family itself was.

If that's the case there's no point in trying to populate font aliases,
so we explicitly propagate this fact back to QFontDatabasePrivate::findFont
so that it can choose to not populate family aliases.

Fixes: QTBUG-98369
Fixes: QTBUG-99216
Pick-to: 6.3 6.2 5.15
Change-Id: I14470554c73eace836f57cb65e63ada594ccf62e
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-03-17 18:43:29 +00:00
Giuseppe D'Angelo
20d0ff1a39 QMutexLocker: add move semantics
The class is similar to unique_lock in that it allows for unlocking
and relocking. Since the locked state is tracked by QMutexLocker itself,
it's trivial to make it movable.

[ChangeLog][QtCore][QMutexLocker] The class is now movable.

Change-Id: I534044f8024575e996c12efb2236761d493798a3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-17 18:57:47 +01:00
Mårten Nordheim
4b8c20a297 Fix deprecated use of QColor::setNamedColor
'Use fromString() instead.'

Change-Id: I4efef147a8b0486f2664fd7fe6c35a9c82479b90
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-17 17:14:38 +01:00
Fabian Kosmale
fb0c7a9956 QVariant: reduce transitive includes
Forward declare more types in qvariant.h, and do the same for qdebug.h
(which will be removed from qvariant in a separate patch).

As we now only forward declare containers (e.g. QMap, QList, ...), code
which includes <QVariantMap>, <QVariantList>... breaks without further
adjustment: So far, those headers simply included qvariant.h. However,
by introducing new actual headers for those types and adjusting
sync.profile, we can avoid this issue.

To avoid breaking leaf modules and user code, we make the change opt-in:
Unless QT_LEAN_HEADERS is defined to a value of >= 1, we still
include the superfluous headers. We also set this macro in qtbase via
QT_EXTRA_INTERNAL_TARGET_DEFINES.

[ChangeLog][Potentially Source-Incompatible Changes] qvariant.h no
longer includes <QList>, <QMap>, <QHash>, <QVarLengthArray>, <QSet> and
<QObject>. Code that relied on transitive includes might need to
explicitly include those headers now. Notably, including <QVariant> (or
qvariant.h) is no longer sufficient when using QVariant(List|Map|Hash).
Using them now requires including respectively <QVariantList>,
<QVariantMap>, or <QVariantHash>. Alternatively, including <QVariant>
and the <QList>, <QMap> or <QHash> header also works.

[ChangeLog][Potentially Source-Incompatible Changes] qdebug.h no longer
includes <QSet>, <QHash>, <QVarLengthArray> and <QMap>. Code that relied
on transitive includes might need to explicitly include those headers
now.

Task-number: QTBUG-97601
Change-Id: I142e5de709ed0b305716369a3266389ab7fbbb71
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-17 16:14:38 +00:00
Fabian Kosmale
468e9c13a9 Misc: Do not depend on transitive includes
As a drive-by, remove superfluous includes from qnetworkmanagerservice.h
and obey the coding conventions for includes in a few more places.

Change-Id: I65b68c0cef7598d06a125e97637040392d4be9ff
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-17 17:14:37 +01:00
Fabian Kosmale
49b25ab07b XCB: Do not depend on transitive includes
As a drive-by, follow the coding convention when including qobject.h

Change-Id: I73066646d7f03ee0138e70567738e296b2183f63
Reviewed-by: Liang Qi <liang.qi@qt.io>
2022-03-17 17:14:37 +01:00
Fabian Kosmale
e4ab3e39e1 Sql: Do not depend on transitive includes
Change-Id: I9407c34c9fb6add655649dd7058bce7a25be5f5d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-17 17:14:37 +01:00
Fabian Kosmale
b73ce88998 Network: Do not depend on transitive includes
Change-Id: Ie37a4d332ff808e2524b1742fa70dc07992fa8c7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-17 17:14:37 +01:00
Fabian Kosmale
b5b4d0ec06 Widgets: Do not depend on transitive includes
Change-Id: Idfd7af066264dd38375d45771693a536a1985607
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-03-17 17:14:37 +01:00
Fabian Kosmale
caed0c3ac3 Gui: Do not depend on transitive includes
Change-Id: I27321235d9c8428de0cff1e22a618299b9e5a97f
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-17 17:14:37 +01:00
Fabian Kosmale
ffa5820fa3 Core: Do not depend on transitive includes
Change-Id: I2c71188a4d27692a2d6ef1aa447b329627214b17
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-17 17:14:36 +01:00
Ulf Hermann
03b281a0f2 QColor: Explicitly return std::nullopt
gcc 10.2 struggles with returning just {} when compiling in release mode
with debug symbols. std::nullopt is also more readable.

Change-Id: Ib050d47e8741ee87bef865dd55ecba622faf25b4
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-17 17:14:36 +01:00
Ulf Hermann
98b8818ad7 QMetaObject: Allow custom meta calls
Add a new entry to the Call enum that can be used by dynamic meta
objects to encode their own metaCall variations.

Change-Id: I7890d11924ab99311b6f016ce97d2ab483c26d27
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-03-17 17:14:36 +01:00
Giuseppe D'Angelo
5089db0303 QFuture: fix QtFuture::connect corner-cases
Connecting to nullptr, or connecting to a non-signal PMF, would result
in a QFuture which would never finish. Catch these cases and handle
them.

Windows+MSVC for some reason fails the test. I can't entirely understand
why, so I've marked it as XFAIL, with QTBUG-101761 to track it.

Change-Id: I314980e7e9b7156d8cddd3b33d5cbf1d0bcd6116
Pick-to: 6.2 6.3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-03-17 17:14:36 +01:00
Alexey Edelev
8adacba3e6 Add VERBATIM option to add_custom_command calls
Use VERBATIM option to prepare the correct command line for the
add_custom_command. This especially sensitive when using build
directories with names containing special symbols, that cannot be
handled by shell correctly.

Change-Id: I51d7041cb806411135fd59bf6273c04a3c695443
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-17 15:15:06 +01:00
Mårten Nordheim
74bef86da8 QVulkanWindow: fix QByteArray::count deprecation warning
By using QBA::size

Change-Id: I716c0e27230cd46e92ca5521d9a19cb296e221bd
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-03-17 14:15:06 +00:00
Sona Kurazyan
893dd5d7be Add QStringView::localeAwareCompare()
QString already has a localeAwareCompare(QStringView, QStringView)
static method. Use it in QStringView::localeAwareCompare(QStringView).

[ChangeLog][QtCore][QStringView] Added
QStringView::localeAwareCompare().

Task-number: QTBUG-98431
Change-Id: Iec3865a5439d9fb653cc1150da21042186bdee98
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-17 14:27:45 +01:00
Liang Qi
f08e57540d GUI: add ScreenWindowGrabbing capability
On Wayland, there is no protocol to do it yet.

Task-number: QTBUG-100792
Task-number: QTBUG-101145
Change-Id: Id72625a8161359111a2d0f43f3215e787778ba6b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-03-17 14:27:44 +01:00
Marc Mutz
60592f72d6 Rest of QtBase: compile-optimize inline swap functions
Instead of using the overly-generic qSwap() monster, use

- qt_ptr_swap() for swapping raw pointers
- member-swap for swapping smart pointers and owning containers

In QtCore, this has proven to give a nice reduction in compile time
for Qt users, cf. b1b0c2970e.

Pick-to: 6.3 6.2
Task-number: QTBUG-97601
Change-Id: I53e031a021031d53a74a712cd0f5e6bb8bf800bd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-17 07:15:06 +01:00
Marc Mutz
f438d29b6f QtNetwork: compile-optimize inline swap functions
Instead of using the overly-generic qSwap() monster, use

- qt_ptr_swap() for swapping raw pointers
- member-swap for swapping smart pointers
- std::swap() for swapping scalars

In QtCore, this has proven to give a nice reduction in compile time
for Qt users, cf. b1b0c2970e.

Pick-to: 6.3 6.2
Task-number: QTBUG-97601
Change-Id: I26586da1f158fe6b18314abd8cf9bb040bc9cad1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-17 07:15:04 +01:00
Marc Mutz
870bb22c17 QtDBus: compile-optimize inline swap functions
Instead of using the overly-generic qSwap() monster, use

- qt_ptr_swap() for swapping raw pointers
- member-swap for swapping smart pointers and owning containers
- std::swap() for swapping scalars

In QtCore, this has proven to give a nice reduction in compile time
for Qt users, cf. b1b0c2970e.

Pick-to: 6.3 6.2
Task-number: QTBUG-97601
Change-Id: I2cb0dd3cef3a2923e7d08bb9d93c692308797e5b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-17 07:15:01 +01:00
Marc Mutz
9f8da21239 QDateTime: future-proof swap()
In Qt 7 32-bit builds, the ShortData will be larger than the
d-pointer.

So don't swap() the d-pointer, but a) delegate to Data to swap itself
and b) swap the ShortData there, adding a static_assert in the .cpp
file that triggers when the assumption that ShortData is always at
least as large as a pointer is violated.

Found while porting away from overly-generic qSwap(), so done that,
too.

Task-number: QTBUG-97601
Pick-to: 6.3 6.2
Change-Id: I5139da58d99e9491a582ff2cb2f817cd96952044
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-17 06:14:58 +00:00
Marc Mutz
73d0174f50 QLibrary: restore translated string
We want to pick this change to LTS branches, so we cannot change the
translated string.

Instead of fixing the order of placeholders, use multi-arg, which
performs only a single pass over the input and doesn't suffer from
placeholder injection by interpolation the way .arg() chaining does.

Requires to use QString::number(), though.

Amends 3636325946.

Pick-to: 6.3 6.2 5.15
Change-Id: I6484a052115096c609edfea27dfd36b196efc1b6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-17 07:14:55 +01:00
Marc Mutz
021134195e QHash: fix -Werror=maybe-uninitialized (GCC 11.2)
The compiler doesn't understand understand that the only way ok can be
true is for qstrntoll() to have been executed.

  qhash.cpp:158:9: error: ‘seed’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
    158 |         if (seed) {
        |         ^~

Help poor GCC by initializing the variable unconditionally.

Amends cc5cc3225d.

Change-Id: Ic8387e0add2291d994f7f4d96c4bc614b2a8aa99
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-17 06:14:20 +00:00
Lorn Potter
d10b910e39 wasm: remove compiler and linker warnings
INITIAL_MEMORY and PTHREAD_POOL_SIZE are linker flags only
USE_PTHREADS is both linker and compiler arguments.

Also increase default INITIAL_MEMORY

Pick-to: 6.3
Change-Id: Id1998efbf1d6de901f404db7e988f6cafd547a39
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-03-17 15:56:19 +10:00
Giuseppe D'Angelo
d0cae531e6 QResultStore: remove unused include
Change-Id: I829e98af4f46156926a1ee68bddf4399bc557439
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-03-17 06:34:55 +01:00
Giuseppe D'Angelo
9d685a870d QLoggingCategory: code tidies
Sprinkle explicit and remove an unnecessary operator in favor
of a named function.

Change-Id: I7e11b3910014827018341fde7d5aba36f9487fc4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-17 05:34:55 +00:00
Giuseppe D'Angelo
e0a7364b50 QThread: avoid lock/relock an empty QMutexLocker
These semantics are deprecated and about to be changed.
Drive by, use nullptr instead of 0.

Change-Id: I213bf7d528d2fa312549f9fa49a5533198eddf88
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-17 02:02:15 +01:00
Michal Klocek
2f894293ae Add missing install of pnglibconf.h for static builds
Installing only pngconf.h is not enough.

This commit amends be2745e478

Pick-to: 6.3
Change-Id: I8de1565434c315c7197d4602a8460ead794176d7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-03-16 20:19:22 +01:00
Tatiana Borisova
715420095a Fix has_signaling_NaN usage for INTEGRITY
- The newest GHS compiler versions set the value of has_signaling_NaN to False.
  Add compilation and autotest fix for GHS-compiler 2021/2022 releases.

Task-number: QTBUG-99123
Pick-to: 6.2 6.3
Change-Id: I45e5da6759a15c60c17f896e565002cbba8524ed
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-16 20:09:37 +02:00
Marc Mutz
1977c922e9 QFlatMap: make insertion STL-compatible
That is, insert() doesn't overwrite an existing entry, and range
insert inserts the first of equivalent keys' values, not the last.

This allowed this author to optimize the implementation of
makeUnique() to a O(N) algorithm (was: O(N²)). Said optimization would
have been possible with the old semantics, too, but I wrote the
algorithm first and only then noticed the broken insert() behavior is
present on QFlatMap, too, so I decided not to let good code go to
waste and to fix both problems at the same time.

In order to give users a hint of the changed semantics, make the new
API opt-in until Qt 6.5, so Qt 6.4 ships with the both the old and the
new semantics disabled, where they contradict.

Fixes: QTBUG-100092
Change-Id: Ic96d8bfe6bed9068dbe8c0d7171bd8921050fd95
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-16 18:28:27 +01:00
Kai Uwe Broulik
e516a7bcf8 QAction: Add NOTIFY changed declaration to priority property
It already emits the signal and was merely missing the declaration.

This fixes warnings about depending on non-NOTIFYable properties
when binding to the priority property from QML.

Pick-to: 6.3 6.2
Change-Id: Ia91ae5d00d722bdb2fc1f89671c3e7faab4b129f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-03-16 17:28:27 +00:00
Volker Hilsheimer
58a14d9433 Enable tests to turn off Windows Vista animations
Animations in that style depend on the current time, which makes it
impossible to run baseline tests. Introduce a dynamic property that
allows us to set the time that animations use.

This way, tests can turn the animation off, or control which time should
be used.

To keep performance overhead low, check only once whether the dynamic
property is set at all.

Pick-to: 6.3
Change-Id: I9bc57b9867fb0d852e101570eca4c7609e7fe1a8
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-03-16 15:56:17 +01:00
Kai Köhne
9f5f64e9db Use QDebugStateSaver in example operator<<()
This makes sure that changes in the debug stream - like nospace() -
do not "leak". Also use the example snippet in QDebugStateSaver
documentation.

Pick-to: 6.2 6.3
Change-Id: I934976d2c7c2335abfec68c763526a5cbb0e6f1e
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-03-16 15:56:17 +01:00
Eike Ziller
9943cf7371 QMainWindow: Fix unused separator widgets blocking mouse events
We need to hide separator widgets that are unused, otherwise they block
mouse events from the underlying widgets.

Pick-to: 6.2 6.3
Fixes: QTCREATORBUG-24600
Change-Id: I98c6d4860f683a861b89c4cad042bb734f590000
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-03-16 09:50:52 +01:00
Robert Löhning
d865129d9e Painting: Fix value check in isUnclipped()
left() == INT_MIN or top() == INT_MIN will still underflow
in QRect's ctor, so the check must be more strict

Pick-to: 6.2 6.3
Change-Id: I12ab148934c8c90865ca9247bd8badeedd4a9f45
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-03-16 02:31:10 +00:00
Robert Löhning
286a63898f Doc: Fix typos
Pick to: 6.3

Change-Id: Iaea3c0e567ddd6a72db0b2ba1731c416cf85ef47
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-03-16 02:26:56 +00:00
Marc Mutz
e74e27e67e QObject: give some TLC to dumpRecursive()
In no particular order:

- use the variable field width feature of QString::asprintf() to
  generate the indentation implicitly, instead of fill()ing a
  QByteArray with the desired number of spaces

- just default-construct 'flags', don't assign an empty string

- use qUtf16Printable() to avoid funneling UTF-16 data through 8-bit
  encodings

- use a C++11 ranged for instead of a counted loop

- remove a pointless isEmpty() guard (the loop won't execute when the
  children().isEmpty())

- avoid copying object->children() (returns by cref, so it's also ok
  to stuff it directly into the ranged for loop).

Add a test.

Pick-to: 6.3
Change-Id: Ie7314713cb48de7e890cdee0760c0361dd24fd18
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-16 02:26:56 +00:00
Marc Mutz
78891e5390 QString/QByteArray: = default the move ctors
Instead of relying on implicit construction of the d-pointer and then
swapping that with other.d (using overly-generic qSwap(), no less),
simply let the compiler do The Right Thing™ via QArrayDataPointer's
move constructor.

Pick-to: 6.3 6.2
Task-number: QTBUG-97601
Change-Id: I3be30f99f6fb0e17d3550edbe64cbe80880e604a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-03-16 03:26:56 +01:00
Mårten Nordheim
156afbc9b8 Fix qt version tagging on windows with namespaces
The libraries linking to QtCore were looking for
__imp_qt_version_tag_6_4 but the exported symbol was
__imp_qt_version_tag_NAMESPACE_6_4 (with the mangled namespace)

Change-Id: Ida7b18bea4b5e7dab9c0efb63279779d1af898cb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-16 01:10:23 +00:00
Kai Köhne
7d5604c194 Deprecate QElapsedTimer::TickCounter
Also remove left-over code paths related to it.

[ChangeLog][QtCore] QElapsedTimer::TickCounter enum is now
deprecated. Qt does not use the Windows API behind this
enum already since Qt 5.9, so it's fair to assume that
any code path relying on the enum is dead code.

Change-Id: I308fe23658835034774e2015a8ee64659102de56
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-16 00:30:34 +01:00
Kai Köhne
aaa3184f8d Doc: Update documentation for QElapsedTimer's in Windows
We only support Windows versions that feature the PerformanceCounter
API (see also 48fd845c61).

Pick-to: 6.3 6.2 5.15
Task-number: QTBUG-84433
Change-Id: I477f9015ee8c87d31f859f529631f3a6b0215ae6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-03-16 00:30:34 +01:00
Thiago Macieira
cc5cc3225d QHash: Initialize the hash seed as soon as QtCore loads
Instead of lazily initializing (with some platform exceptions, see the
equivalent qsimd.cpp commit). The rationale is the same as for
qCpuFeatures(): this the qHashBits() function is hot and the current
code generation needs to save a lot of state because of the possible
call to the C++ runtime functions to enable the thread-safe
initialization of the hash seed.

[ChangeLog][Important Behavior Changes] QtCore now initializes the QHash
global seed before the main() function is run, so it is no longer
possible to use qputenv() to affect the seed value for the current
process. Disabling the random global seed for the current process should
be done programmatically with by calling either the 6.2 function
QHashSeed::setDeterministicGlobalSeed() or, if compatibility with Qt 5
is required, by calling qSetGlobalQHashSeed() with value 0.

Change-Id: I54f205f6b7314351b078fffd16cf7eae93f9e27e
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-03-15 15:05:44 -08:00
Thiago Macieira
41b2c4204b Q_DECL_INIT_PRIORITY: make the initializers actually run
The runtime runs the function pointers located between subsections $XCA
and $XCZ only, so using $QT meant it would never get run.

Change-Id: Ibf4acec0f166495998f7fffd16d8ecb19019ce10
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-03-15 15:05:44 -08:00
Thiago Macieira
9eae3e9b60 QString: reorganize the {starts,ends}With implementations
Same as the previous commit, one of the reasons it was done like this
was because of git blame. The qt_{starts,ends}_with functions that are
shared between QtPrivate:: and QString:: are getting inlined so there's
no code benefit.

Pick-to: 6.3
Change-Id: Ib42b3adc93bf4d43bd55fffd16c19a8ed3c94483
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-15 15:05:44 -08:00
Kai Köhne
54e4e42083 Doc: Remove mentioning of Windows 7, Vista from QFont documentation
We only support Windows 10 in Qt 6.

Task-number: QTBUG-84433
Pick-to: 6.2 6.3
Change-Id: I0c5bacac570dbb97a71f5af04b645d69040a5fe6
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-03-15 23:05:43 +00:00
David Faure
fd4672d020 QShader: fix memory leak in detach()
qAtomicDetach() does   d = new T(*d);  which calls the copy constructor.
Since there was no copy constructor declared for QShaderPrivate,
the compiler generated one which copied the refcount over, instead of
setting it to 1 in the detached instance. As a result, the destructor
didn't delete the QShaderPrivate.

Nothing was calling this constructor that takes a pointer, so clearly
this was a typo for a copy constructor.

Detected in an ASAN build, the qsb tool exited in error.

Pick-to: 6.3 6.2 5.15
Change-Id: Idbe659b52d2600ac7c11b09142a6aa5b25310df9
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-03-15 21:08:21 +01:00
Mårten Nordheim
d8d202a3ba Fix remaining uses of deprecated QScopedPointer::take
Change-Id: I804aef0aabc1c1bccdf92ff8da7b6c2f5377252a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-03-15 21:08:21 +01:00
Marc Mutz
bbae5c891b QFileSystemEngine: fix potential formatting error
It's not immediately clear that trashedName doesn't contain %1 or %2,
in which case the subsequent .arg() would replace that instead of the
intended %2.

Fix by using QString::asprintf(), which doesn't perform multiple
interpolation passes.

Pick-to: 6.3 6.2 5.15
Change-Id: Ib6c24bfea01db4cdc80f7547c8269cce3f815158
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-03-15 20:05:31 +00:00
Marc Mutz
f3c340c276 QStringTokenizer::toContainer(): allow more types of target containers
The previous constraint called for the value_type of the container to
exactly match the value_type of the tokenizer, which means
toContainer() could only ever work on containers of views. But there
is value in allowing QStringList, even though it works only on QL1S
needles (QStringView -> QString isn't implicit). But users may have
other types that for better or worse implicitly convert from views, so
we shouldn't over-constrain the function.

[ChangeLog][QtCore][QStringTokenizer] toContainer() now works on
containers whose value_type can be constructed from the tokenizer's
value_type. It no longer requires an exact match.

Fixes: QTBUG-101702
Change-Id: Ie384cd1c4b51eaa57675f2a014141ceec8651c81
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-03-15 21:05:31 +01:00
Mårten Nordheim
6eda249402 Fix deprecated use of QBA/Q*String::count
'Use size() or length() instead'

Change-Id: I284fce29727c4c1ec9ea38a4e8ea13a9e0af5390
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-03-15 20:18:56 +01:00
Alexander Volkov
e494b39b33 Unix: Correctly update options pane for PDF printer
Update printer and m_currentPrintDevice before calling
QPrintDialogPrivate::selectPrinter() to show values for
PDF printer instead of the previously selected printer.

Pick-to: 6.3 6.2 5.15
Change-Id: Iacc34ca4460ec4de0b4b373cd875628733df01bd
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
2022-03-15 19:18:55 +00:00
Andreas Eliasson
7c12eb1706 Doc: Revise Qt Core module landing page
Use new global include snippets for the 'Using the Module' section and
reorganize the sections structure. The sections should follow this
order:

- Using the Module
- Articles and Guides
- Examples
- (API) Reference
- Module Evolution
- Licenses and Attributions

Task-number: QTBUG-100369
Pick-to: 6.3
Change-Id: I239bcf53719f0036867ac1d513dc74e1bfa7bc8b
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2022-03-15 18:00:10 +01:00
Andreas Eliasson
dc5a9eacf5 Doc: Revise Qt GUI module landing page
Move some of the sections into an overview page and reorganize the
contents structure. In addition, provide links to the different sections
that are covered in the overview.

Task-number: QTBUG-100369
Pick-to: 6.3
Change-Id: I46eb3df4a09e57f5778002ce694decf134b65e83
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2022-03-15 17:00:10 +00:00