Commit Graph

41968 Commits

Author SHA1 Message Date
Allan Sandfeld Jensen
a2501fff81 Avoid reading outside allocated buffer
Bound the inverse lookup result on the low end as well.

Pick-to: 6.4 6.3 6.2
Fixes: QTBUG-104583
Change-Id: Id357fe1c39c88776075d737b08fc2864a2b6e829
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-06-27 16:16:20 +00:00
Topi Reinio
4a14a9c014 Doc: Fix QJniObject::construct() documentation
Even though QDoc accepted the \fn signature without a class scope,
the documentation does not end up on the class reference unless we
mark construct() as a member of QJniObject.

Pick-to: 6.4
Change-Id: Icae44f8eb24aa6b269242084479e735f2637c312
Reviewed-by: Luca Di Sera <luca.disera@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-06-27 16:03:52 +02:00
Laszlo Papp
9521a07af2 QKeySequenceEdit: add a maximumSquenceLength property
At the very least, it would be important to have a single combination
key sequence. This is commonly seen in keyboard shortcut editors where
QKeySequenceEdit is very much applicable.

[ChangeLog][QtWidgets][QKeySequenceEdit] Added a maximumSquenceLength
property.

Done-with: Marc Mutz <marc.mutz@qt.io>
Change-Id: Id7fa5a8593eb150fa67d7e89308492c0a200ac36
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-06-27 12:02:47 +00:00
Mårten Nordheim
4d60ba61dc Fix QDBusInterface crashing with empty path on construction
On some machines having an empty path passed to QDBusInterface
would cause a crash.

This happened because the code created a QDBusMessage and manually
marked it as validated when it was not. The validation would not
pass for this object.

Change-Id: I496dd922fa64353399655a1e84996b99990f5879
Pick-to: 6.4 6.3 6.2 5.15
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-27 14:02:47 +02:00
Mårten Nordheim
2ba153dd5f QHttpHeaderParser: fix int/qsizetype nags
These values won't extend past MAX_INT but it may produce warnings
nonetheless.

Found by clang-tidy.

Pick-to: 6.4 6.3
Task-number: QTBUG-104452
Change-Id: Icd8aa80a318274be00a3b32ad26a92745903cecb
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-27 14:02:47 +02:00
Mårten Nordheim
f5138d3065 QHttpHeaderParser: fix clang-tidy nags
"use empty instead of checking size"
"no else following return"
"initialize your variables"

Change-Id: I4512471ec15a00f7ac1fccf88a3c87b8aa983ad7
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-06-27 14:02:47 +02:00
Lars Schmertmann
e3ea1d02e6 QHttpHeaderParser: Allow larger fields but restrict total size
Our limit of 8k for a single header field was too small for certain
services which returned Location values or WWW-Authenticate challenges
longer than 8k.

Instead, taking inspiration from Chromium, we have a limit of 250k for
the full header itself. And increasing our field limit to 100k, which
would occupy almost half of what the total header allows.

Also took the opportunity to make it adjustable from the outside so we
can set more strict limits in other components.

Fixes: QTBUG-104132
Pick-to: 6.3 6.4
Change-Id: Ibbe139445e79baaef30829cfbc9a59f884e96293
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2022-06-27 14:02:47 +02:00
Andrei Golubev
e1abacfdf7 moc: Cleanup handling of default arguments in functions
Change-Id: I0a381525b92ce5f0b51296a02d9ab98c7a204efc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-27 11:05:23 +00:00
Ulf Hermann
7415e53a8b moc: Strip parentheses from RESET methods in JSON output
READ, WRITE, NOTIFY etc all come without parentheses. What we actually
want to check in the generator is whether the reset method is empty.

Task-number: QTBUG-104508
Change-Id: If8c70c7491b25e3c4d9a39dc2c0add0212e64dea
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-06-27 13:05:23 +02:00
Andreas Eliasson
a6df765b03 Doc: Revise Qt Test Module landing page
Most of the module landing pages now follow a certain content structure.
In this case, the reference section should be placed before the
licenses and attributions section. Also, to make the wording consistent
across all module landing pages, use the globally available word
snippets.

Pick-to: 6.4
Change-Id: I2b2164eb1b8a0eb91db0f1efea8390956d54b29e
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2022-06-27 11:05:23 +00:00
Laszlo Agocs
c0509ef586 vulkan: Have a dummy format type if there is no Vulkan header
...at application build time.

Follow what is already done for some other Vk* types.

Supports 1df2cf6bad7207f16ddca17344cc1324e50f287e in qtdeclarative,
which puts now also VkFormat into a header. We need the function
declaration to compile without a Vulkan SDK (so without vulkan.h).

Pick-to: 6.4
Fixes: QTBUG-104501
Change-Id: I09c87149a53a45f03c9f75b87baec4323db16b1d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-27 12:23:31 +02:00
Eskil Abrahamsen Blomfeldt
20ae170b35 Enabler for fractional scaling of text in Qt Quick
As opposed to the raster engine, in Qt Quick we are using
unscaled positions for the glyphs and using the vertex shader
to scale these after the fact. However, when picking the
correct subpixel rendering for each glyph, we would use the
unscaled position's fractional part, meaning that we
essentially rendered the glyphs at the wrong subpixel position.

This was especially visible when doing fractional scaling, e.g.
125%.

Thus we need to get the fraction of the actual on-screen position
instead. This has to be done both when populating the cache for
the Qt Quick case (this enabler adds it as opt-in) and also when
actually selecting the correct rendering of the glyph (change in
Qt Declarative).

Pick-to: 5.15 6.2 6.3 6.4
Task-number: QTBUG-101008
Change-Id: Ie67948b138f578b5f40d6a950c4aa92394a8f09a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-06-27 06:19:39 +00:00
Bartlomiej Moskal
9efaf8bae9 Android: Do not set release flag for signed package
Before this change, signing package by androiddeployqt automatically
implied the --release option.
It is possible to create both debug and release packages when signing on
Android, so we shouldn't be enforcing this restriction on Qt app builds.

Commit removes setting releasePackage option, when processing the --sign
argument in androiddeployqt.

Task-number: QTBUG-103281
Change-Id: Id40a41255e51d6820b44f078667dc8318a90bbc5
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-06-27 07:48:35 +02:00
Giuseppe D'Angelo
7466422e9c Add a way to declare _exported_ logging categories
If a library declares a logging category that needs to be used
by clients (e.g. via inline methods, macros, etc.), then the
logging category function generated by Q_DECLARE_LOGGING_CATEGORY
has to be exported.

We've seen this problem with Q_NAMESPACE, Q_GADGET, etc.: these
macros also declare functions or objects that in some cases need to
be exported.

And precisely like Q_NAMESPACE, Q_GADGET, etc., people end up
relying on the implementation details of Q_DECLARE_LOGGING_CATEGORY
(specifically, what does it expand to) in order to place the
export directives in the right place.

Introduce a more robust solution and apply it around qtbase.
Cleanup some minor code as a drive-by (remove `extern` and useless
semicolons).

[ChangeLog][QtCore][QLoggingCategory] Added the
Q_DECLARE_EXPORTED_LOGGING_CATEGORY macro, in order to allow dynamic
libraries to declare a logging category that can be then used by
client code.

Change-Id: I18f40cc937cfe8277b8d62ebc824c27a0773de04
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2022-06-27 00:12:56 +02:00
Allan Sandfeld Jensen
821aa1ff09 Avoid SSE2 punning
It is technical UB, even if GCC promises to let it work, but it also
generates inefficient code.

Pick-to: 6.4
Change-Id: I8f0cae3490d32287ecbaa16b1e9ace84223cda2a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-25 19:49:23 +02:00
Allan Sandfeld Jensen
7a146019e4 Sync qt_scale_image_argb32_on_argb32_sse2 and qt_scale_image_32bit
The rounding was different in the SSE2 version compared to the C
version.

Pick-to: 6.4 6.3 6.2
Fixes: QTBUG-85109
Change-Id: I81f0a71ee5425b93da80b6a438e1778a02b9bcfa
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-06-25 19:49:15 +02:00
Thiago Macieira
5db3fd29b4 qmetatype.h: add QT_FOR_EACH_STATIC_PRIMITIVE_NON_VOID_TYPE
This allows us to simplify the explicit specialization of the
QMetaTypeInterface<void> explicit specialization, dropping the warning
push/pop, and remove an unnecessary explicit instantiation.

Pick-to: 6.3 6.4
Change-Id: Id0fb9ab0089845ee8843fffd16f9bdccf1965b95
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-24 20:01:43 -07:00
Thiago Macieira
97fbf7d151 qmetatype.h: remove unnecessary EXPORT macro
It was introduced in commit d9f9bc9bad for
Qt 6.0 to avoid extern __declspec(dllexport), which MSVC doesn't like,
but was made obsolete by commit 77b99e8111
that removed the extern templates altogether for MSVC.

This change is NOT a no-op because Q_CORE_EXPORT expands to
Q_DECL_IMPORT which is __attribute__((visibility("default"))) on ELF
platforms. That's actually a good thing, because the symbol is not
defined in any library that is not called QtCore anyway. GCC and Linux
are also going towards properly requiring imported symbols to be
explicitly marked, which this is.

Task-number: QTBUG-93471
Pick-to: 6.3 6.4
Change-Id: Id0fb9ab0089845ee8843fffd16f99616883281e3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-24 20:01:32 -07:00
Thiago Macieira
8726647df4 moc: put the qt_meta_stringdata_XXXX_t type in an unnamed namespace
Not all user code is compiled with hidden visibility, so make sure one
of the types in the template parameters (the one that is supposed to be
unique anyway) is local and therefore causes the full symbol for the
inline variable not to be exported outside of the translation unit.

Pick-to: 6.4
Change-Id: I6d3880c7d99d4fc494c8fffd16fb262a59b81283
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-24 19:05:58 -07:00
Thiago Macieira
0978646a65 moc: remove the attempt to create one large string literal
Commit dda9c9e2bc fixed some outstanding
issues with moc's calculation of the maximum string length, but it
missed one. This commit instead opts to remove the calculation entirely
and instead have multiple char array members in the qt_meta_stringdata.
We needed a single string back in Qt 4.0 when the stringdata *was* a
single char array.

Since 5.0, we've used a structure with multiple members and pointer
arithmetic going past the end of the arrays, from the top of the object.
That's UB, but since it's always been UB and can't be fixed until Qt 7
anyway, let's go full monty on it and have one char array per meta
object string.

The struct qt_meta_stringdata_Qt_t for namespace Qt now has 1217
stringdataXXX members.

Pick-to: 6.2 6.3 6.4
Change-Id: I6d3880c7d99d4fc494c8fffd16fb0d1573e387dc
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-24 19:05:57 -07:00
Thiago Macieira
3816b14ee8 moc: properly indent the output for the metatype array
Commit 7ff7d73f6a added the indentation,
but there were a few mistakes and it was off by 4 spaces anyway. So re-do
it and take the opportunity to add some comments to explain what we're
seeing.

Before:
qt_incomplete_metaTypeArray<qt_meta_stringdata_QTimer_t,
    QtPrivate::TypeAndForceComplete<bool, std::true_type>,
    QtPrivate::TypeAndForceComplete<int, std::true_type>,
    QtPrivate::TypeAndForceComplete<int, std::true_type>,
    QtPrivate::TypeAndForceComplete<Qt::TimerType, std::true_type>,
    QtPrivate::TypeAndForceComplete<bool, std::true_type>,
    QtPrivate::TypeAndForceComplete<QTimer, std::true_type>,
    QtPrivate::TypeAndForceComplete<void, std::false_type>
,
    QtPrivate::TypeAndForceComplete<void, std::false_type>,
    QtPrivate::TypeAndForceComplete<int, std::false_type>,
    QtPrivate::TypeAndForceComplete<void, std::false_type>,
    QtPrivate::TypeAndForceComplete<void, std::false_type>

>,

After:
    qt_incomplete_metaTypeArray<qt_meta_stringdata_QTimer_t,
        // property 'singleShot'
        QtPrivate::TypeAndForceComplete<bool, std::true_type>,
        // property 'interval'
        QtPrivate::TypeAndForceComplete<int, std::true_type>,
        // property 'remainingTime'
        QtPrivate::TypeAndForceComplete<int, std::true_type>,
        // property 'timerType'
        QtPrivate::TypeAndForceComplete<Qt::TimerType, std::true_type>,
        // property 'active'
        QtPrivate::TypeAndForceComplete<bool, std::true_type>,
        // Q_OBJECT / Q_GADGET
        QtPrivate::TypeAndForceComplete<QTimer, std::true_type>,
        // method 'timeout'
        QtPrivate::TypeAndForceComplete<void, std::false_type>,
        // method 'start'
        QtPrivate::TypeAndForceComplete<void, std::false_type>,
        QtPrivate::TypeAndForceComplete<int, std::false_type>,
        // method 'start'
        QtPrivate::TypeAndForceComplete<void, std::false_type>,
        // method 'stop'
        QtPrivate::TypeAndForceComplete<void, std::false_type>
    >,

Pick-to: 6.4
Change-Id: Id0fb9ab0089845ee8843fffd16fa152d040ef922
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2022-06-24 19:05:57 -07:00
Shawn Rutledge
846b314aaf Emit autolinks in QTextMarkdownWriter
When a markdown document contains a "naked" URL, or an angle-bracketed
<URL>, md4c recognizes it, and we set the AnchorHref charfmt property.
There's no need to expand it into the [text](url) form if the text is
the same as the url, there is no tooltip, and the url is valid.
QTextMarkdownWriter now writes a CommonMark "autolink" in that case:
https://spec.commonmark.org/0.30/#autolinks

[ChangeLog][QtGui][Text] QTextMarkdownWriter now writes an autolink
whenever a hyperlink has no custom text and no tooltip, including
when the document was parsed from Markdown containing a naked URL.

Pick-to: 6.4
Fixes: QTBUG-94713
Change-Id: I432db8499c62e1e0b1e913bfd8ef2147e3c2bb2a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-06-24 22:42:43 +02:00
Shawn Rutledge
56f0ebfe86 Support markdown in QTextEditMimeData; fix pasting trailing newlines
- Since 4edcea762d the dropsite example
  shows markdown if available; and now it shows that when we do DnD
  of a selection from the richtext example, text/markdown is available.
- If we artificially make html unavailable, copying and pasting between
  widget-based rich text editors uses markdown.

In case markdown writer output contains unnecessary backticks due to
monospace fonts getting used, the workaround from
1ad456c908 is applied.

Pick-to: 6.4
Task-number: QTBUG-76105
Task-number: QTBUG-103484
Change-Id: Ie6ca4dbb450dbc36b3d09fd0df1ae5909aaebca7
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-06-24 22:42:28 +02:00
Ulf Hermann
c52e0a9582 QAbstractItemModel: Add revisions to new methods
These methods show up in QML-exposed types. They should be revisioned in
order to keep those types backwards-compatible.

Pick-to: 6.4
Change-Id: I8e826dc2e7db49d8abe69f67605dfb1991855b96
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-06-24 19:14:17 +02:00
Duan Ting
cd268e9e1d Fix typo in code
Found by codespell

Pick-to: 6.4 6.3 6.2 5.15
Change-Id: I75f4b14f3eded035a0c904d8a7174cb6f5b7d9ef
Reviewed-by: Wang Bo <wangbo@uniontech.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-06-23 12:34:00 +08:00
Kai Köhne
bc06e345fe Use [[noreturn]] attribute
Use __has_cpp_attribute mechanism to check availability of
[[noreturn]]. For MSVC 2019 and 2022, this is always
the case, so we  can also remove the (now dead)
__declpsec(noreturn) definition.

Pick-to: 6.4
Change-Id: Ie7b39bd93bc5e1a173e245a3a5d5ff7e9067a59f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-23 01:30:23 +02:00
Kai Köhne
f921b42f34 MSVC: Remove dead Q_DECL_DEPRECATED* definitions
Later on we redefine them to
[[deprecated]], [[deprecated("")]], if the attribute
is available.

Since both MSVC 2019 and 2022 support the attribute,
the __declspec() definition was never used.

   https://docs.microsoft.com/en-us/cpp/cpp/attributes

Pick-to: 6.4
Fixes: QTBUG-93748
Change-Id: I3e12f2ace414e316a811f2ceb44e6f312803439a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-23 01:30:23 +02:00
Thiago Macieira
116d8f987b moc: add Q_CONSTINIT to the static const variables we emit
The macro was added to Qt 6.4, so we define it in each moc output to
empty if it wasn't previously defined. Thus, moc retains compatibility
with older Qt versions.

Pick-to: 6.4
Change-Id: Id0fb9ab0089845ee8843fffd16f9c1539fa0368f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
2022-06-22 13:03:17 -07:00
Thiago Macieira
9959cf60d3 moc: replace offsetof with sizeof
It's the same thing since we have exactly one field in this structure
before stringdata0. But there's a far smaller chance of producing a
warning in user code.

Pick-to: 6.2 6.3 6.4
Change-Id: Id0fb9ab0089845ee8843fffd16f9cdceec33017d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-22 13:03:17 -07:00
Thiago Macieira
dda9c9e2bc moc: fix use of escape sequence of more than one character
We had the code to calculate the length, but were improperly using it
only for the offset, not the length of the string or its containing
array. That resulted in the generated moc output containing:

 QT_MOC_LITERAL(111, 5), // "\xffz"
 QT_MOC_LITERAL(114, 5), // "\0012"
 QT_MOC_LITERAL(117, 23), // "slotWithAReallyLongName"

The two strings are described as occupying 5 bytes (length 4 + null
terminator), which is incorrect. The offset was correct: 114 - 111 = 3
and 117 - 114 = 3. The new output is:

        QT_MOC_LITERAL(111, 2),  // "\xffz"
        QT_MOC_LITERAL(114, 2),  // "\0012"
        QT_MOC_LITERAL(117, 23),  // "slotWithAReallyLongName"

The effect of the array size calculation would only be felt if moc
decided it needed a second string array (for strings over 65535 bytes),
which would cause the offsets in the second array to be all wrong. There
was no such test until now.

Drive-by fixing of the newline, indentation, and the stale comment
referring to QByteArrayData (Qt 5).

Pick-to: 6.2 6.3 6.4
Change-Id: Id0fb9ab0089845ee8843fffd16f9cd01b3e0709a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-22 13:03:17 -07:00
Ye ShanShan
c3b959733a Add QDom internalSubset implementation
QDom's internalSubset() always returned empty because nothing
actually set the internal data member it returns. When parsing
the DECLTYPE, extract the internal subset and save it to the
doctype()'s member when present.

Pick-to: 5.15 6.2 6.3 6.4
Fixes: QTBUG-53661
Change-Id: I6e41ff8b914381168246073b3289d82205b1c255
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-06-23 02:18:39 +08:00
Ulf Hermann
2c0518eb62 moc: Allow reading property values through bindables
The behavior is similar to MEMBER: If the READ accessor is "default",
synthesize it using the bindable.

[ChangeLog][QtCore] You can now specify "READ default" in a Q_PROPERTY
if you also specify a BINDABLE. moc will synthesize a READ accessor in
that case.

Task-number: QTBUG-97249
Change-Id: I4a275adabaed12df95dac505095f847c4be65dfe
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-22 16:05:07 +02:00
Sona Kurazyan
73e1bc09e6 Move QFutureInterfaceBase::cleanContinuation() to removed_api
This method isn't used anymore, but we can't remove it entirely for BC
reasons, because it was called from inline code.

Pick-to: 6.4
Change-Id: I9183c666c466030787ac7c2386706b50abf23eaa
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-06-22 14:32:01 +02:00
Lorn Potter
cf9cd8cc08 wasm: do not allow blocked windows to be resized
Fixes: QTBUG-102869
Pick-to: 6.3 6.4
Change-Id: I69a4afbb67618dce7bcc499208e7e608e9adf212
Reviewed-by: David Skoland <david.skoland@qt.io>
2022-06-22 20:04:35 +10:00
Thiago Macieira
e114fec62a QJsonValue: fix incorrect to{Array,Object} when the value is empty
This is a repeat of commit de6ced6692
"QCborValue: fix incorrect to{Array,Map} when the value is empty" (6.4),
which fixed the same thing for QCborValue. I've just copied the exact
same implementation onto the QJsonValue functions.

Pick-to: 6.2 6.3 6.4 5.15
Fixes: QTBUG-104085
Change-Id: I175efddd75f24ae59057fffd16f6b257bf7ed36d
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-06-21 22:25:32 -07:00
Morten Sørvig
492b338f57 wasm: improve the specialHtmlTargets test
It can actually be undefined, so test for that before checking
the object type.

This fixes the asyncify build.

Pick-to: 6.4
Change-Id: I5a6a0bc60c153290c35c20242400c59cd1312403
Reviewed-by: Aleksandr Reviakin <aleksandr.reviakin@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2022-06-22 07:14:59 +02:00
Thiago Macieira
45de3fedba QThread:idealThreadCount: fix build with FreeBSD 13.1
They added the CPU_COUNT_S macro.

Pick-to: 6.4
Change-Id: I6d3880c7d99d4fc494c8fffd16fabe9f8226ecda
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-06-21 21:52:57 -07:00
Thiago Macieira
cb0b1ee441 moc: remove unnecessary emission of "#include <qbytearray.h>"
We don't need QByteArrayData any more (since 6.0).

[ChangeLog][Potentially Source-Incompatible Changes] moc no longer emits
an #include for QByteArray in the output file. None of the content that
moc generates needed that header, so this should not cause changes for
most people. However, codebases that #include'd the moc output
(something that is recommended) could be depending on this indirect
include.

Pick-to: 6.4
Change-Id: Id0fb9ab0089845ee8843fffd16f9cf13dc8d61b5
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-21 21:52:57 -07:00
Thiago Macieira
3cf38290d9 moc: rename the "offsetsAndSize" member to "offsetsAndSizes"
It contains more than one size.

Drive-by drop the const from the structure, so it becomes properly
trivial (though there's disagreement, see[1]).

[1] https://conformance.godbolt.org/z/rK1xW669K

Pick-to: 6.2 6.3 6.4
Change-Id: Id0fb9ab0089845ee8843fffd16f9cc69ffd90aa4
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-22 04:52:57 +00:00
Luca Di Sera
73d04340ad Doc: Add qthelp dependency to gui and widgets
The documentation for both gui and widgets defines members of the
"helpsystem" group, which definition is given in qthelp.

Due to recent changes in QDoc that automatically link a class page to
its owning group, it is now required for those project to be dependent
on qthelp, so that it is possible to retrieve the necessary linking
information for the group definition.

Hence, such a dependency was added.

Change-Id: Id9399e76bbe10fb9ae0c05d637006b5cdc0b742b
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-06-22 04:49:38 +02:00
Marc Mutz
97f643faee Long live QT_INLINE_SINCE!
We have now had several requests for inlining previously-exported
member functions, but no standard mechanism to effect it.

As QT_REMOVED_SINCE has shown, there is great value in having such a
standard mechanism, so here is one.

With this change, to inline a previously exported (member) function,
simply

- mark the declaration with QT_<MODULE>_INLINE_SINCE

- move the definition into the header file (outside the class),

  - wrap it in QT_<MODULE>_INLINE_IMPL_SINCE

- #include the header into the module's removed_api.cpp

Just including the header into removed_api.cpp is enough, so you may
want to add a comment:

    #include "header.h" // uses QT_<MODULE>_INLINE_SINCE

The effect is as follows:

- A TU in a _different_ library will see an inline declaration,
  followed by the definition, and so it will see a normal inline
  function.

- A TU in the same library will, however, see a non-inline
  declaration, to avoid the ODR violation that at least GCC/ld are
  able to detect.

  - When QT_<MODULE>_BUILD_REMOVED_API is in effect, the TU will also
    see the definition, which is the same setup as before the change,
    except in a different TU, and therefore export the member.

  - When, OTOH, QT_<MODULE>_BUILD_REMOVED_API is _not_ in effect, the
    TU will see no declaration, assuming (correctly), that the
    definition will be supplied by a different TU.

This is, of course, an ODR violation, but not worse than what we do
elsewhere, as the definitions differ only between library and user.

The function is inline only for the users of the library, not the
library itself, which will still see the function as non-inline. If
inlining is critical within the library, too, the existing function
should call a new inline function, and calls in the same library should
be changed to call the new inline function instead.

Use the new mechanism to inline the QLocale ctor we intended to inline
for 6.3, but couldn't, because we hadn't found the magic incantation,
yet. Thiago found it a few weeks later, and this is what this patch is
based on.

Fixes: QTBUG-100452
Pick-to: 6.4
Change-Id: Ia0030cddc64b6b92edfed860170d5204aa74b953
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-06-22 01:09:24 +00:00
Marc Mutz
1a030f6609 QPostEventList: de-inline addEvent()
While in a private header, it did manage to place QList<QPostEvent>
operations near the top spots of all Qt template instantiations in a
QtWidgets build.

Task-number: QTBUG-97601
Pick-to: 6.4
Change-Id: I4fa1972b8764b71ad0559633131e7e44b3d4ae6a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-22 01:09:24 +00:00
Sona Kurazyan
bf3fc5c95c QPromise: run continuation(s) on destruction
If the QFuture is canceled because the associated QPromise has been
destroyed, we still need to run its continuations (i.e. onCanceled
handler, if it's attached), so replaced the cleanContinuation() call
inside ~QPromise() with runContinuation(), which will also take care of
cleaning the continuation.

[ChangeLog][QtCore][Important Behavior Changes] QFuture now runs its
continuations when its associated QPromise has been destroyed.
Previously, if a QFuture was canceled because the associated QPromise
has been destroyed, its continuations were skipped.

Fixes: QTBUG-103992
Pick-to: 6.4 6.3 6.2
Change-Id: Ie05bc760c96c349aade8adb8d2fe5263aff8efac
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-22 03:09:24 +02:00
Alexey Edelev
5d041a15bf Isolate http2protocol_p.h include
http2protocol_p.h is not supposed to be used without the http feature
is enabled. Move its include under QT_CONFIG(http) guard.

Change-Id: I374dd84d3330de2b4c340b9803d0c3d2c13bc8e3
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-06-22 03:03:31 +02:00
Alexey Edelev
36ea34c714 Add the qt_class pragma to file listed in sync.profile classnames map
This makes header files self-contained and reduces the number of
'sources of truth' for syncqt procedure.

Change-Id: I7f5865abc69934603139d23e1b5452da46ccb110
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-22 03:03:31 +02:00
Alexey Edelev
5fce82bc6c Move ssl header files to the general QtNetwork sources
Move public ssl headers to the general QtNetwork sources since they
supposed to be used across the project without corresponding checks
for the FEATURE_ssl presence. The content in these header files has
a conditional implementation guarded by corresponding macros.

Change-Id: I43168469da27321c2d8064ec2e5d7fe31126ebec
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-06-22 03:03:31 +02:00
Alexey Edelev
c769432cd5 Move threads header files out of the FEATURE_thread
Threads header files are used across the project without the check for
FEATURE_thread enabled. So moving them out of the FEATURE_thread
condition in CMake file to make them part of the CMake source tree
even if FEATURE_thread is disabled.

Change-Id: I8ee4ee5ffa16054b9af0df0aa5704b0f87678e1a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-22 03:03:30 +02:00
Sona Kurazyan
c3f76a867b QDom: Clean-up warnings about old-style cast uses
Change-Id: I7cf2089f34e46a901f8b03987feed24773a72c00
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-22 02:26:33 +02:00
Shawn Rutledge
bd1ea2eb92 Replace a few more QString::fromLatin1() with _s literals
Wasn't done in 7d79b94db7

Pick-to: 6.4
Task-number: QTBUG-98434
Change-Id: Id9c26f6b58e2c96a1c5f72154b735b136c57debc
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-06-22 00:14:27 +02:00
André de la Rocha
ecd41111a3 Add ExpandCollapse UI Automation pattern to combo boxes
Also add support to expandable/expanded states to QAccessibleComboBox
in widgets. QtDeclarative will still require updates so that QML combo
boxes report the expanded/collapsed state and react to UIA actions.

Task-number: QTBUG-103591
Pick-to: 6.4 6.3
Change-Id: Iff8ba5e3143778ce17998dbe7f5f76cae658dc19
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-06-22 00:08:34 +02:00
Mate Barany
b9b5734559 Disable useless-cast warning for moc generated code
The useless-cast gcc warning is disabled in the files generated by
the moc. A typical warning is like

using_t = void(Counter::*)(int );
if (*reinterpret_cast<_t*>(_a[1]) ==
    static_cast<_t>(&Counter::valueChanged)) {
        *result = 0;
         return;
    }

Removing the static cast results in a compilation error
"address of overloaded function with no contextual type-of
information" in moc_myobject.cpp files.

Checking whether we have an overload set or a single function
might be too much effort for too little benefit and may not worth
it.

Fixes: QTBUG-71938
Change-Id: I6f67e163a3493b51fb95f54218ce6bf9a302f824
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-22 00:08:34 +02:00
Mikolaj Boc
bc676a7d7a Document QMouseEvent::pos() as deprecated in 6.0
The API is deprecated, but the documentation does not state that.

Fixes: PYSIDE-1750
Pick-to: 6.4 6.3 6.2 6.1 6.0
Change-Id: I038ffeb958312d7648690743e06598a15dfb4cbc
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2022-06-22 00:08:34 +02:00
Alexey Edelev
84e22f9e82 Fix concurrent access to files by androiddeployqt in multi-abi builds
'androiddeployqt' supposed to copy artifacts that may not have
abi-specific identifies. One example is Qt6Android.jar file. We need
to prevent execution of multiple androiddeployqt instances in
parallel. External projects now are divided into two steps. The
first runs the build and can be executed in parallel to the build
steps from the other external projects. The second one triggers
androiddeployqt and can only be run exclusively in relation
to the similar steps from other ABI-specific external projects.

To solve the issue we build the dependency chain between the all
ABI-pecific qt_internal_${target}_copy_apk_dependencies targets to
execute androiddeployqt sequentially. This is non-optimal, but
guarantees that androiddeployqt is not running simultaneously with
another instance in external projects.

Pick-to: 6.3 6.4
Fixes: QTBUG-104013
Change-Id: I39a25dd5f38ed988e0ca74b185024bc602ab81a1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-06-21 21:42:18 +02:00
Andreas Eliasson
ac171469a0 Doc: Revise Qt Test tutorial
- Make it explicit that each chapter can be run as a stand-alone test
application
- Add a CMake section on how to build the executable

Task-number: QTBUG-103730
Pick-to: 6.4 6.3
Change-Id: Id4c87c454521f698dcf16cfdc176318dd3e16786
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2022-06-21 11:08:49 +00:00
Ilya Fedin
56a33edf2a xcb: Port XSync call in QXcbWindow::create to xcb
QXcbConnection::sync is a full equivalent of calling XSync with false,
they both are sending GetInputFocus request and getting its reply

Pick-to: 6.4
Change-Id: I4f91b9447a02def41a8693a54312856b56e74811
Reviewed-by: Liang Qi <liang.qi@qt.io>
2022-06-21 11:07:47 +00:00
Liang Qi
a79e2aafd6 xcb: set primary screen more correctly
For example, when having virtual monitor which includes two real
monitors, the primary information in xcb_randr_monitor_info_t
is normally false, because user can only set it for output.

Kudos to Jiang Wu for his first patch and details of the issue.

Done-with: Jiang Wu <wujiang@kylinos.cn>
Pick-to: 6.4 6.3
Change-Id: I6af443ff69d347a6d86efc9c8ea7a5d18f4c3e24
Reviewed-by: JiDe Zhang <zhangjide@uniontech.com>
Reviewed-by: Jiang Wu <wujiang@kylinos.cn>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-06-21 04:05:53 +02:00
Jiang Wu
fd9aeb1b38 xcb: clear m_singlescreen before update
Pick-to: 6.4 6.3
Change-Id: Iafff57be82b5beb1f5702c00e0b6d7d0dd3ccdc2
Reviewed-by: Liang Qi <liang.qi@qt.io>
2022-06-21 02:05:53 +00:00
Nils Jeisecke
03e76ac23d xcb: fix missing initialization of m_cursor
Regression introduced in 9a4c98e556:

m_cursor is not initialized and never set when monitorInfo is not
available in QXcbScreen::setMonitor. This seems to happen when running
in VNC, e.g. on a Raspberry Pi.

This usually results in crashing the application pretty soon.

Using a unique_ptr solves both the initialization and a possible leak
when setMonitor is called multiple times.

[ChangeLog][Linux/XCB] Fixed crash when no monitorInfo is available (e.g. VNC).

Fixes: QTBUG-104443
Pick-to: 6.3 6.4
Change-Id: If13493c177121a1994b5d00dfbd64f1da694df2e
Reviewed-by: Liang Qi <liang.qi@qt.io>
2022-06-21 01:04:12 +02:00
Lars Knoll
9c1f3b6d4d Add QStringDecoder::decoderForHtml()
Now that QStringConverter can handle non UTF encodings through ICU,
add a way to get a decoder for arbitrary HTML code.

Opposed to QStringConverter::encodingForHtml(), this method will
try to create a valid string decoder also for non unicode codecs.

Pick-to: 6.4
Change-Id: I343584da1b114396c744f482d9b433c9cedcc511
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-21 01:04:12 +02:00
Thiago Macieira
d531c4b65d qsimd: don't enforce shstk (CET) feature on launch
Clang with -march=tigerlake or -march=sapphirerapids pre-defines
__SHSTK__, which QtCore require the feature, even if the OS does not
have support for it. That's of no consequence because the compiler does
not generate shadow stack operations on its own.

Pick-to: 6.2 6.3 6.4
Change-Id: Id0fb9ab0089845ee8843fffd16fa1ad910f008b8
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-06-20 16:04:12 -07:00
Sona Kurazyan
da0d7f61c8 QDom: Stop treating non-BMP characters as invalid
According to https://www.w3.org/TR/REC-xml/#NT-Char unicode characters
within the range of [#x10000-#x10FFFF] are considered to be valid, so
fix the check for valid characters accordingly. This requires changing
the loop over the input QString to iterate over code points (instead of
code units).

Fixes: QTBUG-104362
Pick-to: 6.4 6.3 6.2 5.15
Change-Id: I7dcf5cad05265a54882807a50522d28b647e06ee
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-20 21:29:04 +00:00
Tor Arne Vestbø
7d2488280e Windows: Avoid accidentally copying QWindowsScreenManager
Pick-to: 6.2 6.3 6.4
Change-Id: I60b219e9a3ea62a96c369ee910eacf06d61f4f71
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2022-06-20 20:56:59 +02:00
Alexandru Croitor
91fd8bdb11 CMake: Warn when using qt6_add_big_resources on iOS
qt6_add_big_resources works by calling rcc to generate a resource
.cpp file, compiling it into an object file, then passing the
compiled object file to rcc again for further manipulation.

The path to the object file is passed to rcc using the
$<TARGET_OBJECTS> generator expression.

This generator expression does not work when used in
add_custom_command / file(GENERATE) when targeting iOS, because
CMake claims it does not know where the object file will be on-disk
(presumably because the location is controlled by Xcode itself and it
can vary based on the active architecture and sysroot).

The following error is shown at generation time:
 Error evaluating generator expression:

    $<TARGET_OBJECTS:rcc_object_foo>

  The evaluation of the TARGET_OBJECTS generator expression is only
  suitable for consumption by CMake (limited under Xcode with multiple
  architectures). It is not suitable for writing out elsewhere.

More details about the issue can be found at
https://gitlab.kitware.com/cmake/cmake/-/issues/20516

Trying to work around the issue by manually invoking the compiler
instead of using a genex so we know the location of the object file
hits similar issues in that we don't know the active arch and sysroot
for which to compile the object file.

Until the CMake limitation is lifted or we find a different fix, warn
that qt6_add_big_resources can't be used when targeting iOS and
fall back to using qt6_add_resources instead.

Note that qmake CONFIG+=big_resources also falls back to non-big
resources mode when targeting Xcode (mac-xcode) and doesn't even show
a warning.

Another note is that using CMake + Xcode + qt6_add_big_resources does
work when targeting macOS, although it generates some warnings

 warning same member name (qrc_assets.o) in output file used for input
 files: qrc_assets.o qrc_assets.o
 (due to use of basename, truncation, blank padding or duplicate input
 files)

So there is some hope this could be fixed for iOS in the future.

Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-103497
Change-Id: I91152247651ecd35e8110b8874399cb1b8b394bd
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-06-20 20:56:59 +02:00
Volker Hilsheimer
2e12479e06 QGraphicsScene: respect that items can override selection changes
QGraphicsItems may override itemChange to prevent certain attribute
changes. Overriding ItemSelectedChange this way is explicitly documented
to be allowed.

However QGraphicsScene::clearSelection did not test whether items were
in fact deselected after the call to setSelection, and always cleared
the stored set of selected items.

Fix this by checking the actual selected state of the item as we iterate
over them, and store those items that are still selected in a set that
becomes the new selectedItems set (which will be empty if no item
overrides, which is the default).

Add a test that also checks that clearing the selection emits the
selectionChanged signal correctly (and does not if all selected items
block being deselected).

Fixes: QTBUG-85474
Pick-to: 6.4 6.3 6.2
Change-Id: I665afc132876e02e6e1061b7be37f4f6e4be418f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-06-20 20:44:23 +02:00
Allan Sandfeld Jensen
0bd2876275 Avoid misleading bindingStatus
Set it to nullptr on clear, and deal with possibly null bindingStatus.

Task-number: QTBUG-101177
Task-number: QTBUG-102403
Pick-to: 6.4
Change-Id: I66cb4d505a4f7b377dc90b45ac13834fca19d399
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-06-20 19:06:20 +02:00
Ilya Fedin
c3e624eb50 Port QXlibEglIntegration::getCompatibleVisualId to xcb
In combination with EGL_EXT_platform_xcb support, this allows xcb_egl
to be used without xlib. Without EGL_EXT_platform_xcb support, this
still reduces amount of code using xlib.

Pick-to: 6.4
Change-Id: I29e2b29f7ef8ea34320887f62697f84232b86fba
Reviewed-by: Liang Qi <liang.qi@qt.io>
2022-06-20 15:53:33 +00:00
Giuseppe D'Angelo
1c106b37c7 QXdgDesktopPortalFileDialog: fix C++20 build
In a lambda, capturing of `*this` by reference via `=` is deprecated,
and breaks the build. Capture everything needed instead.

Amends fb981a0954.

Change-Id: I5d3d192e71662b96154cb5979898277bd0720a90
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-20 17:53:33 +02:00
Giuseppe D'Angelo
a7203a8920 QWindow: fix C++20 build
In a lambda, capturing of `*this` by reference via `=` is deprecated,
and breaks the build. Capture everything needed instead.

Amends e7477e8934.

Change-Id: Ibdbf51cb7a5ec54004b14b719dfd44e86d6f0893
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-06-20 17:53:33 +02:00
Louis du Verdier
d7068eaad7 Fix tst_AndroidAssets, broken by recent changes on assets load speed
Recent changes on load speed of individual assets made
AndroidAbstractFileEngine use a cache for basic information in order
to avoid to have to open assets every time a QFileInfo is created,
which was very expensive for older phones.

However, size() method was forgotten and continued to expect that the
asset would be opened first, and therefore QFileInfo().size() would
always return -1.

This change fixes this by caching as well the information about the
size of the asset, and also reverts a part in open() to close() first
in case asset would already be opened, in order to keep previous
behavior (even if this did not cause any known issue).

Fixes: QTBUG-104412
Pick-to: 6.4 6.3 6.2 5.15
Change-Id: I992f31b8f9e14dfec44cec78d0c1a2a3e18bdb7f
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-20 16:18:34 +02:00
Laszlo Papp
4679d16db8 QAbstractItemDelegate: Remove a duplicate doc entry
Pick-to: 6.4 6.3 6.2
Change-Id: I02887e6bf5892b4697af2aabcd1f1335e15b4f06
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-06-20 14:08:35 +00:00
Volker Hilsheimer
145bfe6054 Document QJniObject::construct
Added for 6.4. Not extremely useful as long as the macros that allow
the declaration of new class and type strings also being documented.

Pick-to: 6.4
Change-Id: I9ee466fdd0aaccec1e627ceb313b5a5c17e3f3fa
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
2022-06-20 16:08:35 +02:00
Volker Hilsheimer
e0a729dfd2 Make the new setCurrentId the writer for the respective property
Amends 2140edaaab.

Pick-to: 6.4
Change-Id: Idc1ace4229b8706d9b44f1727105cc9aaab1a86d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-06-20 16:08:35 +02:00
Richard Moe Gustavsen
20a40035fa QTableView: set correct clip on QPainter when using spans
As it stood, QTableView would sometimes show drawing
artifacts when sections (rows or columns) where
rearranged, in combination with spans.

The reason is that the current code would go through the
currently visible cells in the viewport to check if any of
them where affected by a span. But the stored spans (in
QSpanCollection) is kept in sync with the column layout in
the model, and doesn't know anything about the rearranged
columns in the view. But a column with spans that is moved
to the left of the viewport can affect the painting of
the viewport as well, and needs to be taken into consideration.
For that reason, the current solution that uses
QSpanCollection::spanAt(x, y), will in that case fail.

Since it seems sensible that QSpanCollection is kept in sync with
the model (it makes model changes that affect spans easier to
handle), this patch will not change QSpanCollection. Instead, it
will iterate through all the spans (which is assumed to normally be
a limited size), convert them to the column layout of the view
(visual instead of logical), and find the ones that overlap.
Overlapping spans will, like before, be added as clip rects
to the QPainter.

Fixes: QTBUG-91896
Pick-to: 6.4 6.3 6.2
Change-Id: Iabe20df13cbd41a68f1104d3d9e24b89c4b88913
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-06-20 14:03:26 +02:00
Yuhang Zhao
7225ed749d QOperatingSystemVersion: Add new Windows version
And also update some docs to provide more detailed info.

Pick-to: 6.4
Change-Id: I7b51fcb6613399cb4f1dd5d75cf3168df195577b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-20 16:29:29 +08:00
Thiago Macieira
23bf260f10 Fix improper moc includes inside the Qt namespace
Pick-to: 6.3 6.4
Change-Id: Id0fb9ab0089845ee8843fffd16fa1b1413fd0d41
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-06-19 21:32:48 -07:00
Yuhang Zhao
797a493f50 Network: make Public Suffix List constexpr
Upstream PR: https://github.com/rockdaboot/libpsl/pull/182

The repo owner denied the PR because the library only
produces C89-compatible code and constexpr is a C++ feature.

Pick-to: 6.4
Task-number: QTBUG-100485
Change-Id: I9e01705b27022a636a98ac67b19169677d7c7652
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-06-19 16:27:16 +08:00
Yuhang Zhao
1e71071c92 Windows QPA: Fix indention
It seems this block of code was originally copied from elsewhere
so the original indention is preserved.

Pick-to: 6.4
Change-Id: I53ab8e58b4304dfc768bd6472255a6c2d0471d5e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-06-19 10:29:56 +08:00
Fabian Kosmale
122270d6be Long live the ICU-based QStringConverter interface!
This adds support for additional codecs to QStringConverter when ICU is
available.

We store the converter in the state (d[0]), and its canonical name in
d[1]. We need the name there, as in the clear function we close the
UConverter, and set the pointer to null. Consequently, the actual
conversion functions might need to re-open the converter again. The
advantage of this approach is that clear is used in the destructor of
State, and with this approach we properly clean up the state.
There is however a disadvantage: The clear function was so far also used
for resetting the state when QStringConverter::resetState . Discarding
the whole Uconverter for that is however rather costly. For that reason
we modify resetState to call a new function, State::reset. For existing
converters, it behaves the same as clear; for the ICU based converter,
we call the more efficient ucnv_reset. Code compiled against Qt 6.4 can
benefit from this more efficient version; code compiled against older Qt
versions will continue to work, as the conversion functions can just
recretate the converter from the name.
We can distinguish between ICU and non-ICU converters by checking if the
UsesIcu flag is set.

QStringConverter::name is changed to return the name stored in d[1]. The
interface of the ICU converter has a dummy name, so code using the old
name function from QT < 6.4 still returns something, namely a message
asking the user to recompile.
The function is moved out of line, as we need to check for the private
ICU feature, and want to avoid having that check in the public header.

As the QStringConverter ctor taking a name now can allocate memory, it
can no longer be noexcept. Removing the noexceptness is safe, as it was
only added after Qt 6.3.

Note that we cannot extend the API consuming or returning Encoding, as
we use Encoding values to index into an array of converter interfaces in
inline API.

Further API to support getting an ICU converter for HTML will be added
in a future commit.

Currently, the code depending on ICU is enabled at compile time if ICU
is found. However, in the future it could be moved into a plugin to
avoid a hard dependency on ICU in Core.

[ChangeLog][Corelib][Text] QStringConverter and API using it now
supports more text codecs if Qt is compiled with ICU support.

Fixes: QTBUG-103375
Change-Id: I7afb92fc68ef994179ebc7a3aa73beebb1386204
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-19 00:41:12 +02:00
Tor Arne Vestbø
d350373133 Windows: Replace lcQpaWindows logging with lcQpaScreen in screen code
Pick-to: 6.4
Change-Id: I1d2fd586aac1163aa449f813ce3b7244c6ebaee0
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2022-06-18 21:08:08 +02:00
Tor Arne Vestbø
fa0b2ef81c Windows: Decouple screen change monitoring from top level QWindows
The WM_DISPLAYCHANGE message it sent when displays are added, removed,
or update their properties such as the scale/DPI.

We were processing this message as part of QWindowsContext::windowsProc(),
which meant that we would only react to display changes if there was a
QWindow on screen. Just creating a QGuiApplication was insufficient to
pick up changes to screens after startup.

In addition, despite being documented to post messages to child windows,
WM_DISPLAYCHANGE only ends up in top level windows. Presumably it's the
top level window's responsibility to post the message to child windows.
As a result, if a QWindow was a native child window of a foreign window,
such as in audio plugins being hosted in a DAW, we would again fail to
pick up display changes.

We solve both these cases by decoupling the WM_DISPLAYCHANGE handling
from QWindowsContext::windowsProc(), by creating a dedicated window
for listening to WM_DISPLAYCHANGE. This is similar to how we already
handle tray icons, power notifications, clipboard, etc -- the only
difference being that since purely HWND_MESSAGE windows do not
receive WM_DISPLAYCHANGE it's an actual invisible WS_TILED window.

This also lets us remove the workaround for QTBUG-79248, which was
doing screen updates in response to WM_DPICHANGED when detecting
that there were no QWindows.

Task-number: QTBUG-103383
Task-number: QTBUG-79248
Fixes: QTBUG-102343
Pick-to: 6.4
Change-Id: I905d8253069ec339b193edf05c052d21361ca3e9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-06-18 21:08:02 +02:00
Marcel Kummer
e457aeec38 QBoxLayout: Add assertion that catches out of bounds insertion indices
As of Qt6, QList will assert that an insertion index is in range of
existing values. QBoxLayout interprets negative indices as "append at
the end". That part is covered.
Indices larger than the number of items in the layout would trigger the
assertion in QList, but after the insert method had returned. That would
make it hard to debug. This change asserts the index range before
inserting, thus making it easier to spot the problem.

Fixes: QTBUG-103775
Change-Id: Ida099f785263fe8a5c8a1d0a48c4ff87713549b4
Pick-to: 6.2 6.3 6.4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-06-18 21:07:51 +02:00
Thiago Macieira
f23d83c43e qmetatype.h: remove #undef for something that was never #define'd
Pick-to: 6.3 6.4
Change-Id: Id0fb9ab0089845ee8843fffd16f976868e3ab448
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-18 08:44:06 -07:00
Thiago Macieira
4c1b1f2ad8 QMetaType: use explicit load/store operations on QBasicAtomicInt
QBasicAtomicInt::operator int() does loadAcquire() and operator=() does
storeRelease().

Pick-to: 6.2 6.3 6.4
Change-Id: Id0fb9ab0089845ee8843fffd16f9a1ece6823777
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-18 08:43:53 -07:00
Lorn Potter
ff0c7dfc6e wasm: Fix up namespacing in wasm platform plugin
Pick-to: 6.4
Change-Id: I2fdbb6688b252743578dfcd58f9259eb5ac3cca8
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-06-18 09:16:55 +10:00
Lorn Potter
87c2a401da wasm: fix unicode input
also remove duplicated function call to get Qt key for event

Pick-to: 6.3 6.4
Fixes: QTBUG-78826
Change-Id: Ibaf0dd3eb428b65280ed1f840a4849b44f2868e0
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-06-18 05:50:25 +10:00
Alexandru Croitor
81b5395aef CMake: Android: Fix 'qmldir file not found at' warnings
androiddepployqt calls qmlimportscanner to find qml modules.

Due to an issue in a generator expression, CMake did not write out the
android default qml output directory to the deployment json file,
which in turn means that qmlimportscanner did not get that
information.
When the scanner scanned the sources, it found some relative imports
but couldn't find relevant qmldir files because they were in an
android-specific directory.

This caused warnings like 'qmldir file not found at /some/path'
repeatedly.

Fix the generator expression to use $<COMMA> instead of , so that the
genex condition is evaluated successfully and the extra qml import
paths are passed along to qmlimportscanner.

Amends 76665f2a72

Pick-to: 6.4
Fixes: QTBUG-102595
Change-Id: Ia74c3c80f12d05b0a9cd0978df1a58bb5582198a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-06-17 20:59:22 +02:00
Alexandru Croitor
20dd4a43f0 CMake: Fix Xcode common dependency issues for other_files IDE target
A generated file can be added to a resource target, which in turn
adds it to the other_files target. With the Xcode generator, this can
lead to errors like

 The custom command generating foo.txt is attached to multiple
 targets:
      foo_other_files
      foo_resources_1
 but none of these is a common dependency of the other(s).  This is
      not allowed by the Xcode "new build system".

Neither of the targets depend on each other because logically
they shouldn't depend on each other.
And yet XCode wants that each generated file is attached only to one
target, which will be a common dependency for the other targets.

Make sure _qt_internal_expose_source_file_to_ide extracts and uses
that common target dependency just like
qt_add_resources -> _qt_internal_process_resource already does.

One case of a common target dependency is the _lrelease target
in qttools which was added in 5b0e765ab0dddba86662925cb44aeac748a286b7

Another case is in qt_add_shaders in qtshadertools.

I expect we might encounter other cases where we need to introduce a
common driving target.

Pick-to: 6.2 6.3 6.4
Task-number: QTBUG-103723
Change-Id: Ideff023718a6ce109a4b3eefa01bffa79d1c6a3e
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-06-17 20:59:22 +02:00
Volker Hilsheimer
fa814fcfea Provide overload for Qt::AlignmentFlags in item widget items
Amends 53ee4c8b1f, which deprecated
QListWidgetItem::setTextAlignment(int) etc and provided a typesafe
Qt::Alignment overload instead. However, Qt::AlignLeft by itself is of
type Qt::AlignmentFlag, it only becomes a Qt::Alignment when or'ed
with another alignment flag. So the deprecated int-overload was taken
by the compiler, resulting in a deprecation warning.

Add a Qt::AlignmentFlag overload in addition, and document it as
\internal since it is just a C++ technicality that we need both.

Pick-to: 6.4
Change-Id: Ide97eed7f6d1f89a5f955b2ed45167e771bd8c81
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-06-17 20:59:22 +02:00
Axel Spoerl
99c8ffb9f2 Update window state in QWindowsWindow and QXcbWindow geometry setters
When QWidget::resize() is called on a maximized or minimized QWidget,
the window state of the widget and the corresponding QWindow is not
updated (i.e. remains maximized or minimized).

This patch updates the window state to Qt:WindowNoState when
setGeometry() is called in QWindowsWindow or QXcbWindow.

A test is added in tst_QWidget.

Fixes: QTBUG-104201
Pick-to: 6.4
Change-Id: I07491fb9293d13509573fc403750da0a50f6a785
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-06-17 18:59:22 +00:00
JiDe Zhang
8790da8988 xcb: Get some style hints from xsettings
According to
https://www.freedesktop.org/wiki/Specifications/XSettingsRegistry/.
Added support for Net/CursorBlinkTime Net/DoubleClickTime
Net/DoubleClickDistance Net/DndDragThreshold.

Change-Id: Ief208736ed2938792d935bfd730fefdd745394b6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-06-18 02:59:22 +08:00
Ivan Solovev
2ed54dedf3 QMainWindow: fix restoreState() for toolbars
Restoring the toolbar state of a QMainWindow could not update
QWidgetPrivate::widgetItem for the QToolBar, because at that point it
was still holding the pointer to the widgetItem of the previous state.
Later on, when the new state was successfully applied, the previous
state was deleted, and the corresponding widgetItem was reset to
nullptr.

This patch explicitly resets the QToolBar's widgetItem while updating
the state, so that it is later correctly updated while creating a
new QWidgetItemV2.

Fixes: QTBUG-102395
Pick-to: 6.4 6.3 6.2 5.15
Change-Id: I17613d62423edcc0faf85ecb0a714865a50d87e8
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-06-17 20:59:21 +02:00
Volker Hilsheimer
b2fb14b7ba macOS: set print dialog up with page attributes when no printer is installed
When the print dialog is opened without a printer installed, then the
printer's output format is PDF rather than native. In this case, we need
to set the NSPrintInfo with some page atttributes explicitly, and not
default to the application-wide NSPrintInfo.sharedPrintInfo. Otherwise,
the print dialog will show the wrong page size and orientation, and the
printer will not have the previously set values when the dialog returns.

The dialog always shows the wrong values for the page margins (only
available through the presets dialog), but the printer's values are not
overridden. Also, the print range is taken care of correctly by the code
further down in this function, irrespective of the printer's output
format.

Note: this cannot be unit tested as we need to open the native print
dialog on a system without printer installed, and compare the values we
set on the printer before opening the dialog with the values after the
dialog was successfully finished via PDF->Save as PDF.

Fixes: QTBUG-100188
Pick-to: 6.4 6.3 6.2
Change-Id: I8f1561e054f6a867b131111845c9b061778e4eb0
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-06-17 19:06:10 +02:00
Marcel Kummer
29176bf2f8 QBoxLayout: Pull out handling for negative insertion indices
This snippet occurs in every insert function further down. Let's pull
it out in preparation for adding an assertion that the index is in
range, which would also need to be added to every insert function.

Fixes: QTBUG-103775
Change-Id: I419f57434f860df4c947853ac307826994f0198b
Pick-to: 6.2 6.3 6.4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-06-17 18:29:11 +02:00
Janne Juntunen
a2cb9ae8cc QFont: remove support for comma split setFamily()
In the documentation it is said that from Qt 6.2 onwards setFamily()
only sets a single family but so far this hasn't been the case.

Fixes: QTBUG-102768
Pick-to: 6.4
Change-Id: I2a5037ea1385cb8c6644d1e256b89e167c590967
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2022-06-17 19:02:24 +03:00
Edward Welbourne
80f8e380db Remove a misleading sentence from QDomDocument::setContent() doc
QXmlReader has been replaced by QXmlStreamReader and, either way,
there is currently no way to over-ride the purging of space-only
nodes.

Task-number: QTBUG-103753
Pick-to: 6.4 6.3 6.2
Change-Id: I7bae72d81f1b2503f93c691081137b4f60eeadda
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-06-17 10:34:58 +02:00
Morten Sørvig
077eddb3e1 Windows QPA: Update screen on child window DPI change
Windows does not send WM_DPICHANGED to child windows, which means
that the normal DPI change handling code does not run for QWindows
which are embedded in a foreign, non-Qt, window.

Add code which handles WM_DPICHANGED_AFTERPARENT. This event is
sent to all child windows, but not the top-level window. Call
checkForScreenChanged() here, similar to what the WM_DPICHANGED code
does.

This commit does not add code to resize the child window, since
it is uncertain if this is the responsibility of the window which
receives WM_DPICHANGED, or of each child window.

Done-with: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Pick-to: 6.4
Task-number: QTBUG-103383
Change-Id: Icf85dd0afa806609dbbe0ffc36efbc5127962c39
Reviewed-by: <stefan.wastl@native-instruments.de>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-06-16 23:01:04 +02:00
Cristian Adam
7037f4620f Doc: Document how to treat qt_add_big_resources args as source files
The arguments to qt_add_big_resources are not known to CMake as source
files.

They need to be added explicitly to a CMake target in order for Qt Creator
to treat them as source files and in the case of a qrc file to expand
the contents in the project view.

Fixes: QTBUG-104320
Pick-to: 6.4 6.3
Change-Id: Iea755d998e8f9814a82983272731b0c654f80644
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-06-16 21:01:04 +00:00
Ivan Solovev
662184ac68 QComboBox: emit currentIndexChanged() and currentTextChanged() when the model is cleared
QComboBox uses QPersistentModelIndex to store the current index of the
underlying model. When the model is cleared, that index is automatically
invalidated, so calling QComboBoxPrivate::setCurrentIndex(QModelIndex())
does not result in signals being emitted, because we do not detect the
index change.

This patch uses indexBeforeChange to detect such situation and emit all
necessary signals.

Fixes: QTBUG-103007
Pick-to: 6.4 6.3 6.2
Change-Id: I29326830a30a17900839e8d1737a08bd940081ea
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-06-16 19:29:36 +02:00
Volker Hilsheimer
79a11470f3 Accessibility: don't emit focus change when reason is window activation
If a window becomes active, then the accessibility system gets informed
about that already. Qt puts focus on the focus child of the activated
window afterwards, and if this emits another accessibility event, then
accessibility clients like Windows Narrator will stop reading the
activated window, and instead read about the focused widget.

This makes dialogs like message boxes poorly accessible.

Accessibility clients already know that a window became active, and can
query Qt about the focused child within that window.

Amend test case.

Fixes: QTBUG-101585
Pick-to: 6.4 6.3 6.2
Change-Id: I2d6bff7c415a6f29c4a4f7f4e4be38079fb976ca
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2022-06-16 19:29:36 +02:00
Volker Hilsheimer
56d6a36020 Implement a dedicated QAccessibleInterface for QMessageBox
QMessageBox has text values that an accessible client should be able to
read directly without having to navigate through the text labels.

Add test coverage.

Windows Narrator is inconsistent in reading the contents of a message
box. It might skip them completely, even though the text property is
read through the interface.

Task-number: QTBUG-101585
Change-Id: I639c2210a627733c093743790c6a6b83f4bb80d0
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2022-06-16 19:29:36 +02:00
Lorn Potter
4d25429746 wasm: fix some coding style
- shorten a couple extra long lines
 - add space between functions

Pick-to: 6.4
Change-Id: I14ad7448372ba50f4b0299535c4261a5bbf415b7
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-06-16 17:29:35 +00:00
Tor Arne Vestbø
2a76c41fdd macOS: Avoid recursively updating screens when window moves screen
The QWSI APIs for reporting added or removed screens is not transactional,
so when several screens change at once Qt will see each screen change as
a separate state.

As a result, Qt, or the application itself, may react to the first of
many screen updates by moving a window to a different screen -- one
which is going to updated (removed) in the next iteration of QWSI
calls.

This caused trouble on macOS, where we use many different signals to
detect that the system has changed the screens, one of them being that
a window has been moved to a different screen.

In the scenario above, we would be in the process of updating screens
in response to the system going to sleep, which means all 3 connected
screens will be disconnected and replaced with one fake screen provided
by the system.

As we delivered the removal of the first QScreen, Qt or the application,
would respond by moving the window to one of the other two screens, which
in turn would recursively trigger another round of screen updates. This
round would then proceed to remove (and delete) all remaining QScreens.
When we then recursed back to the initial round of screen updates
we would continue iterating and operating on screens that had already
been removed, causing a crash.

Since we know that the screens will stabilize eventually, and that
QCocoaScreen has cached all info based on the displayId and NSScreen,
we can safely skip any recursive invocations of updateScreens().

Fixes: QTBUG-102021
Fixes: QTBUG-84741
Pick-to: 5.15 6.2 6.3 6.4
Invaluable-help-by: Bruno Cadoret <bruno.cadoret_1@signify.com>
Change-Id: I9ff96dbcbc6f308ad2729faf2db2de7ef08513c0
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-06-16 17:43:39 +02:00
hjk
903a883044 QSettings: Fix reading of the [%General] section
The currentSection key was accidentally using the whole remaining
section contents.

Pick-to: 6.4
Change-Id: Iec6e38636e519170eef136401ede4b626e12754a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-06-16 08:25:23 +02:00
Ulf Hermann
4912903e37 Endian: Remove old special integer bitfields
The only way to use them was to put them in a union and then write all
the members of the union to set the various bit ranges. As only one
member of a union can be active at any time, the compiler is free to
optimize those writes away, though. This has started happening in the
wild now.

As we have a replacement, we can remove the old and broken code now.

Task-number: QTBUG-99545
Change-Id: I90718ec06662258d1c15220f54da9eed2186c5a5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-16 06:12:27 +00:00
Thiago Macieira
bc144312c1 qHash: pass QByteArrayView to qHash() by value
The QBAV one should pass the parameter by value, like QStringView. And
now that we have it, the non-View one should call the View one in an
inline function, like we already do for QString.

The extra, defaulted parameter is there only so we get a different
signature in the new inline function compared to the removed one.

Pick-to: 6.4
Change-Id: If05aeeb7176e4f13af9afffd16e7f08062b1dc86
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-15 23:25:00 +00:00
Maximilian Goldstein
64f86ca03e qwasmtheme: Enable hover effects by default
Previously hover effects had to be enabled manually due to not being
enabled in the platform style. This change enables them by default.

Pick-to: 6.4
Fixes: QTBUG-88799
Change-Id: I014e1f5dfcd9b15656f11e12ab75a77d42f4815c
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-06-15 21:08:30 +00:00
Kai Köhne
9d2cc4dd76 Fix typos in docs and comments
Found by codespell

Pick-to: 6.4
Change-Id: Ie3e301a23830c773a2e9aff487c702a223d246eb
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-06-15 21:31:02 +02:00
Edward Welbourne
37bad1f43b Don't exit(1) on unrecognised test function name, just report a failure
This way, if you name several test functions on the command-line,
you'll at least get the ones that do exist run (and you'll be told all
of the ones that don't exist, rather than only the first).

Pick-to: 6.4 6.3 6.2
Change-Id: I14a515fcfacb6ca49e0470b236c05475b25db4f2
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
2022-06-15 20:23:06 +02:00
Louis du Verdier
edd983071e Android: Improve loading speed of individual assets
This change improves the loading speed of files stored in Android assets
folder by caching the information about files already opened.

Prior to the change, when creating a QFile or QFileInfo to an asset
file, the engine would first scan all the file's directory and parent
directories in order to cache all this in FolderIterator::m_assetsCache.
Due to the nature of Android assets, it might be very slow, depending on
the number of images in this tree.

In this patch, individual file accesses will stop using FolderIterator
and will simply open what is asked, caching the information about the
resource in order to avoid to have to call the expensive
AAssetManager_open if the file is accessed again (e.g. by QFileInfo).

Fixes: QTBUG-101161
Change-Id: Iaedf4cdf83d5116053b51895a6795d43bc60f942
Pick-to: 6.4 6.3 6.2 5.15
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2022-06-15 18:23:12 +02:00
Allan Sandfeld Jensen
f53f709504 Replace QT_NO_ACCESSIBILITY with QT_CONFIG(accessibility)
Pick-to: 6.4
Change-Id: Iee4bd8970810be1b23bdba65a74de912401dca65
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-15 18:03:30 +02:00
Guineng Ni
6dbe45c96a macdeployqt: macdeployqt process some libraries(e.g. ffmpeg) incorrect
ffmpeg and nettle are different from other libraries, they use symbol
link as their inner module dependencies. Calling one more
install_name_tool can handle this case.

Fixes: QTBUG-100093
Pick-to: 6.2 6.3 6.4
Change-Id: I12cdd53bd5aa3120910070ba283178686deb3eb0
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-06-15 07:11:10 +00:00
Morten Sørvig
79bead6c3b Add support for painting at integer DPR with downscale
Enable by setting QT_WIDGETS_HIGHDPI_DOWNSCALE=1 and QT_WIDGETS_RHI=1.

This will make the backing store and painter operate at the next
highest integer DPR in cases where QWindow::devicePixelRatio() returns
a fractional value. The backing store image will then be downscaled
to the target DPR at flush time, using the RHI flush pipeline.

[ChangeLog][QWidgets] Added experimental support for always
painting at an integer device pixel ratio (rounding the DPR up if
necessary), followed by a downscale to the target DPR.Enable by setting
QT_WIDGETS_HIGHDPI_DOWNSCALE=1 and QT_WIDGETS_RHI=1.

Pick-to: 6.4
Task-number: QTBUG-86344
Change-Id: Id5b834a0e3499818b0b656161f5e0c38a6caa340
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-06-14 19:16:35 +00:00
Morten Sørvig
d38118c808 Make rhiFlush() support custom source DPR
The rhiFlush() implementation currently assumes that
QWindow->devicePixelRatio() is the correct scale factor for
transforming device independent window geometry to source geometry.

However, this assumption does not hold if/when we add support
for drawing to a rounded-up DPR, with a downscale later in
the rhiFlush implementation.

Fix this by adding a sourceDevicePixelRatio argument to rhiFlush(),
which is set to either QWindow::devicePixelRatio() or
QWidget::devicePixelRatio(), depending on from where it is used.

Change deviceRect() and friends in qbackingstoredefualtcompositor.cpp
to be scale*() functions instead which take a scale factor instead
of a QWindow. Update call sites to use srouceDevicePixelRatio
where that makes sense.

Pick-to: 6.4
Change-Id: Idb7b1e2f36816a201e00f0defe100d2dc079cb17
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-06-14 21:16:35 +02:00
Axel Spoerl
373392eeb4 xcb: Replace qCWarning by qCDebug in QXcbConnection::printXcbError()
Example:
Error "BadWindow" (3) is raised by the XCB backend when a mouse event
is processed on a resource that disappears between posting and
processing of the event.
That constellation is harmless and can occur in async environments.

As XCB errors point to coding issues, this patch changes their logging
behavior from qCWarning to qCDebug.

Fixes: QTBUG-56893
Pick-to: 6.4 6.3 5.15
Change-Id: Idee5ee80efaf9cd6686448779f76c68d5e4c9b63
Reviewed-by: Liang Qi <liang.qi@qt.io>
2022-06-14 13:45:06 +00:00
Laszlo Agocs
9dced35b41 Use consistent ordering in QShader
Fixes: QTBUG-101923
Change-Id: I62df3eba773350e47ed650acb00bc42b3ce6a899
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2022-06-14 14:58:09 +02:00
Eskil Abrahamsen Blomfeldt
992a318d39 CoreText: Fix fonts with synthetic stretch
If a font is synthetically condensed / expanded, we need to scale
the advances as well as the bounding boxes for the glyph cache.
The logic is adapted from DirectWrite font engine, where the same
scaling is already in place.

[ChangeLog][macOS] Fixed a bug where synthetically stretched fonts
would get the wrong advances and sometimes glyphs would be clipped.

Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-103838
Change-Id: I09fc87b245d1f2de980c10ad9253b9a83571f714
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-06-14 14:58:09 +02:00
Eskil Abrahamsen Blomfeldt
81fdfcfc4a Fix font rendering when Qt is configured with -no-harfbuzz
When Qt was configured with -no-harfbuzz, we would get overlapping
glyphs, because we skipped the shaping step but did not set up things
correctly before that. Instead, we force the PreferNoShaping code path
when there is no shaper available.

[ChangeLog][Text] Fixed font layouts when Qt was configured without
Harfbuzz.

Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-100361
Change-Id: I1c54dbc457dbb235548b9d70324d607a0ee6d501
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2022-06-14 14:58:09 +02:00
Shawn Rutledge
8a5fa635ca Trace QImage::Format as int in QImageData::create()
Traces can contain only a few types; for now, enums have to be converted
to int. Amends 6d323c0b22

Task-number: QTBUG-102862
Change-Id: If129d03b13e723350bac987c6e35d471aa6c17e2
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Rafael Roquetto <rafael.roquetto@qt.io>
2022-06-14 14:11:35 +02:00
Kai Köhne
3a5334e5be Doc: Remove \target Transformations
The section is already called Transformations. Making
it a target just causes issues in other contexts.

Pick-to: 6.4
Change-Id: I8dc65bd3254238e51a649f926cd066dfcbe9500d
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2022-06-14 08:15:47 +02:00
Marc Mutz
fa4d18b86c Revert "qxp::function_ref: drop use of q23::invoke_r"
This reverts commit b9cce12e76, which
broke

    function_ref<void(int)> f = [](int i) { return i; };

ie. swallowing of return types.

We could maybe implement the same without invoke_r, with the same
manual if-constexpr that invoke_r has, but it would be a pointless
duplication across the two thunks we have, so just use invoke_r.

Add tests.

Pick-to: 6.4
Task-number: QTBUG-103739
Change-Id: I6034f05d813c06a25e8058ded5b6b62f3ca858b4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-14 01:30:48 +00:00
Marc Mutz
4e66c69bad QLibrary: fix use of deprecated QByteArrayMatcher::indexIn(p, n)
Use the QByteArrayView overload instead.

Deprecated since 6.3, so backporting:

Pick-to: 6.4 6.3
Change-Id: I529104cad59260eed371cedb1ae84a7e9086bbf6
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-06-14 01:30:48 +00:00
Marc Mutz
de005e7976 QByteArray: more GCC 12 -Werror=array-bound whack-a-mole
This one came up on a tsan build, but not on an asan/ubsan one!?!:

    qbytearray.cpp: In member function ‘QByteArray QByteArray::toBase64(Base64Options) const’:
    qbytearray.cpp:3884:42: error: array subscript 1 is outside array bounds of ‘const char [1]’ [-Werror=array-bounds]
     3884 |             chunk |= int(uchar(data()[i++])) << 8;
          |                                ~~~~~~~~~~^
    qbytearray.cpp:37:24: note: at offset 1 into object ‘QByteArray::_empty’ of size 1
       37 | Q_CONSTINIT const char QByteArray::_empty = '\0';
          |                        ^~~~~~~~~~
    cc1plus: all warnings being treated as errors

Fix, as so often, by caching the size().

The code in 5.15 is different, but similar, so picking all the way.

Pick-to: 6.4 6.3 6.2 5.15
Task-number: QTBUG-103923
Change-Id: Iac30e964c8d7d367620d16db65ceeaade33ee6b4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-06-14 01:30:48 +00:00
Thiago Macieira
246f17d470 QApplication: Remove QApplicationPrivateBase porting macro
This was last used in 2011, before Qt 5.0 release, when QPA was yet
another windowing system, not the only option.

Change-Id: Ia4a094014ddb48cc9f6dfffd16f83aad1b7109e7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2022-06-13 17:58:22 -07:00
Thiago Macieira
fb1e0eee07 Q*ApplicationPrivate: remove unused "flags" arguments
They weren't flags. They were the version of Qt that was used in
compiling the application itself. The protection against rollback isn't
necessary any more, since qversiontagging.h, which applies to everything
and not just the main application binary. And using them to make
decisions on functionality or behavior is misguided (see previous
commit).

This commit does not deprecate the front-end classes' argument. In the
future, we may find some need for them.

Pick-to: 6.4
Change-Id: Ia4a094014ddb48cc9f6dfffd16f83a7b58ff95d3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-06-14 00:58:22 +00:00
Thiago Macieira
c4af4dcb5d QCoreApplication: Remove app_compile_version
It's not used for anything, so remove the temptation of trying to use it
to make decisions at runtime about a behavior. It's the wrong tool for
the job: it might tell you the version of Qt the *application* was
compiled against, but not the version any of the Qt-using libraries
were.

Pick-to: 6.4
Change-Id: I175efddd75f24ae59057fffd16f70b77dd87faf4
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-13 17:58:22 -07:00
Edward Welbourne
6ae2bfad41 Fix doc and example of QLoggingCategory::installCategory()
Snippet [22] was unused and the example using snippet [21] neglected
to show how its oldCategoryFilter got initialized, which is what [22]
does. But it turns out the example code was crashy in any case, as it
left the oldCategoryFilter uninitialized (albeit probably null) until
the call to installFilter() had returned, and installFilter() calls
the new filter, so the new filter needs to check oldCategoryFilter
before calling it. The doc also failed to explain why it's OK to not
defer to the prior filter in these calls during installFilter(), so
revise the doc and example so that the latter behaves sensibly and
readers of the former are likely to use the function safely.

This amends commit 8f0654ceb8 which
added the snippets and the use of one of them, but not the other.

Fixes: QTBUG-49704
Pick-to: 6.4 6.3 6.2 5.15
Change-Id: Iddb8d97b0bef417d8f16e7910730cfa59ea3e715
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2022-06-13 22:46:02 +00:00
Tor Arne Vestbø
1480588f44 Print QScreen geometry debug state using the underlying types
A QRect is unambiguous, and easier to parse than a custom rect format.

Change-Id: If8c197a5e522744b9629d5d89536df5c0da7308c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-06-13 21:17:53 +02:00
Tor Arne Vestbø
f7a56b32cc macOS: Resolve screen name via NSScreen on macOS 10.15+
Apple Silicon Macs no longer expose display information through IOKit.
Luckily we can use the 10.15 localizedName property on NSString to
resolve the name.

Pick-to: 6.2 6.3 6.4
Change-Id: Ie75430df1a80808cb7b23d97d1e440d1f3bf75d6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-06-13 21:17:53 +02:00
Tor Arne Vestbø
5909e33d1d macOS: Ignore update requests for offline displays
Accessing a display that's offline may cause crashes,
so to be on the safe side we skip update requests in
this situation.

Task-number: QTBUG-102021
Pick-to: 6.2 6.3 6.4 5.15
Change-Id: I6b48b6722bccde628e510c538943d14f2b0271e5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-06-13 19:17:53 +00:00
Volker Hilsheimer
e6da018c86 Add "We mean it" warning to new private header
Amends 5e48a51608, fixing warning
from syncqt.

Change-Id: I15d22a1bba865777c17180438b6e89ee9e1ae78b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-13 18:34:27 +02:00
Friedemann Kleint
539815569f Fusion style: Fix menu item text being elided when mnemonic and && appear in the text
Pass the text flags to fontMetrics.elidedText().
Amends 0c0892a3e2.

Pick-to: 6.4 6.3 6.2
Task-number: QTBUG-94481
Fixes: QTBUG-103836
Change-Id: I21a9b96ef69e5a5e612a0bdbdf44e5a20931eb59
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-06-13 18:34:27 +02:00
Thiago Macieira
1227af2635 Revert "qglobal.h: include <stdalign.h> in C mode"
This reverts commit 69e8a89358.

Reason for revert: the header is not present in all MSVC installations.

Change-Id: Ib809e59291ef30b9cbf6b4d61e27ea162e5d40b4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-06-13 13:37:37 +00:00
Kai Köhne
04cc705947 CMake: Fix typos
Found by codespell

Pick-to: 6.4
Change-Id: I4907e423b6b345acf82f2d7e0ed62479719d694e
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-06-13 15:37:36 +02:00
Samuel Mira
e07fea6fb4 Android 13: Fix warnings on starting an application
On Android 13, currently in beta, android triggers a warning because it
is using a deprecated getDrawable function.
The patch changes it to use the non-deprecated alternative as suggested
in the warning.

Fixes: QTBUG-103568
Pick-to: 5.15 6.2 6.3
Change-Id: I3e629e7b75044bfb51874256895be0ec7e1088f8
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2022-06-13 13:37:36 +00:00
Volker Hilsheimer
ac80cee846 Don't crash when removing the last visible tab
The code incorrectly tried to ensure that the firstVisible tab was a
valid index, even though there might not be any visible tab left after
removing the last visible tab.

The same logic didn't exist of the lastVisible tab, so we tripped the
assert in qBound, as max (being -1) ended up smaller than min (0).

Fix this by removing the wrong correcting of firstVisible to be always
valid. Make sure we emit currentChanged with -1 when no visible tab is
left after removing the current tab.

Add a test.

Fixes: QTBUG-104003
Pick-to: 6.3 6.2
Change-Id: I27e6438a02d0a0f1ac4d0e0160cee4f33b3f3766
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-06-13 14:04:31 +02:00
Jan Arve Sæther
e7477e8934 Update window geometry when QWindow::m{in|ax}imumSize is updated
More specifically, if either minimum or maximum size are updated, make
sure that the current window geometry is updated so that it is within
the minimum and maximum sizes.

Previously, these constraints was only respected by the window manager
when the user resized the window.

For widgets this already worked, because a top-level widget will take
care of respecting these constraints if they are changed.

Since QWindow::setMinimumSize and QWindow::setMaximumSize started to
share so many common things, a new function (setMinOrMaxSize_helper())
is added.

Task-number: QTBUG-102771
Change-Id: Ia4b2680dcf865f84a3cf6424187f9a6036b76386
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-06-13 09:19:17 +02:00
Wang Fei
e57ab1b454 QMenu: Adjust the position of the submenu
When the submenu is about to exceed the screen,
set the position of the submenu to the left border of the main menu

Fixes: QTBUG-104050
Change-Id: I8935f1bfceb93cfa1097391689f4233991394978
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-06-13 02:58:04 +00:00
Laszlo Papp
e35fc908fd QSettings: fix a typo in the doc
Pick-to: 6.4 6.3 6.2
Change-Id: I059f603f3cc66a40e84179ac3f2a07de3bf31761
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-06-11 17:49:43 +00:00
Shawn Rutledge
eee9d25202 Use CSS classes on html list items for checkbox support
If we replace the bullet character with a UC checkbox character, it
looks ok in a browser, and the HTML parser can recover the BlockMarker
attribute from the css class.

[ChangeLog][QtGui][Text] Checkbox list items can now be read and written
in both HTML and Markdown, including conversions.

Task-number: QTBUG-103714
Change-Id: Ic6b74512075cd4ac16d6f80fdf55b221447491a9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-06-11 14:18:35 +00:00
Thiago Macieira
bd40c18389 Cocoa: fix build: add missing include
qcocoansmenu.mm:21:38: error: implicit instantiation of undefined template 'QVarLengthArray<unsigned short, 10>'

Pick-to: 6.2 6.3 6.4
Change-Id: Iba16e8ea451b444ab213fffd16f4da39dfcc343d
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-06-10 22:42:13 +00:00
Vladimir Belyavsky
865212057b Windows: fix DeferredDelete events processing on QThread::terminate()
On finishing/terminating a thread, when processing posted events,
we need to consider QThread's own data instead of caller thread's data.
Otherwise we can get into unexpected situations such as double
destruction of an object, premature destruction, etc.

Fixes: QTBUG-103922
Pick-to: 6.4 6.3 6.3.1 6.2 5.15
Change-Id: Idf77221ebbaa0b150ee2d0c296b51829ae8dc30e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-10 19:40:32 +00:00
Alexandru Croitor
e2f14e5be7 androiddeployqt: use QFile::exists instead of QDir().exists
Internally QDir().exists calls QFile::exists(filePath(name))

Pick-to: 6.2 6.3 6.4
Change-Id: I2993d924268b10135bd9df4e9f8165b869946efc
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-06-10 21:10:34 +02:00
Alexandru Croitor
0c82f98ec5 androiddeployqt: Only pass qt_install_dir/qml directory if it exists
In Conan's case, the qtbase installed package directory lacks a qml
directory. We pass that as a valid qml import path via CMake ->
deployment json file -> androiddeployqt -> qmlimportscanner
which causes the qmlimportscanner to fail with

 qmlimportscanner: No such file or directory:
 "~/package/some_sha_1/qml"
 Invalid json output from qmlimportscanner.

which in turn fails the androiddeploqt build step.

Make sure to only pass qtbase_install_dir/qml if it actually exists.

Amends 4ef3da04c3
Amends c08b9a49ba

Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-104056
Task-number: QTBUG-88519
Task-number: QTBUG-89588
Change-Id: I4310eb4e265ae8d3e3f09e1e1dbed79210e23de6
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-06-10 21:10:34 +02:00
Ulf Hermann
47c545d983 moc: Improve formatting of output
If we are going to append an else clause, keep it on the same line as
the closing brace.

Change-Id: Idfa0eec49240086dc24268aebbf610d64a2f53d0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-10 14:41:14 +02:00
Ilya Fedin
fb981a0954 Fallback to another file dialog implementation when XDP is inaccessible
Fixes: QTBUG-98988
Pick-to: 6.4 6.3 6.2 5.15
Change-Id: Idca1ab4cae0e9eabebc599f3c8efa136a7973918
Reviewed-by: Jan Grulich <jgrulich@redhat.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-09 01:49:41 +04:00
Thiago Macieira
17454bf9c6 FatalSignalHandler: print the signal name on crash
It's easier to remember what "SIGSEGV" means instead of "11".

GNU libc has offered sigabbrev_np() (non-portable) since 2.32; for older
libcs, we'll be happy with a hardcoded list.

Selftest updated to match... though it didn't seem to be necessary.

Pick-to: 6.4
Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16ebc66ecf6e9465
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-06-08 20:39:18 +00:00
Marc Mutz
2e9bc3494f QLocale: use qsnprintf instead of deprecated sprintf
Fixes warnings such as

 qtbase/src/corelib/text/qlocale_tools.cpp:321:5: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations]

from AppleClang.

Pick-to: 6.4 6.3
Change-Id: Ief10e99abfa0a56c24622ac79db719dde58a4210
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-06-08 20:35:39 +02:00
Volker Krause
193039dff3 Fix renameat2 configure check
Give this a chance to ever succeed by not using undefined variables in
the test code.

Found by a KDE unit test observing changes in inotify behavior between
Qt5 and Qt6.

Pick-to: 6.2 6.3 6.3.1
Change-Id: Iceb743d88dfa093c02d76ce32ea5c8ced24bfc5b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-08 17:43:34 +00:00
Ilya Fedin
6f9f6849c5 Add QXdgDesktopPortalFileDialog::useNativeFileDialog()
Task-number: QTBUG-98988
Pick-to: 6.4 6.3 6.2 5.15
Change-Id: I39417f089d839a9af009791088bd20058532bd7a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-08 21:43:34 +04:00
Mårten Nordheim
4d2ef82089 QTest: Remove pre-Qt6 code
It's disabled now, so can be deleted

Pick-to: 6.4 6.3 6.2
Change-Id: I0d548327e7ef42bbca9ed88556bf9f8456038cc7
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-06-08 19:08:49 +02:00
Vladimir Belyavsky
4a2c31103c Fallback to PerMonitorDpiAware if V2DpiAware is not supported by system
DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 might not be supported
on some legacy Windows 10 editions (prior Creator Update). In this
case SetProcessDpiAwarenessContext returns ERROR_INVALID_PARAMETER.

Fallback to DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE using old API
SetProcessDpiAwareness in such cases as the most suitable.

Fixes: QTBUG-103733
Pick-to: 6.3 6.4
Change-Id: I39216e63ecfcae96aaa159237a52b0a76bc5d956
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-06-08 17:08:49 +00:00
Topi Reinio
e4f9a78c18 Doc: Document the CorePrivate module
Classes to aid Android development are currently available in the
CorePrivate module. In order to have correct information for
the requisites table (for CMake and qmake inclusion), document
the private module, mark it \preliminary, and link the classes
to it using the \inmodule command.

Fixes: QTBUG-103865
Pick-to: 6.3
Change-Id: Id913148751ab925eb4e8488aa28a54b0e0c2d78d
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2022-06-08 16:41:01 +00:00
Edward Welbourne
720de98824 QDateTime::Data, QTimeZone: rule-of-five and noexcept
CodeChecker noted that both QDateTime::Data and QTimeZone have
incomplete rule-of-five method sets; and two of the former's methods
should be noexcept.  Marc tells me the copy constructor can be
noexcept. Added the missing methods and noexcepts.

Change-Id: I8ddaa86207320606a890e90bd2b1593ee82f5a4a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-06-08 18:41:01 +02:00
Edward Welbourne
02b11e0623 PosixZone::parse(): don't reset already-initialized variable
The nameBegin variable was already initialized to pos, so just
increment it in the one case that needs it rather than resetting it in
both branches of the condition.

Change-Id: Ia0d42b604ed21829dc84c27a1907c345f62594d1
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-06-08 18:41:01 +02:00
Edward Welbourne
0a350eaf25 Drop const from a declaration to let a return move
CodeChecker points out that QTimeZone::systemTimeZoneId()'s first
attempt saved its result in a const QByteArray, which consequently
wasn't moved from when returning. That doesn't make a huge difference
for a CoW, but might as well skip the const and let the compiler do
the natural thing.

Change-Id: I966c9137505a8188532b164524dd4e05c0b2ac53
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-06-08 18:41:01 +02:00
Edward Welbourne
b6be97f65e Don't std::move() trivally-copyable type; it makes no difference
CodeChecker says:

 std::move of the variable 'parts' of the trivially-copyable type 'QCalendar::YearMonthDay' has no effect; remove std::move()

So don't bother with the move, and remove && from the signature of the
function being called in all four places. Assert that the type *is*
trivially copyable.

Change-Id: I3c07491b4b1dafdf52916e8699561c58c24ee954
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-06-08 18:41:01 +02:00
Samuel Mira
140ca89a3c Android: Fix QSettings when using content URL
Using QSettings with Content URL in Android failed because of 3 issues:
* the lock file assumed that it could append ".lock" to the file name
for its name
* the lock file assumed that it could write in the same directory as the
file
* the QSaveFile used by QSettings requires direct write on content URL
but setDirectWriteFallback is set to false on QSettings by default

This patch fixes those issues by, when it is an Content URL in Android,
saving the lock file in QStandardPaths::CacheLocation and setting the
setDirectWriteFallback to true.
This does not break backwards compatibility because appending ".lock"
to the Content URL will always make an invalid URL, so it did not work
before.

Fixes: QTBUG-103455
Pick-to: 6.3 6.2
Change-Id: I92867577507b7069e4e6091d94e0931bb6dbcbed
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-06-08 13:44:59 +00:00
Mikolaj Boc
3df23b1fe4 Define out unused functions on WASM build
The struct iovec conversion functions that are needed on Unix are
unused on WASM build. This makes the build fail with -Werror on Mac
since the WASM build is treated as a variant of Unix. Cross-compilation
with clang:
Apple clang version 13.0.0 (clang-1300.0.27.3)
Target: arm64-apple-darwin21.3.0

Fixes: QTBUG-103974
Pick-to: 6.3 6.4
Change-Id: I34c65a18832ceedb9064a98f5729e45667749461
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-08 08:30:45 +00:00
Ivan Solovev
78c677376a QTestLib: improve documentation
Add missing '\since' version numbers.

This commit amends cc6d984390
and 0681a2dd5a

Pick-to: 6.4
Change-Id: Ia10b991c996fb58f08a17e485c4dfcbfbe8eba0a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-06-08 10:30:20 +02:00
Alexandru Croitor
5ddb13d0d4 CMake: Fix Android multi-abi builds in Qt Creator
Qt Creator passes -DANDROID_NDK to the main project configuration
whereas the Qt toolchain file expects -DANDROID_NDK_ROOT.

This causes the configuration of the sub-builds to fail not finding
the android toolchain, and trying to use the CI ndk toolchain path.

Make sure to consider both variables.

Also change the conditions to evaluate the variable as a variable
explicitly, to avoid passing an empty option if the variable is
unset. If the variable is unset, CMake would treat the variable as
an actual string which would always not equal the empty string.

Amends d6919b073a

Pick-to: 6.3 6.4
Task-number: QTBUG-104013
Task-number: QTBUG-102041
Change-Id: Ifee48953ce50bc616c49c59d72e845c6d9418187
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-06-07 16:48:57 +00:00
Marc Mutz
0da17e83ec Fix data race in QCoreApplicationPrivate::sendThroughApplicationEventFilters()
The assertion has the acquire fence at the wrong place:

- QThreadData::thread isn't dereferenced, so the acquire fence on its
  load() isn't needed.

- QObjectPrivate::threadData, however, _is_ dereferenced, so an
  acquire fence is needed; the relaxed load() is insufficient.

Swapping the loadAcquire() and the loadRelaxed() fixes both issues.

Pick-to: 6.4 6.3 6.2 5.15
Change-Id: Iee964490e93ebc323c188e616bf0d448f91fb2b5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-07 06:46:12 +00:00
Marc Mutz
d6575f3717 QByteArray: de-inline to/fromStdString()
Removes another owning container manipulation that made the top entry
in Clang -ftime-trace's most-expensive template instantiations in a
QtWidgets build.

Pick-to: 6.4
Task-number: QTBUG-97601
Change-Id: I8c765ea2e6c46da5188b70c9503dd87e63f6b328
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-07 06:46:04 +00:00
Ilya Fedin
36c1a7ba23 Fix a leak of fallback dialog helper in xdgdesktopportal
Task-number: QTBUG-98988
Pick-to: 6.4 6.3 6.2 5.15
Change-Id: Id066f0dd2cacbc273deacd4f7df66c3787ad4017
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-07 00:32:07 +04:00
Thiago Macieira
69e8a89358 qglobal.h: include <stdalign.h> in C mode
For alignas and aligof as macros up until C2x makes them full keywords.

Change-Id: Ibcde9b9795ad42ac9978fffd16f2bbc054027384
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-06 12:18:24 -07:00
Jani Heikkinen
0cbb471b1b Bump version to 6.5.0
Change-Id: I83a4f915a914bdc18f6706bb902f3e3b13da074f
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2022-06-06 13:23:59 +03:00
Volker Hilsheimer
c450285c41 Windows: Don't terminate threads in Qt
Terminating a thread that we don't have full control over might leave
mutexes or critical sections locked, ending up with an application that
can't allocate memory or open new windows.

Also, if terminating of the thread would fail (which the code tried to
handle), then deleting the QThread anyway would have triggered the
assertion that we don't delete a running thread in ~QThread.

So simplify this code: wait simply returns true if the thread isn't
running anymore, no need for the double-check. Leave the thread running
and leaking if it is stuck somewhere in Windows APIs while executing the
native dialog.

Fixes: QTBUG-103984
Change-Id: I34aa42cbde7c769a58c14bf524781cf3abd13b70
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-06-05 15:11:36 +02:00
Eirik Aavitsland
f67d89ebde Support cosmetic brush patterns in the pdf and opengl paint engines
This implements the recent functionality extension of painting
cosmetic (untransformed) brush patterns, and the corresponding
NonCosmeticBrushPatterns render hint, in the pdf and opengl paint
engines.

As part of the implementation it also fixes a couple of pre-existing
bugs in the opengl engine, relating to updating the brush after
changes in transformation or brush origin.

As a driveby, it also includes a minor fix for the lance testing tool:
request stencil buffer, as that is needed and not always provided by
default. This echoes a recent fix done to tst_baseline_painting.

Change-Id: Ia8811477e015eebeb40ed138bca96643ce1ab0dc
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-06-04 21:15:42 +02:00
Jonathan Liu
0083cde53e QEdidParser: fix number of data blocks
The EDID standard defines 4 x 18 byte descriptors:
  54-71: Descriptor 1
  72-89: Descriptor 2
 90-107: Descriptor 3
108-125: Descriptor 4

Immediately following the 4th 18 byte descriptor are the following:
    126: Number of extensions
    127: Checksum

Therefore the number of data blocks (known as descriptors in the EDID
standard) should be 4 instead of 5.

Pick-to: 5.15 6.2 6.3
Change-Id: I63555b9142125df17b26401d81a6717936832162
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>
2022-06-04 11:22:56 +11:00
Marc Mutz
8aacf83a76 Make Q_ASSUME() an expression (was: statement)
Like Q_ASSERT(), which was fixed for 5.10, it's also useful if
Q_ASSUME() expands to an expression instead of a statement. This way,
it's usable in more contexts, esp. the comma operator.

[ChangeLog][QtCore][QtGlobal] Q_ASSUME() now expands to an expression
(was: statement).

Change-Id: I33dc3d1551a1b7454aa9587b9c33dfa2e3d2b09c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-04 00:22:56 +00:00
Øystein Heskestad
d631e581c0 Unify QSslServer from QtWebSockets and QtHttpServer into QtNetwork
Both QtWeSockets and QtHttpServer has a QSslServer class that is useful
elsewhere. They are different though, so the new class has features
from both versions.

[ChangeLog][QtNetwork] Unify QSslServer from QtWebSockets and QtHttpServer into QtNetwork

Task-number: QTBUG-100823
Change-Id: I523f04db39297ceb9b258f673eb12deecfc6886c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-06-04 02:22:56 +02:00
Øystein Heskestad
782fbe0f63 The new signal pendingConnectionAvailable is added to QTcpServer
The new signal pendingConnnectionAvailable is emitted after a new
connection has been added to the pending connections queue. Connect
to this signal and call nextPendingConnection to handle incoming
connections.

The existing unchanged newConnection signal is emitted after the
overridable function incomingConnection is called, regardless of whether
a new connection is added to the pending connections queue in the
incomingConnection function or not.

If a subclass that overrides incomingConnection either decides to not
add all incoming connections to the pending connections queue, or to
postpone adding the connection until a handshake is successfully
completed, the pendingConnectionAvailable signal should be to used,
because this signal directly corresponds to insertions to the pending
connections queue.

[ChangeLog][QtNetwork][QTcpServer] New signal pendingConnectionAvailable
is emitted when a new connection is added

Task-number: QTBUG-100823
Change-Id: I00c76761389065f68271553e69e6c45c393a2fa8
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2022-06-04 00:22:55 +00:00
Thiago Macieira
8b26233573 qtestcase.cpp: create a common function to print the test runtime
The time was getting printed twice for the stack trace, but zero for the
watch dog if the stack trace was disabled.

Selftest appears to pass (though I thought it shouldn't).

Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16ebc4ec99e7fc5a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-03 16:52:41 -07:00
Øystein Heskestad
8cf168b871 Move file-static const arrays out of qprint_p.h file
Move static arrays into new qprint.cpp file to avoid them being
duplicated in many translation units.

Fixes: QTBUG-102302
Change-Id: I47b7a6244e45672788792ec1a28d4fed20d233a3
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-04 00:29:50 +02:00
Marc Mutz
9fea0c613e QCOMPARE/QVERIFY: fix huge pessimisation in QTestResult::reportResult
The old code allocated a stack buffer, but asked the runtime to
zero-initialize it. That's 1KiB of writes to the stack on every
QCOMPARE and QVERIFY before any actual work is done. Fixing this
little laissez-faire to just initialize the first character in the
buffer results in nice little speedups of ~40%.

This fixes the issue in reportResult(), a Cut'n'paste from compare()
and verify(), which have since been fixed by a previous commit.

Change-Id: I5cad57299490925b88e768dc751304699274db2e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-06-03 20:37:51 +00:00
Ivan Solovev
0681a2dd5a QTestLib: rework QTest::compare_helper()
[ChangeLog][QTestLib] QCOMPARE now evaluates toString() on its
arguments lazily, speeding up the general case where the comparison
doesn't fail. This is true for the QCOMPARE functionality provided
by Qt. If you specialized qCompare() for your own types, then you
need to change its implementation in line with Qt's own qCompare()
specializations in order to enable this feature.

[ChangeLog][QTestLib] QCOMPARE calls with nullptr argument(s) will
now print the actual and expected values upon failure.

Previously it was not like that because of the compareHelper()
overload in qtestresult.cpp that treated the presence of
nullptr-arguments as a reason to ignore formatFailMessage() call.
New implementation does not have this check, and correctly
executes formatFailMessage() for all arguments.

Note that the qCompare() overloads that call QTestResult::compare()
internally were not affected by this patch, because they already
defer toString() invocation until the comparison fails.

Some numbers, collected against shared release developer build.
I checked how this change affects the test execution. The idea was
to pick some tests for types that do not have a specific
QTestResult::compare overload, so I picked a couple of QByteArray
tests.
The comparison is done by running a test 10 times and taking the
average execution duration, as reported in the log.

tst_qbytearrayapisymmetry:
 Before: 15.6 ms
 After:  14.2 ms

tst_qbytearray:
 Before: 41 ms
 After:  36 ms

The benefit is around 9% and 12% respectively.

Fixes: QTBUG-98874
Change-Id: I7d59ddc760168b15974e7720930f629fb34efa13
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-03 20:37:51 +00:00
Ivan Solovev
cc6d984390 Add QTRY_COMPARE_{EQ,NE,LT,LE,GT,GE}_WITH_TIMEOUT()
[ChangeLog][QTestLib] Add QTRY_COMPARE_{EQ,NE,LT,LE,GT,GE}_WITH_TIMEOUT
macros that repeatedly execute QCOMPARE_{EQ,NE,LT,LE,GT,GE} until either
the comparison returns true or the timeout expires. Also add
QTRY_COMPARE_{EQ,NE,LT,LE,GT,GE} macros that simply invoke the
*_WITH_TIMEOUT versions with the usual timeout of five seconds.

Task-number: QTBUG-98873
Change-Id: Ib0d7d1c8c997f442b46acd85da738a8f512cc875
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-06-03 22:37:50 +02:00
Ivan Solovev
343e0ff485 Add QCOMPARE_{EQ,NE,LT,LE,GT,GE}()
[ChangeLog][QTestLib] Add QCOMPARE_{EQ,NE,LT,LE,GT,GE}()
macros. These new macros behave similarly to QVERIFY(a op b),
where 'op' is ==, !=, <, <=, >, >= respectively, but print
a formatted error message with argument values in case of failure.
The formatting is done lazily, which means that the strings will
be generated only when the comparison fails.

Also add a new test for tst_selftest and generate expected output
for it.

Fixes: QTBUG-98873
Task-number: QTBUG-98874
Change-Id: Ic8074798901d7a469b1f58d5cd28bbf49a3da1db
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-06-03 22:37:50 +02:00
Ivan Solovev
9327d1aaf7 Testlib: teach TAP test logger to support new QCOMPARE_* operators
The TAP test logger will now correctly print comparison types such
as QCOMPARE_NE or QCOMPARE_LT, and also provide a proper expected/wanted
value (by adding proper arithmetical operators in front of the value).
Sample output:
  type: QCOMPARE_GE
  message: Left value is expected to be greater than or equal to right value, but is not
  wanted: >= 1 (rhs)
  found: 0 (lhs)
  expected: >= 1 (rhs)
  actual: 0 (lhs)
  at: tst_ExtendedCompare::compareUnregistereEnum() (tst_extendedcompare.cpp:232)
  file: tst_extendedcompare.cpp
  line: 232

As a drive-by: make some variables const.

Task-number: QTBUG-98873
Change-Id: Idb54eaabcb937b42d3fc844f30041aab82d73f69
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-06-03 22:37:50 +02:00
Doris Verria
259df3ca0b qiostheme: Don't determine the appearance mode from the keyWindow
We were querying the traitCollection property of the application's
keyWindow in order to determine the appearance mode (light/dark) of
the app.
However, the application may not have a keyWindow (visible window)
by the time the we set up the appearance mode, so get that information
from the last window in the application's windows array instead.

Change-Id: If7435d9f565b5c594a26027c971c16a1e3a9af26
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-06-03 19:43:20 +02:00
Marc Mutz
474792a751 QCOMPARE/QVERIFY: fix huge pessimisation in QTestResult
The old code allocated a stack buffer, but asked the runtime to
zero-initialize it. That's 1KiB of writes to the stack on every
QCOMPARE and QVERIFY before any actual work is done. Fixing this
little laissez-faire to just initialize the first character in the
buffer results in nice little speedups of up to or exceeding 2x.

Amends d946507727.

[ChangeLog][QtTestLib] Optimized successful QCOMPARE and QVERIFY for
an up to 2x speedup.

This has the potential to meaningfully reduce the load on the CI, so
picking all the way to 5.15.

Pick-to: 6.3 6.2 5.15
Change-Id: Ib93d69282ec87cbd26a60e4ac14413e8cef8ff78
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-06-03 09:01:46 +00:00
Vladimir Belyavsky
66bcb66a51 Windows: fix crash on closing an app when native file dialog is opened
The crash was provoked by QThread::terminate() called
for QWindowsDialogThread from QWindowsDialogHelperBase destructor.
It's still not clear why terminating the thread here causes a crash,
but normally we should avoid terminating a thread anyway.

Current changes make several improvements to avoid terminating the
thread. The main problem was that QWindowsDialogThread::run() was never
returned. That's because QWindowsNativeFileDialogBase::close() was not
called on QWindowsDialogHelperBase destruction. The second problem
was that QWindowsNativeFileDialogBase::close() may still not close
native file dialog because it was not able to find HWND for IFileDialog
instance in some circumstances, so make this by more robust way.

Fixes: QTBUG-93298
Pick-to: 6.3
Change-Id: I55c8cf664ae2cf7c41c8cce43a6bb88a2680bf14
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2022-06-03 09:34:19 +03:00
Mårten Nordheim
4a8611a902 QRhi(d3d): add missing qcryptographichash include
Change-Id: I9e57c9dca3197c224aad9b6da32a2791fbb34d7c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-03 07:44:51 +02:00
Edward Welbourne
8375f33078 Simplify construction of two QTime instances
Rather than default-constructing and later setting its .mds, just pass
the number of millis to the constructor.

Change-Id: I5e259ee99b1ba53c48d8d71f2b479001c26ab7a0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-06-03 06:35:21 +02:00
Edward Welbourne
410b5bc238 Add MINS_PER_HOUR constant and avoid a Coverity overflow warning
Being able to distinguish which 60 is minutes-per-hour and which is
seconds-per-minute has some value in its own right, and doing it with
qint64 values (as usual for DateTimeConstants) takes care of two
Coverity warnings about multiplying before widening.

Use the new constant, and SECS_PER_MIN, in a few other places where
the result isn't an int (we don't want to provoke narrowing warnings).

Change-Id: Iadcb6956ac22a53029bf7b7518369520d2b1fd8b
Coverity-Id: CID 393112
Coverity-Id: CID 393113
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-03 06:35:20 +02:00
David Skoland
fd4f218c1e Expose the qtloader object globally
When testing, we need to query the state of the Qt application,
so change the scope of qtloader from inside the init function
to global scope.

Additionally, adjust the test script accordingly to query and use this
state to make good decisions on how to terminate.

Change-Id: I6264ba20843716eb87340b160680617b718f6bd9
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-06-03 05:30:46 +02:00
David Skoland
2c66a8a850 Streamline error handling in qtloader.js
Added new function handleError which does the usual work whenever there
there is an error, including logging the error to console. Also make
the app exit when the emscripten module fails to load.

Additionally, make sure we correctly report it as crash
if the module fails to load.

Change-Id: I9d723373a34ccbb146959a2207ebded8bcbd4f18
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2022-06-03 05:30:46 +02:00
Morten Johan Sørvig
18f0793f9c wasm: add support for blocking sockets
Add support for blocking sockets on secondary threads and on the main
thread with asyncify. This extends the support for websockify tunneled
TCP sockets, which was previously limited to async sockets on the main
thread.

Blocking sockets support is implemented by emulating select() on top
of emscripten's socket notification support. This is requires synchronization
between the blockee threads and the main thread, since we get socket
notification callbacks on the main thread. The synchronized state is held
in g_socketState where the main thread registers socket readiness state and
blocking threads register themselves.

Blocking using asyncify on the main thread is similar to blocking on
a secondary thread, with the exception that the main thread suspends
with qt_asyncify_suspend() instead of waiting on a wait condition.

Change-Id: Idb5a493644e1e6634057dc2f64f2e99e82e3c01e
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2022-06-02 23:54:46 +02:00
Marc Mutz
6376b1c5a7 QBrush: port from array of char[24] to qOffsetStringArray()
QOffsetStringArray has a more compact representation and silences
warnings from GCC 12 builds with asan and ubsan sanitizers enabled:

    qbrush.cpp: In function ‘QDebug operator<<(QDebug, const QBrush&)’:
    qbrush.cpp:978:77: error: array subscript [0, 31] is outside array bounds of ‘const char [25][24]’ [-Werror=array-bounds]
      978 |     dbg.nospace() << "QBrush(" << b.color() << ',' << BRUSH_STYLES[b.style()] << ')';
          |                                                       ~~~~~~~~~~~~~~~~~~~~~~^
    qbrush.cpp:954:23: note: while referencing ‘BRUSH_STYLES’
      954 |     static const char BRUSH_STYLES[][24] = {
          |                       ^~~~~~~~~~~~
    cc1plus: all warnings being treated as errors

Task-number: QTBUG-103923
Pick-to: 6.3 6.2
Change-Id: I5f81f516894e57b47783e2d89489a676b657fdb7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-06-02 15:14:00 +02:00
Ulf Hermann
a248d8daf5 Endian: Allow special bitfield union fields to cover the whole storage
This requires a different computation of the mask since we can't shift
out of the storage type.

Change-Id: Ife85ca3e0c5ca47f06988a397cc2f8a7e28ad0fe
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-02 14:02:44 +02:00
Marc Mutz
b9cce12e76 qxp::function_ref: drop use of q23::invoke_r
Since P0792r8, pointers to members are no longer supported, which
means we don't need to use std::invoke anymore.

Remove std::invoke in favor of traditional function call syntax, which
should be faster to compile, too.

Change-Id: I2ec3888795471f345ded36bb564d35ac0de29068
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-06-02 12:54:55 +02:00
Marc Mutz
29b65c98e7 Short live qxp::function_ref!
This is an implementation of function_ref, which has been proposed for
inclusion into C++23, but has not been accepted, yet, which is why we
place it in namespace qxp (for eXPerimental) instead of q23.

The implementation is based on wg21.link/P0792r9, which, at the time
of writing, is the latest revision of the paper. It will be used in
both QTestLib and qmldom.

Fixes: QTBUG-103739
Change-Id: I52723eca28f7ac02ce7ce51928361d81ae5c92b1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-06-02 12:54:55 +02:00
Marc Mutz
4042596b72 Short live q23::invoke_r!
Add an implementation of C++23's std::invoke_r. Will need it in our
implementation of function_ref.

Differences to std::invoke_r:

- only constexpr in C++20, not in C++17 (to fix, we'd need to
  implement our own q20::invoke just to add the constexpr keyword;
  let's first see whether we need this).

Task-number: QTBUG-103739
Change-Id: Id864f83f27ed499849b6bde0c34353127e37e7ed
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-06-02 12:54:55 +02:00
Allan Sandfeld Jensen
0806d9799a Fix misuses of 0.9999 constant
Replace it with floor and round. It appears the old behavior
was to work around combining ceil with inaccurate FP, but
it doesn't appear this hacky ceil is needed.

Change-Id: I5c16ec0fa4916e17198a733c46937fde53f2ddb5
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2022-06-02 07:29:39 +02:00
Marc Mutz
bc922223cf QKeySequence: constinit ALL the things
C++20 constinit acts as a static_assertion that the initialiation of
the object doesn't incur runtime initialization overhead.

Task-number: QTBUG-100486
Change-Id: I818f5ca9703273cd41e44e5ce7085cb5c643ca8e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Laszlo Papp <lpapp@kde.org>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-06-02 07:24:22 +02:00
Thiago Macieira
dface58142 QtTest: move the disabling of core dumps from load-time to qInit()
There's no reason it has to be done THAT early. It was added in commit
aec85a53df to have the selftests (which do
crash) not leave lots of core files around. I could replace it with a
QProcess::setChildProcessModifier() function, but the variable is now
documented in the QtTest manual, so it would be no gain.

Function renamed to reflect its implementation.

Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16ebc25df97a98e3
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-06-01 22:12:17 -07:00
Alexandru Croitor
cfd5485d41 CMake: Change QT_RESOURCE_TARGET_DEPENDENCY property to be internal
Rename the property to _qt_resource_target_dependency and make sure we
also consider which scope we are getting the source file property from
if the CMake version is recent enough.

Pick-to: 6.3
Task-number: QTBUG-103470
Change-Id: I755413c91bc0bc9033760a888927b60c470c562b
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-06-02 05:37:40 +02:00
Thiago Macieira
612f5cf9a1 QTemporaryFile: document rename() differences from QFile
We will not do a copy+delete if the destination is on another mount
point (in fact, QFile uses QTemporaryFile for the latter). In my
opinion, that's a misfeature in QFile, because such an operation may
need to display a progress bar to the user so they won't think the
application has frozen. But it's too late to change now.

I don't know why QTemporaryFile is different. It might be because it was
used for the atomic materialization of a file before QSaveFile existed
(5.1) but I didn't research to confirm. It's still useful even in the
presence of that class if the file is really temporary (meant to be
removed when the QTemporaryFile is destroyed).

Pick-to: 5.15 6.2 6.3
Fixes: QTBUG-103740
Change-Id: Iba16e8ea451b444ab213fffd16f4461f3f972d8c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-06-01 19:20:45 -07:00
Marc Mutz
97269ab294 QKeySequence: statically assert the sortedness of the MacSpecialKey array
This array has, in the past, silently failed this test
(cf. 5d8f815e10). Make sure it doesn't
happen again.

Change-Id: I26192749d43de4a7add9d14c7ca04391c1799525
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2022-06-01 21:55:07 +02:00
Marc Mutz
c0bb5b2aa1 Short live q20::is_sorted{,_until}!
This is just the C++11 version with constexpr added, very useful to,
e.g., statically check sorted-ness of static arrays.

Task-number: QTBUG-103721
Change-Id: I60164e49db1cc3892280a19851e01193e3c1fb2a
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2022-06-01 19:55:01 +00:00
Eirik Aavitsland
88c5ccc45a Avoid uninitialized data after getRgbF() even for invalid colors
The other getXxxF() functions will fill in values in the out
parameters even in case of Invalid cspec. So make getRgbF() behave
consistently, and return the same values as getRedF() etc. do in that
case.

Change-Id: Ibb8b0c9526b43ce61118c04b479328dbe88d0419
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2022-06-01 15:54:50 +02:00