Commit Graph

40813 Commits

Author SHA1 Message Date
Zhang Hao
72931f4920 Fix UI mismatch when QPrinter::setDuplex
Amends fa854f214a. If user call
QPrinter::setDuplex method, the QPrintDialog explicitDuplexMode value
won't update.

Fix this by:
1) handle device-specific default and value set in QPrinter in
QCupsPrintEngine(Private)
2) handle the explicitly user-selected value in QPrintDialog(Private)

Done-with: Michael Weghorn <m.weghorn@posteo.de>
Pick-to: 5.15 6.2 6.3
Fixes: QTBUG-99504
Change-Id: I1a471a8554e83aa4bec8bb95fcc95f9135b0ac8c
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-02-18 12:19:17 +08:00
Zhang Hao
715ed74c89 Sync QPrinter orientation when PageSetup Orientation selected
QPrinter orientation will not effect when PageSetup Orientation selected

Fix this by sync PageSetup orientation property to QPrinter.

Fixes: QTBUG-100261
Pick-to: 5.15 6.2 6.3
Change-Id: I264852ea18317308dfcfb58c880f5e8ad8d299bd
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-02-18 09:06:10 +08:00
Thiago Macieira
9e0f1b905a qsimd/x86: lower the target architecture for load-time code
That is, allow QtCore to get loaded and print its "missing features"
text without crashing with an undefined instruction. We'll still
abort(), so it's still a "crash", but it'll happen after the message is
printed.

Tested with Intel's Software Development Emulator[1]:

$ sde64 -wsm -- ./libexec/rcc
Incompatible processor. This Qt build requires the following features:
    fma movbe avx f16c rdrnd bmi avx2 bmi2 avx512f avx512dq avx512ifma avx512cd sha avx512bw avx512vl avx512vbmi avx512vbmi2 gfni vaes avx512vnni avx512bitalg avx512vpopcntdq

[1] https://www.intel.com/software/sde

Change-Id: I6fcda969a9e9427198bffffd16ce8b86524a566e
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-02-17 17:02:18 -08:00
Thiago Macieira
b7c37e5978 qsimd: Initialize the current state as soon as QtCore loads
Instead of lazily initializing. We usually don't do this in Qt, but in
this case there are two very good reasons for it:

1) the call tp qCpuFeatures() was not trivial, with the need to preserve
   a bit of state in the caller function across the call. GCC appeared
   to generate better code than Clang in this regard, but it still
   implied more cost than we'd like to do runtime detection in
   performance-sensitive places in Qt.

2) the early initialization allows us to use the detected state in GNU
   indirect functions on platforms that support it.

In order to do this, I had to rewrite the QT_NO_CPU_FEATURE environment
variable parsing without QByteArray and instead rely on string.h's
strtok().

This can't be done for static Qt builds on platforms that don't support
the GNU init_priority variable attribute or the MSVC equivalent[1],
because otherwise we can't guarantee that this bit of code runs before
everything else in Qt. For those platforms, we keep the existing lazy
initialization.

For shared builds in those platforms, we can use the dynamic
initialization. All known linkers will sort the static initialization
code in the order in which the .cpp are linked into the library.

The x86 QSimdInitialized variable will be removed in the next commit.

[1] https://docs.microsoft.com/en-us/cpp/preprocessor/init-seg?view=msvc-170

Change-Id: I6fcda969a9e9427198bffffd16ce885a27f6b9e2
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-02-17 17:02:18 -08:00
Thiago Macieira
b2a9646be9 QIODevice::readAll: allow reading from a huge non-sequential devices
On 32-bit systems, the non-sequential device could be pointing to a
device of 2 GB or more in size. If so, we should allow reading up to
the limit (2 GB - overhead), like we do for sequential devices in the
block above.

It could also happen on 64-bit systems, but the chance that you do have
a file bigger than 8 EB is remote.

[ChangeLog][QtCore][QIODevice] Changed readAll() handling of large
non-sequential devices like files that are bigger than the maximum
QByteArray size (on 32-bit systems, just under 2 GB). Previously,
readAll() always returned empty; now it will attempt to read from the
device.

Task-number: QTBUG-100546
Pick-to: 6.3
Change-Id: I74249c52dc02478ba93cfffd16d1a14ac92c77bb
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2022-02-17 17:02:18 -08:00
Marc Mutz
e4fe301a77 QColor: port parsing to QAnyStringView
The private setColorFromString() function was never called from inline
code in Qt 6 (didn't check Qt 5, which doesn't matter for BC purposes).

This is in preparation of adding a QColor::fromString(QAnyStringView).

Change-Id: I265d7c388370e2e7bb417db1573658346aad4690
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-18 01:04:42 +01:00
Allan Sandfeld Jensen
40bc850597 Fix bootstrapped AVX512 code
SIMD_ALWAYS isn't defined and function targets not working during bootstrap

Fixes: QTBUG-100817
Change-Id: I3008db3a32d28f9e4285517a6a23198307e236bc
Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-17 23:35:41 +01:00
Noah Davis
bfcf47ab9d testlib/qasciikey: Add keypad navigation keys
Needed to prevent qasciikey.cpp from failing an assertion when
Qt::Key_Select is used in tests.

Change-Id: I56aa517e8f6f332636b3df106d7265677d1b33ee
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-02-17 16:05:23 -05:00
Morten Johan Sørvig
738a11eeac wasm: reliably determine QScreen position
Fix bug where QWindow content would be drawn with an
offset from the QScreen’s topLeft if the page was scrolled.

On Qt for WebAssembly, screen geometry is equivalent
to canvas geometry, where the canvas position is the
position of the canvas on the document body.

getBoundingClientRect() is the correct function to use
here, however it returns a rect relative to the viewport.
Offsetting this rect by offsetLeft/Top can work in some
bases, but this offset is relative to HTMLElement.offsetParent
and not necessarily to the document body.

Determine the correct QScreen position by subtracting
the body position from the canvas position (both relative
to the viewport).

Change-Id: Ifb7fd28adedbf997d63f79f9b626cfcf3664ff54
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2022-02-17 20:17:38 +00:00
Alexey Edelev
f63bd1a800 Move generating of the QML related android deployment settings
Use _qt_internal_generate_android_qml_deployment_settings from
QtQml module when generating corresponding Android deployment
settings.

Task-number: QTBUG-97795
Change-Id: Ib509160e841fde98e818b0758bdfaff421dbc259
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-17 18:53:55 +01:00
Allan Sandfeld Jensen
65a02da1b5 Make large inputs to qNextPowerOfTwo give undefined output
Fixing documentation and removing tests.

[ChangeLog][Important Behavior Changes] The qNextPowerOfTwo()
functions now have preconditions.

Change-Id: If6d5e8bee66826910e89be7cac388a1f0422ebfd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-17 17:20:34 +00:00
Kai Köhne
4cdfe6f117 Do not highlight the Image Scaling Example anymore in Qt Creator
Pick-to: 6.3
Fixes: QTBUG-100645
Change-Id: I9f2e2c022a00a024917327028b403d36ca2a4b48
Reviewed-by: Kimmo Leppälä <kimmo.leppala@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-17 18:16:42 +01:00
Noah Davis
a792df2ace QGnomeTheme: remove unneeded Q_D
Change-Id: I3fcb1de9487bfdfab16bae5603fed09ef72e01ba
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
2022-02-17 11:26:42 -05:00
Patrick Griffis
8c77825bb7 Respect AT_SPI_BUS_ADDRESS env var on Linux
Change-Id: Ic277b5ebe2d752360cebdb2ff728ca219f9d7124
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
2022-02-17 07:56:41 -06:00
Kai Köhne
669f0e92aa CMake deployment: Make it more explicit what platforms are supported
That only Windows and macOS are supported is mentioned, but deep down in
the description. Let's make it more prominent.

Pick-to: 6.3
Change-Id: Ia34a10f2fcbe0b2f86b5a0c5585277e169b11fa6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-17 13:55:58 +00:00
Kai Köhne
fc9d1a3c89 Doc: Remove cmake-variables qdoc group
The group is not used anymore. It also prevents qdoc to properly put
the variables in the breadcrumb menu (under "CMake Variables in Qt6 Core")

Pick-to: 6.3
Change-Id: I1afe3b1cb7be8dcdda9a6c6e1235e4457800179d
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-02-17 06:54:43 +00:00
Noah Davis
43caaca740 QGnomeTheme: Allow Space, Return, Enter and Select to press buttons
GTK buttons can be pressed with Space, Return and Enter, so this should
be considered native behavior for GTK based desktop environments.
Qt::Key_Select is also included here because QAbstractButton has been
pressable with Qt::Key_Select for a long time.

Change-Id: I2c279ad05d1a10e5968a18996b8b40a83d2251fa
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-16 18:46:06 -05:00
Allan Sandfeld Jensen
1cc0494f7d Correct haswell function target for clang
Clang uses arch names directly, and not the "arch=xxx" format of GCC.

Appears we do not use this target though.

Pick-to: 6.3 6.2
Change-Id: I1d295f25fe2278c5c6bc0f617496555e28427bea
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-16 22:47:13 +01:00
Alexey Edelev
fedd4f26ad Add missing dependency to the qvkgen tool when generating vulkan code
Pick-to: 6.3 6.2
Fixes: QTBUG-100574
Change-Id: Ib68a3d77e5d3c9a9fc541a69a2748b94ade3ceef
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-16 22:47:13 +01:00
Morten Johan Sørvig
2ed3cc8e7a wasm: move canvas configuration to Qt implementation
The required canvas configuration is an implementation
detail; move it out of the .html file (which we expect
that users will replace), and into the QWasmScreen
constructor.

This also enables using a div element as the container
element (instead of a canvas), since Qt then can create
and configure the canvas during QWasmScreen construction.

Change-Id: Ia849517d00fa3e8ec307065a524c0c91296dd490
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2022-02-16 21:20:36 +01:00
Noah Davis
97eeded5fc QPA: add ButtonPressKeys ThemeHint
Platforms should allow more than just Qt::Key_Space and Qt::Key_Select
to press buttons. KDE Plasma developers want to be able to press buttons
with Return/Enter. GTK allows buttons to be pressed with Return/Enter,
so this should be considered the native behavior for GNOME as well.
Adding this ThemeHint allows customizing the keys that can press a
button via a QPlatformTheme subclass.

Change-Id: I73284e9b73590fbdd0b94a0cb4557e94b3722af9
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-02-16 15:10:00 -05:00
Kai Köhne
3cd8099cfc Doc: Fix cmake example snippets
The argument to file(GENERATE...) is called CONTENT, not CONTENTS.

Pick-to: 6.3
Change-Id: I22fb9eb966223e034b2606cf24315d3cf6a03df1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-16 17:41:43 +01:00
Marc Mutz
f310f426d0 qvkgen: optimize generated string tables
Use qOffsetStringArray instead of array-of-const-char* to hold
strings. Saves 174 relocations, as well as over 4KiB in combined TEXT
and DATA size on optimized Linux GCC 11.2 C++20 AMD64 builds.

Pick-to: 6.3
Task-number: QTBUG-100536
Change-Id: I5849168d0340f78664e566920f92ad136f9dc435
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-02-16 16:49:16 +01:00
Thiago Macieira
1f7089437a CBOR: disable UUID and QRegularExpression support in bootstrapped builds
We don't need them.

Drive-by opportunity to ensure byteData() didn't return null. It could
happen.

Change-Id: I74249c52dc02478ba93cfffd16d1e1fc060cdaef
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-16 01:59:51 -08:00
Thiago Macieira
a1b2c474fd QPluginParsedMetaData: avoid the indirection through QCborMap
value[x] is the same as value.toMap()[x] but avoids the refcounting up
and down just to call the operator[] overload. We're calling the
operator[] overload taking an integer, which means it could match an
array, but we know the data member won't be one because of how
QPluginParsedMetaData::parse() parses.

Change-Id: I2cffe62afda945079b63fffd16bd5c690b2bfee4
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-16 01:59:51 -08:00
Axel Spoerl
ea0e0a8652 Eliminate double arrow in QToolButton
- InstantPopup mode is set and
- application uses a stylesheet that does not apply to QToolButton

Task-number: QTBUG-100401
Pick-to: 6.3 6.2
Change-Id: Iadf752ad9280d59763f4efc1938927a9b83e6ad9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-16 10:57:20 +01:00
Thiago Macieira
8de0493896 QMetaObjectBuilder: fix addProperty() recording of the property type
Issue introduced by commit 465701bb98.

[ChangeLog][QtCore][QMetaObjectBuilder] Fixed a bug that would cause
addProperty() to use the incorrect type for the property if the
property's name matched a valid type registered with QMetaType.

Pick-to: 6.2 6.3
Change-Id: Ic15405335d804bdea761fffd16d402f2c9611f30
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-16 01:47:09 -08:00
Thiago Macieira
d34282dba0 QFile::copy: add the underlying error messages to ours
Fixes: QTBUG-100867
Pick-to: 6.3
Change-Id: Ic15405335d804bdea761fffd16d401a7c16f32f9
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-16 01:47:09 -08:00
Thiago Macieira
8f1a827d91 QIODevice::read: don't truncate to int(readBytes)
QByteArray in Qt 6 *can* hold more than 2GB-overhead of data.

Untestable.

Fixes: QTBUG-100546
Pick-to: 6.2 6.3
Change-Id: I74249c52dc02478ba93cfffd16d1a0ab398efe9c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-16 09:47:09 +00:00
Zhang Hao
d978c230a4 Do not highlight the HTTP Example anymore in Qt Creator
Pick-to: 6.3
Fixes: QTBUG-100647
Change-Id: I413b37daf784f3a4975caa5a48273f4a83aa1da6
Reviewed-by: Kimmo Leppälä <kimmo.leppala@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-16 14:40:34 +08:00
Alexandru Croitor
e5b3436255 CMake: Add default launch screen storyboard for iOS apps
Bundle a default LaunchScreen.storyboard file for an iOS app and make
sure it's referenced in the generated Info.plist file.

When launching Qt examples, it ensures the app uses the whole screen
space on the device rather than just a square-ish part of it.

The storyboard file is a copy of the qmake one, which qmake adds
to the Xcode projects it generates.

A custom launch screen can be provided either by setting the
QT_IOS_LAUNCH_SCREEN variable or by setting the
QT_IOS_LAUNCH_SCREEN target property.
The value must be an absolute path to the launch screen file.

The automatic addition of the launch screen entry in the Info.plist
file can be prevented by setting the QT_NO_SET_IOS_LAUNCH_SCREEN
variable to TRUE.

The automatic bundling of the launch screen file in the application
bundle can be prevented by setting the
QT_NO_ADD_IOS_LAUNCH_SCREEN_TO_BUNDLE variable to TRUE.

The current implementation has a limitation that only one launch
screen storyboard and one iOS executable can exist within a project.

If there are multiple executables in the project, all of them will
use the launch screen that is specified last (the last
qt_add_executable call).

Because of this limitation, the API is marked as Technical Preview,
to be improved upon in the future. For now it simply serves as an
improvement to the out-of-the-box experience of iOS apps built
with CMake.

Amends 4d838dae5a

Pick-to: 6.2 6.3
Fixes: QTBUG-95837
Change-Id: I6b067d703d635122959a1ef17fcca713da694a86
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-16 05:14:24 +01:00
Mårten Nordheim
a1fb3971f2 QHash: fix off-by-one in assertions
Coverity-Id: 378365
Coverity-Id: 378366
Coverity-Id: 378399
Coverity-Id: 378427
Coverity-Id: 378468
Coverity-Id: 378472
Pick-to: 6.3 6.2
Change-Id: Ib1efeacb59030b9d004320e56f560367f564d207
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-16 04:24:21 +01:00
Marc Mutz
a24ef92468 QColor: eradicate QT_STRINGVIEW_LEVEL
It's not used and not useful.

Task-number: QTBUG-100861
Pick-to: 6.3 6.2
Change-Id: I30f7f41311182f056f2f6d5a9b49385fb09d194e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-16 04:20:51 +01:00
Sona Kurazyan
221df41572 Move QBindingStorage methods marked for removal to removed_api
From the API review.

Pick-to: 6.3
Change-Id: I676ff811a3b3d43ebcbee78ed0210d669d642947
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-16 02:28:53 +01:00
Thiago Macieira
d1f077a435 QJsonValueRef: don't export the entire class in Qt 7
Change-Id: I54f205f6b7314351b078fffd16d061ca8870b453
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 17:00:05 -08:00
Thiago Macieira
705ea62f9e QJsonValueConstRef: prepare for Qt 7
Instead of storing a pointer to the QJsonArray or QJsonObject (like the
Qt 4 & pre-5.15 versions did), do like QCborValueConstRef and store the
pointer to the QCborContainerPrivate.

Unlike QCborValueRef, we must keep the is_object bit because of API
behavior that assigning an Undefined to an object reference deletes it
from the container. I've chosen to use size_t instead of qsizetype for
this because then we don't lose any bits of the index. Therefore, the
index in the case of objects is stored as pair count (like before),
different from QCborValueRef which stores the actual index in the
QCborContainerPrivate.

It's the LSB (on little-endian architectures) so the calculation of
2 * index + 1 is the actual value stored in memory or in the
register. Unfortunately, right now, both Clang and GCC don't realize
this and generate unnecessary instructions. Clang:

0000000000000000 <QJsonValueConstRef::concreteType(QJsonValueConstRef)>:
   0:   mov    %rsi,%rax
   3:   shr    %rax
   6:   mov    %rsi,%rcx
   9:   or     $0x1,%rcx
   d:   test   $0x1,%sil
  11:   cmove  %rax,%rcx

[GCC code is identical, except it uses an AND instead of TEST]

That OR at offset 9 is a no-op because it sets a bit that is already set
in those conditions. At least they don't do unnecessary shifts.

Change-Id: I89446ea06b5742efb194fffd16bb7aadb6a9b341
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 17:00:05 -08:00
Thiago Macieira
a747ab0b72 QJson{Array,Object}: rewrite & simplify some iterator functions
Instead of manipulating indices in multiple functions, make some call
the others. This reduces the number of places porting must happen at, if
we wanted to.

Change-Id: I89446ea06b5742efb194fffd16bb78d24e0528b2
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 17:00:05 -08:00
Thiago Macieira
01fe59a3b7 QJsonObject::removeAt: stop dividing and multiplying by 2
Change-Id: I89446ea06b5742efb194fffd16bb7d17182c6a2a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:05 -08:00
Thiago Macieira
d263147921 QJsonValueRef: optimize the assignment
Inline some content to avoid unnecessary round-trips through
qcborvalue.cpp, qjsonarray.cpp and qjsonobject.cpp.

Unlike the CBOR counterparts, JSON support has this extra functionality
that assigning Undefined causes the item to be removed from the object
(arrays don't have that behavior, they just become null).

And unlike QCborValueRef, we detach on assignment, not on the obtention
of the QJsonValueRef. This is more dangerous, so we may want to revise.

Change-Id: I89446ea06b5742efb194fffd16bb775e9566ca1a
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 17:00:05 -08:00
Thiago Macieira
c1780165ee QJsonValueConstRef: optimize to{Int,Integer,Bool,Double,String}()
The CBOR-based implementation from Qt 5.15 simply created a QJsonValue and
then called the equivalent function on that result. For integrals and
double where the QJsonValue matched the asked type, the cost was minimal
anyway. For the other types and when the type didn't match, this
resulted in up/down the reference counter in QCborContainerPrivate and
an out-of-line call to the destructor.

This improves the performance for code like:

  for (QJsonValue v : array) {
      if (v.toString() == x) {
          doSomething();
      }
  }

This change propagates the inadviseable behavior of allowing a
dereference of the end() reference in concrete() to concreteType() (and
unit-tests it) but does not do the same for the toXxx() functions. Doing
that causes a dereference of QList's end() iterator, which is UB
(asserts false in debug mode).

Change-Id: I89446ea06b5742efb194fffd16bb3beccd1098e4
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:04 -08:00
Thiago Macieira
dccd1e87f5 QJsonValueConcreteRef: optimize concrete()
Inline the content to avoid a round-trip through qjsonarray.cpp and
qjsonobject.cpp.

This change revealed an inadviseable unit test check that dereferences
the end() iterator to get its type. I haven't changed it, but have
marked with ###. I also fixed a likely copy&paste mistake in that test.

Change-Id: I89446ea06b5742efb194fffd16bb774f3bfbe5f5
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:04 -08:00
Thiago Macieira
e99417106f QJsonObject::erase: erase unnecessary and wrong code
Commit 35adb74ddd ("Reimplement JSON
support on top of Cbor") accidentally forgot to multiply by 2 the index
stored in the QJsonObject::iterator. The same mistake was propagated
when QJsonObject::iterator was converted to QJsonValueRef. This had no
ill effects because the o->elements container would always contain more
elements, but it meant the check was ineffective and meant nothing.

So instead of doing nothing when the iterator does not point to this
container, simply assume it does. Bad things will happen if you try to
erase an iterator that points to another container, but that's true for
almost all container/iterator mechanisms.

Drive-by modernization of some of the surrounding lines.

Change-Id: I89446ea06b5742efb194fffd16bb7c322c2fc4f2
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:04 -08:00
Thiago Macieira
f276f9ec6b QCborValue: use assignContainer() in few more places
Change-Id: I5e52dc5b093c43a3b678fffd16b6eb65ef37399d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:04 -08:00
Thiago Macieira
ccea344640 QCborValue: optimize the array-to-map conversion
Yes, this is a cold function, but we can do it in-place if we want to.

Done in three separate passes so the autovectorizer can do its thing, if
it wants to.

Change-Id: I5e52dc5b093c43a3b678fffd16b6eb34d02fc40b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:04 -08:00
Thiago Macieira
f4d49910be QCborValueConstRef: optimize to{Integer,Bool,Double,String,ByteArray}()
The initial implementation from Qt 5.13 simply created a QCborValue and
then called the equivalent function on that result. For integrals and
double where the QCborValue matched the asked type, the cost was minimal
anyway. For the other types and when the type didn't match, this
resulted in up/down the reference counter in QCborContainerPrivate and
an out-of-line call to the destructor.

This improves the performance for code like:

  for (QCborValue v : array) {
      if (v.toString() == x) {
          doSomething();
      }
  }

Change-Id: I5e52dc5b093c43a3b678fffd16b6022da4e2d446
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:04 -08:00
Thiago Macieira
afe2f80c6a QCborValueRef: merge the operator[] into a template
Change-Id: I5e52dc5b093c43a3b678fffd16b6e94ad9d3f39b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:04 -08:00
Thiago Macieira
832fcbf37f QCborValue: merge the const operator[] into a template
Change-Id: I5e52dc5b093c43a3b678fffd16b6ec4b7d841955
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:04 -08:00
Thiago Macieira
072f0d5717 QCborValue: merge the non-const operator[] into a template
Change-Id: I5e52dc5b093c43a3b678fffd16b6e7b32b3e2835
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:03 -08:00
Thiago Macieira
f1c305cbd2 QCborMap: merge the operator[] methods into a template
Change-Id: I5e52dc5b093c43a3b678fffd16b6e7a123338178
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:03 -08:00
Thiago Macieira
11ea172178 QCborMap: merge the constFind methods into a template
Change-Id: I5e52dc5b093c43a3b678fffd16b6e558c4e1f089
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:03 -08:00
Thiago Macieira
3531f578d3 QCborArray: allow large but in-range keys
The 0x10000 limit should not apply if the key is a valid index in the
array.

Change-Id: I5e52dc5b093c43a3b678fffd16b6a2a5a69acd61
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:03 -08:00
Thiago Macieira
800f60657d QJsonObject: use QJsonValueConstRef
Change-Id: I5e52dc5b093c43a3b678fffd16b608f32f8eb4b4
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 17:00:03 -08:00
Thiago Macieira
f5762cd4b3 QJsonArray: use QJsonValueConstRef
Change-Id: I5e52dc5b093c43a3b678fffd16b6086dcd1d3268
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:03 -08:00
Thiago Macieira
51fc317041 QCborMap: use QCborValueConstRef
Change-Id: I5e52dc5b093c43a3b678fffd16b606e4249a205b
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 17:00:03 -08:00
Thiago Macieira
64d568b550 QCborArray: use QCborValueConstRef
Change-Id: I5e52dc5b093c43a3b678fffd16b6077e5c4abd63
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 17:00:03 -08:00
Thiago Macieira
04dc959d49 Introduce Q{Json,Cbor}ValueConstRef
I screwed up when I wrote QCborValueRef by not having the ConstRef
type. The code worked, but it wasn't const-correct, allowing you to
write:

  const QCborArray &arr = something();
  *arr.begin() = QCborArray();

This mistake was brought over to QJsonValue in Qt 6.0, so it has to be
fixed for QJsonValue too. The actual fixes are in the next couple of
commits.

This change is believed to be binary-compatible: the Q{Json,Cbor}ValueRef
classes continue to have the exact same size, except that they're now
empty and have a new base class. They weren't trivial before this commit
doesn't change that.

[ChangeLog][Potentially Source-Incompatible Changes] The iterator
classes for Qt's JSON and CBOR containers (array and map/object) had a
const correctness issue which allowed a const_iterator to mutate the
container being iterated on, even if that container was itself const. Qt
6.4 has a fix for this, but will cause compilation issues where
QCborValueRef and QJsonValueRef were used where the correctness could be
violated. To keep code compiling with both 6.3 and 6.4, either change to
non-const iteration or replace the QxxxValueRef with a const QxxxValue
reference. This change is binary-compatible.

Change-Id: I5e52dc5b093c43a3b678fffd16b6063333765ae0
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 17:00:03 -08:00
Thiago Macieira
9b8f064cd3 QCborValueRef: fix using operator[] to convert an empty array to map
The flag IsContainer was not set, causing the QCborContainerPrivate to
become confused.

This commit also expands and subsumes the existing test for QCborValue
(non-Ref).

Change-Id: I5e52dc5b093c43a3b678fffd16b6a17c6f4a0676
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:03 -08:00
Thiago Macieira
3c7b507d1c QCborValueRef: add a test to confirm that its methods reflect QCborValue
This has found several missing const qualifications, a missing
QCborMap::Iterator method, and a missing one in QCborValue too.

The methods "### TEMPORARY" in this commit are actually removed in two
commits.

Change-Id: I5e52dc5b093c43a3b678fffd16b6939f62954dc4
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 17:00:02 -08:00
Marc Mutz
e7706429bb QLibrary: add a #warning if the fall-back plugin-meta-data parser is used
Change-Id: I4b42f8dbc9fb03fc6e7243ed4914acfb1bdfe62a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-16 01:20:13 +01:00
Ivan Solovev
60799fc141 Android A11Y: Fix value rounding
QAccessibleInterface stores values as QVariants. When dealing with
double values, as a result of some calculation (for example, Slider
value update), rounding errors can be introduced.
When converting double values to QString using QVariant::toString(),
these rounding errors result in strings like
0.30000000000000004 instead of 0.3 or
2.7755575615628914e-17 instead of 0.3 - 3 * 0.1 and similar zeroes.

To fix this issue, this patch introduces a custom conversion for
floating-point values. The idea is to convert QVariant to double,
and then convert double to QString using 'f' format and a suitable
precision, determined from the UI element's minimumStepSize(), if
it has one, otherwise falling back to QString::number()'s default
(which is 6).

Task-number: QTBUG-93396
Pick-to: 6.3 6.2 5.15
Change-Id: Ia5ca7345812e39629e9c191b6d8b896a8f51de80
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-02-15 17:51:33 +01:00
Ivan Solovev
a374d59abc Android A11Y: Announce value together with element name when focused
Before this patch when we focus a new element, only its description
was announced.
For elements like Slider that means that if it had no accessible name
or description, its value would be announced (all is fine here).
But if the slider is defined like that:
 Slider {
     Accessible.name: "int slider"
     value: 5
     from: 0
     to: 20
     stepSize: 1
 }

only the name ("int slider") will be announced, but not the actual
value.

This patch fixes the logic of content description generation. If the
element has value, then it is added to the description and announced
as well.

Task-number: QTBUG-93396
Pick-to: 6.3 6.2 5.15
Change-Id: Ia8667149ebd867945c5f57d951fd6ade0f382598
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-02-15 17:51:33 +01:00
Ivan Solovev
b238f83380 Android A11Y: handle valueChanged events
Before this patch Android A11Y implementation was missing
ValueChanged event handling. As a result, no update was given
when the element's value was changed.

Handling these events allows us to announce value changes on such
objects like Slider, SpinBox, etc...
This is a universal method of value-change announcement, so it
supports all sorts of A11Y gestures.

On the Java side a new function was introduced to announce the
values, because we need to use the actual element's *value*,
not its accessible name or description.

Task-number: QTBUG-93396
Pick-to: 6.3 6.2 5.15
Change-Id: Ic44abd5f01b9b6f5468962131466edaf6a49d498
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
2022-02-15 17:51:33 +01:00
Laszlo Agocs
b48e6e783b Convert Vulkan instance setup from Qt Quick into a Gui helper
Make it possible to reuse what's in QSGRhiSupport from other modules as
well. Both Gui (texture-based widget/backingstore composition) and
Multimedia are potential users of this in the future.

Change-Id: I1b50cc5efd6811e9bc95f6287b9576931d4bcc44
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2022-02-15 15:36:01 +00:00
Øystein Heskestad
6deded8bc4 Change third party SHA-3 implementation to use
Task-number: QTBUG-71327
Change-Id: I14fef2a6f66dfb26f635cc7b6bde2b7cbf733ea7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-15 15:44:51 +01:00
Marc Mutz
d34c3f9e94 QLibrary: use QStaticByteArrayMatcher
Because of code-after-return style, I don't actually know what the
code is used for, but since it's compiled, make sure to not leave a
dynamically-initialized static variable lying around, even if control
never reaches it.

Pick-to: 6.3
Change-Id: I6ce30d8c060f96a2d819ed85f79d18a7ef7e9b05
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-15 15:44:51 +01:00
Alexandru Croitor
1559cd8ff2 CMake: Document source file properties
Pick-to: 6.2 6.3
Task-number: QTBUG-100224
Change-Id: Id4d0e0d84762d9eee2beb10e850d1775ad4f3245
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-02-15 15:44:51 +01:00
Thiago Macieira
d08f59d083 qsimd: simplify the code slightly
Only x86 requires more than 32 different bits in the CPU feature
variable, so enforce the need for 64-bit atomics only for it. Everyone
else can stick to 32-bit atomics, which are supported everywhere.

Change-Id: I54f205f6b7314351b078fffd16cf7c7d50a84102
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 04:20:35 -08:00
Marc Mutz
37a25fce94 QDesktopServices: deprecate destroying URL handlers w/o explicit unsetUrlHandler()
[ChangeLog][QtGui][QDesktopServices] URL handlers that have been passed
to setUrlHandler() must now be removed by calling unsetUrlHandler()
before they are destroyed. Relying on the handler's destructor to
implicitly unset it is now deprecated, because it may already be in use
by concurrent openUrl() calls. Support for implicit unsetting will be
removed in 6.6 and, until then, a qWarning() is raised if it is
exercised.

Fixes: QTBUG-100775
Fixes: QTBUG-100779
Pick-to: 6.3 6.2 5.15
Change-Id: I0c4f91b78f847b135fdeb38766babc892bdc1379
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 12:20:16 +00:00
Fabian Kosmale
06e45cbd6a QFileSystemEngine::canonicalName (Unix): clean up control-flow
When passing a nullptr to realpath, it will allocate memory. That memory
has to be freed (with free) later to avoid a leak, which we so far
didn't.
This patch ensures that we always clean up the memory by using a
unique_ptr. As a drive-by, clean up the control-flow:
- Always pass either the stack buffer or nullptr to realpath.
- Rely on realpath returning nullptr in the error case.
Lastly, fix a few coding-style issues.

Change-Id: Ia906df77324020c267b087ec52a9a6c47aaa2a59
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-15 12:05:33 +01:00
Allan Sandfeld Jensen
e1b76e68d0 Fix clang-cl warning
Warns the include is non-standard, so replace it with standard
includes.

Pick-to: 6.3
Change-Id: I8db4b65a3f706cb31215332277a3378df88a0003
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-15 12:01:31 +01:00
Joerg Bornemann
85970834b5 CMake: Promote qt6_standard_project_setup from technical preview
The API couldn't be simpler (function without arguments), and we want to
use the function on our "Getting Started with CMake" documentation page.

Pick-to: 6.3
Task-number: QTBUG-100793
Change-Id: I83ba66c2970ac7441b425add4df1da2695e50ddb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-15 10:23:03 +01:00
Tor Arne Vestbø
f71d54ee34 Update docs for QSurface::MetalSurface to include iOS
Pick-to: 6.3 6.2
Change-Id: I67fc47b3dc33960e7dfa78890d16d1e7450e30ab
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-15 09:11:00 +01:00
Joerg Bornemann
da27a95aab Compile QNetworkAccessDebugPipeBackend only in developer builds
This fixes a moc warning in non-developer builds.

Change-Id: I879a17715fd682382ce47ce4cfd7e162f8ceb2de
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-15 09:10:59 +01:00
Marc Mutz
3ec76f82ba QBitmap: de-inline dtor
The destructor of this polymorphic class was incorrectly marked for
removal in Qt 6, and, unfortunately, that was carried out. Now it
delivers one of the most-duplicated vtables across all of Qt (at least
four duplicates), and we can never add anything to it until Qt 7
(because existing code de-virtualized it as a no-op).

Task-number: QTBUG-45582
Pick-to: 6.3
Change-Id: I85bd3b13dca9f1fc8cb62ca079a1168a33f71323
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-15 09:08:16 +01:00
Marc Mutz
9b6c288281 De-duplicate vtables, 2022 edition
This de-inlines destuctors of classes whose vtables are proven to be
duplicated even within the set of Qt libraries.

Since these are all private API classes, we can pick all the way back
to 6.2, and we don't need the comment that the dtor must always stay
empty, like for public classes.

As a drive-by, also de-inline the QPaintDeviceWindowPrivate ctor.
That's just code hygiene, it doesn't partake in vtable duplicating.

Pick-to: 6.3 6.2
Task-number: QTBUG-45582
Change-Id: I3477063d6f42edc9a5d352c47900366fd50c3ef6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2022-02-15 09:08:16 +01:00
Yin Jie
60a67dc41e Position QCompleter popup based on the widget's screen geometry
If adding a QLineEdit to a QGraphicsScene as a QGraphicsProxyWidget, the popup
completion of that QLineEdit is drawn in the wrong location. When the completer
getting the rect of screen, it gets the rect of the QGraphicsScene where
QLineEdit is located rather than the rect of the screen, resulting in an error
in the following calculation.

Note that as long as the completer popup is a toplevel widget not parented
to the target widget, it will not be automatically embedded into the graphics
view via QGraphicsProxyWidget. So with multiple views for a scene, or in views
that use transformations, the geometry will still be off.

Pick-to: 6.3
Task-number: QTBUG-20531
Change-Id: If5d8a707ca35a9e4709117b077978145c6143e46
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-15 01:28:30 +00:00
Viktor Arvidsson
7794421bea Windows QPA: Correct mistake when calculating minmaxinfo
Amends 46e9852a1d

The previous code would fail if the windows taskbars are placed
to the top or left on the screen. The mistake was missed because
Windows seems to adjust the window position automatically
in case the window handles WM_NCCALCSIZE and returns 0,
which was the case for me.

Task-number: QTBUG-51327
Pick-to: 5.15 6.2 6.3
Change-Id: I38ef974f7518be63a0bacf080f3359c219284078
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2022-02-14 23:48:23 +01:00
Øystein Heskestad
c6958cbbd6 Add new third party SHA-3 implementation to replace old obsolete one
[ChangeLog][Third-Party Code] Added new SHA-3 implementation to Qt Core.
The code is available under BSD 3-Clause "New" or "Revised" License.

Task-number: QTBUG-71327
Change-Id: Ib1f1003b0ef7e6f6c3787cbbd45f3f06fc667b7e
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2022-02-14 17:32:14 +01:00
Andreas Buhr
d456102962 Make Droid Sans Mono available as fixed font for all Android styles
Fixes: QTBUG-87405
Change-Id: I54ebc06c82c32acd0383ea5fedf78acce4e11977
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-02-14 16:22:28 +01:00
Marc Mutz
40e2bf3495 QFlatMap: temporarily disable some code
... which implements or assumes something about the
broken^Wnon-STL-compliant insertion behavior.

Once this has integrated into all module dependencies, we can
re-implement these APIs using STL-compatible semantics.

Task-number: QTBUG-100092
Change-Id: I54f4f5ce7addd9543866d2c399f48aff50983b88
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-02-14 13:20:03 +01:00
Eskil Abrahamsen Blomfeldt
d6c4a3edf9 Fix integer overflow for broken QPainterPaths
With some bogus input, we can end up with NaN in the
bounding rects of the control points. This in turn
causes problems later when it is converted to ints
and used in code. To avoid it, we exit early if the
rect is invalid (negative or NaN size).

Pick-to: 5.15 6.2 6.3
Fixes: QTBUG-100217
Change-Id: Idbc6700b85cb30198d69fedbf8f3be3e1ab65e40
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-02-14 12:51:10 +01:00
Kai Köhne
8275611766 Core: Remove 'properties' feature
Even QtCore alone cannot be built without the properties feature since
Qt 5.5. While fixing this is easy, other modules like dbus,
networking are also using QObject::property() and friends liberally.

All in all I doubt that anybody will miss the feature (otherwise it
would have been fixed in the last decade).

Change-Id: Iaf3cc20bda54ee2ff3b809fac8fa82b94ecc88c0
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-14 12:50:59 +01:00
Ivan Solovev
b99fdae5f5 Android A11Y: populate child elements when constructing node info
This commit partly reverts 020a6f0dae.
It restores the code that is responsible for filling the children
for individual elements. Without this code, we have only top-level
element and its children in our accessibility hierarchy.

Fixes: QTBUG-100545
Pick-to: 6.3 6.2 5.15
Change-Id: I0604bbf5f1bdb0b3998a25fec7ed0a1fe554da8d
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-02-14 09:34:36 +01:00
Marc Mutz
c8e03f129e QHashSeed: remove 'pure' attribute on globalSeed()
While 'pure' in GCC is weaker than Stepanov's Regular Procedure from
Elements of Programming (equal result for equal inputs), it does not
allow accesses to volatile memory:

> functions declared with the pure attribute can safely read any
> non-volatile objects

The globalSeed() function reads from an atomic variable that can be
changed at any time from another thread.

Atomics, while not volatile objects in the sense of the keyword, must
fall under the pure attribute doc's exclusion criterion:

The difference between a volatile and an atomic access, while
important for the implementation of the function, is indistinguishable
to the caller of the function: both volatile and atomic objects can
change value without the current thread of execution changing them,
with no way for the caller of the function to distinguish which one
occurred.

Therefore, globalSeed() should not be pure.

5.15 is not affected, as qGlobalQHashSeed() is not marked as pure.

Task-number: QTBUG-62185
Pick-to: 6.3 6.2
Change-Id: I6fc52e2bd41ef4aa3f8039072b47c7a1314b98fa
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-12 12:39:52 +01:00
Marc Mutz
b5c4d1f50b QPkmHandler: make const what it never modified
Pick-to: 6.3 6.2 5.15
Change-Id: I0bda0d93ebe60d4923f3e9eb059cddb61192b1b5
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-12 12:39:52 +01:00
Marc Mutz
f482e2a456 QDesktopServices: fix ABA problem in QOpenUrlHandlerRegistry
The registry is designed to be thread-safe, as is openUrl(), and
handlers are required to be thread-safe, too: "the handler will
always be called from within the same thread that calls
QDesktopServices::openUrl()".

The handlerDestroyed() slot was invoked using AutoConnection
semantics, which, if the registry and the handler happen to not be on
the same thread, is QueuedConnection, which means there's a window in
which the handler is destroyed, but it's still listed in the registry,
and a call to openUrl() may make a call to the (deleted) handler.

Worse, if a handler is deleted and new one registered they may end up
on the same address (ABA, or rather, AA problem), and then the delayed
call to handlerDestroyed() may remove the entries to the new handler,
as well as those to the old.

Fix by using Qt::DirectConnection. This fixes the ABA problem, but
doesn't completely fix the partially-destroyed problem, since
QObject::destroyed() is simply too late. We need to require explicit
unsetUrlHandler() calls, which should happen before destruction of the
handler object starts.

[ChangeLog][QtGui][QDesktopServices] Fixed a bug where destroying and
re-creating a handler object in quick succession could cause the
registration for the handler to be lost.

Fixes: QTBUG-100778
Pick-to: 6.3 6.2 5.15
Change-Id: I76fd81724504cc7f38ac262b43e3e9539fe5ebca
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-12 11:39:52 +00:00
Marc Mutz
42e13b7c61 QDesktopServices: fix UB (data race on handlers)
The handlerDestroyed() function is connected to the handler QObject's
destroyed() signal and removes all entries from the registry for which
the destroyed object was listed as the handler.

While handlerDestroyed() is always executed in the context of the
thread owning QOpenUrlHandlerRegistry-as-a-QObject, the documentation
explicitly states that "the handler will always be called from within
the same thread that calls QDesktopServices::openUrl()", implying that
calling openUrl() from a non-GUI thread is supported. The presence of
the mutex also indicates that this should work.

But then the unprotected access to the handlers variable in
handlerDestroyed() is a data race, because nothing prevents a handler
object from being destroyed concurrent to an openUrl() call.

Fix by locking the mutex.

Fixes: QTBUG-100777
Pick-to: 6.3 6.2 5.15
Change-Id: I9ef857efa609b4d16ee21063ccccd316e119576b
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-12 12:39:51 +01:00
Thiago Macieira
4fd4082c3a QStringView: add missing constexpr so we can use is_constant_evaluated
GCC 12 -std=c++20 says:

 qstringview.h:155:39: error: ‘std::is_constant_evaluated’ always evaluates to false in a non-‘constexpr’ function [-Werror=tautological-compare]

With this, it's possible to declare:

  constexpr QStringView sv = u"Hello, World!";
  QStringView f() { return sv; }

And GCC will generate:

        movl    $13, %eax
        leaq    .LC0(%rip), %rdx
        ret

Writing simply
  QStringView f() { return u"Hello, World!"; }

Causes GCC to emit a comparison loop (the std::char_traits::length
function), but at least there's no function call in either C++17 or
20. Clang 13 is able to reduce the loop to a constant and produces the
same code as the constexpr variable in either mode.

Pick-to: 5.15 6.2 6.3
Change-Id: I74249c52dc02478ba93cfffd16d282fa35a5b883
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-12 07:59:32 +00:00
Ilya Fedin
bc3723d462 Make indicator-application hack work in flatpak
Flatpak doesn't share $XDG_RUNTIME_DIR with the host making
QSystemTrayIcon not to work on Xubuntu/Ubuntu MATE/Ubuntu Budgie.

Although, it shares a subfolder, according to
https://docs.flatpak.org/en/latest/sandbox-permissions.html

Amends 0baa26638d

Pick-to: 6.3 6.2 5.15
Change-Id: I2d0043fc5a4c2c51e8fa1a920f3cada3b07eba6d
Reviewed-by: Dmitry Shachnev <mitya57@gmail.com>
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
2022-02-12 03:01:08 +04:00
Viktor Arvidsson
46e9852a1d Windows QPA: Fix frameless maximize on secondary screens
Frameless windows shouldn't cover the taskbar when maximized.
This has been fixed for the main screen in the past but did not
work for secondary screens. According to the code the MINMAXINFO
is only available for the main screen but I believe this is a
misunderstanding of the Windows documentation.  Besides
we use QScreen::availableGeometry() which seems to be correct.

Fixes: QTBUG-51327
Pick-to: 5.15 6.2 6.3
Change-Id: Ib2205c480359d1a870dcfcf0312fbe417f650e28
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-02-11 23:05:20 +01:00
Allan Sandfeld Jensen
a0d1f6b5aa Remove documentation of non-existing QAccessible state
invalidEntry is commented out

Pick-to: 6.3 6.2 5.15
Change-Id: Iffb661ec85b1b633f56c9aba94c1f0727a93c987
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-11 22:56:35 +01:00
Thiago Macieira
47cf674477 QTimerInfo/Unix: Fix roundToMillisecond when it's already rounded
Don't add 1 ms when it's rounded to 1 ms.

Found when running unit tests on QNX, where the clock did not update
between two subsequent calls to clock_gettime().

All of this ought to be refactored to use std::chrono::nanoseconds.

Fixes: QTBUG-100438
Pick-to: 6.2 6.3
Change-Id: I47dc6426c33d3a66dec946ae3589694745ed1835
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-11 13:02:35 -08:00
Sona Kurazyan
407d076124 Remove mentions of QtConcurrent::runWithPromise from docs
cf043a785a unified QtConcurrent::run() and
QtConcurrent::runWithPromise(). Remove the last mentions of
runWithPromise. Also did some minor cosmetic improvements.

Pick-to: 6.3
Change-Id: Ie3b39600978ccfa4a009d3ff68567a348dc7b166
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2022-02-11 22:02:35 +01:00
Mårten Nordheim
52492ff720 HTTP: Make redirect response parsing more generic
To enable its use in the http2 protocol handler.
This factors out the error-reporting code for HTTP 1, which in
any case has to be done differently for HTTP 2, saving duplication
and simplifying the redirect handling code.

Task-number: QTBUG-100651
Pick-to: 6.3 6.2 5.15
Change-Id: I4b470646a9ad5ee702c9b1921d115e137d3d5b8b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-11 21:54:44 +01:00
Alexey Edelev
eab5ec5a37 Strip the ending slashes for resource folders
Setting a value for the QT_RESOURCE_ALIAS source file property on a
path ending with a slash (a directory) is not handled properly by
CMake. This leads to unpredictable values being set for multiple
directories. Fix this by stripping the the final slash from the file
path, which makes CMake think it's a file rather than a directory.

Change-Id: I7a39be68e6f58bf2726c80108da9947057e7add6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-11 21:54:44 +01:00
Allan Sandfeld Jensen
ace9764c99 Fix tst_qmath when compiled with C++20
On several platforms std::bit_ceil() returns 1 for input values that
would overflow the output. Our test expects 0 though. Since the value
is documented as undefined, avoid it.

Pick-to: 6.3 6.2
Change-Id: I00556893a8f0e1e24f08f73cd112b56148bc5bd0
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-11 20:47:21 +01:00
Ievgenii Meshcheriakov
4082fe8a39 Make QProcessEnvironment(Initialization) noexcept
Use default noexcept constructor to initialize `d` member.
Document Initialization enum.

Fixes: QTBUG-100695
Pick-to: 6.3
Change-Id: I7585ad154a9be40021a205b515ffa7b14f188d67
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-11 20:47:21 +01:00
Morten Johan Sørvig
5958c28d9f wasm: improve qstdweb::EventCallback
We are storing a copy of the this pointer in the constructor,
and later deference it to access EventCallback object
memebers. This makes the class noncopyable: delete
the copy constructor to make sure it isn’t.

Also change the callback API to propagate the event
to the event callback.

Change-Id: Ida4bb192b3e905b260ebeec30293aad71b7d8c49
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2022-02-11 18:15:26 +01:00
Pino Toscano
7c54988b1b Avoid a stack buffer when not needed
Allocate a PATH_MAX-sized buffer on stack only in case we are not using
realpath(X, null), i.e. on platforms with older POSIX versions, macOS,
or Android.

This fixes the build on platforms that do not have PATH_MAX (e.g.
GNU/Hurd), and it provides a minor optimization on realpath(X, null)
platforms.

Change-Id: Icd92a1b15ec18c5eef8113408e9610dfac774101
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-11 15:36:02 +01:00
Christian Ehrlicher
15f7ef26b8 QMdiSubwindow: respect minimum size of subwidgets when shown maximized
Size a QMdiSubWindow is no real toplevel widget, QLayout::activate() did
not properly set the minimum size based on it's children. Fix this by
treating a QMdiSubWindow as a toplevel widget during the calculation.

Fixes: QTBUG-100494
Change-Id: Ia2e6c519c7214c36383facd244711bd932231d40
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-11 07:03:24 +01:00
Qiang Li
d54bb53247 QPlainTextEdit: fix the visibility of placeholderText
If one calls setPlainText("") before setting a placeholder text,
the placeholder visibility is not updated, and the placeholder is not
visible. Fix it by updating placeholderVisible properly.

Fixes: QTBUG-96212
Pick-to: 5.15 6.2 6.3
Change-Id: I1bd3f0cb4c59973a847bcf3787e35d7c17b6d673
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-11 02:01:03 +01:00
Thiago Macieira
81b9ee66b8 QLibrary: Suppress GCC 12 warning about dangling pointer access
Introduced in commit d07742f333. Reported
by GCC 12:

qlibrary.cpp:672:9: error: dangling pointer to ‘candidates’ may be used [-Werror=dangling-pointer=]
  672 |         if (isValidSuffix(*it++))
      |         ^~
qlibrary.cpp:634:29: note: ‘candidates’ declared here
  634 |         const QLatin1String candidates[] = {
      |                             ^~~~~~~~~~

This is a false positive report because the lambda does not return a
pointer or iterator. But it's a good update anyway to keep the array
outside the lambda, so it won't be recreated every time.

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

Pick-to: 6.3
Change-Id: I74249c52dc02478ba93cfffd16d230abd1bf6166
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-11 00:19:57 +00:00
Alexandru Croitor
a844695e64 CMake: Fix incorrect link to 'Using qt.conf page'
Pick-to: 6.3
Change-Id: I469fc4adb8982e2bd3d38807950eb0c324c481a6
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-02-10 20:45:38 +01:00
Thiago Macieira
5be4c5aa0f QHash: mark murmurhash() and siphash() hot and never-inline
Don't allow the compiler to inline them in qHashBits() because they
require a lot of register use and add to the hot code path to aeshash().

Now all calls in this function are tail calls.

Change-Id: I54f205f6b7314351b078fffd16cf7f2f97d99144
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-02-10 11:40:48 -08:00
Thiago Macieira
708de710f1 Disable URL support in the CBOR-JSON conversion in bootstrapped mode
We don't need it.

Pick-to: 6.3
Change-Id: I74249c52dc02478ba93cfffd16d1dfc0e88f55ef
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-10 11:40:48 -08:00
Thiago Macieira
5e378aaff6 QStandardPaths/Win: fix build with old MinGW SDK
...that may lack GetCurrentProcessToken. The definition in the new SDKs
is:

  FORCEINLINE HANDLE GetCurrentProcessToken (VOID)
  {
    return (HANDLE)(LONG_PTR) (-4);
  }

This is a partial revert of ae7e11e5c6.

Pick-to: 6.3
Change-Id: I74249c52dc02478ba93cfffd16d23c487229f95d
Reviewed-by: Yuhang Zhao <2546789017@qq.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2022-02-10 11:03:09 -08:00
Joerg Bornemann
9a0cfaf78d Remove QT_FEATURE_sharedmemory from qconfig-bootstrapped.h
This amends commit 75082c9f20.

Change-Id: Idd1f9a8cd86c1d265d20917594fbeea26f1f8bf2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-10 17:52:27 +01:00
Mårten Nordheim
24249c0b67 QStringConverter: Add missing include on Windows
It's relied on implicitly, which is no longer valid in dev.
And may accidentally be broken in other branches.

Pick-to: 6.3 6.2
Change-Id: I2272b6914e883e20d0989a1762eb1a5c1aef4e0e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-10 16:52:26 +00:00
Fabian Kosmale
5f987317a7 Split namespace macros from qglobal.h into their own header
Task-number: QTBUG-99313
Change-Id: I7fb0a82de68ebcc75d86612b4b3f79dc0099db1f
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-10 17:40:55 +01:00
Andreas Buhr
00f1bd00d0 Set Roboto as the default font on Android
Roboto is the default font on Android. So far, Helvetica
was used, which is usually unavailable on Android.

Task-number: QTBUG-87405
Change-Id: I53332403a43f6a005ce73ece68b8dddc41b4b58c
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-02-10 15:43:00 +01:00
Allan Sandfeld Jensen
8d714c0c69 Fix compiling with C++20 on macOS
This code triggers warnings about mixing enums of different
types, which breaks compiling with warnings-are-errors.

'bitwise operation between different enumeration types is deprecated'

Pick-to: 6.3 6.2
Change-Id: Ib6c19f02f7c7593c9e22da5e648ea1f2f2ae757b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-10 12:54:36 +00:00
Kevin Funk
f57fd83f7d Fix -Wsuggest-override warnings from Clang 11+
Before this patch, Clang versions greater than 11.0.0 emitted
-Wsuggest-override warnings whenever the Q_OBJECT macro was used.

Excerpt from compiling GammaRay against Qt 6, using Clang 13.0.0:

```
.../qtbase/src/corelib/io/qfile.h:96:5: warning: 'qt_metacall' overrides a member function but is not marked 'override' [-Winconsistent-missing-override]
    Q_OBJECT
    ^
.../qt5/qtbase/src/corelib/kernel/qtmetamacros.h:166:17: note: expanded from macro 'Q_OBJECT'
    virtual int qt_metacall(QMetaObject::Call, int, void **); \
                ^
.../qt5/qtbase/src/corelib/io/qfiledevice.h:54:5: note: overridden virtual function is here
    Q_OBJECT
    ^
.../qt5/qtbase/src/corelib/kernel/qtmetamacros.h:166:17: note: expanded from macro 'Q_OBJECT'
    virtual int qt_metacall(QMetaObject::Call, int, void **); \
                ^
```

This was also discussed on the QtCreator mailing list:
  https://www.mail-archive.com/qt-creator@qt-project.org/msg08500.html

Pick-to: 6.2 6.3
Change-Id: I149782472ce8a2e30ed8062ada460c39926f1613
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-10 12:38:19 +00:00
Thiago Macieira
dcdb8884e7 QFreeList: replace a Q_ASSERT(false) with Q_UNREACHABLE()
Q_ASSERT goes away in release builds, Q_UNREACHABLE() does not.

This also solves the GCC 12 warning about out-of-bounds access in
QAbstractEventDispatcherPrivate::allocateTimerId():

In member function ‘_PTp* std::__atomic_base<_PTp*>::load(std::memory_order) const [with _PTp = QFreeListElement<void>]’,
    inlined from ‘_Tp* std::atomic<_Tp*>::load(std::memory_order) const [with _Tp = QFreeListElement<void>]’ at atomic:579:25,
    inlined from ‘static T QAtomicOps<X>::loadAcquire(const std::atomic<T>&) [with T = QFreeListElement<void>*; X = QFreeListElement<void>*]’ at thread/qatomic_cxx11.h:249:29,
    inlined from ‘X* QBasicAtomicPointer<X>::loadAcquire() const [with X = QFreeListElement<void>]’ at thread/qbasicatomic.h:233:64,
    inlined from ‘int QFreeList<T, ConstantsType>::next() [with T = void; ConstantsType = QtTimerIdFreeListConstants]’ at qfreelist_p.h:245:34,
    inlined from ‘static int QAbstractEventDispatcherPrivate::allocateTimerId()’ at kernel/qabstracteventdispatcher.cpp:99:24:
bits/atomic_base.h:820:31: warning: ‘long unsigned int __atomic_load_8(const volatile void*, int)’ writing 8 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=]
  820 |         return __atomic_load_n(&_M_p, int(__m));
      |                ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
In file included from qglobalstatic.h:1,
                 from qglobal.h:1395:
qglobalstatic.h: In static member function ‘static int QAbstractEventDispatcherPrivate::allocateTimerId()’:
qglobalstatic.h:127:23: note: at offset -8 into destination object ‘holder’ of size 56
  127 |         static Holder holder;
      |                       ^~~~~~

Pick-to: 5.15 6.2 6.3
Change-Id: I74249c52dc02478ba93cfffd16d232b275d5d216
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-10 11:10:15 +00:00
Sivan Nanthiran
cb9ef46c77 Change comparison data type to fix int overflow
Since the value returned by CGDisplaySerialNumber is uint32_t,
comparing it with a long data type can cause overflow when the
value is greater than or equal to 2^31. And since this is a serial
number, in some machine this value can be greater than 2^31.
In those machines, QScreen::name will be empty due to the failed
check here.

Pick-to: 6.3 6.2 5.15
Change-Id: Ia037ba9e7a6d8025cc4b41c1b428eba38455330d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-10 11:10:14 +00:00
Marc Mutz
65b62d2d5c QPageSize: pack StandardPageSize struct
On most platforms, the old struct had a padding hole before the FP
members, as well as after the character array.

By packing the integer members into bit fields, we compress five ints
incl. the padding hole (24 bytes) into 64 bits w/o padding (8
bytes). The size of the struct shrinks from 80 to 64 bytes, saving
almost 2KiB in TEXT size. Four bytes of tail padding remain, and are
available to grow the character array in the future.

More compactification could be had by changing the FP members (either
by turning them into floats and/or by making them a union over {mm,
in}, because one can be calculated from the other), but these are for
another patch, because they change return values.

Pick-to: 6.3 6.2
Change-Id: I0e7f354a0341e94e9a9401a7d3b4529a8ff20a3d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-10 10:03:37 +01:00
Thiago Macieira
6586b030d1 Fix GCC12 warning about using a pointer after realloc()
qmalloc.cpp:92:18: warning: pointer may be used after ?void* realloc(void*, size_t)? [-Wuse-after-free]
   92 |         qptrdiff oldoffset = static_cast<char *>(oldptr) - static_cast<char *>(actualptr);
      |                  ^~~~~~~~~

Pick-to: 6.2 6.3
Change-Id: I74249c52dc02478ba93cfffd16d230165b6f030f
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-09 20:13:34 -08:00
ChunLin Wang
52a83658c3 Don't replace IntersectClip with ReplaceClip on a QPicture
QPainter should not try to be smart and optimize IntersectClip with ReplaceClip when working on a QPicture paint device. Doing so will change the end result as the actually state when replayed might be different from the one it was recorded in.
QPainter will no longer try to replace IntersectClip with ReplaceClip if the paint engine is a QPicture.Consistent with QPainter::setClipRect and QPainter::setClipRegion.

Fixes: QTBUG-100420
Pick-to: 6.2 6.3
Change-Id: I1e0ebbc2d6e1ffd98b9f3f537e83893579606a4b
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-02-10 12:08:05 +08:00
Zhang Hao
bb67b6ff26 Always update pressedPosition when drag was enabled
Since e02293a76d and
2e0c29a4bb was committed,
If a item width more than others,the selectionRect.x() always consist
of currentStartSelection item's rect.center().x(),this will cause
selectionRect size is not right.

Because the code of 2e0c29a4bb is to fix
the new bug introduced by e02293a76d,
we need to use a better way to solve QTBUG-78797.

When itemview enable drag,we need always update pressedPosition because
pressedPosition was used to determine the drag distance, otherwise keep
previous logic.

Fixes: QTBUG-78797
Fixes: QTBUG-81542
Fixes: QTBUG-99512
Pick-to: 6.2 6.3
Change-Id: Ibc5020e35b0eb319e4b5546bdba39ff527c209a6
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-02-10 03:37:18 +00:00
Fabian Kosmale
ae7799a924 qtextstream.h: streamline includes
[ChangeLog][Potentially Source-Incompatible Changes] The qtextstream
header no longer includes <QString>, <QStringEncoder> and
<QStringDecoder>. Code which relied on the implicit inclusion of those
classes might now need to include the headers explicitly.

Task-number: QTBUG-97601
Change-Id: Ifb8c8452026195a772c0588dbbbc53fb51cac548
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-10 04:34:13 +01:00
Alexey Edelev
2201934efa Use 'copy' but not 'copy_if_different' on Windows platforms
Use custom script to copy big Android artifacts on Windows platforms.
The script uses 'copy' but not 'copy_if_different' when source file
size is bigger than 2GB. 'cmake -E copy_if_different' only compares
first 2GB of files because of cmake issue, so this step only
workaround the problem.

Pick-to: 6.2 6.3
Task-number: QTBUG-99491
Change-Id: Id076734700e334dfc3330da412462c2b53829b33
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-10 02:31:05 +01:00
Assam Boudjelthia
5deb4e7d25 Android: document how to handle code that loads QML from strings
If an app is loading QML from a string at runtime from C++, the
dependencies/imports might not be bundled into the app package,
and then the app might fail at runtime. A fix is to have a QML
file with needed imports to properly deploy those impots' libs.

Fixes: QTBUG-100394
Pick-to: 6.2 6.3
Change-Id: I10136dc2dd1ac1f4ffe00bcf2cfd6c98e050ef28
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2022-02-10 01:45:10 +02:00
Marc Mutz
d60af047fe QUrl: use qOffsetStringArray for idn_whitelist
Removes 61 relocations from QtCore:

before:

  $ ~/bin/relinfo.pl libQt6Core.so.6.4.0
  libQt6Core.so.6.4.0: 6364 relocations, 5407 relative (84%), 318 PLT entries, 1 for local syms (0%), 0 users

after:

  $ ~/bin/relinfo.pl libQt6Core.so.6.4.0
  libQt6Core.so.6.4.0: 6303 relocations, 5346 relative (84%), 318 PLT entries, 1 for local syms (0%), 0 users

Pick-to: 6.3
Task-number: QTBUG-100536
Change-Id: I29be3416eaacf7b2049d1e3eec15600d7e7c37c0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-09 21:26:20 +00:00
Mårten Nordheim
4fe79a23cd QAbstractSocketPrivate: Initialize members in-class
Change-Id: I267b5037801f226379a154731be9ef81cccb828e
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-02-09 22:26:20 +01:00
Mårten Nordheim
50c8ec9fa4 QAbstractSocket: Don't pretend pause and resume is a stack
It only stores one layer of state, and pausing twice in a row will just
overwrite the previous state. This doesn't happen often but can happen,
especially on Windows if a certificate needs to be looked up in the system
certificate stores (socket gets paused) and then a recoverable error
occurs in QNAM (socket gets paused again).

Fixes: QTBUG-100362
Fixes: QTBUG-63196
Fixes: QTBUG-98476
Pick-to: 6.3 6.2 5.15
Change-Id: Ie524c48e11b6fa8010b78cc1bf3931efe2ce3351
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-02-09 22:26:20 +01:00
Allan Sandfeld Jensen
f3d89adf6d Remove redundant semi-colons
Triggers warnings in clang

Pick-to: 6.3 6.2
Change-Id: I324a3c253eed9ed31a7475040da77d5c1bcdb394
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-09 21:26:19 +00:00
Allan Sandfeld Jensen
5a90ca19e6 Remove redundant semi-colons
Clang warns us against them.

Pick-to: 6.3 6.2
Change-Id: I9af45e9254f6a1adb3e8d78983f458b0302b0d57
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-09 21:26:19 +00:00
Ivan Solovev
7c00ad4e9a Android: Re-focus focused accessibility node after orientation change
Before this patch the accessibility focus on a selected element could
be drawn incorrectly after the screen orientation has changed.
The reason for that is that wrong X and Y offsets were used for it.
The offsets are used to take the sizes of different panels (like
buttons and notifications bar) into account.
Normally they are updated only when getNodeForView() is called and the
whole accessibility info is reconstructed.
However, when the screen orientation changes, we get some
getNodeForVirtualViewId(selectedId) calls before the whole accessibility
tree is recreated. This is when redrawing happens, and as I understand,
this is an internal Android event, so we can't do much about it.

The most straightforward fix for the problem would be to query the
offsets also in each getNodeForVirtualViewId() call. However, offset
calculation seems to be quite heavy operation, and
getNodeForVirtualViewId can be called very often (esp. if we have a lot
of UI elements). As a result, this fix can't be implemented.

In this patch I came up with the second approach - once getNodeForView()
is called, and it detects that the offsets have changed, we force
re-focus of the currently selected element. This allows us to retain the
offsets-caching mechanism.

Fixes: QTBUG-93402
Pick-to: 6.3 6.2 5.15
Change-Id: Ic420afe1fe5e80fbdf91b2b2651f2daa71c6e44d
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-02-09 21:46:25 +01:00
Marc Mutz
0a24e2e984 QSettings: use QtMiscUtils hex tools instead of rolling your own
Removes a static string literal. QtMiscUtils allows the compiler to
possibly avoid the array, or share with other TUs

Pick-to: 6.3
Change-Id: I449800f113620a53d2f4b11fe027ebcb710f7b86
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-09 21:46:25 +01:00
Marc Mutz
e65a14f82f QTzTimeZonePrivate: make ZoneNameReader constinit'able
It's used as a thread_local static, so it better be.

What prevented it was the unused inheritance from QObject and the
missing constexpr ctor of the StatIdent() data member.

Fixed both.

Pick-to: 6.3
Change-Id: I312ed6dc8bf7193cdaa7dc708bf19b018e56ec8a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-09 21:46:25 +01:00
Marc Mutz
38d2f60f9a QPropertyBindingSourceLocation: make (source_location) ctor constexpr
The typical argument, source_location::current(), is consteval, so it
cannot actually be used outside constexpr contexts. Having a
non-consteval, non-constexpr ctor to accept the return value is
conceptually wrong, as a constexpr-only result is forced though a
non-constexpr function. It may even trigger MSVC's consteval bug:

  https://developercommunity.visualstudio.com/t/Cannot-use-std::source_location-in-C-m/1436152

because the work-around given, wrapping in a lambda, means wrapping
the result in a constexpr context, and that may just be the root cause
of the issue.

Pick-to: 6.3 6.2
Change-Id: I49534cf86f32e16b13d7e169cd5cb0c8fc374d69
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-09 21:46:24 +01:00
Marc Mutz
e128ed2c5d Convert string tables in QShaderDescription to use string literals [2/2]
Avoid allocating all these strings on load. Part 2: JSON keys.

Pick-to: 6.3 6.2
Change-Id: I1724a58d700509c3af90ad1b87cb1bccae1075b8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2022-02-09 20:46:24 +00:00
Marc Mutz
bfd21b888b QPageSize: remove 119 relocations
Also saves ~1.4KiB in combined TEXT and DATA size on optimized Linux
GCC 11 C++20 AMD64 builds.

Pick-to: 6.3 6.2
Change-Id: I53922ccd191e412a13e3e23f2e26fdb3bf43af33
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-09 21:46:24 +01:00
Marc Mutz
d04d571d3a QEventDispatcher/GLib: avoid three relocations
This string table is small, so instead of using qOffsetStringArray(),
just don't make it static. The compiler will do it's thing, then,
without introducing relocations.

Proof:

  $ ~/bin/relinfo.pl libQt6Core.so.6.4.0
  libQt6Core.so.6.4.0: 6303 relocations, 5346 relative (84%), 318 PLT entries, 1 for local syms (0%), 0 users

vs.

  $ ~/bin/relinfo.pl libQt6Core.so.6.4.0
  libQt6Core.so.6.4.0: 6300 relocations, 5343 relative (84%), 318 PLT entries, 1 for local syms (0%), 0 users

Task-number: QTBUG-100536
Pick-to: 6.3 6.2
Change-Id: I7f5c3c127867c9baebfb270ef3e257dd818f821a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-09 21:46:24 +01:00
Alexey Edelev
15bcf03f3e Mention that the QT_ANDROID_ABIS property only affects executable targets
Pick-to: 6.3
Task-number: QTBUG-100208
Change-Id: I3ca0a2b74f87557772fd7ac34f280ec1b2344dd1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2022-02-09 21:46:24 +01:00
Thiago Macieira
29fceed2ff QProcess/Unix: ensure we don't accidentally execute something from CWD
Unless "." (or the empty string) is in $PATH, we're not supposed to find
executables in the current directory. This is how the Unix shells behave
and we match their behavior. It's also the behavior Qt had prior to 5.9
(commit 28666d167a). On Windows, searching
the current directory is the norm, so we keep that behavior.

This commit does not add an explicit check for an empty return from
QStandardPaths::findExecutable(). Instead, we allow that empty string to
go all the way to execve(2), which will fail with ENOENT. We could catch
it early, before fork(2), but why add code for the error case?

See https://kde.org/info/security/advisory-20220131-1.txt

[ChangeLog][Important Behavior Changes] When passed a simple program
name with no slashes, QProcess on Unix systems will now only search the
current directory if "." is one of the entries in the PATH environment
variable. This bug fix restores the behavior QProcess had before Qt 5.9.
If launching an executable in the directory set by setWorkingDirectory()
or inherited from the parent is intended, pass a program name starting
with "./". For more information and best practices about finding an
executable, see QProcess' documentation.

Pick-to: 5.15 6.2 6.3
Change-Id: I54f205f6b7314351b078fffd16cf7013c97ee9fb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-09 11:26:32 -08:00
Marc Mutz
ec03db7bb3 Fix C++20 ambiguous relational operators between QJsonValue{,Ref}
In C++20, any given relational operator is also considered in its
reversed form, so e.g.

   given op==(X, Y)
   and X x, Y y, then y == x will compile, by using the reversed op(X, Y)

This, unfortunately, makes some existing asymmetric operator overload
sets ambiguous, and instead of applying tie-breaker rules, at least
Clang is warning about these.

For us, this means we need to make our overload set non-ambiguous. The
QJsonValue{,Ref} classes failed this, because they only provide the
following member-operators:

- QJsonValue::op==(const QJsonValue&) const
- QJsonValueRef::op==(const QJsonValue &) const

For member functions, there are no implicit conversions on the LHS. So
in C++17, we have a nice dichotomous overload set:

- LHS is QJsonValue -> use QJsonValue::op==(QJsonValue)
- LHS is QJsonValueRef -> use QJsonValueRef::op==(QJsonValue)

In both of these, it the RHS is a QJsonValueRef, it's implicitly
converted to QJsonValue for the call.

Enter C++20, and the reversed signatures are suddenly available, too,
which is a problem for QJsonValueRef <> QJsonValueRef, which could be
resolved, as in C++17, using

  lhs.QJVR::op==(QJV(rhs))

or it could now be

  rhs.QJVR::op==(QJV(lhs)); // reversed

Says Clang 10:

  tst_qtjson.cpp:990:5: warning: ISO C++20 considers use of overloaded operator '==' (with operand types 'QJsonValueRef' and 'QJsonValueRef') to be ambiguous despite there being a unique best viable function [-Wambiguous-reversed-operator]
    CHECK(r0, a0, r1);
    ^     ~~      ~~
  qjsonvalue.h:189:17: note: ambiguity is between a regular call to this operator and a call with the argument order reversed
    inline bool operator==(const QJsonValue &other) const { return toValue() == other; }
                ^

A similar argument makes op!= ambiguous.

Says Clang 10:

  tst_qtjson.cpp:988:5: error: use of overloaded operator '!=' is ambiguous (with operand types 'QJsonValueRef' and 'QJsonValueRef')
    CHECK(r0, r0, r1);
    ^     ~~  ~~
  qjsonvalue.h:190:17: note: candidate function
    inline bool operator!=(const QJsonValue &other) const { return toValue() != other; }
                ^
  qjsonvalue.h:189:17: note: candidate function
    inline bool operator==(const QJsonValue &other) const { return toValue() == other; }
                ^
  qjsonvalue.h:189:17: note: candidate function (with reversed parameter order)

To fix, provide the missing operators as free inline functions (so Qt
6.2 and 5.15 don't get new symbols added) so there's always exactly
one best match.

This is a fix for 6.2 and 5.15. At the time of writing, 6.3 isn't
released, yet, so there, we could QT_REMOVED_SINCE the pre-existing
member operators in favor of hidden friends (as per QTBUG-87973).

Use C++17'isms to prevent an automatic merge to 5.15, which requires

   contains(QT_CONFIG,c++2a):CONFIG += c++2a

added to tst_qtjson.pro.

[ChangeLog][QtCore][QJsonValue] Fixed relational operators to not
cause warnings/ambiguities when compiling in C++20.

Pick-to: 6.3 6.2 5.15
Change-Id: Ic70f3cad9987c87f7346d426c29cc2079d85ad13
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-02-09 20:26:31 +01:00
Sona Kurazyan
c0ede98727 Export QFutureCallOutInterface to allow external use
2dea20e4b0 de-inlined the dtor to avoid
duplicating its vtable in multiple translation units, but the class is
used externally, so we need to export it now.

Pick-to: 6.3
Fixes: QTBUG-100569
Change-Id: I7cf2abdfdeb59bced0631838fe329ba94ab8c73a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-09 20:26:31 +01:00
Joerg Bornemann
d03385df9d Remove QXml* from bootstrap lib
Those classes are not used by any bootstrapped tool.

Also remove the QT_BOOTSTRAPPED code paths.

Change-Id: Ic5a9b153a578fedcba37cd81a62ccf0182a2d34f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-09 19:49:37 +01:00
Joerg Bornemann
4fb5923432 Remove QLine, QPoint, QRect, and QSize from bootstrap lib
Those classes are not used by any bootstrapped tool.

Change-Id: I82fc32e16d044b91ab3a79109ab98a3010df2e2d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-09 19:49:37 +01:00
Thiago Macieira
ea89d0a36c qglobal: add a way to selectively export in Qt 6 XOR Qt 7
Because at least one compiler *cough*MSVC*cough* is unable to dllexport
a method that is in a dllexport'ed class.

Change-Id: I54f205f6b7314351b078fffd16d06b4e6ef0c086
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-09 10:49:37 -08:00
Thiago Macieira
0e84d04b90 qglobal: Move the export macros further up in the file
Before the #ifdef __cplusplus and namespace start. We don't need to
export anything from C (and I hope that remains the case), but at least
this removes the need for QT_{BEGIN,END}_INCLUDE_NAMESPACE. Which also
weren't needed.

Pick-to: 6.2 6.3
Change-Id: I54f205f6b7314351b078fffd16d0bc84c57cb2ec
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-09 18:49:37 +00:00
Joerg Bornemann
b9cd52bef3 Remove QDom from bootstrap lib
It's not used by any bootstrapped tool.

Change-Id: Id6751e80bb34642aeaea1c2bb4f24b480280623d
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-09 19:49:36 +01:00
Joerg Bornemann
c22b30f594 Remove QSystemSemaphore from bootstrap lib
This class is used by androidtestrunner, which is not bootstrapped.

Change-Id: Ie75b4dd039f773a8ccb58f243bf9f74a5121c3f3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-09 19:49:36 +01:00
Tor Arne Vestbø
985f0e9ca5 macOS: Don't print stack trace via lldb on test failure if SIP prevents it
If the CSR_ALLOW_UNRESTRICTED_FS bit of System Integrity Protection (SIP)
is enabled lldb will fail to print a valid stack trace when launched from
the crashed process, and might also resulting in hanging or crashing the
parent process (Terminal e.g.):

  https://github.com/llvm/llvm-project/issues/53254

We detect this situation and avoid printing a stack trace if so.

Pick-to: 6.3 6.2
Change-Id: Iad8cab5fcdc545d810ca4d4e985aefc0988d0234
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-02-09 18:19:57 +01:00
Tor Arne Vestbø
13fa00519d doc: Update GenericDataLocation location on iOS
Now matches implementation.

Fixes: QTBUG-100364
Pick-to: 6.2 6.3 5.15
Change-Id: I1274b8b485f1a02a79b7abebc2289613958f9a76
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-09 18:19:57 +01:00
Tor Arne Vestbø
242e35e774 Avoid file-static initialization of symbols that need @availability check
Fixes crash in key mapper on iOS < 13.4, where the symbols are not
available.

Pick-to: 6.2 6.3
Fixes: QTBUG-100518
Change-Id: I9bb1a75b17e5f0f50205b757fdb673218d7fb5e0
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-02-09 18:19:57 +01:00
Volker Hilsheimer
851143eff1 macOS: Prevent recursion when modifying the edit menu
Amends d42cfeb84f, which would result in
infinite recursion when the Edit menu was populated and added to the
menubar after the menubar has been shown.

Add a macOS-only test case that reproduces the crash without the fix.

Fixes: QTBUG-100441
Pick-to: 6.3
Change-Id: I018a7aa7f01558a3b9732b4d6d96a911dc7fbd19
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-09 18:19:57 +01:00
Mårten Nordheim
a6f4a1b282 QNetConMonitor/Win: Drop all warnings down to debug
The things they warn about are not of any serious consequence
to users or end-users and there's nothing they can do about it.
Adding to that, in Qt 6 it has a reduced role since
QNAM::networkAccessible was removed.

Fixes: QTBUG-100482
Pick-to: 6.3 6.2
Change-Id: I178d056c513b5dbb122d5c731af602d3dc117d8e
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-02-09 16:48:26 +01:00
Fabian Kosmale
4fe8ed6288 Reduce qaccessible includes
Forward declare some types in qaccessiblewidgetfactory_p.h instead of
including qaccessible.h. In turn, qapplication.cpp which relied on
transitive includes now needs to include qaccessible_base.h.

Change-Id: I8ac00d45a7ffccd84769fb210f29364a45bcd59e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2022-02-09 16:48:26 +01:00
Fabian Kosmale
1734c4ee98 qaccessible: Split QAccessible into own header
qaccessible.h includes quite a few heavy headers. While QAccessibleEvent
and QAccessible can be forward declared, the enums in QAccessible
cannot. By moving QAccessible into its own lightweight header, we can
significantly reduce the cost of using the enums.
qaccessible.h still includes qaccessible_base.h, and the syncqt rules
are adjusted to ensure that this changes is source compatible.

Additionally, we no longer include cstdlib, as we only need cstring.

[ChangeLog][Potentially Source-Incompatible Changes] <QAccessible> no
longer includes <stdlib.h>. This might break code that relied on
transitive includes.

Task-number: QTBUG-97601
Change-Id: I15fbd9c85f5746885f9e89eabfc6d07b9bb1f968
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2022-02-09 15:48:26 +00:00
Ivan Solovev
e0c61193ea Android A11Y: execute C++ code on main Qt thread
The C++ code, which is called from Java, was executed on Java thread.
However Qt has its own main GUI thread, where all GUI elements and their
accessibility instances are created.
As a result we have threading issues when accessing A11Y objects from
Java thread.

This patch uses QMetaObject::invokeMethod calls to dispatch all the
critical parts of the C++ code to the main thread.
It uses BlockingQueuedConnection, so that Java thread can still use
these methods synchronously.
The proper context is based on the m_accessibilityContext object, which
is created as a child of the base accessibility QObject of the
application (which is the QGuiApplication instance in most cases).

Task-number: QTBUG-95764
Pick-to: 6.3 6.2 5.15
Change-Id: Iff4f3f2645657f6aca426fa19ccc86a2cbe4d4d0
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Jarkko Koivikko <jarkko.koivikko@code-q.fi>
2022-02-09 16:48:26 +01:00
Ivan Solovev
6d00aac109 Android: extract parentId for hidden object in advance
This commit amends 850a7f1238.
We can't extract the parentId for the hidden object on Java side,
because the Java call is executed in a separate thread, so the
original hidden object can be destroyed somewhere in the middle of
parentId() call.
As a workaround, we get the parentId in advance, on C++ side, and pass
it as a parameter to JNI function.

Task-number: QTBUG-95764
Pick-to: 6.3 6.2 5.15
Change-Id: Ied2ab4ab39b947f3f582575cf77cc76fbac9e274
Reviewed-by: Jarkko Koivikko <jarkko.koivikko@code-q.fi>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-02-09 16:48:26 +01:00
Joerg Bornemann
81178294f1 Doc: Fix some \cmake*since statements
Some properties and commands were mistakenly assigned to Qt 6.3.

Pick-to: 6.3
Task-number: QTBUG-100212
Change-Id: I504021863ce628628af469f0ac12881c2eb07dbb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-09 16:48:25 +01:00
Allan Sandfeld Jensen
2536d73adc Fix accuracy with screen composition
It was using a faster divide by 256 instead of an accurate divide by
255. This meant black screen wasn't a null operation as it should be.

This also fixes alpha mixing for a few other compositions.

Pick-to: 6.3 6.2 5.15
Fixes: QTBUG-100327
Change-Id: I149ad39147176e00ce753979d55dc8633704dc1a
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-02-09 15:33:46 +01:00
Edward Welbourne
76bdbeb862 Document float-to-qfloat16's rounding more carefully
Having just spent another afternoon wrapping my head around why this
code is correct, I chose to save the next person (quite possibly me)
faced with it the slowest half of the effort that went into doing so.
This amends commit d3ff95dcb8

Change-Id: If0fcd2fb1fff5e99b1046d07039169e928fda9e4
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-02-09 15:33:46 +01:00
Eskil Abrahamsen Blomfeldt
d4de57de42 Fix regression when displaying emojis on Windows
This amends b0e8ba783b. A
copy-paste error accidentally broke emojis on Windows.

Change-Id: I758572604370d170b8effd6c0ff97e09489fafa4
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
2022-02-09 15:33:45 +01:00
Mårten Nordheim
9ec94f31b0 QNetworkInformation: Rename parameter-less load() to loadDefaultBackend
To clarify its purpose and separate it from the others

Pick-to: 6.3
Change-Id: Id9efcf474ac0cd8777393380bb85c83780454005
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-02-09 15:17:54 +01:00
Mårten Nordheim
af7e5c78d9 QSocks5: Un-virtualize what is never overridden
Change-Id: Iec9f56ff24c94f05eba4fc54fa48df3af3de7801
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-09 15:17:53 +01:00
Kai Köhne
604ace0095 Widgets: Do not include qundogroup.h, qundostack.h in QtWidgets header
The headers are already included in QtGui/QtGui. This also fixes
an issue when compiling with the respective features disabled.

Pick-to: 6.2 6.3
Fixes: QTBUG-100290
Change-Id: I5e7c6578952535315bacde218a26d2133c486b2c
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-09 15:17:53 +01:00
Andreas Eliasson
29229f34b2 Doc: Fix minor grammar issues in qtgui landing page
Task-number: QTBUG-100369
Pick-to: 6.3
Change-Id: I89497facbb33c4a47420a1ba0dd61f51ab407a77
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2022-02-09 15:17:53 +01:00
Andreas Eliasson
5cd8d217b4 Doc: Fix minor grammar issues in qtdbus-index
Task-number: QTBUG-100369
Pick-to: 6.3
Change-Id: Id224b7838b49934b46f00ea44c67aa1c201648d6
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2022-02-09 15:17:53 +01:00
Andreas Eliasson
de47400387 Doc: Merge two bullet list items into one
My understanding is that the two bullet list items should be
treated as one item.

Pick-to: 6.3
Change-Id: Ibdd2bbc8677e925e71e6de7b3f076a1fab3914bf
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2022-02-09 15:17:53 +01:00
Andreas Eliasson
6f0cde223a Doc: Remove link command
This link command simply links back to the same page. Also, none of the
other modules put their module name inside a link command at the
beginning of the document, for example: The Qt QML module provides...

Pick-to: 6.3
Change-Id: I2299b92f44ee736d181f34d9e71a31ba210a34e8
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2022-02-09 15:17:52 +01:00
Laszlo Agocs
178c1a6243 rhi: Add the long-pending probe() helper, with backing for Metal
There is a TODO for this in Qt Quick from the 6.0 times. To decide
upfront if Metal can be expected to function, or if a fallback to
OpenGL needs to be triggered (especially important with macOS virtual
machines, where, unlike any real macOS system, Metal may not be
present at all), the scenegraph calls create() and then drops the
result. The idea to make this less wasteful was back then to add a
dedicated probing function which can, possibly, perform the checks in
a more lightweight manner than full initialization. Implement this
now, focusing on Metal.

Brought to attention by QTBUG-100441: printing warnings about not
having an MTLDevice is confusing in a Metal-less macOS VM, because it
is not an actual error, only part of the probing at scenegraph
initialization. We can now avoid printing confusing warnings there.

Change-Id: Ie52c36af9224bedc3f5e4c23edb486d961c9f216
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-02-09 14:02:57 +01:00
Tor Arne Vestbø
1f93ff529b Add warning about native interface APIs to platform headers
Those platform specific classes are not covered by our
binary/source compatibility guarantee between minor releases.

Pick-to: 6.3
Change-Id: I2a69c7ea07feea62fdf9899839e47fc540f89c12
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-09 14:02:57 +01:00
Fabian Kosmale
0477c78a04 QMetaProperty: remove property auto-registration code
Qt 6 automatically registers all types used in properties. Thus, the
functionality is mostly obsolete since Qt 6. We can simply return the
stored metatype's id instead.
The code in moc is kept in place for compatibility with older code,
though there seem to be no remaining users of the metacall in Qt itself
anymore.

Change-Id: I3c654150988ae7780b4e9ea1f16191fdadf8d791
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-02-09 14:02:57 +01:00
Fabian Kosmale
0af3d57980 qmetatype: Remove left-over module association code
Qt 6's metatype does no longer care whether the type is from Core, GUI
or a user metatype.

Change-Id: I4f41d44a61a9839f58b957219c2404512630587a
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-09 14:02:57 +01:00
Fabian Kosmale
454a9424b7 qmetatype_p.h: remove unused function
Change-Id: Ib07e1c87e4e9fe5d1018876b044513fae951ac0e
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-02-09 14:02:56 +01:00
Fabian Kosmale
348f67d7ec qmetatype.h: remove unused includes
[ChangeLog][Potentially Source-Incompatible Changes] The qmetatype.h
header no longer includes qvarlengtharray. It might be necessary to
include the header explicitly if code previously relied on it being
implicitly included.

Change-Id: If58245836715ec8a323ec8cbadc67d73a742b15f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-09 14:02:56 +01:00
Shawn Rutledge
49d3080155 xcb: Show valuator atom names properly in categorized logging
During a touch update, this looked questionable since I don't have any
barcode readers or buttonboxes attached:

XI2 touch event type 19 seq 1481 detail 193 pos  116.3,   77.8 root pos 6476.3, 2941.8 on window 3e00006
   valuator              BARCODE value 47796.365791 from range 0.000000 -> 65535.000000
   valuator            BUTTONBOX value 59504.858830 from range 0.000000 -> 65535.000000
   touchpoint  193  state  QEventPoint::Updated  pos norm  QPointF(0.729326,0.907986)  area  QRectF(...

After the fix it's like this:

XI2 touch event type 19 seq 1235 detail 201 pos  154.0,   64.3 root pos 6168.0, 2794.3 on window 5000006
    valuator    Abs MT Position X value 45520.589958 from range 0.000000 -> 65535.000000
    valuator    Abs MT Position Y value 56519.790001 from range 0.000000 -> 65535.000000
    touchpoint  201  state  QEventPoint::Updated  pos norm  QPointF(0.6946,0.862437)  area  QRectF(...

ValuatorClassInfo's QXcbAtom::Atom is a Qt enum, which has to be
converted to xcb_atom_t before we can call xcb_get_atom_name_name.
Originally in ce2fe90faa vci was of type
XIValuatorClassInfo; then 7499d4404f
changed it to our ValuatorClassInfo struct, but didn't add the lookup
indirection to this qCDebug.

Pick-to: 5.15 6.2 6.3
Change-Id: Ib6107f17d6c6c209573e3df54149d6cfffc0b8b6
Reviewed-by: Liang Qi <liang.qi@qt.io>
2022-02-09 06:47:19 +00:00
Shawn Rutledge
cf2ec5a5fc doc: clarify that passive-grab API is only for Qt Quick Pointer Handlers
...for now anyway. The plan is to have C++ API for custom handlers
later on; and we'll see if we find any other "must-have" use cases.

Task-number: QTBUG-68110
Pick-to: 6.2 6.3
Change-Id: I5e624a500af37797345d25bb5f54b146b13a45ca
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
2022-02-09 06:46:57 +00:00
Thiago Macieira
8058127a9d QLibraryInfo: remove load-time variable
Since this is only used by qtpaths and qmake, let's not make every
application pay the price of dynamically initializing a QString whenever
QtCore is loaded (which 100% of Qt applications do). Instead,
initializing a null pointer costs zero and is one third the size of
QString. Even the assignment in qmake and qtpaths is faster this way.

Pick-to: 6.3
Change-Id: I6fcda969a9e9427198bffffd16ce8d1eb8dc19da
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-05 11:57:34 -08:00
Shawn Rutledge
6b2c9b81af Deprecate QContextMenuEvent and QMouseEvent ctors without globalPos
As with QHoverEvent, it's better to require globalPos rather than
"initialized to QCursor::pos(), which may not be appropriate" as the
docs have pointed out for many years now. This removes the remaining
calls to QCursor::pos() in event constructors.

Task-number: QTBUG-52430
Task-number: QTBUG-69433
Task-number: QTBUG-100324
Change-Id: I076dae56f37abaad7085cc95dddee453a80a45f3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-05 17:18:35 +01:00
Allan Sandfeld Jensen
a300c3810c Detect clang-cl features as clang not as msvc
Clang-cl supports the clang detections, and only approximates specific
MSVC version.

This works as the MSVC standard library is ahead of the clang standard
library. Where this logic was written 7 years ago when it was not the
case.

Pick-to: 6.3
Change-Id: Ic13e2f2fbcde011a0d8831cc48c0c9041bfe3b99
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-05 11:06:37 +00:00
Fabian Kosmale
e400ba64a3 Use acq_rel ordering semantics in qatomic_cxx11.h ref/deref
Change ref() and deref() in qatomic_cxx11.h to use acq_rel ordered
semantics as documented instead of the stricter sequential consistency
that was previously used implicitly.

It was pointed out in the discussion on atomic reference counts that
acq_rel semantics should be sufficient for reference counts. It also
turned out that that is all that the definition of "Ordered" in the
documentation really guarantees.

Original-patch-by: Kevin Kofler <kevin.kofler@chello.at>
Change-Id: I6cd50b34bdc699ff8b7c8fe6d303b28d71494731
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-05 07:26:55 +01:00
Marc Mutz
4d8cbf9863 QLibraryInfo: de-duplicate QT_BUILD_STR
The string was used as the return value of QLibraryInfo::build() and
also string-pasted into the format string in qt_core_boilerplate(). As
a proper substring (not suffix) of the format string, QT_BUILD_STR
could not be shared among the two users.

Fix by interpolating QT_BUILD_STR into the format string, so
QT_BUILD_STR appears by itself in both functions. The string should
now be shared, but compilers have quite low limits on lengths of
strings they will share, so turn the macro into an static function so
the actual string literal appears only once, guaranteeing
de-duplication.

It also feels a bit safer to interpolate the build string instead of
pasting it into the format string; it's not immediately obvious that
it cannot contain %s itself, even if we could expect a compiler
warning in that case.

Change-Id: I69d90c37c3a3dcf8ac46d4f36e7c0d2cf3b947af
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-05 07:26:55 +01:00
Marc Mutz
64de057ebe QLibraryInfo: mark isDebugBuild() noexcept and CONST
It's literally

   return true; // or
   return false;

so it can be marked as noexcept and (the stronger form of) pure.

Change-Id: Id55fee1db5d18201be2ea6c6778ece3de68b05f2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-05 07:26:55 +01:00
Mårten Nordheim
d32fb5f1fe QProcess(Win): change int to qsizetype where appropriate
Even if it's unlikely any of those would exceed 2 billion entries.

Pick-to: 6.3 6.2
Change-Id: Ib0d4d4e7a64fcde03b7f24bc0667d63c4a737deb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-05 05:18:44 +01:00
Christian Strømme
96f16e7487 Convert string tables in QShaderDescription to use string literals [1/2]
Avoid allocating all these strings on load. Part 1: tables.

Pick-to: 6.3 6.2
Change-Id: Ibf7af9aea0088efe68b247c68022b98143634616
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-05 03:55:11 +01:00
Marc Mutz
c3c2a0f754 QDBusAdaptorConnector: place a static int into BSS instead of DATA
The cachedRelaySlotMethodIndex started out as -1, assuming no slot
could have that index.

But 0 is just as good a marker, because we know that method index 0
will be one of QObject's (destroyed() or deleteLater()).

So start out with a zero initial value, which means the variable can
be placed in the BSS segment now and doesn't need to be stored in
DATA.

Pick-to: 6.3 6.2
Change-Id: I40b96d54f11e60348f465cafa15af98d41038c95
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-05 03:23:33 +01:00
Marc Mutz
7277ffee52 QCalendar: fix build
Apple Clang 12:

qcalendar.cpp:456:22: error: loop variable '[key, value]' is always a copy because the range of type 'QFlatMap<QString,
QCalendarBackend *, (anonymous namespace)::CaseInsensitiveAnyStringViewLessThan, QStringList, std::vector<QCalendarBackend *>
>' (aka 'QFlatMap<QString, QCalendarBackend *, (anonymous namespace)::CaseInsensitiveAnyStringViewLessThan, QList<QString>,
vector<QCalendarBackend *> >') does not return a reference [-Werror,-Wrange-loop-analysis]
    for (const auto &[key, value] : byName) {
                     ^

Change-Id: I54f205f6b7314351b078fffd16d05e5cd3ef4c22
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-05 01:26:14 +01:00
Sona Kurazyan
013d0fcf5f Fix a typo in QFutureWatcher docs
Pick-to: 6.3 6.2
Change-Id: I431d21e6161d117a7b2ee28ee9db955726d50f79
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-04 21:55:02 +01:00
Mårten Nordheim
3e3a109ef2 QLocale: Un-inline QString& constructor
Because it's BiC.
From the API review.

Pick-to: 6.3
Change-Id: I69f1fe58428241a876ae9058e8a0108a8e496c22
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-04 16:15:43 +01:00
Shawn Rutledge
bd71fb2514 QGuiAppPrivate::processMouseEvent: don't assume eventpoint didn't move
During delivery of a pointer event, another type might be synthesized
from it; and we are not yet "done" with all access to the original event
until the delivery of the synthesized event is completed. Further,
there could be a nested event loop if exec() is called on a dialog.
If QPointingDevicePrivate::pointById() causes activePoints to grow
(for example if we handle a fresh incoming touch event in the nested
event loop), reallocation could cause the persistentPoint reference near
the top of processMouseEvent() to be dangling by the time we get to the
bottom; so we need to call queryPointById() again to be sure to get the
persistent QEventPoint that is actually used in the current mouse event
to ungrab.

Fixes: QTBUG-97157
Pick-to: 6.2 6.3
Change-Id: Ib3b90eef5db691675b03474fd75981e972d11d2d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-04 12:33:25 +01:00
Eskil Abrahamsen Blomfeldt
26a0638222 Fix infinite loop in dash stroker
When the positions were large enough, we would get precision errors
with the floating point numbers.

We calculate the relative position:
  dpos = pos + dashes[istart] - doffset - estart
and then later
  pos = dpos + estart

If estart is a huge number (range of 10^18) and dashes[istart] is
a low number (10^1), then estart + dashes[istart] == estart and
the loop will never progress, dpos will be 0.

Since the loop should never iterate more than dashCount times
(since we cut away all full dash sequences before entering it),
we add a failsafe that exits the loop if it detects the error.

Fixes: QTBUG-99690
Pick-to: 5.15 6.2 6.3
Change-Id: Ia6a42f21b6b4c6adf5cdd703b6483750513a88ba
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-02-04 12:02:45 +01:00
Thiago Macieira
4a93285b16 QtCore: use C++11 thread_local instead of QThreadStorage
It's more efficient than our QThreadStorage and definitely much better
than the Q_GLOBAL_STATIC+QThreadStorage solution. We can do this because
the last compiler not to have thread_local support was MSVC 2013, which
is no longer supported since Qt 5.11.

QThreadStorage also managed the lifetimes of pointers for us, so the
equivalent thread_local requires std::unique_ptr.

Change-Id: Id59bdd8f1a804b809e22fffd15405f1b394c48d8
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-03 19:58:36 -08:00
Thiago Macieira
de6ced6692 QCborValue: fix incorrect to{Array,Map} when the value is empty
When QCborValue referred to an empty array or map, toArray() and toMap()
would respectively return the default value instead of the empty object,
as expected.

Pick-to: 6.2 6.3
Change-Id: I5e52dc5b093c43a3b678fffd16b60456d0037ad7
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-03 14:45:46 -08:00
Marc Mutz
1e62f08998 QBuffer: exterminate three thread-safe static guard variables
Instead of duplicating two dynamically-initialized statics each in two
functions, causing four threading guards to be emitted by the
compiler, pack the two variables into a static struct and the struct
into an Extracted Method, leaving just a single threading guard.

https://godbolt.org/z/a9e5o848f

Uses C++14 NSDMI-in-aggregates, so doesn't work in 5.15.

Pick-to: 6.3 6.2
Change-Id: I98e053df48aafd5720ceffd514d6811fd3b28b1a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-03 22:12:06 +00:00
Marc Mutz
40828992eb QCollator: port from QString::compare_helper to QtPrivate::compareStrings
The call becomes simpler, and QCollator no longer needs to befriend
QString.

Pick-to: 6.3
Change-Id: Ie2c977dc39973423f07563a0702a83fa3c75270d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-02-03 21:21:29 +01:00
Alexandru Croitor
b43528ea00 Fix mach_port_t not being found
Fixes errors like
In file included from
qtbase/include/QtCore/6.4.0/QtCore/private/qcore_mac_p.h:1:
qtbase/src/corelib/kernel/qcore_mac_p.h:61:9:
error: unknown type name 'mach_port_t'

Amends e05300163e

Pick-to: 6.2 6.3
Change-Id: I8f4c579e9b8ef187859497361c4e126a486a543c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-02-03 20:05:05 +01:00
Ievgenii Meshcheriakov
58c48b40d1 QUrl: Use Q_CORE_REMOVED_SINCE instead of explicit version checks
Use Q_CORE_REMOVED_SINCE macro for fromAce()/toAce() API changes.

Pick-to: 6.3
Change-Id: I057c6d648c2141929f04e4b4c4a38ba3275261ab
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-03 18:31:44 +01:00
Ievgenii Meshcheriakov
6afa04f16c QLocale: Use Q_CORE_REMOVED_SINCE instead of explicit version checks
Use Q_CORE_REMOVED_SINCE macro for languageToCode()/codeToLanguage()
API changes.

Pick-to: 6.3
Change-Id: I8cc5279b1272165541c345241af49523c0f25737
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-03 18:31:44 +01:00
Eskil Abrahamsen Blomfeldt
b0e8ba783b DirectWrite: Turn off grid-fitting for unhinted text
When QFont::PreferNoHinting is set, we disable the automatic
grid-fitting done by DirectWrite in order to get shapes as close
as possible to the original design.

[ChangeLog][Windows][Text] Automatic grid-fitting is now disabled
for fonts that set QFont::PreferNoHinting.

Change-Id: Idfd3707153799bb8aa13f0d23e4dd6f1893ce53d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-02-03 18:31:43 +01:00
Shawn Rutledge
0a64a044b6 Add a QHoverEvent ctor taking global mouse position; deprecate the other
The QSinglePointEvent ctor assumes that the given globalPos is correct,
so it was wrong that the QHoverEvent ctor passed along a local position
as global. It's better to require globalPos as an argument; and in fact
it seems that everywhere we construct a QHoverEvent, global position is
available, or possible to get by transformation (which is better than
resorting to QCursor::pos()).

Also, don't convert to QPoint: pointer events have qreal resolution and
there's no reason to truncate them.

Fixes: QTBUG-100324
Change-Id: I919455da36265988d3d149eb97563c9ed0d2c660
Pick-to: 6.3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-03 10:18:43 +01:00
Giuseppe D'Angelo
c7a52d9d54 QTestLib: code tidies
Rename the `failureLocation` variable to `messageLocation`, as
it does not necessarily contain information about a failure.

Change-Id: I9e78dc76c8111c78e34c36f6623e9a8cc9e4764e
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-03 04:34:08 +01:00
Giuseppe D'Angelo
e7d627339c QPluginLoader: report the right load hints
A default-constructed QPluginLoader erroneously reports that the
load hints are empty. However, setting a filename would then
automatically set the PreventUnload hint, surprising the user.

Return the correct flags instead.

Amends 494376f980

Change-Id: I7a95964cb680afd3adf2f71ed73d2f93023238f2
Fixes: QTBUG-100416
Pick-to: 5.15 6.2 6.3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-03 03:26:40 +01:00
Giuseppe D'Angelo
a605b9297d QPlainTestLogger: do not print "failure location" if there's no failure
When running a test under increased verbosity levels, QTestLib would
print "failure location" for every QTest function (QVERIFY, QCOMPARE,
...), even if there's no failure at all.

Keep the code centralized, but split the formatting of failures and
non-failures (other messages).

Task-number: QTBUG-96844
Change-Id: I3c508653176b68579dc0eb0cffcc153a52da2e2c
Pick-to: 5.15 6.2 6.3
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-02 23:08:37 +01:00
Alexey Edelev
63f79d7ffb Add documentation for qt_finalize_project command
Task-number: QTBUG-100207
Pick-to: 6.3
Change-Id: I902ae827efad422771494ae3ad2da48d48d5c9cb
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-02 22:37:33 +01:00
Andreas Hartmetz
f84206ba69 Better document attaching a QFutureWatcher to a started QFuture
It is an important and useful part of the API contract that the
QFutureWatcher signals will emit complete information after
setFuture() on an already started QFuture. If that wasn't so, some
API clients would need two code paths to gather state and progress
information: one through the signals for not yet started QFutures,
and one through the state querying APIs for already started
QFutures.

The previous documentation was not precise enough to rely on, even
though the implemented behavior - cf.
QFutureInterfaceBasePrivate::connectOutputInterface() -
seems well thought out and implemented to rely on.

Pick-to: 6.3 6.2
Change-Id: Iaf3db37a851f07ac85881adaea5c83612a7fd843
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-02 21:53:41 +01:00
Giuseppe D'Angelo
64e33727bb QPlainTestLogger: code tidies
Remove a couple of unnecessary string literals that only coped with an
impossible situation (default return after a switch that cover all the
enumerators).
Add a Q_UNREACHABLE() for good measure.

Change-Id: I8065218554edf98408d9c0823b8c301932681c59
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-02 20:08:25 +01:00
Edward Welbourne
d98b43005e Nail down handling of nextTransition() when before the first rule
Avoid, for years before the first rule, a whole lot of complications
needed when handling dates later than that rule's start. It is not
entirely clear the code would previously have Done The Right Thing; it
now is clear what it does.

Change-Id: I00a79c0a4733f1deb0bbfecb03e1c64a104d08a3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-02 19:36:43 +01:00
Viktor Arvidsson
31b8a7e5ed macOS: Use native resize cursors for diagonal resize
The diagonal resize cursors provided by Qt does not
quite look like the ones used everywhere else on macOS,
especially for scaled desktops. After some googling this
seems to be how everyone else uses the native versions
since they are private API.

Pick-to: 5.15 6.2 6.3
Change-Id: I3461d07638f4e49cd3e25ab65ef5aa65730bb3a6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-02 16:45:37 +01:00
Viktor Arvidsson
724e4646e2 Fix clipped glyphs in text rendering of QGraphicsTextItem
[ChangeLog][QtGui] Clipping of visible glyphs when doing
partial updates of a graphics view was off by 1. Also fixed
an issue that caused rounding errors when transforming
the clip rect into the glyphs draw space which was caused
by transforming a QRect instead of a QRectF.

Fixes: QTBUG-93432
Pick-to: 5.15 6.2 6.3
Change-Id: Ibdb0e4116872af0f88bf03d9b3ac95331058b882
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2022-02-02 16:45:37 +01:00
Alexey Edelev
1b34ee080e Mention AAB packages in the qt_android_add_apk_target description
Task-number: QTBUG-100229
Pick-to: 6.3 6.2
Change-Id: I03066d1493ec9a78e8fe677e1bb0d4fdd5799d34
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-02 15:16:01 +01:00
Alexey Edelev
7faf776096 Add the list of supported Android ABIs to the related documentation
Task-number: QTBUG-100208
Pick-to: 6.3
Change-Id: I147d8a6b31164f7d9578c205af729643ec066134
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-02 15:16:01 +01:00
Allan Sandfeld Jensen
b94e204861 Only use inlined target functions when supported
To support clang-cl builds, until we add the necessary logic to enable
function targets for this case.

Pick-to: 6.3
Fixes: QTBUG-98253
Change-Id: Ied296babaa85a13321663d50019fad49134f0f44
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-02 15:16:00 +01:00
Giuseppe D'Angelo
453f469216 QAbstractItemView: do not access invalid model indices (3/N)
The slots connected to rowsAboutToBeRemoved and columnsAboutToBeRemoved
attempt to find a new current index by scanning the model around the
existing current index -- in case that index is indeed about to be
removed.

The problem is that the scanning was done without any sorts of bounds
checking; instead it was relying on the model's index() to return an
invalid index for an out of bounds request.

Fix that by adding bounds checking. Since models are not supposed
to return invalid indices for in-bounds index() calls, added some
warnings if that happens.

For some reason, the code handling rows and columns isn't perfectly
symmetrical. Rows are searched both forwards and backwards, while
columns only backwards, and the related code is slightly different.
Filed QTBUG-100273 to try and understand what's going on.

Change-Id: I7452d8c521e74daa4408e6cc969ce5a6059f53ea
Pick-to: 5.15 6.2 6.3
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-02-02 15:09:22 +01:00
Andreas Buhr
63937ffe6e Fix flags in QFileSystemModel
In 63eea5e5c69434871eaef9d9dc7184d7e54d7276, the
Qt::ItemNeverHasChildren flag was introduced. QFileSystemModel
was modified to use this flag for items which are not directories,
but only if the QFileSystemModel is not read-only and
the directory is writable.
This patch modifies QFileSystemModel to use the ItemNeverHasChildren
flags also if the model is read-only and if the item
is read-only.

Amends 63eea5e5c69434871eaef9d9dc7184d7e54d7276

Change-Id: Ie7f7d58ecf7baade93f9f03d120da84d3c005d42
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
2022-02-02 10:28:13 +01:00
Volker Hilsheimer
55433f90af Stylesheet: Fix tab layout when tab has a font and icons
Amends e3b2b12a91, which made the
style sheet calculate the font-dependent text size, but didn't
add the space needed for the close button or a tab icon.

QTabBar's layout code already adds the space needed for icons
and margins to the size; so instead of overwriting that size,
subtract the size needed by the normal font, and then add the
size needed for the font form the style rule, considering both
vertical and horizontal tab bars.

Fix the test case to style only one tab rather than the entire
tab bar, otherwise the font is applied to the entire tab bar,
and not just to a specific tab, which is the style sheet style
code in question.

Pick-to: 6.2 6.3
Task-number: QTBUG-6905
Change-Id: Ieed0ba146a32e81229419adecaf41f467cfd5959
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-02-02 07:10:12 +01:00
Sören Bohn
0b7b3a069e Network: Emit authenticationRequired when using Ntlm
Adds a new state Phase1 to QAuthenticatorPrivate::Phase which is used
when authenticating using Ntlm. The new state forces an emit of the
authenticationRequired signal and tracks that it is called only once.

Fixes: QTBUG-44096
Pick-to: 6.2 6.3 5.15
Change-Id: Icc9662d4fdc1f0f8c8e8bc5538f211baaa055d4c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-02-02 07:10:12 +01:00
Ilya Fedin
5a0849ed6b Handle glib optional components properly
Fixes: QTBUG-97929
Pick-to: 6.3
Change-Id: Ic73548cb10680a2ccd60faed2b0548c82892eaa1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-02 08:56:10 +04:00
Marc Mutz
9f31f579ec Sequential erase/_if: don't apply predicate twice to element
The code was trying to avoid a detach in the case no element needed to
be removed, by first running find_if() on const_iterators, and then,
after converting its result to (mutable) iterators, start the
remove_if() algorithm where find_if() left off.

But this applies the predicate to the element found by find_if() (if
any) _twice_: first just before we exit the first find_if() and then
just as we enter remove_if(), which will start by running find_if()
again, with the result of the initial find_if as 'first'.

Apart from being needlessly inefficient, this violates the
specification of Uniform Erasure, which defines sequential erase_if()
as being equivalent to remove_if() + container erase(), with the
former being specified to apply the predicate exactly once per
element.

Fix by writing the remove_if() part by hand.

Instead of doing the dance with the loop invariant documentation
twice, simply implement erase() via erase_if() (complicated a bit by
the weird passing of predicates by lvalue reference instead of by
value, as would be idiomatic). This exposes users to:

[ChangeLog][QtCore][Potentially Source-Incompatible Changes] A fix in
the implementation of the erase-like algorithms of sequential Qt
container may re-enable signed/unsigned comparison warnings previously
suppressed by having occurred in std library code. To fix, cast the
value to look for such that it has the same signedness as the
container's elements.

... but the issue would be the same had we inlined std::remove()
instead of passing a lambda to sequential_erase_if(), so it's nothing
we can, nor should, work around.

[ChangeLog][QtCore][Containers] Fixed a bug in the implementation of
most sequential Qt container's erase-like algorithms (member
removeAll()/removeIf() and free erase()/erase_if()) where the equality
operator or the predicate, respectively, was applied to the first
matching element twice. Each element is now tested exactly once.

Pick-to: 6.3 6.2
Change-Id: Ib6d24b01b40866c125406f1cd6042d4cd083ea0d
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2022-02-02 04:16:59 +00:00
Robert Löhning
27b560373d QImageReader: Check for existing handler in initHandler
Some calling code did this beforehand, other didn't. Now, the function
itself checks for an existing handler before doing anything else.

Change-Id: I8fc43fb8788c9dfe825b15ffa2fa69ee43915cd6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-02-02 04:12:17 +01:00
Marc Mutz
961f5a6fa2 QGuiApplication: invert meaning of qt_is_gui_used
The default value was true, which is non-zero, forcing the variable
out of the BSS and into the DATA segment.

Fix by inverting the meaning so the default value can be false.

Since qt_is_gui_unused sounds a bit complicated, however, take a cue
from the variable's only writer and rename it qt_is_tty_app.

Pick-to: 6.3
Change-Id: I198e9786f7e71178d69fecb5179287bf39b3a1d6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-02 03:48:00 +01:00
Thiago Macieira
ac7f73e507 qfloat16: add AVX512VL qfloat16 conversion tail
Slightly simpler implementation for the tail because of the OpMask
support.

Change-Id: I60fdef243d0c4e04890dfffd16266facd53d78aa
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-02-01 08:31:15 -08:00
Timur Pocheptsov
8247c0dac3 QMacStyle::standardIcon - use the real file name
When converting to cmake, aliases from the (now deleted) qstyle.qrc were omitted and
now we have to use the original names.

Pick-to: 6.3 6.2
Fixes: QTBUG-100317
Change-Id: Ieb83e95c62f10c0e2193602e4c12c5fc1667e15a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-01 17:12:08 +01:00
Tor Arne Vestbø
e05300163e Move QIOType wrapper for io_object_t to QtCore
Since we require C++17 now we can use auto for the retain and release
template arguments, which allows us to get rid of the wrapper functions
for IOObjectRetain and IOObjectRelease.

Pick-to: 6.2 6.3
Change-Id: Ifc4bf0fe50dfd0eaf6bb2e143acce6df7df17bdc
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-02-01 16:56:02 +01:00
Tor Arne Vestbø
7d19efa7bb testlib: Disable window restoration on macOS in a non-persistent way
The recommended way to register defaults on macOS is via registerDefaults:
which puts the key/value into the volatile NSRegistrationDomain.

This stops testlib from dumping preference files into ~/Library/Preferences:

  ❯ plutil -p tst_qwidget.plist
  {
    "ApplePersistenceIgnoreState" => 1
  }

Pick-to: 6.2 6.3 5.15
Change-Id: I4ac812014f9ff97bc446806eaf2108cd1c8b89c3
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-02-01 16:56:02 +01:00
Oliver Wolff
2430172639 configure: Check for basic cpp/winrt support
Some configurations (like MSVC2019 with c++20 on Windows 10) fail
to compile winrt/cpp headers as these include experimental
coroutines unconditionally. In these cases we can fall back to the
legacy implementation.

Pick-to: 6.2 6.3
Change-Id: Ibd574995f8ca1f865bbcdabede1ffcd0c340022f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-01 16:51:01 +01:00
Joerg Bornemann
0ad8dd4805 Doc: State Qt versions for when CMake commands etc. were introduced
Introduce the qdoc macros \cmakecommandsince, \cmakepropertysince, and
\cmakevariablesince that insert a paragraph akin to the \since context
command.

Example:
    \cmakecommandsince 6.3
produces the paragraph
    This command was introduced in Qt 6.3

The macro text is wrapped in \n\n to ensure that we always generate a
new paragraph.

Pick-to: 6.2 6.3
Task-number: QTBUG-100212
Change-Id: Id5c8e8812e6b0b915674d108a0e775091e9eacd8
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2022-02-01 16:51:01 +01:00
Alexandru Croitor
ac4a913f33 CMake: Deduce install prefix of example in qt_internal_add_example
We want to get rid of the INSTALL_EXAMPLEDIR and INSTALL_EXAMPLESDIR
code in each example project.

This was an internal workaround to ensure examples are installed into
a relative path somewhere under $qt_prefix/examples and not in
$qt_prefix/bin or similar.

To achieve that we do two things.

First, deduce the install prefix for each example in the
implementation of qt_internal_add_example (our add_subdirectory
wrapper) and assign it to CMAKE_INSTALL_PREFIX before calling
add_subdirectory. We need to make sure to remove the default
value of CMAKE_INSTALL_PREFIX in the generated
cmake_install.cmake file.

Second, we set an internal variable called
QT_INTERNAL_SET_EXAMPLE_INSTALL_DIR_TO_DOT before the add_subdirectory
call, which will be checked whenever find_package(Qt6Core) is called
in an example project. If the variable is set, the
INSTALL_EXAMPLEDIR var is set to "." in the scope of where Qt6Core
is found.

This ensures that the hardcoded INSTALL_EXAMPLEDIR values in our
example projects are changed to ".".

With both changes, our example project install(TARGET DESTINATION)
calls will now install to
"${CMAKE_INSTALL_PREFIX}/examples/${example_relative_dir}/."

Once all repositories are updated to use qt_internal_add_example
instead of add_subdirectory, we can get rid of the
QT_INTERNAL_SET_EXAMPLE_INSTALL_DIR_TO_DOT workaround.

For repositories that still don't use qt_internal_add_example,
the install prefix rewriting will not happen, but the examples will
still be installed to the proper place because they use their own
hardcoded INSTALL_EXAMPLEDIR value.

Amends d97fd7af2b

Pick-to: 6.2 6.3
Task-number: QTBUG-96232
Task-number: QTBUG-98545
Change-Id: I78c118e10c41b519c570c7d87529afd15aeed900
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-02-01 16:51:00 +01:00
Laszlo Agocs
fb8bd02e63 rhi: d3d11: Switch the default swap effect and scaling mode
[ChangeLog][QtGui][QRhi] With Direct3D 11 the default swap effect is now
DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL combined with DXGI_SCALING_NONE. This
should provide a better (less "jumpy") resizing experience for Qt Quick
content in particular, because the stretch effect for size-mismatched
present is not ideal for user interfaces. We'd rather want to keep the
size as-is and have the white border on the right/bottom (which we will
have anyway, inevitably). This is also closer to what one gets with
OpenGL (though that may depend on the driver as well). For Vulkan on
Windows, the behavior will remain very similar to what
DXGI_SCALING_STRETCH does, depending on the implementation probably,
because the Vulkan spec fails to address the handling of scaling modes
for size-mismatched presents. To get the old D3D behavior, i.e.
FLIP_DISCARD+SCALING_STRETCH, set the environment variable
QT_D3D_FLIP_DISCARD to a non-zero value.

Pick-to: 6.3
Fixes: QTBUG-99637
Change-Id: Ic8a219fbf3cdb6458b7ec9149bf27e771d9f7ddd
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-02-01 15:06:46 +01:00
Alexey Edelev
f9e48854af Use IMPORTED_LOCATION of rcc target
Use IMPORTED_LOCATION of rcc target when generating Android
deployment settings, instead of the hardcoded host path.

Introduce a helper function to find the location of the imported tool
target.

Change-Id: Icfa51ee7a01b3f58fc4892da03055f9ed531cc0b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-01 15:06:46 +01:00
Laszlo Agocs
1b672951ca rhi: d3d11: switch to uuidof everywhere
There seems to be bizarre issues with IID_* as they are not always
exported or are in a different library depending on the SDK and where
dxguid.lib comes from. If not mistaken, we don't need these symbols at
all because in C++ one can use __uuidof instead (which would not be
possible in C code and there the IID_ objects are necessary).

Pick-to: 6.3
Change-Id: I04712382630768a742bb5f42cc5fca9ad10ff719
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-02-01 14:32:58 +01:00
Ben Fletcher
5962605abb rhi: Code quality - remove defaults from switch enums
On code review of previous RHI patches it was noted that many switch on
enum statements contain a default.  This is discouraged as it prevents
the compiler from automatically identifying switch statements that do
not cover all enum cases.

This patch addresses rhi base classes.  Further patches required for
specific backend implementations.

Change-Id: Ib2bb30c66fd214b65a4ca7b787c7c610f3c313f5
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-02-01 05:32:57 -08:00
Giuseppe D'Angelo
035babe502 QAbstractItemView: do not access invalid model indices (2/N)
Similar to the parent patch, the private selectAll() was doing
two out of bounds accesses on an empty model. Guard it.

Change-Id: If0f3ce1e6c44a152791313e47db79985e71ef955
Pick-to: 5.15 6.2 6.3
Reviewed-by: David Faure <david.faure@kdab.com>
2022-02-01 14:32:57 +01:00
Giuseppe D'Angelo
33ad8b6fa9 QAbstractItemView: do not access invalid model indices (1/N)
Calling selectAll() on a view with an empty model, with the view
in ContiguousSelection, causes an out of bounds access into the model.
Guard the access.

Change-Id: I3830a979bad760e9e1526c1c8b12d9767d41fc99
Pick-to: 5.15 6.2 6.3
Reviewed-by: David Faure <david.faure@kdab.com>
2022-02-01 14:32:57 +01:00
Giuseppe D'Angelo
22ac61e62a QAbstractItemView: code tidies
In preparation for an upcoming fix, refactor an if over an enumerator
to a switch (which is how this code should've been to begin with).

Change-Id: I11a2de6d66f0359b985b587b7fd37022a7bf56e6
Pick-to: 5.15 6.2 6.3
Reviewed-by: David Faure <david.faure@kdab.com>
2022-02-01 14:32:57 +01:00
Marc Mutz
472722382d QCoffPeParser: simplify std::optional check
Even in C++98 one could declare variables in if statements and
contextually convert them to bool:

   if (D* d = dynamic_cast<D*>(base))
      ~~~
   else if (D2* d = dynamic_cast<D2*>(base))
      ~~~

std::optional is contextually convertible to bool, so we don't need
C++17 if initializers. Just use

   if (auto optional = ~~~~)

Pick-to: 6.3
Change-Id: Ie64c2c1ceb7b608eda0534d837f46d3c4be49bf8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-01 12:47:58 +01:00
Marc Mutz
0d9f4e7526 Make one QT_REMOVED_SINCE/QT_BUILD_REMOVED_API per module
A single global QT_REMOVED_SINCE will start hurting us once more
modules downstream of QtCore start using the mechanism.

With every use of feature, the set of code that needs to compile under
QT_BUILD_REMOVED_API increases. Since we use QT_REMOVED_SINCE in
situations where overloading the new and the old function don't work
in general, this means all code included by any removed_api.cpp needs
to be very carefully written to ensure that any calls to the overload
set formed by the combination of old and new function(s) don't create
ambiguities.

Likewise, the set of APIs that change semantics under
QT_BUILD_REMOVED_API also increases. At some point, the combination of
removed_api.cpp including almost every module header and almost every
header exposing source-incompatibilities when included in
removed_api.cpp will make maintenance a headache.

By making QT_REMOVED_SINCE and QT_BUILD_REMOVED_API per-module
(QT_CORE_REMOVED_SINCE, ...), easy now that we generate the export
macros using CMake, we limit the scope of this problem to the module
using the feature. Downstream modules (say, QtWidgets) will now see
the QtCore API like every other user, even in the
widgets/compat/removed_api.cpp TU.

Pick-to: 6.3
Change-Id: I177bc7bd5aa8791639f97946c98e4592d2c7f9d9
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-01 11:47:58 +00:00
Marc Mutz
543489fed2 QTextTable: fix signed/unsigned warning
Even disregarding the warning, we're instantiating
QList<int>::removeAll<uint>(), which is wasteful, so cast the fragment
to int, like in the indexOf() call a line above.

Detected by a rewrite of, essentially, QList::removeAll() as
removeIf() + lambda, which brought the comparison from an -isystem
header (std::remove()) into Qt code (the lambda), and apparently
un-suppressed the warning.

Qt 5.15 has the same code, but is unaffected, because removeAll() is
no template there.

Pick-to: 6.3 6.2
Change-Id: Id9fe33be647fc3dc958e316f0fbe03009b2a7adc
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-01 07:50:56 +00:00
Laszlo Agocs
2c008d6faf rhi: d3d11: Try uuidof instead of IID_* to help old MinGW
Fixes: QTBUG-100294
Pick-to: 6.3
Change-Id: Iee90355ecd48a753f9a7ec53e7f5758e3d12eddf
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2022-02-01 03:02:18 +01:00
Marc Mutz
aaa74e8f99 QWeakPointer: make default ctor constexpr
... and thereby also QPointer's.

Found by applying C++20 constinit around the codebase.

Pick-to: 6.3 6.2
Change-Id: I9f149b2346624ca913c29b796f94ac7d24fe560a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-01 01:59:10 +00:00
Marc Mutz
724a369308 QGuiApplication: constant-initialize lastCursorPosition
Because we used (exported) qInf() to initialize static QPointF
QGuiApplicationPrivate::lastCursorPosition, the initialization was
done at runtime.

Fix by using qt_inf(), which is inline and constexpr.

Pick-to: 6.3 6.2 5.15
Change-Id: I8b07c6c8bf1f644eaa88f2f33166045726915725
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-01 01:31:49 +01:00
Ben Fletcher
9ef702a37b rhi: Add the basic infrastructure for geometry shader support
.. but this will only be supported on Vulkan, OpenGL 3.2+, and Open GL
ES 3.2+ for the time being.

The situation is:

- Vulkan is working.  qsb accepts .geom files already, and QShader has
  existing geometry shader support.

- OpenGL 3.2 and OpenGL ES 3.2 are working.

- D3D11 is not working.  D3D11 supports geometry shaders, but SPIRV-
  Cross does not support translating geometry shaders to HLSL.

- Metal is not working.  Metal does not directly support geometry
  shaders.

Change-Id: Ieb7c44c58b8be5f2e2197bf5133cf6847e6c132d
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-01-31 08:53:37 -08:00
Ben Fletcher
1c3ae79ad3 rhi: Add support for polygon fill mode
Support for Polygon Mode (Triangle Fill Mode in Metal, Fill Mode in D3D)
in the RHI graphics pipeline.

Options are Fill and Line

Status:
    OpenGL - ok
    Vulkan - ok
    Metal - ok
    D3D11 - ok
    OpenGL ES - does not support glPolygonMode.

Change-Id: I20b7ef416624700c3dc8d1cbe6474f4ca3889db8
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-01-31 08:52:05 -08:00
Sona Kurazyan
f2f5c7d2b7 QtFuture::connect: fix for signals with a single std::tuple argument
If the signal passed to QtFuture::connect() takes multiple arguments,
we need to wrap the arguments in a std::tuple when reporting the result.
To detect this case we were checking if the result type of a QFuture
returned by QtFuture::connect() is a std::tuple, but this was not
correct: the result type could be a std::tuple also if the passed
signal takes a single std::tuple argument. Instead, check if the signal
takes more than one argument.

As a drive-by modified the tst_QFuture::signalConnect to use const
values for tuples used in multiple test-cases, to avoid repetition.

Fixes: QTBUG-100071
Pick-to: 6.2 6.3
Change-Id: I1ce39cf87028f36ef94a9d1a4423b0c51473afd4
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-01-31 17:40:43 +01:00
Jani Heikkinen
994fd04b2b Bump version to 6.4.0
Change-Id: Ie0e2133d6c9125b901364c979c60b6efd585f026
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2022-01-31 17:20:06 +02:00
Mårten Nordheim
8437c27582 QNetworkReply: rename socketConnecting to socketStartedConnecting
From the API review.

Pick-to: 6.3
Change-Id: Ic05737db79327e7811fcd974a70914b837e06601
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-01-31 14:24:11 +01:00
Edward Welbourne
9a83706046 Fix misguided winding backwards past start of start of MS TZ data
QWinTimeZonePrivate::data()'s search for a rule applicable to a given
time, in the first year whose milliseconds qint64 can represent, tries
to look at the preceding year to get start-of-year data, which leads
to misleading results. It does so to determine whether to use a rule's
standard or daylight-saving details, but this year is long before the
invention of daylight-saving time, so we can bypass the whole mess.

Unfortunately, MS's data does pretend (in some zones) that DST has
always been in effect, so cutting off that claim at some historical
point will actually get better results for before the cut-off than for
the period after it, until the relevant zone actually adopted DST.
Conservatively put the cut-off at 1900, before any actual zone used
DST, albeit after the idea was originally floated.

This fixes a failure found by some QDate::{start,end}OfDay() tests
that I want to introduce.

Pick-to: 6.3
Task-number: QTBUG-99747
Change-Id: I15cf9dd092b946191e8863c7e85fbeb4ba6c106d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-01-30 20:45:15 +01:00
Marc Mutz
2e4db2596a QCalendar: port registry from QHash to QFlatMap
Unlike many other uses of QFlatMap, this actually promises to hit the
QFlatMap sweet spot, and we're using all its levers.

To wit:

- Enable lookup via QAnyStringView through a transparent comparator
  without having to convert the QAnyStringView to QString first. This
  is impossible with QHash, because qHash() values are not consistent
  for different string types: u"a"_qsv == "a"_L1, but qHash(u"a"_qsv)
  != qHash("a"_L1).  The relational operators don't have this
  consistency problem, and they also implement case-insensitive
  comparison, another thing qHash lacks.

- Pick different types of containers for keys and values. For the
  keys, use QStringList, which makes availableCalendars() trivial and
  extremely fast. We can reserve() the flat_map to limit the effect of
  reallocations, because we have a pretty good idea about how many
  entries we'll have. For the values, use the same container as for
  byID. This might be better with QVarLengthArray, but that's for
  another patch.

- Fix the double lookup in registerBackendLockHeld() by using
  try_emplace() instead of contains() + insert().

To enable QFlatMap's full potential, we still need to teach
ensurePopulated() to create the two containers for the QFlatMap
unordered and let QFlatMap sort them in one go, but that, too, is for
another patch.

Change-Id: I7fe4f3f7596e9b234696fbc8e467128b85629f8a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-30 14:18:36 +00:00
Edward Welbourne
9135531c33 Refine QTZP_win's msecsToDate() by trusting arithmetic
Division and modulo are guaranteed to be consistent, with the former
truncating towards zero, so the latter giving a remainder that either
is zero or has the same sign as the numerator. In particular, when the
numerator is positive, the remainder is necessarily greater than minus
it, so the formerly correct but unilluminating arithmetic necessarily
gave the answer one and we can just --jd rather than doing anything
cleverer. Assert the fact that ensures this.

Pick-to: 6.3 6.2
Change-Id: Ia718bb947192f1fd2eb36549be12d30e4ee03d58
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-30 15:17:55 +01:00
Marc Mutz
58e8ae5605 QFlatMap: fix is_transparent detection
Add a level of indirection via void_t such that

    struct is_transparent {};

works, and not just

    using is_transparent = <unspecified>;

Pick-to: 6.3
Change-Id: I3ca2af6a07e6989dc95abc10fb2d0078a5269e5b
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-01-30 10:11:46 +01:00
Marc Mutz
2b617a29dc QFlatMap: remove binary_find()
The private binary_find() overload set is literally identical to the
public find() one, so cut out the middle man.

One less level of function templates to compile.

Pick-to: 6.3
Change-Id: Ia7b248d883b7bcff39c4f7b470d2567970572885
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-01-30 10:11:25 +01:00
Marc Mutz
64bc6509c3 QFlatMap: add full is_transparent support [3/3]: add overloads
Now add the missing overloads for mixed-type lookups, supported by
is_transparent Compare objects.

Pick-to: 6.3
Change-Id: Ib588b6a4f733d5d9908c8c7d7c209df6e7bd6674
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-01-30 04:14:21 +01:00
Marc Mutz
1ae5b3628d QCalendar: replace two overloads with one QAnyStringView function
The backend was already ported, so this is just about applying
QT_REMOVED_SINCE and updating the docs.

Change-Id: I2c78908deb9cdb3cee19ce8bc148ab3117c1ad9a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-01-30 00:03:45 +01:00
Marc Mutz
9bfc8f348d QFlatMap: add full is_transparent support [2/3]: shuffle functions
Move the do_{remove,take}() functions into the private section,
cleaning up after the previous step.

Pick-to: 6.3
Change-Id: I3325336458b34e7f376b42bfe68355d93ff4ce70
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-01-29 20:04:24 +01:00
Thiago Macieira
ce41151215 qfloat16/F16C: rewrite the F16C conversion with overlapping
We don't have to be completely sequential. It's perfectly fine to
overlap loads and stores and this leads to simpler code.

Change-Id: I6fcda969a9e9427198bffffd16ce56ebbc948379
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-01-28 22:40:25 -08:00
Thiago Macieira
073454901d qfloat16: add missing static
Commit 0df7831d01 moved these functions
into this file, but forgot to add the marker.

Drive-by replace Q_DECL_NOEXCEPT with noexcept

Pick-to: 6.3
Change-Id: I6fcda969a9e9427198bffffd16ce5543c5fd544e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-28 22:40:23 -08:00
Thiago Macieira
cdb78d7993 qsimd/x86: disable the F16C, FMA, and VAES features if AVX is disabled
Those three features can't be used without the VEX prefix, which
requires that the OS has enabled saving of the AVX state on context
switches (i.e., use XSAVE).

The list is automatically maintained by the updated script in
OpenDCDiag[1]. I need to update the copy in util/x86simdgen.

[1] https://github.com/opendcdiag/opendcdiag/blob/main/framework/scripts/x86simd_generate.pl

Pick-to: 6.3
Change-Id: I6fcda969a9e9427198bffffd16ce55193a6cb069
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-01-28 22:40:22 -08:00
Thiago Macieira
671035035a QVersionNumber: remove the "pure" attribute from commonPrefix()
This function can allocate memory, so it's not pure.

Pick-to: 5.15 6.2 6.3
Change-Id: I6fcda969a9e9427198bffffd16ce7fcff3ae021d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-28 22:39:57 -08:00
Thiago Macieira
c05ee60a2f QEvent: initialize the static userEventTypeRegistry constexprly
The {} is the difference.

Pick-to: 5.15 6.2 6.3
Change-Id: I6fcda969a9e9427198bffffd16ce8dabd213393e
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-29 04:26:09 +00:00
Marc Mutz
82147ce33a QString: optimize finding size=1 needles in QLatin1Strings
Use memchr() if the needle has size() one, and add a fast path in
findString(QLatin1String, QStringView) to circumvent the QVLA path. We
might want to extend this and use a simple C array for very short
needles and (cached?) Boyer-Moore for anything larger.

Pick-to: 6.3
Change-Id: I8364ea9f004d537be8a09cc751408d8adb902d13
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-01-29 03:43:29 +00:00
Marc Mutz
7b7c3355f2 QFlatMap: add full is_transparent support [1/3]: split functions
Extract Methods do_foo(iterator) from their respective foo(Key)
methods.

This is done in order to separate the common code from the code that
will differ in the is_transparent overloads.

Leave the function bodies where they previously appeared, for easier
reviewing.

Pick-to: 6.3
Change-Id: I49f41f9121a047df696f39daeaa0a9da6a16dddb
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-01-29 02:40:12 +01:00
Marc Mutz
f08f28548a QFlatMap: implement mutable op[] via try_emplace()
De-duplicates code.

Pick-to: 6.3
Change-Id: Id7841a0717cd66bd56d489e6d2630e9eeb284316
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-01-29 02:40:12 +01:00
Ben Fletcher
1e07787142 rhi: Fix tessellation support for OpenGL
Added shader stage mapping for tessellation stages.

Manual test rhi/tessellation now works for OpenGL.

Change-Id: I7906b21e9d6e20883f17729f077dba57aa29f4fd
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-01-28 14:31:02 -08:00
Marc Mutz
37714d255b QCalendar: replace ostream-style qWarning with printf-style one
Saves the <qdebug.h> include and expands to a lot less code.

Pick-to: 6.3 6.2
Change-Id: Ic1a0aa707e7c0d4bd54da45a7fcafbf898681b2d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-01-28 22:00:22 +01:00
Marc Mutz
d030606a5a QFlatMap: use erase() in remove()
De-duplicates code.

Pick-to: 6.3 6.2
Change-Id: I95d3d6f57c2f3716b8f3f549d1cc2a02cde9e996
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-01-28 22:00:22 +01:00
Marc Mutz
1cb192bf3d QFlatMap: replace manual const_cast<>s with std::as_const
Shorter, because it doesn't need to name the type.

As a drive-by, replace all remaining uses of the private full_map_t
alias with 'QFlatMap', the class name, which, also in templates,
refers to the class, not the class template.

Pick-to: 6.3 6.2
Change-Id: Ie3bada43d9d28a84543e8baa8a36c522dff80b9e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-01-28 22:00:21 +01:00
Thiago Macieira
7792360413 QVersionNumber: remove "pure" declaration from fromString()
GCC doesn't like that we modify the contents of passed by pointer in the
pure function. Reading the description of this attribute in the GCC
manual was ambiguous then, but I can see the GCC maintainers'
interpretation.

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

Fixes: QTBUG-62185
Pick-to: 5.15 6.2 6.3
Change-Id: I6fcda969a9e9427198bffffd16cdf815d059d252
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-28 13:00:21 -08:00
Marc Mutz
55a88206f3 QCalendar: eradicate Java-style iterator
We had QT_NO_JAVA_STYLE_ITERATORS in .qmake.conf, but it was lost in
the transition from QMake to CMake, and - plop - they start trickling
in again.

Pick-to: 6.3 6.2
Change-Id: Ib92937e5fe510aba2aad92809f7a6d5fbae6f3a0
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-01-28 22:00:21 +01:00
Marc Mutz
096e8b5f65 QLocale: replace a QList with QVLA for duplicate tracking
An alternative would have been QDuplicateTracker, but the maximum
number of entries in the tracker is statically limited to six, so we
don't need a fancy hash table, linear scan is good enough.

Pick-to: 6.3
Change-Id: I8ca97d239723b51892cb13a43b1d1a6412faa561
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-01-28 22:00:21 +01:00
Ilya Fedin
d13ee2dc1a Let QXcbGlxWindow::createVisual fallback to QXcbWindow::createVisual
When flatpak refused to install org.freedesktop.Platform.GL.default for
me, I got into a situation without GL drivers and Qt applications
stopped getting transparency windows.

They fallback to use root_visual and it doesn't provide sufaces with
alpha, I tried to add fallback to QXcbWindow::createVisual just like
QXcbEglWindow::createVisual does and voila, they got transparency.

Pick-to: 6.3 6.2 5.15
Change-Id: I9f401643b3ef231048c6e9e250121c96514101f5
Reviewed-by: Liang Qi <liang.qi@qt.io>
2022-01-28 16:15:28 +01:00
Thiago Macieira
1acdb290e8 QUrl: use qsizetype & size_t in place of int & uint
Allows for URLs with more than 2 billion characters. I'm sure someone
needs this...

Change-Id: I0e5f6bec596a4a78bd3bfffd16c9991e4e6cacbf
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
2022-01-28 01:50:48 +00:00
Ivan Solovev
850a7f1238 Android A11Y: fix content update notification when object is hidden
When the object is hidden, we should not use its viewId to notify
content changed. Instead, we need to use its parent id.

Task-number: QTBUG-95764
Pick-to: 6.3 6.2 5.15
Change-Id: I608658e21c401d76459a09e4b274c60b849ace86
Reviewed-by: Jarkko Koivikko <jarkko.koivikko@code-q.fi>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-01-28 00:22:41 +01:00
Ivan Solovev
f6ddb3e921 Android: explicitly remove accessibility focus when element is hidden
Before this patch when an element that had an Accessibility focus was
hidden (for example, a button because of Accessibility.onPressAction),
the focus was still remaining on that hidden element. So the next
doubletaps on the screen caused the Accessibility.onPressAction() of the
hidden element to be executed again and again.

To fix this, we have to explicitly send a FOCUS_CLEARED event to the
Android OS, when the object is hidden.
Another needed fix is to set the m_focusedVirtualViewId in
notifyObjectFocus() properly.

Fixes: QTBUG-93393
Pick-to: 6.3 6.2 5.15
Change-Id: I6ff8a19868b96842719924037545c4ecc91e0dad
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-01-28 00:22:41 +01:00
BogDan Vatra
c1a93b20ff [Android]: Handle the screen name, modes and refreshRate properly
Fixes: QTBUG-87136
Fixes: QTBUG-93823
Fixes: QTBUG-94959
Pick-to: 6.3 6.2 5.15
Change-Id: Id480e22611ec949b5e3ee780fc695fb502a5950c
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-01-28 00:22:41 +01:00
Joerg Bornemann
75082c9f20 Remove QSharedMemory from the bootstrap library
It's not used by any bootstrapped tool anymore.

Pick-to: 6.2 6.3
Fixes: QTBUG-100074
Change-Id: I92cf441c200174e73b483cb4f08bab6c3e7d9c09
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-27 13:31:56 +01:00
Marc Mutz
cd3569d69a QString: optimize compare_helper
For a long time now we have fast mixed UTF-16/UTF-8 comparisons. But
no-one told this ol' relic, which still converted UTF-8 to UTF-16 for
comparison.

Fix by using QtPrivate::compareStrings(QSV, QU8SV), which, as the
central entry point, uses the fast-path.

Consequently, compare_helper can now be noexcept.

Pick-to: 6.3 6.2
Change-Id: I4cc9f07d9bc48628f1fe695e80015a9a07b79d6f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-27 04:25:17 +01:00
Marc Mutz
88fd9a281a QFlatMap: avoid post-(in|de)crement on iterators
Generic code needs to avoid post-increment and -decrement, because
they're less efficient than pre-increment and -decrement when
implemented in class types as opposed to scalars (extra copy
necessary).

Use the common pattern of implementing post- using pre-increment.

Pick-to: 6.3
Change-Id: Ida38df04c6c6f877453e5b3a1983457cc7f63f11
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-01-27 04:25:17 +01:00
Marc Mutz
8224fd45d0 QtCore: includemocs
This leaves moc_qnamespace.cpp in mocs_compilation.cpp.

Including moc files directly into their classes' TU tends to improve
codegen and enables extended compiler warnings, e.g. about unused
private functions or fields.

Pick-to: 6.3 6.2 5.15
Change-Id: Ifdff378c74828e12ec770cb2f453dab3a880e2a5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-27 01:36:04 +01:00
Marc Mutz
97b465455b QCalendar: move memory allocation out of critical section
By Amdahl's Law, provides for more scalability.

This is just for backporting. The registry should really be able to
perform lookups without allocating memory...

Pick-to: 6.3 6.2
Change-Id: Ifbb832a06991b9ee9a1fd6a43db567bb572fca4f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-27 01:36:04 +01:00
Alexey Edelev
4ecbebebf7 Check if 'aab' target exists when adding <target>_make_aab as dependency
The global 'aab' target has its own switch QT_NO_GLOBAL_AAB_TARGET
that prevents it from being created. We need to check if 'aab' target
exists before adding <target>_make_aab as a dependency.

Pick-to: 6.3 6.2
Change-Id: Iea569e3b6c7dfb6d0efa60dd2001fb9de161f725
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-01-26 23:57:00 +00:00
Joerg Bornemann
7015eafa5c qt6_standard_project_setup: Don't enable AUTORCC
We discourage using AUTORCC, so don't make it the default for our
"standard project setup".

Pick-to: 6.3
Task-number: QTBUG-87643
Task-number: QTBUG-100209
Change-Id: I2715ec561266bfed5ea4ac7722ab1f1c8b982788
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-01-26 23:57:43 +01:00
Volker Hilsheimer
8359e44324 Offscreen: Fix implementation of QScreen::grabWindow
If id == 0, then we should grab the specified rect from the screen.

To do that, find all windows intersecting with the screen geometry, and
compose their backing store images into a screen-size pixmap.

Otherwise, find the respective backing store and grab only that.

Remove the old code respecting the desktop widget, which is no longer a
thing in Qt 6. The code was also wrongly grabbing only the first
containing - not intersecting - window's backing store into the screen
pixmap.

Enable the QScreen::grabImage test for the offscreen platform, where it
now passes.

Task-number: QTBUG-99962
Change-Id: I16eca7b082d65095a62c73624f86a4423e997a7a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-01-26 17:18:18 +01:00
Volker Hilsheimer
5d1bb2ed57 Offscreen: Implement QPlatformBackingStore::toImage
Re-applies 77895514d5419b77535de093b544aee30686cd22, which was
reverted after tests started to XPASS-fail in qtdeclarative. Those
tests are now get consistently QSKIP'ed, so reapply the change.

This makes testing of actually produced output easy in unit tests,
and makes a number of previously failing QtDeclarative tests pass.

Task-number: QTBUG-99962
Change-Id: I167b46b954dee18bdbf90c09c5e42a8c179a1fac
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-01-26 17:18:18 +01:00
Jungi Byun
574b625914 evdev: Prevent race condition in touch events processing
Unlike other input devices, touch devices are managed by corresponding
handler threads which are not the main thread. InputEvent that is
inherited by TouchEvent has a constant pointer member for device, but in
touch events case, handler threads may destroy the device which is
pointed by events while processing these events in main thread,
and this may cause critical potential issues such as crash. In order to
prevent this race condition, move device of QEvdevTouchScreenHandler
into main thread and delete this device later if QGuiApplication
instance exists when handler thread quits, and check event's device is
valid when processing touch events.

Change-Id: I02583238d97d768abcc544ee882160eda3178282
Reviewed-by: Elvis Lee <kwangwoong.lee@lge.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2022-01-26 01:01:31 +00:00
Eskil Abrahamsen Blomfeldt
2e29a427ca Windows: Change default hinting preference for high-dpi
When high-dpi is enabled, we would previously default to
QFont::PreferVerticalHinting which maps to the asymmetric
antialiasing strategy, where only horizontal antialiasing is
enabled.

The idea behind this is that it provides crisper text,
especially for smaller font sizes, but for larger font sizes
the aliasing artifacts outweigh the added sharpness.

Inspecting native Windows applications, such as the system
settings, it looks like asymmetric antialiasing is used
up to a certain font size threshold. The documentation uses
a font size of 16 as the suggested threshold.

In accordance with the documentation, we use PreferNoHinting
for font sizes above this threshold.

[ChangeLog][Windows] When high-dpi scaling is active, the
default text antialiasing has been set to symmetric for
larger fonts (pixel size higher than 16 px). The old default
can be selected manually as QFont::PreferVerticalHinting.

Fixes: QTBUG-99066
Change-Id: Ibf53556f6e2cbbe1dc5d30c6c1743a499a99a90b
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-01-25 17:20:26 +01:00
Edward Welbourne
78eac57f3d Check for null driver() before trying to exec()
QSqlQuery::exec() took for granted that it can dereference driver(),
which should be true for all sane usage; however, it should not crash
if used misguidedly. Added regression test, based on bug report's
reproducer, which crashes without the fix.

Fixes: QTBUG-100037
Pick-to: 6.3 6.2 5.15 5.12
Change-Id: I94600bc60f89e82a1121b418144006a683921a38
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2022-01-25 16:18:35 +01:00
Giuseppe D'Angelo
2d95b75345 QByteArray: fix isUpper/isLower
577d698b8e changed QString::isUpper /
isLower behaviors to match Unicode semantics: a string is uppercase
if it's identical to its own toLower/toUpper folding. These semantics
come from Unicode so they're not up for debate.

That commit however left QByteArray untouched. Generally speaking, we
want to move away from QByteArray as "text storage" -- this has
partially happened between Qt 5 and Qt 6, where QByteArray went from
Latin-1 semantics to ASCII semantics. Still, QByteArray offers
toUpper/toLower and isUpper/isLower and all this family of functions
should be consistent in behavior.

Apply the same fix that was applied to QString.

[ChangeLog][Important Behavior Changes] The semantics of
QByteArray::isLower() and QByteArray::isUpper() have been changed. Now
lowercase (resp. uppercase) byte arrays are allowed to contain any
character; a byte array is considered lowercase (resp. uppercase) if
it's equal to its own toLower() (resp. toUpper()) folding. For instance,
the "abc123" byte array is now considered to be lowercase.
Previously, the isLower() (resp. isUpper()) functions checked whether
the byte array only contained ASCII lowercase (resp. uppercase)
characters, and was at least 1 character long. This had the side effect
that byte array containing ASCII non-letters (e.g. numbers, symbols,
etc.) were not lowercase nor uppercase.

[ChangeLog][QtCore][QByteArray] QByteArray::isLower() and
QByteArray::isUpper() now work correctly with empty byte arrays. The
semantics of these functions have been changed.

Pick-to: 6.3 6.2
Fixes: QTBUG-100107
Change-Id: Id56a42f01b2d1af5387bf0e6ccff0f824f757155
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-25 15:29:20 +01:00
Oliver Wolff
32caaacee3 windows arm64: Use correct Q_PROCESSOR_ARM_64 define check
Inclusion of qt_windows.h is needed to avoid  "No Target Architecture"
in winnt.h.

Change-Id: Ic67ce8a306ef52c4ce3e6eaad0b7864632610737
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-25 14:22:27 +01:00
Marc Mutz
1f118a54f8 Revert "QLatin1String: Add overloads taking QLatin1Char"
This reverts commit 1c164ec7f2,
except for the test additions.

Reason for revert: We need to optimize the implementation, not
complicate the API.

Found during the 6.3 API review.

Pick-to: 6.3
Change-Id: I91c3f65ed6d1fc438deb0e028d578a07c0005362
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-25 11:59:02 +00:00
Yuhang Zhao
c532a57670 Fix build with clang-cl
1. Clang-CL can't recognize "/d2FH4" and it's causing
lots of warnings when compiling. So don't apply it
when building with clang-cl.
2. The definition of "FS_INFORMATION_CLASS" need to
be visible to clang as well. Don't know why it was
excluded originally.

Pick-to: 6.3
Change-Id: I7b6e14999eea0ba1f0d73962ff03a35548f88a5a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-25 14:09:31 +08:00
Thiago Macieira
5e2ce03510 QEventDispatcherWin32: use SetCoalescableTimer for (Very)Coarse timers
The tolerance can be set per timer, unlike on Linux.

Fixes: QTBUG-98316
Change-Id: I5e52dc5b093c43a3b678fffd16b788a30bcb9574
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-24 19:28:48 -08:00
Tatiana Borisova
b5124d9719 Fix run time failure for UI autotests (INTEGRITY)
- Add WFD resources release:
  It provides possibility to re-create native window on run time.
  It allows to run several Qt UI applications (one by one) without device reboot.

- Fix crash that found during window re-creation: ~QOpenGLCompositorBacking() calls
  QOpenGLCompositor::instance(). But compositor is deleted for that moment.

Task-number: QTBUG-99123
Pick-to: 6.2 6.3
Change-Id: I1e6dc9a012a166d1fd6cd1c24f9d2e9a8995fc00
Reviewed-by: Kimmo Ollila <kimmo.ollila@qt.io>
Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-01-25 02:59:36 +02:00
Laszlo Agocs
406bb6ae20 rhi: Make sure pixelSize() to a texture rt is always up to date
This is an issue for QQuickWindow in practice, although it is not hit
by our current tests.

Pick-to: 6.3
Change-Id: Ia73704c1af6a82b2689ce7b844d3b0eb9a17ec18
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2022-01-25 01:04:07 +01:00
Mårten Nordheim
4b6064aef4 QOperatingSystemVersion: fix #if check for macos version check
It would check the version regardless of OS, but this macro doesn't exist
on non-darwin platforms.

Amends 3446313c7a

Pick-to: 6.3
Change-Id: I7bdc302c85626d410e77bea1eb7aac7fbf1cb679
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-25 00:31:10 +01:00
Mårten Nordheim
c781d5ed08 Move private QOperatingSystemVersion::compare to removed_api
From the API review.

Pick-to: 6.3
Change-Id: I9877990f75189b99a372ea6342d07a7031228ac7
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-25 00:31:10 +01:00
Sona Kurazyan
4cd8eeaf8c Fix memory leak in QtConcurrent::run when called with a NULL QThreadPool
QThreadPool automatically deletes the runnable after it finishes running
the task. In case QThreadPool is nullptr, we should delete the runnable
manually. This amends 87b93c29be.

Pick-to: 6.3 6.2 5.15
Change-Id: Id7e4ed3d4d6de05990edf62e4099852983debc64
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-24 22:40:35 +01:00
Marc Mutz
df0f8e036c Replace cxx17_bm_searcher config check with feature test macro
This enables the code also for boostrap.

Amends b24e689cb5.

Pick-to: 6.3
Change-Id: I8efc76c20690282a2428f360d6b93896966b97ee
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-24 20:11:23 +00:00
Marc Mutz
af2d9bc3c4 Optimize finding UTF-16 needles in L1 haystacks
We were converting the full L1 haystack to UTF-16. But, even so, we
won't be able to find non-L1 UTF-16 needles in L1 haystacks!

Optimize by converting the needle (not the haystack) to L1, after
checking it's actually L1.

Pick-to: 6.3
Change-Id: I413d7a602d44ecb2d3149dc4fa87c690c40e6aaa
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-24 21:11:22 +01:00
Sona Kurazyan
d1639da0d5 Mark ResultStoreBase as final
The class is not intended for inheriting from it (see also
e502906305), so we can mark it as final
to explicitly forbid this. The tests were still using it as a base
class to clean the results during destruction, so fix them accordingly.

Task-number: QTBUG-99883
Pick-to: 6.3
Change-Id: I4a7ee3e2b462bd704e4b5a95ed733144805d6e5b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-24 20:54:36 +01:00
Alessandro Portale
edf1c3b001 Unify indentation in help information of androiddeployqt
Some of the parameters in the help information were indented by 3
characters instead of by 4.

Pick-to: 6.3
Change-Id: Id11cda79d61c4eab82ee09e33034db55730123c5
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-01-24 12:57:23 +00:00
Sona Kurazyan
1daaf613dc QFuture: add a missing include for qpromise.h
QPromise is now used in qfuture_impl.h, so we need to include it. Remove
qfuture.h include from qpromise.h, to avoid circular dependency.

As a drive-by, simplify a type-trait: is_convertible_v<T, S> is true
whenever is_same_v<T, S> is, so we don't need to instantiate both.

Fixes: QTBUG-100144
Pick-to: 6.3 6.2
Change-Id: Ic6df43d96d9d168cc44c2949e41c5e490f4c50ce
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-01-24 09:37:54 +00:00
Fabian Kosmale
0842b01f02 QProperty: Work around constexpr issues on MSVC
MSVC complains about illegal uses of void, even though the code should
be guarded by an if constexpr statement.
 qproperty.h(85): error C2182: 'val': illegal use of type 'void'
 qproperty.h(92): error C2182: 'abstract declarator': illegal use of type 'void'

Avoid the issue by using a dedicated dummy type instead of void.

Fixes: QTBUG-100072
Task-number: QTQAINFRA-4242
Pick-to: 6.3 6.2
Change-Id: Idc4886c26c3794e709eb762ba836139f720f8133
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-01-23 23:11:50 +01:00
Marc Mutz
228b5dd074 QStaticByteArrayMatcherBase: make dtor protected
Base class dtors should either be public and virtual or else protected
and non-virtual.

We don't want to model polymorphy, so protected and non-virtual it is.

Pick-to: 6.3
Change-Id: I3c545b01c3ec831ee8b4a0c522501222a69923e9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-23 09:48:34 +01:00
Marc Mutz
cce7e35253 Q(Static)ByteArrayMatcher: manage indexIn() overloads
Unlike QString and QStringView, QByteArrayView and QByteArray don't
overload well.

Solve the overload issue the usual way: by making the QByteArray one a
Q_WEAK_OVERLOAD. This is trivial for QStaticByteArrayMatcher, which
isn't exported, but require QT_REMOVED_SINCE magic for
QByteArrayMatcher, which is.

The additional const char* overload has shielded us from the worst
fall-out so far, it seems, but it makes for a truly horrible overload
set:

    matcher.indexIn(str, 3);

Q: Is the 3 here the length of the haystack or the value of the from
parameter?

A: It depends on decltype(str)!

If the (const char*, qsizetype, qsizetype=0) overload is the better
match, then 3 limits the haystack's length.

If, otoh, the (QByteArray(View), qsizetype) overload is the better
match, then it's the value of the from parameter.

As if this wasn't bad enough, QByteArray implcitly converts to const
char* by default!

A follow-up patch will therefore deprecate the (ptr, size) overloads,
so we de-inline the QByteArrayView ones to avoid having to touch the
implementation once more.

Found during 6.3 API review.

Pick-to: 6.3
Change-Id: I9640e0bdd298d651511adebcc85f314db9221d34
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-01-23 09:48:28 +01:00
Marc Mutz
3d3558dc8f QStaticByteArrayMatcher: fix searching in 2+GiB haystacks
Add a test (same techniques as for the 4+GiB check in
tst_qcryptographichash).

Takes ~1s to build the 4GiB test data here, and skips
when RAM is too low:

  $ qtbase/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher haystacksWithMoreThan4GiBWork
  [...]
  QDEBUG : tst_QByteArrayMatcher::haystacksWithMoreThan4GiBWork() created dataset in 891 ms
  [...]

  $ (ulimit -v 2000000; qtbase/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher haystacksWithMoreThan4GiBWork)
  ********* Start testing of tst_QByteArrayMatcher *********
  [...]
  SKIP   : tst_QByteArrayMatcher::haystacksWithMoreThan4GiBWork() Could not allocate 4GiB plus a couple hundred bytes of RAM.
     Loc: [/home/marc/Qt/qt5/qtbase/tests/auto/corelib/text/qbytearraymatcher/tst_qbytearraymatcher.cpp(242)]
  [...]

Found during 6.3 API review.

[ChangeLog][QtCore][QStaticByteArrayMatcher] Fixed searching in
strings with size > 2GiB (on 64-bit platforms).

Fixes: QTBUG-100118
Pick-to: 6.3
Change-Id: I1df420965673b5555fef2b75e785954cc50b654f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-01-23 01:06:57 +00:00
Marc Mutz
3ec587666f QByteArrayList: optimize 32-bit builds of legacy join() helper
On 32-bit machines, qsizetype is int, so we don't actually need to
QT_REMOVE_SINCE the QByteArrayList_join() helper, because it didn't
change.

Thanks to Thiago for showing me the QT_POINTER_SIZE trick in a similar
change to QVersionNumber.

Pick-to: 6.3
Change-Id: Iae6e315107e42da51fcb4e7325b6d40b9c3fe0bc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-01-22 13:08:05 +01:00
Volker Hilsheimer
902087a090 Revert "Offscreen: Implement QPlatformBackingStore::toImage"
This reverts commit 77895514d5419b77535de093b544aee30686cd22, which
is in principle correct, but results in XPASS'ing tests in qtdeclarative
that we need to adapt first.

Originally reverted only for 6.3, but now also in dev given the amount of
tests that have a QEXPECT_FAIL for the offscreen platform in qtdeclarative.

Change-Id: Ic914655c737c3b279c14a66220775f3c7a6cdab8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 8498d1a14b5a8392ee6b50a87b82f9d85d13193e)
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-01-22 11:30:13 +00:00