Commit Graph

45401 Commits

Author SHA1 Message Date
Amir Masoud Abdol
7367cba9eb Compile Network with NOMINMAX
On Windows, when building using Unity Build, min/max macro form
`window.h` makes it to some files, and messes up evaluation of code like
`std::numeric_limits<T>::max()` which leads to compilation error.
We don't use min/max macros in Qt base, and it might be the time to pass
NOMINMAX to our targets.

Pick-to: 6.5
Task-number: QTBUG-109394
Change-Id: Ia1ff5de36538075264c8556ef3b0416f3c15168c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-05-24 08:39:53 +02:00
Volker Hilsheimer
8e46ac8d05 Doc: fix warnings from parameters not matching the documentation
Change-Id: I6588336e12db0a3af9b9dfd2ab22a3e1b7c54238
Reviewed-by: Safiyyah Moosa <safiyyah.moosa@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-24 07:04:31 +02:00
Thiago Macieira
ecaf93c366 QDnsLookup: centralize printing of warnings
Any resolution error that is caused by an invalid request, invalid reply
(only happens on Unix), or a system error can be printed as a warning,
using category "qt.network.dnslookup". Those warnings are disabled by
default.

Change-Id: I5f7f427ded124479baa6fffd175fc40b3e21c969
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-23 21:23:45 -07:00
Thiago Macieira
f5b584022b QDnsLookup: replace Q_GLOBAL_STATIC with Q_APPLICATION_STATIC
Replaces a lot of the manual content.

Change-Id: I3e3bfef633af4130a03afffd175e839f4b05975c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-23 21:23:45 -07:00
Thiago Macieira
9a4eb45df1 QDnsLookup: simplify the processing of the runnable and reply
Change-Id: I3e3bfef633af4130a03afffd175e827dce2af966
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-23 21:23:44 -07:00
Thiago Macieira
bce7009f55 QDnsLookup: add support for setting the port number of the server
I couldn't make my Windows 10 or 11 query a non-standard port. It kept
complaining about "The parameter is incorrect.", so as a result the unit
test doesn't actually test the new feature there. I can't find a single
example of this on the Internet; my speculation is that the backend API
that DnsQueryEx uses does not support setting port numbers
(DnsQuery_{A,W} didn't offer that option).

[ChangeLog][QtNetwork][QDnsLookup] Added setNameserverPort().

Change-Id: I3e3bfef633af4130a03afffd175d60a581cc0a9c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-23 21:23:42 -07:00
Thiago Macieira
029e0bf552 QDnsLookup: add a number of functions to simply setting error conditions
This also updates a few messages and transfers the translation context
from QDnsLookupRunnable to QDnsLookup.

Change-Id: I3e3bfef633af4130a03afffd175e86715e4a25e3
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-23 21:23:42 -07:00
Thiago Macieira
c5c7712910 QProcess/Unix: allow startDetached() to also use vfork()
The same arguments that applied to the regular process-starting code in
commit e1a787a76e (6.4) apply here too.

Task-number: QTBUG-104493
Change-Id: Icfe44ecf285a480fafe4fffd174da1b05d0054bc
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-05-23 18:41:43 -07:00
Thiago Macieira
815bb2a4fb QProcess/Darwin: disable use of vfork() on this OS
The CI is failing running all the startDetached() tests, despite this
passing on my machine (both macOS 12 and 13). We don't know why it's
happening, so we just disable use of vfork(). This doesn't affect the
regular startProcess() because forkfd() requires full fork() in OSes
without pidfd or pdfork, but it does prevent changing startDetached()
behavior, starting with the next commit.

Change-Id: Ib5ce7a497e034ebabb2cfffd1761d91c456f20e0
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-05-23 18:41:41 -07:00
Amir Masoud Abdol
840939799e Remove duplicate code
There is an identical entry right above it.

Pick-to: 6.5
Change-Id: Ia962b19c01be2fdd143eeb5932c6ba309c73be34
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-05-23 18:57:20 +02:00
Mårten Nordheim
ada2c573c1 Schannel: Reject certificate not signed by a configured CA certificate
Not entirely clear why, but when building the certificate chain for a
peer the system certificate store is searched for root certificates.
General expectation is that after calling
`sslConfiguration.setCaCertificates()` the system certificates will
not be taken into consideration.

To work around this behavior, we do a manual check that the root of the
chain is part of the configured CA certificates.

Pick-to: 6.5 6.2 5.15
Change-Id: I03666a4d9b0eac39ae97e150b4743120611a11b3
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-23 14:29:59 +02:00
Eirik Aavitsland
2385d66923 Image IO: increase the default allocation limit
Time passes, Moore's law is working.

As a drive-by, make the doc more informative.

Fixes: QTBUG-113637
Pick-to: 6.5
Change-Id: Ic388b8850ace02c429d4d8175d31db86912d3afe
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-05-23 14:29:58 +02:00
Shawn Rutledge
8d11e05f8f doc: Reduce expectations for QInputDevice::devices()
I was hoping we could get the list mostly correct and complete on most
platforms; but in practice, it's proving difficult on most platforms.
Hopefully we can find ways to improve it over time.

Task-number: QTBUG-101648
Task-number: QTBUG-101875
Task-number: QTBUG-112432
Task-number: QTBUG-113706
Task-number: QTBUG-113711
Change-Id: I16b6900cddb54197fb7b833a513e36996de72d51
Pick-to: 6.2 6.5
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-05-23 10:36:35 +02:00
Friedemann Kleint
bfa557da91 uic: Generate QFont::HintingPreference
Task-number: QTBUG-113670
Pick-to: 6.5
Change-Id: I326d310b2a0df9a6f11e33588e553dff66e5a6f4
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-05-23 10:13:08 +02:00
Christian Ehrlicher
67b8dec0d0 QSqlDatabase: use a QReadWriteLock to access DriverDict
DriverDict might be accessed from different threads so we have to make
sure it's thread-safe. Use the already existing QReadWriteLock from
QConnectionDict for later merging of these two global instances. The two
instances do not interfere each other (DriverDict is a dictionary for
custom registered sql drivers, QConnectionDict contains all current
active database connections) so the dual-use of the mutex is fine.

Pick-to: 6.5 6.2 5.15
Change-Id: I84c77df666e72e826d0d3d291cecd5417bbd1baf
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-23 06:20:09 +02:00
Giuseppe D'Angelo
313bb32364 QRegularExpression: match newlines when converting wildcards
A * or a ? in a wildcard pattern is allowed to match any character,
including newlines. When converting a wildcard pattern to a PCRE,
* and ? were converted to ., which by default does _not_ match over
newlines (/s is necessary).

There isn't a metacharacter that matches everything, so either we modify
the returned pattern to enable dot-matches-all (for instance, by
wrapping the returned expression in (?s:...)), or use a character class
that includes everything. Picking this last approach for simplicity.

Change-Id: I86703f654e3414783427c4c8e0bb018885b42e54
Fixes: QTBUG-113676
Pick-to: 6.5
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-23 00:03:37 +02:00
Thiago Macieira
c5221f6be0 QProcess/Linux: add a flag to re-enable the vfork()-like semantics
Commit 29b2fe40dc disabled it by reverting
commit d6bf71123d. We now add the promised
flag to opt-in. The flag is added to all Unix systems, but it really
only applies to Linux right now.

No ChangeLog because the whole UnixProcessParameters structure is new
and has its own changelog.

Task-number: QTBUG-104493
Task-number: QTBUG-111243
Task-number: QTBUG-111964
Change-Id: Icfe44ecf285a480fafe4fffd174d4effd3382495
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2023-05-22 10:43:53 -07:00
Thiago Macieira
f9c87cfd44 QProcess/Unix: add setUnixProcessParameters()
This commit adds those three flags that are either frequent enough or
difficult to do: close all file descriptors above stderr and reset the
signal handlers. Setting SIGPIPE to be ignored isn't critical, but is
required when the ResetSignalHandlers flag is used, as this is run
after the user child process modifier.

[ChangeLog][QtCore][QProcess] Added setUnixProcessParameters() function
that can be used to modify certain settings of the child process,
without the need to provide a callback using setChildProcessModifier().

Change-Id: Icfe44ecf285a480fafe4fffd174d0d1d63840403
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-22 10:43:50 -07:00
Volker Hilsheimer
6a4afebc5c macOS: Fix assertion in accessibility implementation for treeviews
In QAccessible's widget implementations, trees are treated as tables,
with a rowCount implementation that is based on the view's current
item content. That item content is the view's content, not the model's,
and it changes when tree branches are expanded.

The Cocoa bridge for accessibility allocates arrays of row data
structures based on the rowCount implementation. Those data structures
need to be invalidated and recreated when the view's content changes.
To do that, emit an accessibility event for a model reset when laying
out items changes the size of the view's item array. We don't know what
changed during that layout process to makes this any more granular.

Amends 11ae55e918, but the problem
with the data structure being stale and incorrect would have been there
before that chain of changes optimizing. It didn't trigger an assert,
but probably resulted in incorrect data being reported.

To make trees testable, we need to actually expose them as AXOutline
to the macOS accessibility framework. Until now, they have been treated
like plain QWidget, e.g. AXGroup. This made them in practice in-
accessible. With this change, VoiceOver works much better (although not
perfeclty yet).

Also remove an assert that could be triggered by an accessibility
client asking for a cell for an invalid index (which can be reproduced
by navigating around in a tree, following debug warnings from
QAccessibleTree::indexFromLogical: invalid index).

Pick-to: 6.5
Change-Id: I7650342aa0dcd7925a94ae6a36de5a0b344c467d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-05-22 16:45:28 +02:00
Axel Spoerl
980a499ad0 Implement color role AccentColor in QStyleSheetStyle and QCssParser
The color role AccentColor has been added to QPalette.

This patch implements the new color role in QCssParser and subsequently
in QStyleSheetStyle.
The QBrush variable names used to populate brushes, have been changed
into speaking names for better code readability.

tst_QCssParser has been adapted accordingly.
The test function accentColor() has been added in tst_QStyleSheetStyle.

Documentation has been updated.

Change-Id: Ib09ddc1b61868f2bb8f70f654e83ea1c35276d30
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-22 14:45:26 +00:00
Axel Spoerl
227b639499 Make Gnome theme react to color theme changes without GTK
Qt doesn't react to color theme changes on systems running Gnome
without GTK.

This patch adds support for such in QGnomeTheme, following
https://blogs.gnome.org/alexm/2021/10/04/dark-style-preference/

Pick-to: 6.5
Change-Id: I1f6252d4f394b810b9e4aebe00f2715c8fec3b56
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-22 16:43:02 +02:00
Ievgenii Meshcheriakov
8d13a9e387 QtDBus: Move dispatch enabling code into a single function
Remove the helper class.

Change-Id: I82edd7fa1ce1d8b9044938a1378f992a40a0bbdf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-22 11:49:30 +02:00
Samuli Piippo
f99e518327 QDnsLookup/Windows: add missing typedefs for older mingw
Amend 9a73bc5f3d with more typedefs
missing from older mingw headers:

| src/network/kernel/qdnslookup_win.cpp:40:3: error: 'PDNS_QUERY_COMPLETION_ROUTINE' does not name a type; did you mean 'LPOVERLAPPED_COMPLETION_ROUTINE'?
|    40 |   PDNS_QUERY_COMPLETION_ROUTINE pQueryCompletionCallback;
|       |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| src/network/kernel/qdnslookup_win.cpp:47:9: error: 'PDNS_QUERY_RESULT' has not been declared
|    47 |         PDNS_QUERY_RESULT   pQueryResults,
|       |         ^~~~~~~~~~~~~~~~~
| src/network/kernel/qdnslookup_win.cpp:77:5: error: 'DNS_QUERY_RESULT' was not declared in this scope; did you mean 'DNS_QUERY_REQUEST'?
|    77 |     DNS_QUERY_RESULT results = {};
|       |     ^~~~~~~~~~~~~~~~

Change-Id: I812525aaa938764d337923820d0eb8b3e24a0004
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-22 05:27:33 +00:00
Axel Spoerl
17c589df94 Shoehorn AccentColor into QPalette and keep existing 64bit resolve mask
It is necessary to add an AccentColor role to QPalette.
QPalette currently has 21 color roles and 3 color groups, which
require 63 bits to resolve. The resolve mask is implemented with a
qint64, which doesn't provide spare bits for another color role.

The color role NoRole is used as a default value, marking that a role
has not (yet) been defined. The enum value does not represent a valid
brush, even though it can theoretically be stored in QPalette's shared
data.

This patch adds the enum value AccentColor to QPalette::ColorRole,
increasing the available color roles to 22.
To keep the resolve mask at 63 bits, AccentColor is mapped to NoRole
in static constexpr bitPosition.

As the enum range would exceed 64 bits without this tweak, 3 additional
bits are substracted in the respective static assertion.

With NoRole having no bit in the resolve mask, the following adaptions
have been implemented:
- QPalette::resolve() is adapted to explicitly ignore NoRole.
- QPalette::isBrushSet() always returns false for NoRole.
- tst_QPalette::setAllPossibleBrushes() to verify the latter
- operator== ignores NoRole (documentation updated)

AccentColor is added in tst_QPalette::roleValues and enum documentation
is adapted.

In QPalette's default constructor, the AccentColor brush is defaulting
to the Highlight brush, it this is available. Otherwise it is made 30%
darker or lighter than the Base brush, depending on dark/light mode
heuristics.

QPalette's data stram functions have been extended from QDataStream
Version Qt_6_6. If earlier versions are de-serialised, the AccentColor
defaults to Highlight. An autotest function dataStream() has been added
to tst_QPalette.

The QDataStream Version Qt_6_6 has been bumped to 21.
tst_QDataStream has been adapted to the new version and the new
color Role.

Change-Id: I98bbf9de95fb83bda921e9614a0db3a3c0ebdf75
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-21 18:36:37 +02:00
Axel Spoerl
0328e4297e QGenericUnixThemes: Make DBus listener configurable
The DBus locations and signals QGenericUnixThemesDBusListener has
listened to, were hard coded.
While these hard codings were in line with the signals emitted by the
Linux systems officially supported by Qt, this approach has made it
impossible for Qt to react to (color) theme changes when they are
announced by other DBus signals.

This patch replaces hard coded signals with a QFlatMap member.
The member is populated with the DBus locations/signals currently
supported.

If the environment variable QT_QPA_DBUS_SIGNALS_SAVE contains a valid
file name, the default configuration is stored in a JSON file.
If the environment variable QT_QPA_DBUS_SIGNALS contains a valid file
name, the default configuration is replaced with its content.

While the patch doesn't change existing behavior, it adds the
possibility to customize alternative DBus signals to listen to.

Task-number: QTBUG-103093
Pick-to: 6.5
Change-Id: I37e085c74bf53eed5cda7ec0dd7105562df0ed21
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-21 18:18:20 +02:00
Laszlo Agocs
1dd8b5ceec rhi: Make it a QPA-style private but semi-public API
qrhi.h, qshader.h, qshaderdescription.h (and qshaderbaker.h from
shadertools; done separately) become "RHI APIs", following the concept
of QPA APIs.

Mirror completely what is done for QPA headers, but using the "rhi"
prefix for the headers. This involves updating syncqt to handle the
new category of headers. (a note on the regex: matching everything
starting with "qrhi" is not acceptable due to incorrectly matching
existing and future headers, hence specifying the four header names
explicitly)

There is going to be one difference to QPA: the documentation for
everything RHI is going to be public and part of the regular docs, not
hidden with \internal.

In addition to the header renaming and adding the comments and
documentation notes and warnings, there is one significant change
here: there is no longer a need to do API-specific includes, such as
qrhid3d11[_p].h, qrhivulkan[_p].h, etc. These are simply merged into a
single header that is then included from qrhi.h. This means that users
within Qt, and any future applications can just do #include
<rhi/qrhi.h> (or rhi/qshader.h if the QRhi stuff is not relevant), no
other headers are needed.

There are no changes to functionality in this patch. Only the
documentation is expanded, quite a lot, to eliminate all qdoc warnings
and make the generated API docs complete. An example, with a quite
extensive doc page is added as well.

Task-number: QTBUG-113331
Change-Id: I91c749826348f14320cb335b1c83e9d1ea2b1d8b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-21 15:42:58 +02:00
Thiago Macieira
30a8e79243 QCallableObject: work around VS2022 compiler bug
Address Sanitizer in Visual Studio reported:

 ==17744==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x11ffe2ba0760 at ...
 WRITE of size 1 at 0x11ffe2ba0760 thread T0
 0x11ffe2ba0760 is located 0 bytes to the right of 16-byte region [0x11ffe2ba0750,0x11ffe2ba0760) allocated ...

Disassembly of QCallableObject's constructor shows that the compiler did
emit that 1-byte store of a null byte, 16 bytes after the object start,
of an object whose size is 16 bytes. The location of this code implies
it was the initialization of the StorageEmptyBaseClassOptimization
sub-object. Without an explicit constructor, this was an aggregate
initialization.

This seems to be the same issue as [1]. The workaround is to give it an
explicit constructor, the same workaround as [2].

I suppose other people using Empty Base Optimization haven't run into
this issue because that empty base usually overlaps something inside the
object. So an alternative workaround would be to invert the order of
derivation such that StorageEmptyBaseClassOptimization was the first
base.

[1] https://developercommunity.visualstudio.com/t/address-of-empty-base-class-is-wrong-c-bad-code-ge/322444
[2] https://developercommunity.visualstudio.com/t/empty-class-derived-from-empty-base-class-causes-r/451088

Change-Id: I5f7f427ded124479baa6fffd17609adca0f8e235
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-20 20:18:23 +02:00
Thiago Macieira
8566c2db85 QUuid: add support for 128-bit integers
[ChangeLog][QtCore][QUuid] Added support for converting between QUuid and
quint128, on platforms that offer 128-bit integer types (all 64-bit ones
supported by Qt, except MSVC).

Change-Id: Id8e48e8f498c4a029619fffd1728c9553e871df5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-20 04:59:43 +00:00
Thiago Macieira
befda1acca QTypes: add q{u,}int128 as a first-class, integer type
This is supported on all 64-bit platforms by Clang and GCC and will be
used by QUuid, with support in QDataStream and partial support in
QTextStream. CBOR also has a reserved "additional information" field for
128-bit quantities, but it's not allowable right now.

This conflicts with the quint128 type in QtBluetooth, which was not an
integral type. It has been removed in 1e903be81f43da4e31385bb7866bb4d3f07e5eba.

Change-Id: Id8e48e8f498c4a029619fffd172893c81aed3481
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-19 20:09:42 +00:00
Christian Ehrlicher
b40ab2f8a6 SQLite: Update SQLite to v3.42.0
[ChangeLog][Third-Party Code] Updated SQLite to v3.42.0

Pick-to: 5.15 6.2 6.5
Change-Id: Ie4eca58cfe94f19252279412c2f5a2515f1bee4c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-19 13:53:10 +02:00
Amir Masoud Abdol
3431aeafc0 Resolve symbol conflict between qmutex_unix and qwaitcondition_unix.cpp
In `qmutex_unix.cpp`, renamed `report_error` to `qt_report_error`; and
in `qwaitcondition_unix.cpp` renamed `report_error` to
`qt_report_pthread_error`. In addition, I removed the temporary
exclusion of the qwaitcondition_unix.cpp from unity build.

Pick-to: 6.5
Task-number: QTBUG-109394
Change-Id: Ia411bf1d8ca77512cf3898acb28b37f343ff94fd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-19 09:20:16 +02:00
Ahmad Samir
393e496385 Moc/Symbols: fix narrowing conversion warnings
- Port to qsizetype
- Use range-for/algorithms instead of index-based loops

Drive-by changes:
- Methods defined in-class are implicitly "inline"
- Make two methods const (saves using std::as_const in one place), and
  there is no reason why they are not const
- For consistency initialize members in-class / in constructor init-list

Pick-to: 6.5
Change-Id: If7f1546625028cbe13339430977b19952fedbd42
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-18 22:39:38 +03:00
Ahmad Samir
d413917eb3 Moc: fix some narrowing conversion warnings by using reverse iterators
And de-duplicating some code.

Pick-to: 6.5
Change-Id: Ibfb581cd296a120ff8328ae672020cc36ca5d328
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-18 22:39:30 +03:00
Ahmad Samir
976c3615a3 Moc: fix some narrowing conversion warnings by using range operations
I.e. range-for and in one case QList::append(iterator, iterator).

Drive-by changes:
- Check a QByteArray isn't empty before using at()
- Shorten a long line, QString::fromLocal8Bit() works with QByteArray

Pick-to: 6.5
Change-Id: I7e54ce39f65ccb1fe5e60693ac98e239b9f0d794
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-18 22:39:25 +03:00
Ahmad Samir
5c7702a8f9 moc/utils.h: fix a narrowing conversion warning
By taking a qsizetype, and using std::all_of.

Pick-to: 6.5
Change-Id: If81465194d92d04af637b0032d9504d6524893aa
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-18 22:39:20 +03:00
Thiago Macieira
5b6f59d6e7 IPC: QNativeIpcKey: enable the slow path
I had designed this to be fast for the common, new case of using
QNativeIpcKey objects with a key, a type and maybe in the future we'd
need a flag or two. Turns out that the very first thing I'll need is a
QString, so enable this code path.

This isn't currently exercised because it's not possible to enter it,
yet. It'll come in the next commit.

Change-Id: Idd5e1bb52be047d7b4fffffd17506af2f2de3060
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-18 11:01:51 -03:00
Thiago Macieira
d31a046956 IPC: QNativeIpcKey: use actual QUrl to format and parse the string form
Instead of pretending to be QUrl and doing a poor job at it. I'm not
going to implement QUrlQuery parsing and I'll need one option now to
store the original, legacy key.

Change-Id: Idd5e1bb52be047d7b4fffffd175068c6a82c039b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-18 09:01:50 -05:00
Antti Määttä
d5f5f1a42a CTF: Remove extraneous semicolon in metadata
Removes extra semicolon from floating point array metadata.

Pick-to: 6.5
Change-Id: If3e8b8097ff0c08c1f1f84cadbe389c7f7a2b1aa
Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
2023-05-18 14:20:02 +03:00
Dennis Oberst
15eca98214 QPartialOrdering: update docs and change parameter names
Let's be more explicit with QPartialOrdering's showcase of its
functionality in the docs and define a possible function-declaration.
Also change all parameter names to lhs and rhs, respectively.

Pick-to: 6.5 6.2 5.15
Change-Id: Ibc5c0b418bff3278e10e415c7f5bfa86227fc066
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-05-17 10:09:18 +02:00
Antti Määttä
4dd9a27640 CTF: Use UTC date-time in metadata
Force UTC date-time and use ISO date-time. Also isMonotonic is
always true so the conditionals can be removed.

Change-Id: I7419d62ee7a526c3c6d4b7628d52d45b601e84d6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-17 11:00:55 +03:00
Marc Mutz
8712e35aec QVarLengthArray/QList: make assign() return a reference to *this
While std::vector::assign() returns void, std::basic_string::assign()
returns std::basic_string&. In Qt, we want to be consistent between
{QVLA,QList,QString,QByteArray}::assign(), and returning *this is the
more general solution, so do that.

Task-number: QTBUG-106196
Task-number: QTBUG-106200
Change-Id: I2689b4af032ab6fb3f8fbcb4d825d5201ea5abeb
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-17 06:44:45 +02:00
Marc Mutz
782ccc6de5 QList: re-use the prepend buffer, if any, on assign()
Task-number: QTBUG-106196
Change-Id: I62d8610529cab528ae1b114d29707133b4fc28dc
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-17 06:44:39 +02:00
Thiago Macieira
06830bd78d QDnsLookup: reject looking up domain names that are too long
Both the libresolv and the Win32 API operate in 32-bit quantities, so we
could be aliasing with low values. In any case, RFC 1035 limits to 255.

    Various objects and parameters in the DNS have size limits.  They are
    listed below.  Some could be easily changed, others are more
    fundamental.

    labels          63 octets or less

    names           255 octets or less

Pick-to: 6.5
Change-Id: I3e3bfef633af4130a03afffd175e8957cd860bef
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-16 19:31:37 -07:00
Thiago Macieira
37f1fb78ee QSemaphore: add QDeadlineTimer API
This removes the last use of QtPrivate::convertToMilliseconds().

Change-Id: I6f518d59e63249ddbf43fffd1759fee2e00d36f4
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-05-16 19:13:03 -07:00
Tor Arne Vestbø
bc4e9e432a Fix unused variable 'FakeErrnoForThrow' [-Wunused-const-variable]
Amends ba05af82d3.

Change-Id: I979d43af3e937edd69b75c9138f1b24ebdc8fac3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-16 21:54:40 +00:00
Thiago Macieira
9cef9df822 QModelIndex: improve qHash
QModelIndex's qHash is really bad. It was retained from Qt 5, but ends
up producing poor results in large hashes.

This can't be fixed in Qt 6.

Task-number: QTBUG-113613
Change-Id: I5f7f427ded124479baa6fffd175f7810e1dc2580
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
2023-05-16 14:54:39 -07:00
Thiago Macieira
e1c3083dad QDnsLookup: make the query() function non-static
Simplifies arguments and will allow me to add stateful helper methods.

Change-Id: I3e3bfef633af4130a03afffd175d6044829a96f2
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-16 11:46:42 -07:00
Thiago Macieira
365af87f94 QDnsLookup/Windows: don't append domain search suffixes
The Unix code doesn't do that.

[ChangeLog][Important Behavior Changes] QDnsLookup on Windows will no
longer append the system's configured domain name for look ups that
contained only a single label (that is, no dots). This matches the Unix
behavior.

Change-Id: I5f7f427ded124479baa6fffd175f69e537cf9ca2
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-16 11:46:41 -07:00
Thiago Macieira
eb51454b90 QDnsLookup/Unix: rework the buffer-size check code
This is neater with a simple offset and avoids the potential UB code this
was carrying in:
  p += size;
  (p < response + responseLength)

It's UB to add to a pointer a size that moves it past the end of its
array. In practice we don't expect this to happen because of
construction (p is always pointing to a heap or auxiliary-thread stack
buffer), but in theory it could happen that said buffer is too close to
the end of the virtual address space and adding `size` causes it to
overflow back to small values.

Change-Id: I5f7f427ded124479baa6fffd175f59939c15c666
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-16 11:46:40 -07:00
Marc Mutz
7ca633d9a8 QArrayDataPointer: add a C++20 ranges-style optional projection to assign()
This will be useful for implementing QString::assign(), which
otherwise has the problem that it's d_ptr is based on char16_t, but
it's assign() is supposed to be able to deal with iterators whose
value_type returns QChar.

Task-number: QTBUG-106198
Change-Id: I87882bf749b4e21b7b32391167962d3e6bae9983
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-16 20:09:40 +02:00
Dennis Oberst
bbbe5f45c4 QList: add STL-style assign()
Implemented assign() methods for QList to align with the criteria of
std::vector, addressing the previously missing functionality.

Reference:
https://en.cppreference.com/w/cpp/container/vector/assign

[ChangeLog][QtCore][QList] Added assign().

Fixes: QTBUG-106196
Change-Id: I5df8689c020dafde68d2cd7d09c769744fa8f137
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-16 20:09:39 +02:00
David Edmundson
0c5135a9df Clarify documentation about QGuiApplication::setDesktopFileName format
Whislt the documentation says "base name" there are lots of examples in
the wild of clients using the wrong name here. Writing it explicitly
might help.

Task-number: QTBUG-75521
Pick-to: 6.5
Change-Id: Ic17ca161cf58449e85e25d9b6b8ace44fe14f18a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-05-16 18:09:38 +00:00
Tor Arne Vestbø
842dbca617 macOS: Detect menu bar roles for untranslated menu titles as well
If an application added an "About" menu action, and then loaded
the qtbase translations, we would try to match the incoming menu
title ("About") against QCoreApplication::translate("QCocoaMenuItem",
"About"), which since qtbase provides translation in the QCocoaMenuItem
context would fail, and we would not detect the menu item role
successfully.

For this to work, the application developer would need to add their
own translations for every menu item, and these translations would
have to match the QCocoaMenuItem translations in qtbase.

By also comparing the menu titles against the untranslated heuristics
we now account for the situation that the app has not translated
its menu items.

If the app does add translations of its menu items these still need
to match the QCocoaMenuItem context translations.

Change-Id: Ic2f019cd42b7e080187f9738840f84b0cec239df
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-16 20:09:38 +02:00
Volker Hilsheimer
b7c15f7f24 Remove the "classwizard" example
It adds nothing new to what the trivial and license wizard examples
show, other than a bunch of somewhat messy and outdated code to generate
C++ code files based on the input.

The example is referenced in a few parts of the documentation, but there
are equivalent snippets in the trivial and license wizard examples, so
point at those instead, and add some relevant API usage where needed.

Pick-to: 6.5
Change-Id: If1ff57e775bad28920d9e019aeccae69d1f4d127
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-05-16 18:33:18 +02:00
Volker Hilsheimer
11da92ba94 Convert "extension" dialog example into snippets
Pick-to: 6.5
Task-number: QTBUG-108751
Change-Id: I8ca4e058b832674dc0c8b84024cb70a667ee8db4
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-05-16 18:33:18 +02:00
Marc Mutz
cb2ff3b733 Make QGenericRunnable a private nested class of QRunnable
We don't intend to make QGenericRunnable public API, so prevent people
from using it outside QRunnable::create().

Change-Id: I49f182463ca307aaf6370adfa43bae14b4ce0df8
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-16 17:55:49 +02:00
Oliver Wolff
47e63d436e Don't grab QWhatsThis background on Windows
The workaround also is no longer needed on Windows so it can be removed
completely.

This patch amends 6a28b391f7.

Task-number: QTBUG-113556
Pick-to: 6.5
Change-Id: I69155e54da26acd49faf72816d1439fb3e322de9
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-16 15:55:49 +00:00
Fabian Kosmale
3cee2f1950 q20chrono: Fix feature test macro check
While the comment behind the else already had the correct value, the
actual check and the comment behind the endif had the wrong one. This
would cause build /headers clean check failures when using older
compilers in C++20/2a mode.
Also, remove the check for __cplusplus: A sufficiently high enough value
of __cpp_lib_chrono already implies __cplusplus > 201703L; the only
thing the check did was to hide the issue on more modern compilers.

Fixes compilation with e.g. gcc 9.3.
Amends bde5eeecaf

Change-Id: I74e761d9dc4048e9abf9cea9ea7e63260ea1111e
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-05-16 17:55:49 +02:00
Volker Hilsheimer
8e94af2ed0 Revamp the shapedclock example
Rename it to "Translucent Background", as that's what the example shows
how to do. And modern applications shouldn't use a (binary) mask to
create shaped windows. Instead, set the TranslucentBackground attribute,
don't paint pixels that should be fully transparent and use anti-aliased
or semi-opaque painting for pixels that should be translucent.

Adjust the example and documentation accordingly. Move the statment that
widget masks create coarse visual clipping to the QWidget::setMask
documentation.

Pick-to: 6.5
Change-Id: Id49d854093f2cb471afb178d32723081c7543543
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-05-16 13:37:38 +02:00
Volker Hilsheimer
322387ce7b Accessibility: call update handler even if not active
Update handlers should get informed about accessibility updates even if
the platform's accessibility bridge is not activated. E.g. an analytics
or test framework (like Qt Insights) might want to use the handler to
record relevant events.

While many events are only delivered if QAccessible::isActive returns
true to avoid spending computing time on creating the relevant event
data (e.g. in item views that can be expensive), the most important
events are still delivered. And requiring activation of accessibility
before events can be recorded through a handler has side effects on
performance, which we want to avoid.

Change-Id: I896b873574f6ad2527f755912d4950aa1f898097
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2023-05-16 13:36:20 +02:00
Fabian Kosmale
fd565750f3 qoffscreensurface.h: Add module to Q_MOC_INCLUDE
Depending on the build configuration, just using <QScreen> will not find
the header.

Pick-to: 6.5
Fixes: QTBUG-113619
Change-Id: Iaaf6f75ce82f8e32a1b1835614accd898b45824e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-16 10:47:21 +02:00
Thiago Macieira
5f5daae04a QHash: suppress GCC 12 & 13 warning that QHash could overflow
It can't unless you really have so many elements that it should
overflow. When growing, we call bucketsForCapacity(), which won't
overflow; when copying/detaching, we allocate the exact same amount of
memory that we've previously allocated, so that has to be good too.

There was nothing wrong with the previous code. The warning was showing
how the compiler had detected a possible overflow and caused a call to
operator new(-1) to force std::bad_alloc to be thrown. Disabling the
warning did not work in LTO mode. So we mimic it: Q_CHECK_PTR will call
qBadAlloc() for us if exceptions are enabled, or qt_check_pointer() if
not but assertions are (if neither are, then we have no means of
reporting the error, so let's just assume that it can't happen).

In function ‘allocateSpans’,
    inlined from ‘__ct ’ at qhash.h:581:48,
    inlined from ‘detached’ at qhash.h:596:20,
    [...]
qhash.h:551:19: warning: argument 1 value ‘18446744073709551615’ exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]

Commit 1d167b515e is the likely source of
this warning.

Fixes: QTBUG-113335
Pick-to: 6.5
Change-Id: Ieab617d69f3b4b54ab30fffd175bb8d36228209c
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
2023-05-15 18:18:01 -07:00
Thiago Macieira
1acbcc318a QHash: centralize the span allocation
Deduplicates code and will allow me to insert some magic.

Pick-to: 6.5
Task-number: QTBUG-113335
Change-Id: Ieab617d69f3b4b54ab30fffd175bb4a2af610ff8
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-05-15 18:18:00 -07:00
Thiago Macieira
0cb46b25f3 QDnsLookup/Unix: modernize with qFromBigEndian
Instead of explicit code.

Change-Id: I3e3bfef633af4130a03afffd175d515f846a629a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-15 14:54:00 -07:00
Thiago Macieira
25869c0aad QDnsLookup/Unix: do skip DNS records that aren't of class IN
There's nothing saying the server can't supply those to us, so let's
explicitly skip them. The Windows version already does this because the
windns.h API only supports records of class IN.

Test for this after setNameserverPort() is added.

Pick-to: 6.5
Change-Id: I3e3bfef633af4130a03afffd175e6ddc756c91c5
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-15 14:54:00 -07:00
Thiago Macieira
48b6c8503a QProcess/Unix: enable setChildProcessModifier for startDetached
Do this by making the actual child-execution code common between
startProcess() and startDetached(). It does mean we've moved the chdir()
operation from the child to the grandchild process, though.

[ChangeLog][QtCore][QProcess] The modifier function set with
setChildProcessModifier() will now also be executed when the process is
started with startDetached().

Change-Id: Icfe44ecf285a480fafe4fffd174d9aa57dd7dfff
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-15 19:10:03 +02:00
Thiago Macieira
fb40737b0d QProcess/Unix: improve the error message if the child modifier throws
Functionality added for 6.5, but after translatable string freeze.

Change-Id: Icfe44ecf285a480fafe4fffd174d984c5349e0cb
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-15 19:10:03 +02:00
Thiago Macieira
ba05af82d3 QProcess/Unix: protect against stack unwinding in the child process stub
There are two types of stack unwinding that can happen on Unix systems:
C++ exceptions and PThread cancellations (on some systems, like Linux,
PThread cancellations can be caught in catch(...) statements). We call a
variety of PThread cancellation functions from inside the child stub,
like close(). To avoid problems, we disable PThread cancellations
completely before fork() or vfork().

The C++ exception case is simpler, because we can be sure of catching
them with the catch (...) statement and simply transform them into an
error message. This is also testable, which the PThread cancellation
isn't.

The error message isn't ideal because we're string-frozen. I'll improve
it for 6.6.

Pick-to: 6.5
Change-Id: Icfe44ecf285a480fafe4fffd174d97a475c93ff1
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-15 10:10:03 -07:00
Ahmad Samir
d2242c353f MOC: pass the erroneous Symbol as an arg to Parser::error() overload
We already know the Symbol while parsing, passing a reference to it to
error() makes it simpler to construct the error message.

This fixes an issue where reporting an error about "NONSENSE" in e.g.:
Q_PROPERTY(Foo* foo NONSENSE foo)

would be off-by-one and the error message would say:
path/to/file.h:11:1: error: Parse error at "foo"

instead of 'at "NONSENSE"', which is where the parser actually found an
unexpected attribute.

Fixes: QTBUG-36367
Pick-to: 6.5
Change-Id: Ief70e544af41f7575fbeea9b936fa8197c3ef43d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-15 19:20:21 +03:00
Tor Arne Vestbø
6a28b391f7 Don't grab QWhatsThis background on non-Windows platforms
The logic was introduced in 186589abd48b17fdb9b631211008753e2d1701b3
due to Windows supposedly not supporting NoSystemBackground. It's
not clear whether this is still the case, but as this workaround
causes problems on other platforms, such as bringing up the screen
capturing permission dialog on macOS, it should be limited to Windows.

Fixes: QTBUG-113556
Pick-to: 6.5
Change-Id: I197adb5fc177faebc0f2fcd28612e3daa0c22ed5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-15 18:20:20 +02:00
Ahmad Samir
c4ce22ef24 QEventDispatcher/WASM: fix a lambda name
It's returning milliseconds not nanoseconds.

Change-Id: I7dbc3f4043694b6ddf87c6ad9e4d20d3a9af0fd1
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
2023-05-15 17:21:22 +03:00
Tor Arne Vestbø
08f85c27bb Darwin: Use direct runtime interface to manage autorelease pools
The Objective-C runtime supports autorelease pools via a language
specific ABI supplement, akin to the “Itanium” generic ABI for C++.

 https://clang.llvm.org/docs/AutomaticReferenceCounting.html#runtime-support

These interfaces are used by NSAutoreleasePool internally, as well as
inserted by the compiler when using the @autoreleasepool syntax in
Objective-C code.

We have our own wrapper, QMacAutoReleasePool, which allows us to
set up pools in C++ code as well. We now use these lower level
interfaces in the implementation, instead of NSAutoreleasePool,
as this reduces overhead due to not needing to allocate and destroy
a NSAutoreleasePool.

This also opens up the possibility of using Automatic Reference Counting
(ARC) in Qt down the road, as explicit NSAutoreleasePool usage is forbidden
in that mode (while @autoreleasepool is not, and uses the runtime ABI
internally as before).

Change-Id: I06fdb4a24ae4972820f866e0a129a1b355bc8a6b
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-05-15 15:51:01 +02:00
Tor Arne Vestbø
7cf7e88417 Darwin: Disable QMacAutoReleasePool tracker unless explicitly enabled
There's a few orders of magnitude of overhead using QMacAutoReleasePool
with the tracker enabled, so disable it even for debug builds, unless
explicit auto release pool debugging has been enabled via the environment
variable QT_DARWIN_DEBUG_AUTORELEASEPOOLS.

Pick-to: 6.5
Change-Id: Iec00c703eb21e1914903954cfd02f9f6b1ec2a1f
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-05-15 15:51:00 +02:00
Tor Arne Vestbø
59c686080d Darwin: Disable QMacAutoReleasePool tracker in release builds
It adds overhead that is noticeable, especially in tight loops that
rely on an auto-release pool. For example, this improves the QLocale
date to string transformations an order of a magnitude.

Task-number: QTBUG-104785
Pick-to: 6.5
Change-Id: I246dc4e114bd75dd4e3e9e42b061c4c20c94d522
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-05-15 15:51:00 +02:00
Tor Arne Vestbø
e95f03f989 Darwin: Remove QMacAutoReleasePool heap allocation detection
This is handled by the Objective-C runtime nowadays, where it will
abort if the situation is detected, with the option to break on
objc_autoreleasePoolInvalid to debug the situation.

Pick-to: 6.5
Change-Id: Idf2c4aacc77e41a3deebf270303f4f13cfb0819b
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-05-15 13:51:00 +00:00
Volker Hilsheimer
f4b338833e Move the addressbook tutorial into manual tests
The tutorial is building an elaborate UI around a QMap. It doesn't use
structured data, and it doesn't use model/view (which the dedicated
addressbook example in itemviews does).

It's not a good way of building an application, and the individual APIs
for creating layouts, dialogs, or import/export are explained well
enough in other examples.

Pick-to: 6.5
Change-Id: Iffe47a0f6e04a933edb917c877ae845f50b74b4a
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-05-15 14:52:17 +02:00
Ievgenii Meshcheriakov
a035e8b768 QDBusMetaObjectGenerator: Use uniform loops to iterate over methods
Use the same structure for iterating over signals and other
methods in 3 places. Introduce MethodMap type alias to make
types shorter.

Change-Id: I732b582fc8c47616037087b77a79eb13ecf17019
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-15 14:02:47 +02:00
Ievgenii Meshcheriakov
0f37c47713 QtDBus: Convert some loops to ranged for loops
Convert some loops that are using Java-style iterators into
ranged for loops for better readability.

Change-Id: I14f6339608d201fe06a753be236db52815cbf5c4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-15 14:02:47 +02:00
Edward Welbourne
4768fcf836 Fix case-sensitivity of exponent separator check in Cyrillic fall-back
When matching the locale's correct exponent separator, QLocale was
doing a case-insensitive match; but the Cyrillic fall-back was
matching case-sensitively, so failed to catch the case of lower-case e
and its Cyrillic equivalent, when used in a Cyrillic font in place of
the upper-case form of the other, where that's the locale's official
separator. So make this comparison case-insensitive.

Added some test-cases for the lower-case exponential separator.

Pick-to: 6.5
Fixes: QTBUG-113443
Change-Id: I18e22d7b3451fbb61e87d5b93661eadff3c7356e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2023-05-15 14:02:47 +02:00
Edward Welbourne
7337474d04 Convert remaining QT_NO_XMLSTREAM* to use feature system
Replace the check in qxmlstream.h with a QT_REQUIRE_CONFIG since the
code that includes this header does no checking, whether on the define
or the feature, so is better off getting told about the missing
feature at the point of include than complaining about an undefined
type despite its header being overtly included.

For the rest, just do the usual transformation to QT_CONFIG(),
flipping the ones that were #ifdef rather than #ifndef, so the
condition is positive. Shifted a couple of open-braces of classes to
the next line, where they belong, in the process.

Change-Id: If9c496082f0489b0f9f4070364cbf840e603fce1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-15 14:02:43 +02:00
Edward Welbourne
526ce669ed Clean up phrasing of --help-all and other help options
The options included by --help-all, although they are "specific to
Qt", are "specific" to all Qt applications, so - in the present
context, of QCommandLineParser - not specific at all. It's the options
described by -h that are specific, to the present command; the Qt
options are generic (in the present context).

So rework the help string for --help-all itself and the documentation
of the function. It had, in any case, an overly-complex first line,
that descended into too much detail. Updated test to match.

Pick-to: 6.5
Task-number: QTBUG-111228
Change-Id: I06da0af41be60e6e1b7616984001ddb9ca33aad6
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
2023-05-15 14:02:43 +02:00
Andreas Buhr
ae34a78b24 Don't create a QTimeZonePrivate object for an unsupported time zone ID
The QTzTimeZoneCache created one cache entry for every time zone
which was looked up, even if the code was invalid. This uses some
memory for each time zone code queried and thus allows DOS attacks
if user supplied time zone codes are parsed.
This patch prevents the creation of QTimeZonePrivate objects for
invalid time zone IDs.

Change-Id: I22007f6681bea54fa08639f4f786e1a49d10f920
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-15 14:02:42 +02:00
Edward Welbourne
13e8609fc9 Include all available IANA DB zones for the TZ backend
Previously, QTzTimeZonePrivate::availableTimeZoneIds() only reported
the zones listed in the zone.tab file, which maps territories to
zones. It thus omitted several zones that are provided by the IANA DB,
but not the primary zones for any territory. This meant that it was
possible to pass a zone name to the constructor successfully, despite
isTimeZoneIdAvailable() claiming it isn't available.

Pick-to: 6.5
Change-Id: I9e4eb7f4cfe578204951b995f0ad9ffd7eed5f9c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-15 14:02:41 +02:00
Topi Reinio
cb8a71dac6 Doc: Replace mentions of deprecated macro
Q_ENUMS() is deprecated in favor of Q_ENUM().

Pick-to: 6.5
Task-number: QTBUG-113229
Change-Id: I29cc23c87b1d6e8eeb49dd1d3ddaf4ca7d2cf8c2
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2023-05-15 08:57:02 +00:00
Topi Reinio
506d237751 Doc: Make QByteArray(qsizetype size, Qt::Initialization) doc public
The constructor that doesn't explicitly initialize the content of the
array can be useful in some cases.

Pick-to: 6.5
Fixes: QTBUG-111582
Change-Id: Icc4bd753f1944a91be70316a7303bb822f79d472
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-15 08:56:21 +00:00
Yuhang Zhao
b5d874e36f Fix the QT_REQUIRE_VERSION macro
Rewrite the whole macro as a function and use QVersionNumber instead
of manual parsing to make it more modern and more readable.

Change-Id: I25498320ef6cd9f19be9267421e2727cd28cfd7c
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-15 08:47:17 +00:00
Thiago Macieira
9a73bc5f3d QDnsLookup/Windows: use DnsQueryEx so IPv6 servers are supported
Similar test with link-local server on the same network:

$ $objdir/tests/manual/qdnslookup/qdnslookup.exe @fe80::1e1b:dff:fee2:49e6%Ethernet
; <<>> QDnsLookup 6.6.0 <<>> qdnslookup @fe80::1e1b:dff:fee2:49e6%Ethernet
;; status: NoError
;; QUESTION:
;qt-project.org                 IN A

;; ANSWER:
qt-project.org            3532  IN A    52.18.144.254

;; Query time: 17 ms
;; SERVER: fe80::1e1b:dff:fee2:49e6%Ethernet#53

Server's dnsmasq log shows it was queried.

We don't know why we must set the port to 0. It works for me the regular
way, but not for everyone who tested this patch.

[ChangeLog][QtNetwork][QDnsLookup] setNameserver() now supports IPv6
servers with on Apple systems, AIX, FreeBSD, NetBSD, Solaris, and
Windows.

(AIX, NetBSD and Solaris not directly tested, but their docs online show
they have res_setservers())

Change-Id: I3e3bfef633af4130a03afffd175d5bfd4e7922b9
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-14 21:44:21 -07:00
Thiago Macieira
678964b242 QDnsLookup/Unix: add support for res_setservers()
This API is found on FreeBSD, Darwin, Solaris, AIX, and Android Bionic.
That means we complement IPv6 support for most platforms.

Test on macOS:

$ $objdir/tests/manual/qdnslookup/qdnslookup @fe80::1e1b:dff:fee2:49e6%en0
; <<>> QDnsLookup 6.6.0
;; status: NoError
;; QUESTION:
;qt-project.org                 IN A

;; ANSWER:
qt-project.org            3336  IN A    52.18.144.254

;; Query time: 2 ms
;; SERVER: fe80::1e1b:dff:fee2:49e6%en0#53

Dnsmasq log on the server confirms it was queried.

Change-Id: I3e3bfef633af4130a03afffd175d59c67faa463f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-14 21:44:20 -07:00
Thiago Macieira
eb9f88a078 QDnsLookup/Unix: modernize the setting of IPv6 server addresses
Instead of using #if, this now uses SFINAE to detect the presence of the
glibc extensions to set IPv6 nameserver addresses. It's also possible
that this fixes some bugs that have always been there, but never checked
because we don't have a way to unit-test explicit name servers.

To that effect, this commit adds a manual unit test that mimics the BIND
tool "dig". When running:

 ./qdnslookup qt-project.org any @dns.google

it printed for me:

; <<>> QDnsLookup 6.6.0
;; status: NoError
;; QUESTION:
;qt-project.org                 IN ANY

;; ANSWER:
qt-project.org            3600  IN MX   10 mx.qt-project.org
qt-project.org            3600  IN NS   ns14.cloudns.net
qt-project.org            3600  IN NS   ns11.cloudns.net
qt-project.org            3600  IN NS   ns12.cloudns.net
qt-project.org            3600  IN NS   ns13.cloudns.net
qt-project.org            3600  IN A    52.18.144.254
qt-project.org            3600  IN TXT  "v=spf1 mx ip4:193.209.87.4 include:spf.protection.outlook.com ~all"

;; Query time: 241 ms
;; SERVER: 2001:4860:4860::8844#53

strace confirms the DNS queries were sent to the correct address.

Change-Id: I3e3bfef633af4130a03afffd175d56a92371ed16
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-14 21:44:19 -07:00
Thiago Macieira
49eb9021e3 QProcess/Unix: use open() + fchdir() to change directories
This means we have more system calls (2 more in the parent), but we
can now detect non-existent or inaccessible directories before fork().

Pick-to: 6.5
Change-Id: Icfe44ecf285a480fafe4fffd174d1003581bff59
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-15 00:12:43 +02:00
Thiago Macieira
6b561ccf44 QProcess/Unix: use pid_t for the pid
Qt 5 and earlier versions used to share this member with Windows, where
we needed to store a pointer. We had the Q_PID public type, which was
removed in commit b73d5a0511 (6.0). That
commit made the QProcess::processId() public API use qint64, which is
fine. But we don't need to store more bits than the OS actually
requires.

This further reduces QProcessPrivate's size to 688 bytes on 64-bit Unix,
with 5 bytes of tail padding.

Pick-to: 6.5
Change-Id: Icfe44ecf285a480fafe4fffd174d3fa9345872c0
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2023-05-15 00:12:41 +02:00
Thiago Macieira
29b2fe40dc Revert commit "don't ever force fork() instead of forkfd()"
This reverts commit d6bf71123d and the
docs from commit 82b75570f0
("QProcess/Linux: fix file descriptor leak in case of failed child
start").

Despite the title of the commit being reverted, the actual consequence
is slightly different: we always use the forkfd() function, but we
change whether we force the use of the fork() library function by use of
the FFD_USE_FORK flag.

Commit 97645478de (5.15) first added the
FFD_USE_FORK flag with a hack to detect whether the setupChild() virtual
might have been overwritten. A configure-time feature to force the flag
was added in commit 2ed99ff5ca (6.0).
Before the 6.0 release, commit d6bf71123d
removed the conditional use of FFD_USE_FORK, with the changelog message
saying "pthread_atfork() callbacks are consistently not invoked".

We've also since added vfork()-like behavior. We tried it for Qt 5.15
and reverted shortly afterwards because we had got the memory semantics
wrong. Commit e1a787a76e (6.5) finally got
it right, for Linux, which revealed another set of problems with
functions used in the child process modifier.

Therefore, we're going to make vfork() and clone() usage opt-in if the
child process modifier is active. This commit is the first part:
disabling their use by default. The flag to opt in will come in Qt 6.6.

[ChangeLog][QtCore][QProcess] Reverted a change from Qt 6.0 that made
the childProcessModifier() callback be run in a child created by means
other than a real fork() library call, a situation in which certain
other library functions would be unusable, unreliable, or cause
deadlocks. A flag to opt in to the solution with better performance will
be added to Qt 6.6.

Task-number: QTBUG-104493
Fixes: QTBUG-111243
Fixes: QTBUG-111964
Pick-to: 6.5
Change-Id: Icfe44ecf285a480fafe4fffd174d3e66843e5a29
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-15 00:12:41 +02:00
Thiago Macieira
2b98dd7645 QProcessPrivate: repack and reorganize the members
Reduce the number of #ifdef blocks and use quint8 for the enums that
don't need more than 8 bits anyway (none of them do). Plus move the
std::function callback to an indirect block, as most users of QProcess
won't set them and this type is 4 pointers with libstdc++ and libc++.

After this, QProcessPrivate on 64-bit Unix is 688 bytes, of which:
- 392 bytes from QIODevicePrivate
- 295 bytes of own data
- 3x56 bytes per Channel (which have 5 bytes of tail padding each)
- 1 byte of tail padding and no middle padding

Pick-to: 6.5
Change-Id: Icfe44ecf285a480fafe4fffd174d188a0821d060
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-15 00:12:39 +02:00
Thiago Macieira
7dba2c8761 QDnsLookup/Unix: make sure we don't overflow the buffer
The DNS Records are variable length and encode their size in 16 bits
before the Record Data (RDATA). Ensure that both the RDATA and the
Record header fields before it fall inside the buffer we have.

Additionally reject any replies containing more than one query records.

[ChangeLog][QtNetwork][QDnsLookup] Fixed a bug that could cause a buffer
overflow in Unix systems while parsing corrupt, malicious, or truncated
replies.

Pick-to: 5.15 6.2 6.5 6.5.1
Change-Id: I3e3bfef633af4130a03afffd175e4b9547654b95
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2023-05-14 19:47:03 +00:00
Thiago Macieira
0fc0e821f1 QDnsLookup: remove the #if QT_CONFIG(thread) check
There's no fallback anywhere, so this class simply doesn't work if
threading isn't supported. Writing it is an exercise left for whoever
cares for that configuration.

Change-Id: I3e3bfef633af4130a03afffd175e6f68a3f4673f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-14 12:47:01 -07:00
Thiago Macieira
471f134cdd QDnsLookup: remove the explicit metatype registration for the Reply type
It's unnecessary in Qt 6 if we use the new-style connect or if the type
was fully defined in the compilation of the unit containing the moc
output.

Change-Id: I3e3bfef633af4130a03afffd175e6f4e87adf5e1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-13 16:15:02 -07:00
Thiago Macieira
d26709cd8c Network: Remove Q_DECL_METATYPE_EXTERN for single-.cpp metatypes
These were added in commit 20e6a049fe as a
massive sweep of all Q_DECLARE_METATYPE, without thought as to whether
they were actually needed or not. If they are used as a metatype in a
single .cpp file, they don't need to be.

Incidentally removes the entirely incorrect Q_NETWORK_EXPORT of
QDnsLookupReply.

Pick-to: 6.5
Change-Id: I3e3bfef633af4130a03afffd175e6f378f09a3aa
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-13 16:15:01 -07:00
Thiago Macieira
c257e518c1 QProcessPrivate: remove the member variable "crashed"
It was only used to later set exitStatus = CrashExit, so simply do it
early.

Drive-by removal of a magic numeric literal in the middle of the source
code. It's still magic, but at least we avoid accidentally making typos.

Pick-to: 6.5
Change-Id: Icfe44ecf285a480fafe4fffd174d4176a5d87641
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-13 20:25:27 +00:00
Thiago Macieira
45a03fc506 QNativeSocketEngine: move some code from the _p_p.h to _p.h file
So I can use it in qdnslookup_unix.cpp.

Change-Id: I3e3bfef633af4130a03afffd175d506949968990
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-13 13:24:24 -07:00
Alexey Edelev
f71eb4a642 Avoid littering CMake logs with QTP0002 warnings
It doesn't make any sense to setup and get policy when we build either
Qt or standalone tests, since the value will be ignored anyway. So
skip the policy setup for Qt builds to avoid littering the CMake logs
with QTP0002 warnings.

Amends c4debab927

Change-Id: Iacae8f9ecbb6c9da2f3af77b2016454c8d4194e6
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-12 17:55:21 +02:00
Tor Arne Vestbø
798456c0a3 Add QIconLoader debug logging to aid fallback logic investigation
The icon loader machinery is a bit opaque, so let's add some logging
to understand the interactions.

Pick-to: 6.5
Change-Id: Ic400b6043607795ad92771f9d9f189699f185366
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-05-12 16:20:29 +02:00
Alexey Edelev
a3cb388eaa Check if next property in the list is not empty before adding a comma
Property merging genex only checks if previous value is not empty, but
doesn't check if an actual value that we concatenate is not empty too.
Add the check to make sure we don't have trailing comma in the json
lists.

Fixes: QTBUG-112885
Pick-to: 6.5
Change-Id: I1a5265ddf1b12f763650daf3c6e3538ed52a1674
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-05-12 14:20:28 +00:00
Peter Varga
2550568a92 Enable [[noreturn]] attribute for non-MSVC compilers on Windows
Avoids -Wsometimes-uninitialized warnings with clang-cl.

Also do not allow to return qt_message_fatal() if built with other
compiler than MSVC.

Amends 97b32fa0b6

Fixes: QTBUG-113351
Change-Id: I9ce87057e764af1e25de93388ae983891df66d2e
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-12 15:33:52 +02:00
Morten Sørvig
417b61b015 wasm: fix qtloader.js container element regression
As of Qt 6.5 the html document should not create canvas
elements directly, but instead create div container
elements and let Qt create and manage the canvas elements.

However, qtloaders.js has not been updated to match this
and is still creating canvas elements when given div
elements.

Remove the canvas creation code and invert the primary
and fallback case: config.containerElements is now passed
to instance.qtContainerElements. config.canvasElements
is copied to config.containerElements, if set.

Change-Id: I7372db93ee4de5b23a0a5d992597a3fbd9711a33
Pick-to: 6.5 6.5.1
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
2023-05-12 10:15:03 +00:00
Thiago Macieira
cdd0e8fa67 QSlotObjectBase: move the which parameter to the 4th position
This places the first through third parameters on the exact positions
that they will be used to perform the operations in the switch, saving
the compiler from generating a few instructions to move data around. All
ABIs Qt supports that pass any function parameters in registers at all
pass at least 4.

We keep the return type as void (instead of returning bool, for the
Compare case) so the compiler can apply tail-call optimizations for
those two typical cases.

PMF case: https://gcc.godbolt.org/z/9oP5boKfj
Function case: https://gcc.godbolt.org/z/e9vEzd5dj
Functor case: https://gcc.godbolt.org/z/s8Ejjra7P

Change-Id: I3e3bfef633af4130a03afffd175d3e3009c56323
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-11 21:53:22 -07:00
Thiago Macieira
05ebf3e54b IPC: QNativeIpcKey: fix big-endian builds
We weren't using the LSB in big-endian builds because the bitfield was in
the wrong order: it was either using the MSB (in 32-bit builds) or
something in the middle for 64-bit. So use quintptr in the bitfield to
ensure proper sizing and correct the order.

Additionally, we now store the d "pointer" as a quintptr, so as to avoid
storing the actual pointer to QNativeIpcKeyPrivate with the LSB set.

Change-Id: Idd5e1bb52be047d7b4fffffd17506adb77d52805
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-11 21:53:21 -07:00
Thiago Macieira
e2a76797e0 QLatin1StringView: un-inline Latin1-UTF8 compare_helper
Commit c630b231ec ("Untangle
QLatin1StringView from qstring.{h,cpp}") moved QLatin1StringView from
qstring.h, causing compilations that included qlatin1stringview.h but
not qstring.h to produce a warning.

By un-inlining, we get an improved comparison functionality without
memory allocation too. So win-win.

 qlatin1stringview.h:325:23: warning: inline function ‘static int QLatin1String::compare_helper(const QLatin1StringView&, const char*)’ used but never defined

This is BC because the actual function that used to be inline continues
to be so, and the old implementation is fine, albeit slower.

Change-Id: Ieab617d69f3b4b54ab30fffd175c4e11d4a3b6dd
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-11 21:53:21 -07:00
Thiago Macieira
4f00e6c8b9 QReadWriteLock: inline the constructor and destructor
Change-Id: Ieab617d69f3b4b54ab30fffd175b2500dd860431
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 19:56:23 -07:00
Thiago Macieira
6ac0406464 QDnsLookup: treat NOTIMP replies as server failures
"Not implemented" is not "invalid reply".

Pick-to: 6.5
Change-Id: I3e3bfef633af4130a03afffd175e2687e7585f36
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 17:05:27 -07:00
Amir Masoud Abdol
68b625901f Network: link directly to libresolv instead of dlopen()ing it
There's little need for us to dynamically load it. The reasons why that
was necessary aren't in the public history (Qt 4.5 already had it[1]). I
remember writing the code in 2007-2008, I just don't remember why.

On modern Linux and FreeBSD, there's no libresolv.so any more and those
symbols have been rolled up into libc.so. It's still necessary on Darwin
systems, so this commit introduces WrapResolv.

It also resolves the unity build issues relating to libresolv symbols.

[1] https://code.qt.io/cgit/qt/qt.git/tree/src/network/kernel/qhostinfo_unix.cpp?h=v4.5.1

Task-number: QTBUG-109394
Change-Id: Ic5799e4d000b6c9395109e008780643bac52122b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 17:05:25 -07:00
Thiago Macieira
ff9da1db0b QMutex: add QDeadlineTimer-based tryLocks
This simplifies the code greatly, because we don't need to use
QtPrivate::convertToMilliseconds any more, as QDeadlineTimer has
nanosecond precision.

Internally it becomes simpler too because lockInternal was already using
QDeadlineTimer. I just had to use the parameter instead and update the
two non-futex implementations to take it again. This may even be fixing
a mistake in case sem_timedwait(2) got interrupted.

Change-Id: I6f518d59e63249ddbf43fffd1759fed9f50b3606
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 12:31:57 -07:00
Thiago Macieira
63704529b7 QReadWriteLock: add tryLockForXxx overloads taking QDeadlineTimer
This propagates inside the internals, ending up in wait_until calls in
the internal std::condition_variable. For systems with proper support
for monotonic waiting (Linux, FreeBSD), this should improve performance.

We could even remove the hasExpired() check and pass a time point in the
past too. Right now, there's a minor performance drawback for
tryLockForXxxx(), because we will make at least two system calls to get
the time.

Change-Id: I6f518d59e63249ddbf43fffd1759fc5b2e40256a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 12:31:57 -07:00
Thiago Macieira
fcae43237b QReadWriteLock: inline the lockForXxx functions
We can now do that because tryLockForXxxx(-1) is fast for the
uncontended case too.

Change-Id: I3d728c4197df49169066fffd1756ddd06caf7b52
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 12:31:56 -07:00
Thiago Macieira
34914099a1 QReadWriteLock: remove the untimed tryLockForXxxx functions
They're unnecessary now because the timed function is fast enough.

Note: the default argument will move to the QDeadlineTimer functions
before the Qt 6.6 release.

Change-Id: I3d728c4197df49169066fffd1756ddc0e4f796d3
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 12:31:56 -07:00
Thiago Macieira
834c755977 QReadWriteLock: force the loop to exist in a separate function
This allows the fast, uncontended case to exist in a function that does
much less work and therefore needs to save less state in its
prologue. This is interesting too for LTO because the compiler can then
inline the fast, uncontended path where the locks were used.

Pick-to: 6.5
Change-Id: I3d728c4197df49169066fffd1756dc04d8a5f04a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 12:31:56 -07:00
Thiago Macieira
0c0778fb36 QReadWriteLock: remove the private function from the symbol table
Just move it to the private class. This also allows this function to get
inlined in QWaitCondition::wait().

Pick-to: 6.5
Change-Id: I6f518d59e63249ddbf43fffd1759fc99c28c7ca8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-11 12:31:55 -07:00
Ievgenii Meshcheriakov
859ef05633 QDBusConnectionPrivate: Fix handling of queued messages
Handle any queued messages before attempting to dispatch
any newly received messages. This ensures that messages are
processed in the order they were sent.

Add a regression test for this bug using code adapted
from the bug report by Pascal Weisser. Because of the
nature of the bug, this new test does not always fail
even when compiled with affected versions of Qt though.

Fixes: QTBUG-105457
Pick-to: 6.2 6.5
Change-Id: I2725f3450ad537d63d6660e21645ac2c578e1768
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-11 19:58:12 +02:00
Volker Hilsheimer
9c9c5d9828 Fix QMetaObject::invokeMethod for free functions and std::bind
Amends 3bf5b5f894, after which free
functions and std::bind could no longer be used as callables in
QMetaMethod::invokeMethod.

For free functions to work we need to decay to function pointers when
choosing what type QtPrivate::Callable aliases.

And std::bind has operator() overloads and the return type cannot be
deduced. So simplify the definition of the ZeroArgFunctor - we know
the function prototype if we know the return type.

Add testcase for calling std::bind and free function, and remove the
now unneeded helpers for functor argument and return type deduction.

Change-Id: I54aac5cb6d660267e6b2f5ab05d583e8826cdf9a
Reviewed-by: Zoltan Gera <zoltan.gera@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 19:36:55 +02:00
Tor Arne Vestbø
af8e75f54f Revert "QIconLoader: use system fallback theme as the first fallback option"
This reverts commit 4710fb3528.

The theme it responsible for defining a set of good fallbacks,
and we should respect that order. We should also respect any
override the application developer does of the fallback theme,
and not unconditionally fall back to the system fallback theme.

Change-Id: I77f1a74c71a2a7db70464666b1a96a00fb4a1d8f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-05-11 14:59:58 +02:00
Edward Welbourne
9f1252da28 Fix QTimeZone::offsetData() for the case without transitions
A zone without transitions, such as any UTC-based one, would
previously return invalid data for the offset data at a given
time. The method was documented to be "the equivalent of calling
offsetFromUtc(), abbreviation(), etc" but these methods do return
sensible data for a zone with no transitions. Furthermore, the backend
data() method on which it depends is implemented by all backends,
including the UTC one, with no transitions.

Fix offsetData() to also return data when no transitions are
available. Improve docs.

Adapt the checkOffset() test to test offsetData() as well as the
various functions to get parts of it. In the process, change that test
to use a QTimeZone row instead of its name as a QByteArray, so that we
can also have rows for lightweight time representations.

Change-Id: I241ecf02a26a228cca972bca5e2db687fe41feb4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-05-11 13:46:42 +02:00
Tor Arne Vestbø
1ea0625ca8 macOS: Replace [QNSView drawRect:] assert with warning
AppKit will in some cases call this method, even if we are layer backed,
just because we implement it. We should remove the implementation, but
doing so requires us to also move from displayLayer to updateLayer for
the layer backed drawing, which requires more testing.

Pick-to: 6.5
Fixes: QTBUG-113500
Change-Id: I70bde34fdb433105d85ccea0514a5342e2c1e725
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-05-11 12:47:56 +02:00
Marc Mutz
6da9662143 QRunnable: fix Coverity dead-code warnings in create()
Coverity complained about the call to warnNullCallable() being dead
code for most instantiations of the create() function template. It's
right, of course, even though warning in a template that clearly has
instantations where it's not dead code isn't exactly helpful.

Nonetheless, take the opportinity to avoid the dead code warning at
the expense of a bit or un-DRY-ing:

- because we now use them more than once, cache the result of
  is_*function_* predicates in constexpr variables

- then scope the is_null variable such that its use is not subject to
  dead-code removal anymore (at instantiation time; it may still be
  removed by the optimizer)

As drive-bys, add a comment about the reinterpret_cast, and make the
custom template predicates variable- instead of class templates.

Coverity-Id: 407640
Change-Id: I272223042c2aae9d814e82c466e1d29e1c42bfa1
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2023-05-11 12:47:55 +02:00
Marc Mutz
5ddfa8bbe6 QGenericRunnable: remove common prefix from nested classes
Helps keep the code fit into line length limitations.

Change-Id: I2e861c6f0a991cc36991572c4386040b8e11ca40
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-11 12:47:54 +02:00
Marc Mutz
acd675c38c Move QGenericRunnableHelper info QGenericRunnable
Because we can, and it prevents all the machinery from being exported
by the Q_CORE_EXPORT on QRunnable.

Change-Id: I80e0690956bff612f2048eefb2b64bc198835f1f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2023-05-11 12:47:54 +02:00
Marc Mutz
fdc29b9714 Move handling of helper from create() to QGenericRunnable
Keeps the helper contained in QGenericRunnable.

Change-Id: I52d075efc55c5eb78fe97ade261b58fc75e2a6c1
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-11 12:47:53 +02:00
Marc Mutz
e3442c05bd QStyleSheetStyle: avoid #define ceil()
There's only one user of this function-like macro and already broke
unity-build, so make it a lambda instead and scope it close.

Remove the previous work-around (#undef at end of TU).

Pick-to: 6.5
Change-Id: I0bd7cd41b89a6f32144d2040ff2b4a18d0045d21
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2023-05-11 12:47:53 +02:00
Bartlomiej Moskal
64db65ae90 Android: fix problem with release package for cmake based builds
After 9efaf8bae9 commit there is no
possibility to create release package for cmake based builds.

Added a new cmake variable (QT_ANDROID_DEPLOY_RELEASE) to allow turning
on release build manually.

Task-number: QTBUG-112921
Task-number: QTBUG-108132
Task-number: COIN-882
Pick-to: 6.5
Change-Id: Idf015b4ad3f8cba792aab75a01e1c81225cad4f0
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-05-11 12:47:52 +02:00
Marc Mutz
3c3de181ef QCallableObject: use QtPrivate::CompactStorage
... optimizing the storage of empty function objects.

I thought we had applied this a long time ago, but it turns out that
QPrivateSlotObject (c61d9873e5) is only
for QObjectPrivate::connect()...

This adds the same optimization for regular QObject::connect(). This
is BC, since we don't touch the base class (QSlotObjectBase), and the
QCallableObject subclasses are all-inline or explicitly Q_DECL_HIDDEN.

Amends c61d9873e5.

Change-Id: I63fd1b6f882b58f9f98eae67c636c3615248ad79
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-11 10:38:33 +00:00
Eirik Aavitsland
aaccd50224 Add QBezier methods for computing a quadratic curves approximation
Useful for operating on QPainterPaths with algorithms designed for
quadratic, and not cubic, curves.

Change-Id: I1af2d6e4f2b66ce675cde863f67d65fbf9db7d39
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-05-11 12:38:33 +02:00
Assam Boudjelthia
f1778f34e0 Android: fix QDir::entryInfoList() with content URIs
Correctly return only the fileName portion from
AndroidContentFileEngineIterator::currentFileName(); which
QDirIteratorPrivate::matchesFilters() expects when looking for matches
of the file pattern provided to the QDirIterator.

Fixes: QTBUG-112738
Pick-to: 6.5 6.2 5.15
Change-Id: I98dba2df014b27f33cd7e54fab3ad2de8c7c1750
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2023-05-11 13:38:32 +03:00
Jan Grulich
4710fb3528 QIconLoader: use system fallback theme as the first fallback option
When searching for an icon, we either use the system theme or the theme
set as a fallback through QPlatformTheme, it's only one or the other.
It can easily happen that the fallback theme we pick as a parent theme
will not fit into the application style (color-wise). For example using
KDE apps on GNOME, where we use "Adwaita" icon theme, we would always
fallback to "Breeze", however, using dark theming, we want to fallback
to "Breeze-dark" and this can be easily set through QPlatformTheme
integration, but it's not going to be used when the system icon theme
is valid and in such case the fallback theme will be ignored.

This change makes the system fallback theme used as the default fallback
by putting it to the list of parent themes.

Pick-to: 6.5 6.2 5.15
Change-Id: I966cd8ddd0e5576e3593d349fe7ee7139136bfdf
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-05-11 10:46:58 +02:00
Joerg Bornemann
adbfdacacc Doc: Don't advertise qt_add_big_resources on qt_add_resources page
Don't refer to qt_add_big_resources as the preferred way of adding big
resources. The qt_add_resources command has support for big resources
these days.

Move the link to add_big_resources to the "see also" part of the page.

Pick-to: 6.5
Change-Id: I030ef079db8ac41417049e58e98eb7aa6fd809e9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-05-11 10:10:16 +02:00
Antti Määttä
3962a27bd8 Tracepointgen: Fix debug print warnings
Pick-to: 6.5
Change-Id: Id6386fd4226024b6bd919b20adc4a5b02c53bc80
Reviewed-by: Hatem ElKharashy <hatem.elkharashy@qt.io>
Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
2023-05-11 11:10:16 +03:00
Marc Mutz
d026fad3d9 QPointer: also make conversion to pointer-to-const work
The QWeakPointer conversion SMFs cannot actually be used for QObject
payloads, as, for unknown reasons (some comment about vtable this
author doesn't understand), conversion goes through QSharedPointer,
the creation of which throws the checkQObjectShared() warning and
yields a nullptr.

We need to continue to use the QWeakPointer(T*, bool) constructor the
QPointer(T*) ctor also uses.

It's high time we dissociated QPointer from QWeakPointer...

Amends 5f28d367d9.

Fixes: QTBUG-112464
Change-Id: I2f93843af3daf02323d77a4259eaa3745d8de3a8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-11 08:10:16 +00:00
Thiago Macieira
8a873c2d6d QDeadlineTimer: avoid a system call for timeout == 0
The constructor's documentation already had the note saying that we
could apply this optimization, but it wasn't there and looks like it
never was. This only applies to the default constructor, which sets t1
to zero, which is the epoch. This could be a problem for an OS whose
monotonic clock starts with negative values, but I don't know such an OS
exists and this hasn't been a problem so far.

This commit doesn't change the behavior of the old-style, non-
std::chrono getters, because we always transform any negative remaining
time to 0. It is only possible to observe it by asking the remaining
time or the deadline using the std::chrono API.

Change-Id: I6f518d59e63249ddbf43fffd175a3fc2911e91fb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 00:28:50 -07:00
Thiago Macieira
ec0e0d1e81 QDeadlineTimer: make it so any negative millisecond count is "forever"
We have quite a few Qt API that assumes this, so making this change
helps transitioning them to QDeadlineTimer.

[ChangeLog][Important Behavior Changes] QDeadlineTimer will now
interpret negative millisecond remaining times as "forever", instead of
only the value -1. This brings the API closer in line with other API
like QMutex. This change does not apply to the nanosecond counts in the
API, nor to the API based on std::chrono.

Change-Id: I6f518d59e63249ddbf43fffd175a3e5bead564ae
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 00:28:49 -07:00
Thiago Macieira
d848e6d87d QDeadlineTimer: use std::chrono::ceil() in setRemainingTime()
In case the time is of less than 1 ns, we want to make sure it remains
non-zero.

Change-Id: I3e3bfef633af4130a03afffd175d9c4903271f80
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-05-11 00:28:49 -07:00
Ievgenii Meshcheriakov
e5ecebef4f QtDBus: Remove unused extern declaration of qDBusInitThreads()
Change-Id: I318ca15d9da9fe9f9a0d68494d0f55061d88987e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-11 09:23:43 +02:00
Tim Blechmann
1269f33d3b animation: use Q_EMIT in private header
qabstractanimation_p.h is pulled in from qmltc generated code, that
users may decide to build with `QT_NO_KEYWORDS`

Change-Id: I6ce1e82b3c68f6b7e1e349b40945a6f398d8baf5
Pick-to: 6.5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-11 15:23:07 +08:00
Qt CI Bot
9da69c7969 Merge integration refs/builds/qtci/dev/1683731304 2023-05-11 07:23:05 +00:00
Tor Arne Vestbø
d3ede38edd Darwin: Cache system locale's zero digit and invalidate on locale changes
As part of ed2b110b6a the implicit caching
of some of the system locale queries was removed, resulting in a
three orders of magnitude performance regression on converting
dates to strings via QLocale::system() on macOS and iOS.

We now cache the most critical of these, the zero digit, in the Darwin
backend, and clear the cache in response to the system locale changing,
restoring the performance two orders of a magnitude closer to that of Qt 5.

We're still one order of magnitude off, which seems to stem from the
auto release pool in QSystemLocale::query().

Fixes: QTBUG-104785
Pick-to: 6.5 6.2
Change-Id: I26f96147d430f08a721c55a1048d586a4af3a76c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-05-11 09:23:04 +02:00
Mårten Nordheim
86a0e70d65 QDataBuffer: decrease size on shrink()
Having the size potentially be larger than the capacity can't
be considered anything other than a bug.

Pick-to: 6.5
Change-Id: Id059c0f2c7320f992d897011d7aa944c5cb86058
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-05-10 16:53:13 +02:00
Marc Mutz
ad398b2df6 QStyleSheetStyle: fix unity-build with chunk-size 13
The definition of ceil() as a function-style preprocessor macro
appears to clash with the definiton of QFixed::ceil(), included
later. That's an educated guess, though, because the error is
completely different:

    qstylesheetstyle.cpp:141:19: error: expected unqualified-id before ‘int’
      141 | #define ceil(x) ((int)(x) + ((x) > 0 && (x) != (int)(x)))
          |                   ^~~
    qstylesheetstyle.cpp:141:19: note: in definition of macro ‘ceil’
      141 | #define ceil(x) ((int)(x) + ((x) > 0 && (x) != (int)(x)))
          |                   ^~~
    qstylesheetstyle.cpp:141:19: error: expected ‘)’ before ‘int’
      141 | #define ceil(x) ((int)(x) + ((x) > 0 && (x) != (int)(x)))
          |                  ~^~~
    qstylesheetstyle.cpp:141:19: note: in definition of macro ‘ceil’
      141 | #define ceil(x) ((int)(x) + ((x) > 0 && (x) != (int)(x)))
          |                   ^~~
    qstylesheetstyle.cpp:141:19: error: expected ‘)’ before ‘int’
      141 | #define ceil(x) ((int)(x) + ((x) > 0 && (x) != (int)(x)))
          |                 ~ ^~~
    qstylesheetstyle.cpp:141:19: note: in definition of macro ‘ceil’
      141 | #define ceil(x) ((int)(x) + ((x) > 0 && (x) != (int)(x)))
          |                   ^~~

Fix by #undef'ing at the end of the TU. This is a minimal fix,
suitable for backporting to older branches. A more modern fix will be
forthcoming as a follow-up patch.

Pick-to: 6.5 6.2
Change-Id: I8c1b6c7834e55b2bf28044a78ddf5bb544b23c65
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-10 12:00:28 +02:00
Thiago Macieira
3efefcceba QSlotObjectBase: move the m_ref after m_impl for Qt 7
This moves the padding that exists on 64-bit architectures from between
the two fields to the end of the the structure. In turns, this allows
certain ABIs to reuse the tail padding space of the base class to store
some information. It can only be used if the functor has alignment of 4
or less, but the interesting case is when it's an empty but final
functor.

The pahole report goes from:
struct CallableObject : QSlotObjectBase {
        /* class QSlotObjectBase     <ancestor>; */      /*     0    16 */
        struct FinalFunctor        func;                 /*    16     0 */
        /* XXX last struct has 1 byte of padding */
        /* size: 24, cachelines: 1, members: 2 */
        /* padding: 8 */
        /* paddings: 1, sum paddings: 1 */
} __attribute__((__aligned__(8)));

to (pahole gets very confused by this trick):
struct CallableObject : QSlotObjectBase {
        /* class QSlotObjectBase     <ancestor>; */      /*     0    16 */
        /* XXX last struct has 4 bytes of padding */
        /* XXX 65532 bytes hole, try to pack */
        struct FinalFunctor        func;                 /*    12     0 */
        /* size: 16, cachelines: 1, members: 2 */
        /* padding: 4 */
        /* paddings: 2, sum paddings: 5 */
        /* BRAIN FART ALERT! 16 bytes != 0 (member bytes) + 0 (member bits) + 65532 (byte holes) + 0 (bit holes), diff = -524160 bits */
} __attribute__((__aligned__(8)));

Change-Id: I3e3bfef633af4130a03afffd175d3be98511bae5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-10 01:30:54 -07:00
Volker Hilsheimer
ccd3b28aab Rename QFunctorSlotObject to QCallableObject
After the recent changes we only have a single implementation of
QSlotObjectBase, which can handle free functions, member functions,
functors, and lambdas. Rename it to callable, and explicitly hide
the static implementation function so that it doesn't become a symbol
of static libraries using Qt.

Also rename makeSlotObject to makeCallableObject, and polish coding
style and comments in the qobjectdefs_impl header a bit.

Change-Id: Id19107cedfe9c624f807cd8089beb80e9eb99f50
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-10 10:30:54 +02:00
Volker Hilsheimer
0306247f5a Remove Java iterator APIs for moving back if operator-- is not available
QSet's iterator doesn't have operator--, but the
Q_DECLARE_SEQUENTIAL_ITERATOR macro declared and implemented functions
hasPrevious/previous/peekPrevious/findPrevious for the QSetIterator
anyway, depending on that operator. The resulting code couldn't compile.

Use SFINAE to remove the various "previous" functions from Java-style
iterators if operator--() is not present.

This removes the hasPrevious() API as well, even though it could compile
(as we only check whether the iterator points at constBegin). But since
nothing useful can be done with that information, it's best to remove
that member function as well.

[ChangeLog][Potentially source-incompatible changes] QSetIterator no
longer has a hasPrevious() member function. The underlying iterator
doesn't implement operator--(), so couldn't be moved backwards anyway.

Fixes: QTBUG-113379
Change-Id: I47b0ba384d8fcd127123d8fa509cd89e10ea8c99
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-10 09:49:24 +02:00
Thorbjørn Lund Martsum
8c0153a526 Fix QMenu (+other theme) sizes on Windows multiscreen systems
The reason this worked before is unclear. It could be suspected
that we have made a dpi awareness change or Microsoft changed
the behavior of the OpenThemeData function.

Regardless, we expect the result to match the primary display which
OpenThemeData doesn't do (anymore). Instead it returns a value based on
the hwnd screen (which btw didn't always match the widget) and the cache
system would then re-use that theme also for hwnds on other screens.

The most obvious solution is to use OpenThemeDataForDpi to make sure
we get a theme result matching the primary sceen. Then our correction
of the result by with multiplying
QWindowsStylePrivate::nativeMetricScaleFactor(widget)
works again.

This fix does not only fix QMenu sizes. It fixes the size for all
widgets that use this theme function, which could return near
random results before.

We load this library dynamically since MinGW 11.2.0 won't link with it.

[ChangeLog][QWidgets][QMenu] Fixed menu sizes on Windows systems
with more screens.

Fixes: QTBUG-112911
Pick-to: 6.5
Change-Id: I8fdfde2ef5b2aa407cbc74c85afe2c0b74026cff
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Yuhang Zhao <yuhangzhao@deepin.org>
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
2023-05-10 05:36:09 +02:00
Tor Arne Vestbø
dcff882f30 macOS: Clear event dispatcher interrupt before running NSAlert modal session
If the event dispatcher is interrupted we propagate the interrupt to
lower event loop levels, in case they too need to be interrupted. And
we defer the actual interrupt of the NSApplication to the next time we
process Qt events, to avoid AppKit dropping queued events on the floor.

This logic relies on QCocoaEventDispatcher::processEvents() setting the
interrupt flag to false, which signals that we should not continue to
tear down any further event loops.

Unfortunately, native run loops such as running application modal
sessions, are not driven by QCocoaEventDispatcher::processEvents(),
so we never reset the interrupt, and end up ending the session
immediately.

To work around this we need to explicitly clear the interrupt flag
before starting native modal sessions. This also fixes the issue
seen in QTBUG-111524 with showing native alerts from nested event
loops.

Fixes: QTBUG-112697
Task-number: QTBUG-111524
Pick-to: 6.5 6.5.1
Change-Id: I6aaec97011fd18c4a513c1dde3173b1cc4d50112
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-10 00:20:18 +00:00
Tor Arne Vestbø
e51ff5c493 a11y: Don't add scrollbar container as a11y child if scroll bar is re-parented
If someone has, for unknown reasons, re-parented the scroll bar of a
scroll area to outside the scroll area, we should not blindly add the
parent widget of the scroll bar as an a11y child of the scroll area.

We don't need to explicitly add the scroll bar itself as a child either,
as that will be handled by whoever is the new parent widget, as a normal
scroll bar would.

Fixes: QTBUG-93768
Pick-to: 6.5 6.2
Change-Id: Ib26f31674602e2221311e864ad31bbf141cad8f6
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-05-10 02:20:18 +02:00
Jaishree Vyas
8f6ec8cea2 Clarify module changes in Qt6
Changed Briefs for better understanding

Fixes: QTBUG-109324
Pick-to: 6.5
Change-Id: I15b0c0dc12b1bf96626fb8ea4ad16d04b2b118ca
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2023-05-09 22:36:06 +00:00
Eskil Abrahamsen Blomfeldt
6160ea45b6 Implement API for enabling / disabling OpenType features
Similar to the font-features-settings in CSS, this is a low-level
API that allows you to pass the information to the shaper in order
to enable or disable specific font features by name.

[ChangeLog][QtGui][Text] Added an API to QFont which makes it
possible to enable and disable specific typographic features
in OpenType fonts.

Change-Id: Ib48c678f3b97a5a562b08ae34dc895800c8885c0
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
2023-05-09 23:39:41 +02:00
Marc Mutz
3327fccfd5 QGenericRunnable: use CompactStorage
...optimizing the storage of empty function objects.

Change-Id: I6db7384e1ebb87249d5b93922a6c92f0767cc401
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-09 22:54:06 +02:00
Marc Mutz
b7780b5e5d Long live QtPrivate::CompactStorage<>
This is a generalization of QPrivateSlotObject's FunctionStorage.

Changes from the old API:
- uses a more neutral API (s/func/object/)
- preserves cv-qualifiers and value categories
- preserves constexpr'ness
- adds a disambiguation tag (e.g. for use in a compressed_pair).

The main feature is that it transparently uses the empty base-class
optimization to stow away empty classes without allocating separate
bytes for them.

To be used for the public QSlotObject and QGenericRunnable, at least,
so finally pulled the trigger and made it a separate component.

Change-Id: I9a13bbdd1dcf64aaf5fc7b2d40a60050d61800b6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-09 22:54:05 +02:00
Eike Ziller
9f0b4e18cd QTextMarkdownImporter: Fix performance for non-trivial documents
While parsing the markdown document, each addition of text and
formats was triggering a relayout of the so far existing document,
leading to quadratic behavior and very bad performance for any
non-trivial markdown document.

Guard the changes while parsing with a begin/endEditBlock to
avoid these intermediate updates.

The performance impact can for example be observed with the
markdown editor in Qt Creator (11+).

Pick-to: 6.5
Change-Id: I5f89441ea41bc3c6281b616f0c5528b49b48e432
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2023-05-09 22:30:29 +02:00
Kai Köhne
e21c4be5d6 Unconditionally use Q_NORETURN for qAbort()
The exception for MSVC was probably added due to similar logic in
qlogging.h, but in this case, qAbort never returns also with MSVC.

Change-Id: Ica2155c34d4b32b20af5b1fcb5af35bb3ff6f668
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-05-09 22:30:29 +02:00
Allan Sandfeld Jensen
7b7a01c266 Fix specific overflow in qtextlayout
Adds qAddOverflow and qMulOverflow definitions to QFixed

Fixes: QTBUG-113337
Pick-to: 6.5 6.5.1 6.2 5.15
Change-Id: I13579306defceaccdc0fbb1ec0e9b77c6f8d1af9
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-08 18:29:22 +00:00
Mårten Nordheim
1b736a815b Hsts: match header names case insensitively
Header field names are always considered to be case-insensitive.

Pick-to: 6.5 6.5.1 6.2 5.15
Fixes: QTBUG-113392
Change-Id: Ifb4def4bb7f2ac070416cdc76581a769f1e52b43
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-08 20:28:46 +02:00
Ahmad Samir
5f6600fa26 QMimeProvider: fix a clazy warning
Polymorphic class QMimeXMLProvider is copyable. Potential slicing.
[-Wclazy-copyable-polymorphic].

Change-Id: I1eff1389140ce9426db32a37df89935a7b3db3a5
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2023-05-07 14:30:23 +03:00
Ahmad Samir
8d46cff650 QMimeProvider: de-duplicate some code
Drive-by change: use range-for with a QHash::asKeyValueRange().

Change-Id: I173d28d759bef8f23330338127eeff3018af4a55
Reviewed-by: David Faure <david.faure@kdab.com>
2023-05-07 14:30:11 +03:00
Ahmad Samir
5083900ce3 QMimeProvider: use non-const stack variable for better move semantics
Change-Id: I8e539f9c2a9dc4a8aa388c5640b379326c38f817
Reviewed-by: David Faure <david.faure@kdab.com>
2023-05-07 14:30:02 +03:00
Ahmad Samir
329722a322 QMimeBinaryProvider: manage m_cacheFile with a std::unique_ptr
Change-Id: Ic68772a75c255a3a2880fa49b2456c34e3153493
Reviewed-by: David Faure <david.faure@kdab.com>
2023-05-07 14:29:48 +03:00
Ahmad Samir
9547ef58c7 QMimeDatabase: handle glob-deleteall tags
According to the Freedesktop spec[1], a mimetype that has glob-deleteall
overwrites other glob-pattern definitions for a mimetype if it is in a
higher precedence dir, the default order is (from high to low)
~/.local/share/mime, /usr/local/share/mime, /usr/share/mime. Or if the
XDG_DATA_DIRS env var is set, then it takes precedence. The
QMime*ProviderS in m_providers are constructed/stored in that same
order, high to low).

For QMimeXMLProvider, we can just clear the glob patterns associated
with those mimetypes from the lists/maps. For the QMimeBinaryProvider
however, we can't change the binary (mmap'ed) cache file, instead check
mimetype names against the exclusion list before modifying a
QMimeGlobMatchResult.

[1] https://specifications.freedesktop.org/shared-mime-info-spec/latest/ar01s02.html

This test uses XDG_DATA_DIRS so only viable when USE_XDG_DATA_DIRS is
defined.

Fixes: QTBUG-101755
Pick-to: 6.5
Change-Id: Icadbdf1027155296377c5a6ab3be8e41b6668325
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Faure <david.faure@kdab.com>
2023-05-07 14:29:17 +03:00
Thiago Macieira
a2551c45d4 Move the formatting of <chrono> durations to QDebug & QtTest
[ChangeLog][QtCore][QDebug] Added pretty formatting of C++ <chrono>
durations.

[ChangeLog][QtTest] Added pretty formatting of C++ <chrono> durations
for QCOMPARE expressions.

Change-Id: I3b169860d8bd41e9be6bfffd1757cc087ba957fa
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-06 17:54:23 +00:00
Yuhang Zhao
59f8da17e6 QWizard: Win: fix wrong frame size and title bar size
The frame size is resize border size + padded border size [1], so our
current calculation is not correct, and thus the title bar size is
also wrong.

[1] We also use this calculation in the Windows QPA, and it's also
widely used by many open-source repositories, including Microsoft's
own products.

Change-Id: I5a4c1f91a31a22cade6227131659a6de73bb6808
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-06 06:21:52 +00:00
Thiago Macieira
1373a20f99 QTestEventLoop: don't stop the test fails outside the main thread
This amends commit 115f828ae4
"QTestEventLoop: stop when the test fails" from Qt 6.3 to not attempt to
stop the QTestEventLoop instance if the failure happened outside the
main thread. This is to prevent the QTEL from being created outside the
main thread and thus cause warnings about QObject in addition to and
logged before the real test failure.

[ChangeLog][QtTest][QTestEventLoop] The QTestEventLoop no longer
attempts to exit its event loop if the failure was detected outside the
main thread.

 QWARN  : tst_QMutex::tryLock_non_recursive() QObject: Cannot create children for a parent that is in a different thread.
 (Parent is QCoreApplication(0x7fffffffe710), parent's thread is QThread(0x802e29000), current thread is QThread(0x7fffffffd5a8)
 FAIL!  : tst_QMutex::tryLock_non_recursive() 'timer.elapsed() >= waitTime - systemTimersResolution' returned FALSE. ()

Change-Id: Ieab617d69f3b4b54ab30fffd175b139322a1f02c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-05-05 23:21:52 -07:00
Thiago Macieira
25e13c9079 Q{Plugin,Factory}Loader: downgrade warnings to debug messages
Since we don't have different environment variables for the plugin paths,
users have to set QT_PLUGIN_PATH to where plugins for both Qt 5 and 6
(and future versions) are located. This causes Qt to print warnings that
those couldn't be loaded because the major version mismatches. So don't
print them any more.

QT_DEBUG_PLUGINS and the category logging filter can still be used to
enable them.

Fixes: QTBUG-107459
Pick-to: 6.5
Change-Id: Idd5e1bb52be047d7b4fffffd175318ca1f8017bd
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
2023-05-05 23:21:52 -07:00
L. E. Segovia
6136b92f54 Windows: implement retrieval for missing QScreen metadata
This commit implements the manufacturer, model, and serialNumber
properties of QScreen for the Windows operating system. These were not
available previously because the Display Devices API allows piecemeal
access to the EDID fields, and the GDI API only returns the i-th device
name, e.g. "\\.\DISPLAY1".

Accessing the EDID of a given screen is possible by, given a
WindowsScreenData instance storing the device path, pivoting from
SetupDiOpenDeviceInterfaceW and then extracting the corresponding blob
from the Registry through a key handle retrieved with
SetupDiOpenDevRegKey. This blob can be parsed just like in Linux with
the QEdidParser class. The resulting metadata is applied to
the WindowsScreenData instance.

Additionally, this commit implements support for clone groups by making
getPathInfo return a list of the matching DISPLAYCONFIG_PATH_INFO
instances, and then concatenating the monitorFriendlyDeviceName
and the EDID manufacturer, model and serialNumber properties.

This commit makes the Windows and Direct2D QPA plugins dependent on
setupapi, and extends the QEdidParser class availability condition to
include these platforms.

Pick-to: 6.5
Change-Id: I56886b035a3d15e6f90aad5d797aeda21f99ff74
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2023-05-06 00:09:43 -03:00
Thiago Macieira
fdd0f7f8af QPrinterInfo: fix mismatching types to ternary operator
How did this ever work? Q_GLOBAL_STATIC has been a structure for a long
time, but somehow this doesn't work with my latest changes.

 qprinterinfo.cpp:73:49: error: operands to ‘?:’ have different types ‘QtGlobalStatic::GlobalImpl<{anonymous}::Q_QGS_shared_null>’
 {aka ‘const QtGlobalStatic::Impl<QtGlobalStatic::Holder<{anonymous}::Q_QGS_shared_null, {anonymous}::Q_QGS_shared_null> >’} and ‘QPrinterInfoPrivate*’

Pick-to: 6.5
Change-Id: I6f518d59e63249ddbf43fffd175a264225f0480f
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-05-05 16:17:55 -07:00
Ahmad Samir
bde5eeecaf q20: add C++20 chrono days/weeks/months/years
Change-Id: Ie2a167cbe6672694e15b7810daf7fad3fe0656a1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-05 16:17:54 -07:00
Volker Hilsheimer
3bf5b5f894 Use QSlotObject helpers in functor-cases of QMetaObject::invoke
Add helper that allows us to determine the argument list and return type
of a functor. This triggers a compile time error if the functor has
operator()() overloads (we only support zero-argument call operators, but
there might be const/noexcept variations). Use that helper to declare a
ZeroArgFunctor type which also declares a ReturnType and Arguments alias.

Add a Callable alias that now combines FunctionPointer and ZeroArgFunctor
into a single type that we can then use to merge the specializations of
QMetaObject::invokeMethod.

[ChangeLog][Potentially source-incompatible changes] Using a functor
with several operator() overloads in QMetaObject::invokeMethod now causes
a compile time error. Qt would previously ignore const and noexcept
overloads and always call the mutable version on a copy of the functor.

Change-Id: I3eb62c1128014b729575540deab615469290daeb
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-05 21:45:56 +02:00
Tobias Koenig
2162e0dfc4 Schannel: Add support for import of PKCS12/PFX files
Add the missing functionality to the Schannel backend to
make QSslCertificate::importPkcs12() work on Windows.

[ChangeLog][QtNetwork][QSslCertificate] Add support for
PKCS12 import with Schannel backend.

Change-Id: Ibb501724d0dc78b0507ac8becf4776fbba0a0623
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-05 19:58:36 +02:00
Yuhang Zhao
392b6e657c Windows QPA: remove unused function
Change-Id: I3f029dcd6e49339d3193ecf66e707d7d7afc5e2f
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Timothée Keller <timothee.keller@qt.io>
2023-05-05 17:53:00 +00:00
Tor Arne Vestbø
b5397e1976 macdeployqt: Consider debug libs when looking for module dependencies
Otherwise we will fail to add plugins such as the SQL plugins,
because we think that the Sql module is not in the list of
module dependencies.

Pick-to: 6.5
Change-Id: Ie03d2506e8d86904f51b4198641ad61a6977e592
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-05-05 19:05:09 +02:00
Tor Arne Vestbø
920bcc0946 macdeployqt: Detect debug dylibs, not just debug frameworks
A debug dylib has a binary name like libQt6Core_debug.6.dylib

Pick-to: 6.5
Change-Id: I54a7a7017b880c734777d0738acf46c19689148d
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-05-05 19:05:08 +02:00
Assam Boudjelthia
ac8a39c416 Android: fix content url handling of filenames with spaces
The Android APIs expect the content url filenames to have
percent encoded spaces, so handle that internally, if missing,
under the content file engine.

Fixes: QTBUG-112663
Pick-to: 6.5 6.2 5.15
Change-Id: Ieb2ee41a2587f985b589ca54b88f1cff89992154
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2023-05-05 17:40:46 +03:00
Marc Mutz
b6d5d419cc QObject: simplify ImplFns of Q(Private)SlotObjects
Drag the cast out of each case to before the switch.

DRYs the code.

Pick-to: 6.5
Change-Id: I117cc5d38379a11e9852fba61794fa59dc24a30f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-05 13:53:44 +02:00
Marc Mutz
3c4743c66c Future-proof QGenericRunnableHelper
Collapse the two function pointers into a single one, taking an Op
enum. Add a possible return value (void*) and extra argument (also
void*). The intent is to allow extensions in a BC way,
e.g. cloning. We can't add new function pointers (sizeof changes), so
we need to fold everything into a single function.

Change-Id: Id0f3f74149c61e4e65622aeabfd2fcea3c6d7fb3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-05 13:53:44 +02:00
Piotr Wierciński
fb2fccc534 wasm: Add DOM accessors functions through NativeInterface
Expose document and clientArea emscripten objects through
NativeInterface.
This is required by WebView implementation for wasm platform.

Task-number: QTBUG-75183
Change-Id: I6f2f084a9dbceb80d2186c7395c008f268a91e39
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
2023-05-05 12:27:36 +02:00
Kai Köhne
a1f7fb73c2 Doc: Fix links to QDomDocument::setContent()
Mark the deprecated signature as overload. Otherwise qdoc
does not know which method to link to in case of \l setContent().

Pick-to: 6.5
Change-Id: I48a4cee39cd870c960decf0bc1bb9b6dffcbbd70
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2023-05-05 10:55:27 +01:00
Eskil Abrahamsen Blomfeldt
2bd610ed12 Update download location for Harfbuzz as well
This amends 151287fb51.

qt_attribution.json now has the download link for the
Harfbuzz version used. It was for the wrong version
before, but now it should be correct.

Pick-to: 6.5 6.5.1
Task-number: QTBUG-113352
Change-Id: If79f6a814d909e687c8371aa0948b11b88f3d14b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-05 10:22:05 +02:00
Antti Määttä
fa67cd0334 Use boolean to indicate QTableWidgetItem is header item
QTableWidgetItem uses additional enum flag ItemIsHeaderItem which has
the same numerical value as ItemFlag ItemNeverHasChildren.
This causes conflict since the user can set the latter flag using
the setFlags, while the ItemIsHeaderItem is only used internally
to mark header items.

Remove the additional flag and use boolean instead to fix the conflict.

Pick-to: 6.2 6.5 6.5.1
Fixes: QTBUG-113209
Change-Id: Icff549c7e452d9f84575a524361719204817274e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-05 05:28:19 +00:00
Volker Hilsheimer
2434573f5e QTabBar: don't overshoot when scrolling right
Amends ca15f650a1, after which scrolling
right to fill any gap might have resulted in overshooting to a negative
scrollOffset.

When we scroll right to fit the current tab, then we never want to end
up with a negative scroll, so clamp the result accordingly.

Augment test case accordingly. Since some styles align the tab bar in
the center, replace the calculation of the scroll offset with access to
the private data member (which inverts the sign when compared to the
calculated value).

Task-number: QTBUG-113140
Fixes: QTBUG-113376
Pick-to: 6.5 6.5.1
Change-Id: Ibdc6686b9dbd41b1ae3560e2227fa121d9b20e18
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-05-04 19:58:50 +00:00
Thiago Macieira
275e0e48a9 Deprecate Q_ASSUME
No replacement provided because we didn't agree on how to do it. But the
current implementation is bad (with GCC, at least), so tell people to
stop using it.

[ChangeLog][Deprecations] The Q_ASSUME macro is now deprecated. Do not
use it in new code and consider removing it from existing code.

Change-Id: Idd5e1bb52be047d7b4fffffd175322ee3402756b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-04 16:58:49 -03:00
Thiago Macieira
c98d70ef7b QMutex: remove unused tst_QMutex forward declaration
Commit d4b206b246, which split
QRecursiveMutex from QMutex and thus rewrote a lot of the tests, removed
the friendship, but not the forward-declaration.

Pick-to: 6.5 6.2
Change-Id: I6f518d59e63249ddbf43fffd1759d28f1547ec9f
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-05-04 19:41:48 +00:00
Volker Hilsheimer
6ef5e186a9 Simplify invokeMethod implementations using QSlotObject helpers
Remove duplication for overloads covering member function pointer
or function pointer cases, as those are now covered by the new
QtPrivate::makeSlotObject helper.

Change-Id: Ife1e05416958e40a4759ca06cf7db185031b8a86
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-04 19:40:33 +02:00
Mårten Nordheim
a443b5f2ec Update public suffix list
The removed testdata is no longer valid because their entries were
removed from the list.

Fixes: QTBUG-113339
Pick-to: 6.5 6.5.1
Change-Id: I34bd56394ab3c0ef2f930d5b21c3fe1089262dbd
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2023-05-04 17:40:33 +00:00
Marc Mutz
3fda04644a QRunnable: Extract Method warnNullCallable()
The warning doesn't depend on the template argument, so factor it into
an out-of-line Q_DECL_COLD_FUNCTION. This will automatically mark the
is_null check as [[unlikely]], too.

As a drive-by, use printf-style qWarning() (expands to less code and
doesn't require #include <qdebug.h>).

Change-Id: I9ac2d912eb1d4f3d1d9b41d77700bed6d6850b0a
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2023-05-04 19:40:33 +02:00
Volker Hilsheimer
a43ca591c1 Fix hiding in QComboBox when there is no selection
If there is an effect on the selected item we want to show it,
but if there is no item to highligh we just close the combo.

Fixes: QTBUG-113311
Pick-to: 6.5
Change-Id: I287af75d27e6f6ff969e4706e16cc8c4812129ea
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-04 19:40:32 +02:00
Øystein Heskestad
3dd3268ded Revamp DOM Bookmarks example
Fixes: QTBUG-111974
Pick-to: 6.5
Change-Id: Ia62eaf36f616278e49112884db8aec37e2b1dcc5
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
2023-05-04 17:30:04 +00:00
Allan Sandfeld Jensen
0e7e1c3396 Take move-only functions for the threadpool
We never copy the function so only need it to movable. Moves the
functions to templates using the new QRunnable create version.

[ChangeLog][QtCore][QThreadPool] Methods taking callable functions,
can now take move-only lambdas.

Fixes: QTBUG-112302
Change-Id: I2cb200f0abcf7e0fdbef0457fe2a6176764ad93d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-05-04 15:05:18 +02:00
Ievgenii Meshcheriakov
1403b63a57 QtDBus: Convert QDBusMetaTypeId into namespace
There are no member variables in this private struct, so it can
as well be a namespace.

Change-Id: I397b9680ee70e17d780db9de33ad44a00ac7792a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-04 15:05:17 +02:00
Ievgenii Meshcheriakov
08a37f9cee QtDBus: Use non-textual version of QMetaObject::invokeMethod
Use type-checked version for better run-time performance and
compile-time type checking.

Change-Id: I92c97d162137770bc373e28fa8e4e115ac5533e6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-04 15:05:17 +02:00
Ievgenii Meshcheriakov
6f05e91695 QtDBus: Replace some text-based singnal-slot connections
Use type-checked connections for better run-time
performance and compile-time type checking.

This excludes connections to private slots that are
not trivial to replace.

Change-Id: I97f591dba880f8d09c73565f2b5555524f6ab4a8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-04 15:05:16 +02:00
Edward Welbourne
7d75039482 Make default local time a static const
QDateTimeParser::fromString(), when parsing a date-time, uses the
start of 1900, in local time, as its default date-time. (This is a bad
choice and steadily getting worse.) This turns out to be somewhat
expensive for some client code, so make it a static const so that we
only compute it on the first call, as for getM{in,ax}imum().

The potential downside is that a change to system time zone won't be
reflected in this value. However, any sane parse-format should require
over-writing all fields of this initial value, in any case, so the
issue is less severe for this default value than for the existing
getM{in,ax}imum() statics.

Change-Id: Iacfd827fe76c4e5fbdc5e5b6efefed13bc673af4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-04 14:06:08 +02:00
Edward Welbourne
4c93b9c1d0 Refactor QGregorianCalendar::julianFromParts to return std::optional
It's a private static used to optimize internal use, so we can freely
get rid of its out parameter this way.

Change-Id: Id62612987f10ecbbd9702610fd172286adbfd442
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-04 14:06:07 +02:00
Edward Welbourne
22909abeae Split out a helper function for QLocalTime
Packaged calls to QGregorianCalendar::julianFromParts(), to convert a
struct tm's date fields to a Julian Day number: the tmToJd() function
hopefully makes it clearer what's going on.

Change-Id: Icdbd9d4d915a053ab49dabee645582523ac826c7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-04 14:06:07 +02:00
Alexey Edelev
4fa6cd8cea Normalize paths using std::filesystem::weakly_canonical
std::filesystem::weakly_canonical resolves symbolic links in paths.
This allows syncqt to work with paths that are symbolic links and
real paths.

Fixes: QTBUG-113295
Pick-to: 6.5
Change-Id: Ie7478b4accf279e8abf9f3849d18807cee99f085
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-04 12:53:23 +02:00
Amir Masoud Abdol
a0923d5d3a Resolve symbol ambiguity when building with Unity Build
In unity build, we may get `error: reference to 'detail' is ambiguous`
between the `detail` namespace defined in `qpropertyprivate.h`, and
`qflatmap_p.h`. For now, this causes an issue during the compilation of
`qcalendar.cpp` and it may occur in other places where qflatmap is
included.

Pick-to: 6.5
Task-number: QTBUG-109394
Change-Id: Ie4bbb66543d26a5db58488e924333d98ce0adebf
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-04 12:53:23 +02:00
Marc Mutz
038c1c5978 QString/QByteArray::op>>: don't assume clear() makes the container isNull()
This is something we may want to change at some point, so be explicit
and assign a null container instead of relying on clear().

Add a comment that was present in the QString, but missing in the
QByteArray implementation.

Pick-to: 6.5
Task-number: QTBUG-31283
Task-number: QTBUG-60745
Change-Id: I10d82b8a0c67fff314af526c7b7e0f247c3405fd
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-05-04 12:53:23 +02:00
Eskil Abrahamsen Blomfeldt
151287fb51 Update harfbuzz to version 7.2.0
Pick-to: 6.2 6.5 6.5.1
Fixes: QTBUG-113352
Change-Id: I134f5b49c2ae5bef31edfc5cd87f0ff62d6c18b1
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-04 11:48:29 +02:00