Commit Graph

47278 Commits

Author SHA1 Message Date
Ahmad Samir
3dffd5aa0b QStringList: add indexOf() QString/QStringView/QL1SV overloads
[ChangeLog][QtCore][QStringList] Added indexOf() overloads that take
QString/QStringView/QLatin1StringView, and a Qt::CaseSensitivity
parameter. Prior to this using QStringList::indexOf() called the methods
inherited from the base class.

Task-number: QTBUG-116918
Change-Id: Ibc42130b6509f6ecfe7de0d6be378f226ae61982
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-22 14:37:47 +03:00
Ahmad Samir
a6ad755734 QStringList: add filter(QStringMatcher) overload
Now that users can pass a QStringMatcher to do the matching, change the
existing overload to not use QStringMatcher.

Thanks to Giuseppe D'Angelo for the idea of passing a QStringMatcher to
filter instead of using a magic number to decide whether to use
QStringMatcher or not.

Results of running filter() and filter_stringMatcher, times are in msecs
and this was compiled with gcc -O3:

              Without       With QStringMatcher
list10        0.00022       0.000089
list20        0.00040       0.00014
list30        0.00058       0.00018
list40        0.000770      0.00023
list50        0.00094       0.00027
list70        0.0012        0.00037
list80        0.0014        0.00041
list100       0.0018        0.00050
list300       0.0054        0.0014
list500       0.0091        0.0023
list700       0.012         0.0032
list900       0.016         0.0041
list10000     0.17          0.045

Drive-by change: optimize tst_QStringList::populateList().

[ChangeLog][QtCore][QStringList] Added filter(const QStringMatcher &)
overload, which may be faster for large lists and/or lists with very
long strings.

[ChangeLog][Possible Performance Changes][QtCore][QStringList] Changed
the implementation of filter(QStringView) overload to not use
QStringMatcher by default. Using QStringMatcher adds overhead, so it is
beneficial/faster when searching for a pattern in large lists and/or
lists with long strings, otherwise using plain string comparison is
faster. If using QStringMatcher makes a difference in your code, you can
use the newly added filter(QStringMatcher) overload.

Change-Id: I7bb1262706d673f0ce0d9b7699f03c995ce28677
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-22 14:37:33 +03:00
Thiago Macieira
feb67bbdd2 QStorageInfo/Unix: exclude invalid volumes from mountedVolumes()
Invalid are usually those mounted on a filesystem we can't access:

$ df /run/user/0/gvfs
df: /run/user/0/gvfs: Permission denied
$ ./qstorageinfo /run/user/0/gvfs
Could not get info on /run/user/0/gvfs

df already doesn't include it by default:

$ df | grep -c gvfs
0

But we were:

$./qstorageinfo | sed -n '1p;/gvfs/p'
Filesystem (Type)                        Size  Available BSize  Label   Mounted on
gvfsd-fuse (fuse.gvfsd-fuse)    RW          0          0     0          /run/user/0/gvfs

Note also how this is showing a total size of 0, which is usually the
type of filesystem we exclude. It's actually -1 but got rounded down to
0 when we divided by 1024.

Pick-to: 6.6
Change-Id: I8f3ce163ccc5408cac39fffd178d7e4f9dc13b24
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-10-21 15:21:39 -07:00
Thiago Macieira
39843b65f4 QStorageInfo/Linux: decode the names encoded by udev in-place
This function is only called with the name of a file coming from
QFileInfo::fileName() so it's usually already detached anyway. And if
there's nothing to decode, pass the string through without even
attempting to modify it.

Pick-to: 6.6
Change-Id: I9d43e5b91eb142d6945cfffd1787651437074d35
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-10-21 15:21:30 -07:00
Thiago Macieira
4107e4d8ca QStorageInfo/Linux: avoid parsing /dev/disks/by-label for every entry
Instead, create a (flat) map of the entries that we can seek on while
creating the list of mountedVolumes(). On my machine, that went down
from 14 times to 1.

Pick-to: 6.6
Change-Id: I9d43e5b91eb142d6945cfffd17875458541f28f9
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-10-21 15:21:27 -07:00
Thiago Macieira
3e330a79ec QStorageInfo/Linux: rewrite the label retriever to use device IDs
Instead of the previous realpath() comparison resulting from the symlink
processing. parseMountInfo() was extracting the device number from
/proc, so this information was already readily available.

We must take care of anonymous block devices (major == 0). Certain
filesystems, such as btrfs, always use them, so we must still stat() the
device path to get the real block device.

This implementation assumes that udev only creates entries in the
/dev/disks/by-label directory that are symlinks to real devices, but
that must already be the case because they are in /dev in the first
place. An alternative implementation would be to compare the inode and
host device (st_dev) of the entry, if different /dev entries could have
different labels. I don't think that's possible. But multiple /dev
entries for the same device is definitely possible.

Pick-to: 6.6
Change-Id: I9d43e5b91eb142d6945cfffd1787552af3d09676
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-10-21 15:21:24 -07:00
Thiago Macieira
ddc39eb3a4 QStorageInfo/Linux: fix mountedVolumes() for paths mounted over
This fixes a similar problem as the previous commit. Because Linux
allows one to mount over non-empty paths, it's possible to make
mountpoints unreachable, and yet they will still be present in the
/proc/self/mountinfo listing. Because we have the device ID from the
scan, we can confirm that the mountpoint matches the MountInfo.

 # mkdir -p /tmp/foo/bar
 # mount -t tmpfs /tmp/foo/bar
 # mount -t tmpfs -o size=1M /tmp/foo
 # mkdir /tmp/foo/bar
 $ ./tests/manual/qstorageinfo/qstorageinfo | awk 'NR==1 || /tmp\/foo/'
Filesystem (Type)                        Size  Available BSize  Label                           Mounted on
tmpfs                           RW       1024       1024  4096                                  /tmp/foo

Change-Id: I79e700614d034281bf55fffd178f8b99b10a8b69
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-10-21 15:21:23 -07:00
Thiago Macieira
1cd6c6c69e QStorageInfo/Linux: fix setPath() for paths mounted over
Linux allows admins to mount new filesystems over non-empty paths
(though I managed to do so on FreeBSD and macOS too), so we must find
the most recent mount that applies to this path instead of the longest
matching mountpoint. We do that by scanning the /proc/self/mountinfo
list backwards and thus any matching isParentOf() must be the correct
one.

 # mkdir -p /tmp/foo/bar
 # mount -t tmpfs tmpfs /tmp/foo/bar
 # mount -t tmpfs -o size=1M tmpfs /tmp/foo
 $ ./tests/manual/qstorageinfo/qstorageinfo /tmp/foo/bar
 Filesystem (Type)                  Size  Available BSize  Label                Mounted on
 tmpfs                     RW       1024       1024  4096                       /tmp/foo

But we must guard against an earlier mount still being (somehow)
accessible. We've seen this in the CI, where /run is earlier than / but
still somehow accessible -- I guess this is one or a pair of mount
--move.

An additional benefit is that don't even attempt to compare to the
virtual filesystems mounted by the system early after boot, if what
we're looking for isn't the root.

See next commit for a fix for QStorageInfo::mountedVolumes().

Change-Id: I79e700614d034281bf55fffd178f8befc5e80edb
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-10-21 15:21:21 -07:00
Tor Arne Vestbø
70d7c6a937 Avoid creating child windows twice when already visible
When a child window is made visible without its parent having been
created yet, we defer creating and making the child visible until
the parent is created.

But if a child window is explicitly created, we create the parent
first. And creating the parent will in turn apply visibility to
all children that had their visibility deferred. Which includes
creating the child.

This results in child -> parent -> child creation recursion,
which means that when we return from creating the parent window
we already have a platform window for our child, and should
bail out.

Pick-to: 6.6 6.5
Change-Id: I11dc4864b57f031de2cca70b79cdfc057d4fbd0d
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-10-21 19:23:12 +02:00
Ahmad Samir
341854a4f3 QStringMatcher: add a method that returns a string view of the pattern
The existing pattern() method always returns a QString, which means that
if the matcher was constructed using a QStringView, pattern() would
uncoditionally convert it to a QString.

This is useful to check if a match is exact:
auto pattern = matcher.patternView();
if (pattern.size() == needle.size() && matcher.indexIn(needle) == 0)
    ....

This may be needed for a later change in QStringList::contains();
regardless of that, this change makes sense on its own.

Change-Id: I49018551dd22a8f88cf6b9f878a5166902a26f58
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-21 16:50:16 +03:00
Ahmad Samir
90532e0b01 QFSFileEngine: minor code clarification
Change-Id: I44f30f827cdb8e841a43ac911327286db051a725
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-10-21 16:50:14 +03:00
Ahmad Samir
e8909dcfd0 QSystemError: pass errno when calling stdString()
errno should be queried immediately after a libc function call fails,
calling it later on in QSystemError::stdString() may be too late.

Part of the goal of this, and similar, changes is removing the default
value of the stdString() method's parameter, to signify to users of that
method that errno should be stored ASAP if there is an error.

If there is any intervening code that may call a system/libc function
store errno in a local int var, otherwise use it directly in the
QSystemError::stdString() call, which takes by value.

Task-number: QTBUG-115199
Change-Id: If3f601a023ed0014e260089771220668dad88be8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-10-21 16:50:10 +03:00
Giuseppe D'Angelo
313421a73b Apple event dispatcher: fix a last atomic assignment
Amends 1399b3ccce -- this one just slipped through the cracks.

Change-Id: I72c6c93b85cc609546fbd2af7c9a80f3ac360ee2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-10-21 10:56:11 +00:00
Tasuku Suzuki
85d21cec30 Fix build with -no-feature-abstractbutton
Task-number: QTBUG-117698
Change-Id: I0ff494d680626301267e9d415f7fd161366a3932
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-10-21 01:20:30 +00:00
Eirik Aavitsland
071291a0d4 Update bundled libjpeg-turbo to version 3.0.1
[ChangeLog][Third-Party Code] libjpeg-turbo was updated to version 3.0.1

Fixes: QTBUG-117804
Pick-to: 6.6 6.5 6.2 5.15
Change-Id: Ia6cdb02eb9c590fe024bdf75566976756c6e13c6
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-10-21 02:18:37 +02:00
Thiago Macieira
0cd2158533 qt_safe_poll: round up when converting to milliseconds for poll(2)
When running on operating systems that don't offer modern APIs, we need
to round up to ensure we don't under-sleep and wake up before the timers
actually expire. In most cases, this is not a big deal because we'd go
right back to sleep and then wake up again.

The problem is that this new sleep would be for a duration of 0
milliseconds, so we'd end up busy-waiting until the timers do expire.
It's for less than 1 ms, but it's still power-consuming.

It's also perceptible when someone uses processEvents(), because we
could end up saying we didn't process anything, despite waiting for more
events. Since that violates the guiding rule for processEvents() (don't
ever use it), I don't consider this a big deal.

Fixes: QTBUG-118199
Pick-to: 6.5 6.6
Change-Id: I79e700614d034281bf55fffd178f0611be96bfa7
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-10-20 17:18:37 -07:00
Mårten Nordheim
ef76bd02a6 Remove Qt_6_PRIVATE_API ELF from a symbol used by ~QNetworkDatagram
As in 0f0371c830.

Pick-to: 6.6
Fixes: QTBUG-118229
Change-Id: Ie05c213ceb694413194826e4e119f3fb9ff1f1e8
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-21 02:18:37 +02:00
Christian Ehrlicher
01eb95acf0 QCommonStyle: simplify removeAnimation
Simplify removeAnimation by directly passing the pointer to remove to
the function instead trying to figure them out later on and relying on
QObject::sender().

Change-Id: I9de3a138c60b0da8dd1ab23fe8521798b7f4c13c
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-10-21 01:14:52 +02:00
Christian Ehrlicher
4d9d66d7a8 QCommonStyle: use pmf-style connect
Use pmf-style connect in QCommonStyle and remove the unused function
animationTargets() as a drive-by

Change-Id: I60e361ab00429a95eeab8799743996cea3f1469a
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-10-21 01:14:51 +02:00
Christian Ehrlicher
af5d0b0f0c QStyleSheetStyle: use pmf-style connect
Use pmf-style connect in QStyleSheetStyle. styles subdir is now
old-style connection free.

Change-Id: I926ff308a823212b0512328b96dd6779d6cb30fa
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-10-21 01:14:51 +02:00
Christian Ehrlicher
be8607d5de QFusionStyle: don't use xpm files for standardIcon()/Pixmap()
Don't use pixelated xpm files for SP_TitleBarNormal/Min/CloseButton -
use the high-res icons from QCommonStyle instead.

Task-number: QTBUG-118122
Change-Id: Ie187eac29b75084abf9151a0f6921b1276be1419
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2023-10-21 01:14:51 +02:00
Christian Ehrlicher
e0395cdbf7 QFusionStyle: remove dead code from drawItemText()
The !enabled branch does nothing so it can be safely removed. Also
remove the unneeded documentation since it's a simple reimplementation
from the base class.

Change-Id: Iea6e77ab42b09a30f73ae2f1f671eb4198a31c41
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-21 01:14:51 +02:00
Volker Hilsheimer
f1c2a24255 JNI: clean up QJniEnvironment a bit
Remove superfluous explicit function prototypes in documentation, and
remove the unused QJniScopedLocalRefPrivate specialization of
QScopedPointer<_jobject>.

Change-Id: I6407522746bc9756cdaceea8e0e0a32d0830eeee
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-10-21 00:55:04 +02:00
Volker Hilsheimer
8cf199077f JNI: make converting QJniArray constructors explicit
Amend 80d4d55e25. It should not be
possible to convert a QJniArray<jobject> to e.g. a QJniArray<jstring>,
so SFINAE out any construction that would convert between unconvertible
element types. To prevent the fall-back to constructing from QJniObject,
make those constructors explicit, which they should have been anyway.

Change-Id: I17fd9dfcea425a7bfa34d7bef736bab2be42a536
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-10-21 00:55:03 +02:00
Volker Hilsheimer
66b5803ab9 Adapt QRawFont to use QFont::Tag
Add an overload for fontTable (we can't deprecate the const char *
overload as it will be used for string literals, even if the tag-
overload would work), and use the tag type in the test instead of
QByteArray.

Task-number: QTBUG-117046
Change-Id: I104f11a25e9c453a5d1081b6cf320bdc186b7e80
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-10-20 21:37:15 +02:00
Volker Hilsheimer
19bc5de296 Remove obsolete font tag helpers and \preliminary tag from documentation
Fixes: QTBUG-117046
Change-Id: I7e68298ba1c52bea9bdc2fca0c1f082df76d952e
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-10-20 21:37:11 +02:00
Volker Hilsheimer
61ceff89f7 Replace MAKE_TAG macro with QFont::Tag
Task-number: QTBUG-117046
Change-Id: I26e0af634fed87199bb49d57e3aa3f4e3fea0e39
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-10-20 21:37:02 +02:00
Volker Hilsheimer
eb02561f58 Use QFont::Tag in the Windows font database implementation
Replace the local MAKE_TAG macro definition with QFont::Tag's support
conversions to and from big endian byte ordering.

Also replace the incorrect usage of the big-endian-producing MAKE_TAG
macro in the DirectWrite implementation. The IDWriteFontFace
documentation suggests to use the DWRITE_MAKE_OPENTYPE_TAG macro for
producting the tag, which is equivalent to the LittleEndian
implementation of QFont::Tag::value.

Task-number: QTBUG-117046
Change-Id: I1e522c1c6006b8bcf66110bd74a36a42ed28f7e4
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-10-20 21:36:59 +02:00
Volker Hilsheimer
bde443801f QFont: add a tag type for features and other advanced properties
Instead of overloads and generic string literals with runtime checks,
use a dedicated Tag type for specifying the font feature. The Tag type
can only be instantiated with a string literal of exactly 4 characters
(plus the terminating null)l; longer or shorter literals result in a
compile time error.

Constructing a Tag from any other string type is possible through the
named fromString constructor, in which case we can only check the length
and warn at runtime.

The type's API is almost completely constexpr so that we can use it to
calculate e.g. enum values.

Task-number: QTBUG-117046
Change-Id: I31038c7c6fd2b843a105b032f021e506b0b60822
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-10-20 21:36:52 +02:00
Mårten Nordheim
fa8943640c Schannel: Enable ALPN for some mingw configurations
... by checking if SECBUFFER_APPLICATION_PROTOCOLS is defined.
In this case, we assume that the current environment supports ALPN.
Then we no longer do a blanket block for all mingw configurations.

Pick-to: 6.6
Change-Id: I2eedb813a5bdc3b1a5097053b04aa45d25d175aa
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-10-20 18:08:20 +00:00
Assam Boudjelthia
028a31b505 Android: remove unneeded allowNativeHeapPointerTagging manifest flag
Amends b0907db9eae4b85fcab4fa997428c438d9443ee0.

Pick-to: 6.5 6.6
Task-number: QTBUG-91150
Change-Id: Ic7886a9fc69781e4f21417075516106ccb6c7bf5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-10-20 18:46:29 +03:00
Anton Kudryavtsev
b419b5b65a QString: port replace_helpers to QSpan
to simplify code

Change-Id: I597432b16d36c6f1d9948d83c9e7270bc7ac160e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-20 18:46:28 +03:00
Edward Welbourne
32500a76a0 Rename the JSON Save Game Example to Saving a Game to File
Partly because it also saves to CBOR, but also because our guidelines
say to avoid using "Example" in the title.

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: Id858475a6b0474228cfe8044e188cc763f56e3a8
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-10-20 11:19:48 +02:00
Po-Hao Su
0ec1024ff8 QSortFilterProxyModel: remove duplicate implementations
Since these functions perform the same operation as the base class
QAbstractProxyModel, we can use the counterparts of the basic class
directly to keep the implementation clean.

Change-Id: Ie16a988f5ad25eb202351713e6aee73df266209b
Reviewed-by: David Faure <david.faure@kdab.com>
2023-10-20 10:17:11 +08:00
Thiago Macieira
79ef045ffd Remove Qt_6_PRIVATE_API ELF version from a symbol used by ~QReadWriteLock()
Same problem, and same solution, as in
0f0371c830.

Pick-to: 6.6
Change-Id: I79e700614d034281bf55fffd178f56772b09cf25
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-10-19 21:09:17 +00:00
Marc Mutz
4cc31901ea QCborStreamWriter: use (new) QUtf8::convertFromLatin1() to speed up append(QL1SV)
Use the new function to convert into a QVLA instead of first
converting to a QString and then to a QByteArray. One conversion and
one buffer instead of two each.

Pick-to: 6.6
Change-Id: Ieaa24c8ef325797b5a89e8da0ca4310667c00fa7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-19 22:52:22 +02:00
Axel Spoerl
fd09519bbd QGtk3Theme: define light, midlight, mid, dark and shadow colors
Define color groups used for shading and in order to render specific
inactive texts, e.g. menu item text.

Found-by: Piotr Wierciński <piotr.wiercinski@qt.io>
Pick-to: 6.6 6.5
Change-Id: I736f5aff1ff5379ce3f78b53e547b0b5f552779f
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
2023-10-19 20:21:51 +02:00
Volker Hilsheimer
08bb24dd0a JNI: make QJniArray class use stored JNI environment
Instead of creating a temporary QJniEnvironment for each access to the
array, reuse the one stored in the QJniObject. This is much more
efficient, and also protects against invalid access to the array from
multiple threads.

Change-Id: Id253a51ca64d4b3af333b14ec62ae176e1663604
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-10-19 20:21:51 +02:00
Timur Pocheptsov
113a6b89b8 Make static data-members constexpr
While a minor issue, it's possible to use them in a way requiring
a definition, triggering a linker error. We can either make them
inline or constexpr.

Pick-to: 6.6 6.5
Fixes: QTBUG-118170
Change-Id: Ia3dede91b989b295c3e792691d534648581a27c2
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-10-19 17:06:29 +02:00
Piotr Wierciński
82a9ecb175 wasm: Fix UB in QEventDispatcher
Calling std::mutex::try_lock() when the mutex is already owned by
the thread casuses undefined behavior.

Change-Id: I024ced271cad8a034bebf80b48e31e7e7461c560
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2023-10-19 14:10:37 +00:00
Nikunj Arora
1e7fa7dbe8 androiddeployqt: Copy templates and stdcpp lib in auxillary mode
[ChangeLog][Android][Deployment Changes]  Now the auxillary mode
of androiddeployqt also copies the templates and the stdcpp lib
file without building the APK.

Fixes: QTBUG-115241
Change-Id: I3d4647277e7f62f079c683645443462ef8026948
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2023-10-19 16:32:11 +03:00
Edward Welbourne
e72a898c50 Clarify the behavior of QDateTime around 24-hour transitions
For those that simply repeat or skip a whole calendar day, life is
fairly simple. However, Alaska's 24-hour transition at 15:30 LMT Sitka
(incidentally combined with a change of calendar) is a bit trickier.
Also fix a typo I noticed in passing.

Write tests to determine what the actual behavior is and document
enough to make the actual behavior seem unsurprising once encountered,
without trying to go into all the excruciating details. Naturally, MS
time-zone data lacks the data on the historic transitions involved in
these tests, so MS (when not using ICU's time-zone data) is excluded.
It seems Cupertino believes Alaska was always in the USA, too.

Change-Id: Ia638c04d2ffc3a956a70a2a85badb7bbfdbb791c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-19 14:45:56 +02:00
Edward Welbourne
a49ccc08c3 QDateTime: disambiguate times in a zone transition
Previously, requesting a time that got repeated - on the given date,
due to a fall-back transition - would get one of the two repeats,
giving the caller (no hint that there was a choice and) no way to
select the other. Add a flags parameter that captures the available
ways to resolve such ambiguity or select a suitable time near a gap.

Add such a parameter to relevant QDateTime methods, including
constructors, to enable callers to indicate their preference in the
same way. This replaces DST-hint parameters in various internal
functions, including QTimeZonePrivate's dataForLocalTime(). Adapted
tst_QDateTime to test the new feature.

Adapt to gap-times no longer being invalid (by default; or, when they
are, no longer having a useful toMSecsSinceEpoch() value). Instead,
they don't match what was asked for. Amend documentation to reflect
that. Most of the code change for this is to QDTParser and QDTEdit.

[ChangeLog][QtCore][QDateTime] Added a TransitionResolution parameter
to various QDateTime methods to enable the caller to indicate, when
the indicated datetime falls in a time-zone transition, which side of
the transition to fall or whether to produce an invalid result.

[ChangeLog][QtCore][Possibly Significant Behavior Change] When
QDateTime is instantiated for a combination of date and time that was
skipped, by local time or a time-zone, for example during a
spring-forward DST transition, the result is no longer marked invalid.
Whether the selected nearby date-time is before or after the skipped
interval may have changed on some platforms; unless overridden by an
explicit TransitionResolution, it is now a date-time as long after the
previous day's noon as a naive reading of the requested date and time
would expect. This was the prior behavior at least on Linux.

Fixes: QTBUG-79923
Change-Id: I11d5339abef9e7125c4e0dc95a09a7cd4f169dab
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-19 14:45:56 +02:00
Anton Kudryavtsev
5452972755 QString::remove: use std::move more
Change-Id: I140a55d79661f013d07ab1805b49026e252d01c8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2023-10-19 09:23:37 +00:00
Marc Mutz
546208f0ff QIODevice: mark checkWarnMessage() as Q_DECL_COLD_FUNCTION
It's only called in exceptional circumstances, so the compiler should
optimize it for size, not speed, and paths leading up to calls to this
functions should be automatically marked as [[unlikely]].

Marking the function as cold accomplishes both.

GCC 11 seems to have had this figured out by itself, possibly
backtracking from the unconditional qWarning() in the first line of
the function, but it did have a (very small) effect on Clang 15, so
leave it in, if only as documentation.

Pick-to: 6.6 6.5 6.2
Change-Id: Ie8e9049300825a3aae2f9678a2907ceea0b21d1c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-10-19 05:45:47 +00:00
Mitch Curtis
18152699e4 Increase QTest failure message limit
QPalette specifically has quite a large amount of output (1363
characters) when toString
is called on it. We should make sure that we can fit that in our
failure messages. This patch does that by increasing the limit from
1024 characters to 4096.

Fixes: QTBUG-5903
Fixes: QTBUG-87039
Pick-to: 6.5 6.6
Change-Id: I1dc5078ad05858bb6542c3a06c6b84711af79e4f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-19 10:57:21 +08:00
Mårten Nordheim
478df0ca80 Make QHttpNetworkConnectionPrivate::parseRedirectResponse static
We will use it without holding an instance later. And there's
no reason it is not static already.

Change-Id: I06d455bb2852244c8a4993ea75ceda4e1cb679fb
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-10-18 19:48:54 +02:00
Kai Köhne
bef5d486d5 Doc: Highlight 5 network examples
Pick-to: 6.5 6.6
Task-number: QTBUG-117222
Change-Id: I5d18a1c86201404609cbc58fd127f001cdc32478
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2023-10-18 19:01:45 +02:00
Mikolaj Boc
0607c25f3e Make WASM IDB settings use the fallback mechanism correctly
Change-Id: Ibb65efc0faa5ec6e6c60782747c9295e4fc5ff21
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-10-18 19:01:45 +02:00
Edward Welbourne
37142571ae Update QTZ::transitions() doc to say what the atUtc values mean
Previously, it was left to the caller to guess.

Change-Id: Icc22b8c874046de78e16253cf0cc3ba2f334362b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-18 17:20:14 +01:00
Santhosh Kumar
756857b5d0 Fix tooltip palette issue in gtk3 theme
The tooltip text doesn't show with right palette when application runs
in dark mode using gtk3 theme.

This patchset removes explicitly setting ToolTipText palette in
gtk3theme.

Pick-to: 6.6 6.5
Change-Id: Id90626a377733814c3f32f0bf7e5539097b76dd6
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-10-18 16:26:57 +02:00
Jøger Hansegård
4d11ba66de Fix QNetworkAccessManager hang with low integrity level sandboxing
QNetworkAccessManager may fail to finish with Windows apps that are
running with low integrity level sandboxing.

The root cause is that such applications are not allowed to open ROOT
system certificate store with write privileges. This causes the
CertOpenSystemStore helper function to fail, because it attempts to open
certificate stores with the option of adding or deleting certificates.

We only use the CertOpenSystemStore with the intent of fetching
certificates from the certificate store, so we do not need write access.
The fix for this issue is threfor to open the system certificate store
as read-only by using the lower-level CertOpenStore function.

The CERT_SYSTEM_STORE_CURRENT_USER flag is provided to CertOpenStore to
keep the documented behavior of CertOpenSystemStore, which states "Only
current user certificates are accessible using this method, not the
local machine store."

Fixes: QTBUG-118192
Pick-to: 6.5 6.6
Change-Id: I529b760398f84137a0e95c8088a71b293d302b54
Reviewed-by: Fredrik Orderud <forderud@gmail.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-10-18 16:26:57 +02:00
Nicolas Fella
255f6b67b8 Add missing documentation for QWaylandApplication::seat()
Documentation for the other functions refer to seat(), but that itself
isn't documented

Pick-to: 6.6
Change-Id: I9a628e87153b687b2fa444798de1af74e6251eee
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-10-18 16:18:26 +02:00
Assam Boudjelthia
2e69cb8132 Android: update Android Jar build.gradle file to AGP 8
To allow building and developing from Android Studio and get rid of
warnings.

Change-Id: I5f896a270917120f98eefd2f4aa449714451f994
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2023-10-18 17:18:26 +03:00
Assam Boudjelthia
17ef5be087 Android: remove code path that's never reached in QtLoader
This check for error code is never reached, the error code is
always set to 0 in startApp() and then check for in loadApplication()
while the latter method is only called by
startApp().

Task-number: QTBUG-114593
Task-number: QTBUG-115016
Change-Id: I762009d76567cc1d090fe29048c35220d433dd1d
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2023-10-18 16:54:32 +03:00
Assam Boudjelthia
ac8c27bb1d Android: remove unused member m_optionsMenuIsVisible
The variable m_optionsMenuIsVisible is assigned but never
used.

Task-number: QTBUG-114593
Change-Id: Ie4b61b37f2bc05d8d2a348dcad7487eb8fa1ac00
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2023-10-18 16:54:31 +03:00
Assam Boudjelthia
820cf7fbc8 Android: Cleanup QtInputDelegate reformat and divide into sub methods
Clean the long lines on the code, extract into smaller methods where
appropriate, and some small naming or logic clarifications. Some of the
deeper code might use some simplification but that's for another patch
with better debugging to avoid potential regressions.

Task-number: QTBUG-118077
Task-number: QTBUG-114593
Change-Id: I8964b87727819b4846c51f5fa5febfa8caae4f8d
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2023-10-18 16:54:31 +03:00
Assam Boudjelthia
ac7f22ed0a Android: move input handling from QtActivityDelegate to separate class
To further simplify the code and logic of the delegate, move keyboard
input code to separate class. Make an input delegate available under the
QtActivityDelegate to allow classes like QtNative and the Activity to
access that. For now, it's okay to leave access from QtNative to that,
but for future even that should be simplified and the Activity should be
accessing that directly.

For the case where the QtInputDelegate needs access to
QtActivityDelegate, for now namely updateFullScreen(), a new Listener
is implemented to be implemented under QtActivityDelegate.

Along the way use newer JNI APIs under C++ QtAndroidInput.

Don't make them static methods, so that it can be possible later to
do various keyboard operations to specific activity and not a global
one.

Task-number: QTBUG-114593
Task-number: QTBUG-118077
Change-Id: I110b897f6f16d0ae5f5a645551b4a82e8ad3f2fb
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2023-10-18 16:54:31 +03:00
Volker Hilsheimer
ed2fbed479 JNI: emit warning in debug mode in case of JNI environment conflicts
If a QJniObject method that uses the stored JNIEnv pointer is called
from a different thread than the one the object was created in, then a
FATAL abort of the JNI runtime is likely, but hard to debug (the error
messages from JNI are visible in the logcat log of adb).

In debug mode, compare the stored JNIEnv pointer with the one provided
for the current thread, and emit a critical runtime warning if they do
not match, as this indicates a race condition to the underlying JAVA
object.

Change-Id: Ief578f445bcfab1939ddbe95c6ba796279be9115
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-10-18 15:02:23 +02:00
Volker Hilsheimer
944200b5a9 JNI: Reduce amount of temporary QJniEnvironment instantiations
Almost all operations on a QJniObject require a QJniEnvironment,
including the construction and destruction of a QJniObject. Instead of
instantiating a temporary QJniEnvironment object in each call, store the
one from the constructor in the private, and reuse it.

Pass the stored environment through to other functions needing it, and
add a checkAndClearExceptions() wrapper.

Static class members still need their own QJniEnvironment, but we can
reuse the one we have to get both jclass and jmethodID rather than
creating new QJniEnvironments in several wrappers.

As a drive-by, clean up nullptr usage in the test that failed when
shortcutting isSameObject for the trivial cases.

Change-Id: Ibadbd2be8a0ec9ab62daf285608ee7fe0a3c8852
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-10-18 15:02:22 +02:00
Volker Hilsheimer
b7a7351767 JNI: treat equivalent C++ types as the same JNI types as well
Our signature mapping treats both e.g. bool and jboolean as "Z", and it
is allowed to pass a bool variable as an argument to a function expecting
a jboolean. Except for fields and callMethod return values, where we only
allowed the JNI primitive types.

Fix this by comparing the signatures and size of the type we have with
the JNI types that there are explicit functions for. Cast from and to
the JNI type in both directions to address narrowing (e.g. jboolean is an
unsigned char and converting to bool would be narrowing, even though
both are 8bit types).

This way we can get boolean fields using getField<bool>, and int fields
using getField<int> etc.

Change-Id: I2f1ba855ee01423e79ba999dfb9d86f4b98b1402
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-10-18 15:02:22 +02:00
Volker Hilsheimer
872f7b0b4e JNI: convert to and from JNI types for callObjectMethod as well
While we can probably deprecate this function, with the change of
Q_DECLARE_JNI_CLASS'ed types to be QJniObjects we need to correctly
translate from e.g. jobject to QJniObject.

Amends 62cb5589b3.

Change-Id: Id3c23fc0724e2eff895029b694d418481abcb8e6
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
2023-10-18 15:02:22 +02:00
Mikolaj Boc
322e2a2821 Simplify QWasmIDBSettingsPrivate
Since QWasmIDBSettingsPrivate is only supported on JSPI now, there is
no need to maintain the isReadReady flag anymore. This lets us simplify
the class a lot.

Change-Id: I67322389463af13b5110091a4f8433f08da19925
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-10-18 15:02:22 +02:00
Marc Mutz
381d6210c2 qevent.h: don't include <QPointer>, fwd-declare it
The header uses QPointer in-name-only, so it doesn't need to include
the class' header file. A forward-declaration suffices.

[ChangeLog][Potentially Source-Incompatible Changes] The headers
qevent.h and qfuture.h no longer include the header qpointer.h.

Change-Id: I8d3c3b56f5928a0745a523abf5df3b8106dc15ee
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-10-18 14:41:33 +02:00
Christian Ehrlicher
7398645292 QCommonStyle: misc cleanup
Simplify addIconFiles() by passing an initializer list instead an
c-array + size

Task-number: QTBUG-118122
Change-Id: Id54bbe8436a9106e59b6fede81e31c3065623b4d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-18 06:16:22 +02:00
Christian Ehrlicher
f2c2242c74 SQLite: Update SQLite to v3.43.2
[ChangeLog][Third-Party Code] Updated SQLite to v3.43.2

Pick-to: 5.15 6.2 6.5 6.6
Change-Id: I50ab6d53ada764e1d9390e4d768f4abf0de5652f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-18 06:16:20 +02:00
JiDe Zhang
518c98cea4 Remove unnecessary code in QCursor
Dont't checks before call QCursorData::initialize().
The inside of QCursorData::initialize() already checks initialized.

Change-Id: I4b34218132df9decf7d04dcc31e873daf300ffe6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-10-18 04:15:03 +00:00
Thiago Macieira
c94bed69b7 moveToTrash/Unix: refactor to use openat()/mkdirat()/renameat()
This ensures much better security against race conditions and attacks,
at the expense of a few more system calls.

On first run (when no trash dir is yet present):

  openat(AT_FDCWD, "/home/tjmaciei/.qttest/share/Trash", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory)
  mkdirat(AT_FDCWD, "/home/tjmaciei/.qttest/share/Trash", 0700) = 0
  openat(AT_FDCWD, "/home/tjmaciei/.qttest/share/Trash", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = 5
  newfstatat(5, "", {st_mode=S_IFDIR|0700, st_size=0, ...}, AT_EMPTY_PATH) = 0
  getuid()                                = 1000
  openat(5, "files", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory)
  mkdirat(5, "files", 0700)               = 0
  openat(5, "files", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = 6
  openat(5, "info", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory)
  mkdirat(5, "info", 0700)                = 0
  openat(5, "info", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = 7
  close(5)                                = 0
  openat(7, "tst_qfile.moveToTrashOpenFile.fjYRxv.trashinfo", O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC, 0666) = 5
  openat(AT_FDCWD, "/usr/share/zoneinfo/UTC", O_RDONLY|O_CLOEXEC) = 8
  newfstatat(8, "", {st_mode=S_IFREG|0644, st_size=114, ...}, AT_EMPTY_PATH) = 0
  newfstatat(8, "", {st_mode=S_IFREG|0644, st_size=114, ...}, AT_EMPTY_PATH) = 0
  read(8, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096) = 114
  lseek(8, -60, SEEK_CUR)                 = 54
  read(8, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096) = 60
  close(8)                                = 0
  write(5, "[Trash Info]\nPath=/home/tjmaciei"..., 103) = 103
  renameat(AT_FDCWD, "/home/tjmaciei/tst_qfile.moveToTrashOpenFile.fjYRxv", 6, "tst_qfile.moveToTrashOpenFile.fjYRxv") = 0
  close(5)                                = 0
  close(6)                                = 0
  close(7)                                = 0

On subsequent runs:

  openat(AT_FDCWD, "/home/tjmaciei/.qttest/share/Trash", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = 5
  newfstatat(5, "", {st_mode=S_IFDIR|0700, st_size=18, ...}, AT_EMPTY_PATH) = 0
  getuid()                                = 1000
  openat(5, "files", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = 6
  openat(5, "info", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = 7
  close(5)                                = 0
  openat(7, "tst_qfile.moveToTrashOpenFile.sPjrcA.trashinfo", O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC, 0666) = 5
  openat(AT_FDCWD, "/usr/share/zoneinfo/UTC", O_RDONLY|O_CLOEXEC) = 8
  newfstatat(8, "", {st_mode=S_IFREG|0644, st_size=114, ...}, AT_EMPTY_PATH) = 0
  newfstatat(8, "", {st_mode=S_IFREG|0644, st_size=114, ...}, AT_EMPTY_PATH) = 0
  read(8, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096) = 114
  lseek(8, -60, SEEK_CUR)                 = 54
  read(8, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096) = 60
  close(8)                                = 0
  write(5, "[Trash Info]\nPath=/home/tjmaciei"..., 103) = 103
  renameat(AT_FDCWD, "/home/tjmaciei/tst_qfile.moveToTrashOpenFile.sPjrcA", 6, "tst_qfile.moveToTrashOpenFile.sPjrcA") = 0
  close(5)                                = 0
  close(6)                                = 0
  close(7)                                = 0

Change-Id: I9d43e5b91eb142d6945cfffd1787117927650dab
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-10-17 19:08:25 -07:00
Thiago Macieira
25b1990784 moveToTrash/Unix: use the file's inode number as collision avoidance
Instead of a sequential and thus predictable counter. This improves the
performance of when you keep creating and trashing the same file base
name. The previous algorithm would try all occurrences from 0 to however
many trashings have happened.

This could have been any random number, but the source file's inode is
"random" enough for us.

strace of the second file's trashing:

openat(AT_FDCWD, "/home/tjmaciei/.qttest/share/Trash/info/tst_qfile.moveToTrashOpenFile.vLwfNe.trashinfo", O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC, 0666) = -1 EEXIST (File exists)
newfstatat(AT_FDCWD, "/home/tjmaciei/tst_qfile.moveToTrashOpenFile.vLwfNe", {st_mode=S_IFREG|0644, st_size=16, ...}, 0) = 0
openat(AT_FDCWD, "/home/tjmaciei/.qttest/share/Trash/info/tst_qfile.moveToTrashOpenFile.vLwfNe-23527891.trashinfo", O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC, 0666) = 4
newfstatat(AT_FDCWD, "/etc/localtime", {st_mode=S_IFREG|0644, st_size=2852, ...}, 0) = 0
write(4, "[Trash Info]\nPath=/home/tjmaciei"..., 103) = 103
renameat2(AT_FDCWD, "/home/tjmaciei/tst_qfile.moveToTrashOpenFile.vLwfNe", AT_FDCWD, "/home/tjmaciei/.qttest/share/Trash/files/tst_qfile.moveToTrashOpenFile.vLwfNe-23527891", RENAME_NOREPLACE) = 0
close(4)                                = 0

Change-Id: I9d43e5b91eb142d6945cfffd1786d73459c2eb3d
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-17 19:08:25 -07:00
Thiago Macieira
77c661b275 moveToTrash/Unix: use lower-level API to write the info file
So we can more easily get any errors from attempting to write the file.
It is possible to get them with QFile, by either doing .flush() or using
QIODevice::Unbuffered, but using the C API is a definite sure way. Plus,
since this is QFileSystemEngine, this avoids the possibility that QFile
may choose to use a different file engine than the native one, for some
reason. And it reduces overhead.

This allows us to more easily detect why the file creation failed and
therefore stop looping if the error wasn't EEXIST. That will avoid an
infinite loop in case the necessary directories exist but aren't
writable.

It's also moved above the renaming, such that the failure to populate
the info file prevents the renaming too. Both operations can have the
same likely errors, ENOSPC and EIO. The likelihood of EIO is very low,
for both; but for ENOSPC it's far more likely for writing the
file. Avoiding the ENOSPC error for the renaming is handled in a later
commit.

Change-Id: I9d43e5b91eb142d6945cfffd1786d417142ac728
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-10-17 19:08:25 -07:00
Thiago Macieira
6359e8b8bd moveToTrash/Unix: avoid creating too many QStorageInfo
QStorageInfo is great, but rather expensive, so this introduces a faster
check by stat()ing the source file and $HOME, to see if they are the
same device, saving us two or three QStorageInfo constructions. That is
a necessary condition: if they aren't the same device, we know rename()
into $HOME/.local/share/Trash will fail.

But it's not a sufficient condition: they need to be the same mount
point and that's something only QStorageInfo will give us. Strictly
speaking, the only way to be sure that you can rename() into the trash
path is to, well, attempt it (as usual, something for a later commit).

Change-Id: I9d43e5b91eb142d6945cfffd1786c474cac25083
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-10-17 19:08:25 -07:00
Thiago Macieira
de24134aa7 moveToTrash/Unix: avoid TOCTOU in creating the unique file name
This is not a security issue because we still use QIODevice::NewOnly
(O_EXCL) and loop again. But because we do so, we don't need to check
for existence with QFile::exists() in the first place.

Pick-to: 6.6
Change-Id: I9d43e5b91eb142d6945cfffd1786c98a39781517
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-10-17 19:08:25 -07:00
Thiago Macieira
1c5575f194 moveToTrash/Unix: trust freeDesktopTrashLocation() to find the directory
Make it receive the QSystemError so it can set the error condition
properly in case the suitable location for this input file can't be
found. This also includes the case when the input file does not exist in
the first place, which I moved into the function because upcoming
commits will imply this check anyway.

Change-Id: I9d43e5b91eb142d6945cfffd1786c6e59d3b0204
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-17 19:08:24 -07:00
Ahmad Samir
ba0b4a1dc8 QGraphicsAnchorLayout: remove a redundant member container
The m_children container isn't used at all, so remove it. Spotted by
Volker Hilsheimer.

Change-Id: I79db1f77c0e4caf8ebab1573a82e07396a6a806b
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2023-10-18 03:05:55 +03:00
Thiago Macieira
dec72d165b QThread/Unix: don't hardcode OSes for PThread cancellation support
Instead, check the macro that we're about to use. This is also done in
qprocess_unix.cpp

Pick-to: 6.5 6.6
Change-Id: I8f3ce163ccc5408cac39fffd178d657b7594d07a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-10-17 23:52:27 +00:00
Ivan Solovev
9e26f1da0b QDateTime: improve docs about invalid vs valid datetime relation
Extract the information about the relation between invalid and valid
datetimes into a snippet, and include it in the documentation of
every relational operator.

Pick-to: 6.6 6.5 6.2 5.15
Change-Id: I61b239647efe928eb0758cfc5649b33ab4d06c7d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-10-17 23:34:22 +02:00
Tor Arne Vestbø
8f2828683e Windows: Don't re-apply application badge if one has not been set
We need to re-apply the application badge when the color scheme changes;
when a task bar button is being created for the fist time; or after Explorer
has crashed and re-started.

But we should only do that if the user has set an application badge
via our APIs. Otherwise we might end up clearing an existing badge
that was set via the native APIs directly.

Fixes: QTBUG-118117
Pick-to: 6.5 6.6
Change-Id: I1f1fecba44c118d4e3f7ef4119139c3ebd23f047
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2023-10-17 23:34:22 +02:00
Wladimir Leuschner
4f51742ee1 Prevent state change of selected LineEdit in QWindowsVistaStyle when hovering
Hovering over a selected LineEdit gives the selected state precedence
over hover state.

Fixes: QTBUG-117606
Pick-to: 6.5 6.6
Change-Id: Ia52ce94443100bf3fb5d83b8dffa2752818ca33d
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
Reviewed-by: Timothée Keller <timothee.keller@qt.io>
2023-10-17 22:44:36 +02:00
Timothée Keller
9a64449cc3 Windows QPA: remove SWP_NOCOPYBITS for plain moves
The SWP_NOCOPYBITS flag helps suppress some jittering during resizes.
At the moment this is called even for plain moves with no window
resizing. Make sure that the window geometry has changed before applying
the SWP_NOCOPYBITS flag

Fixes: QTBUG-115992
Pick-to: 6.6 6.5
Change-Id: Ic0cb32d9eb3b557bf2b2ef5b6ba80d34e27c5c19
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Pavel Dubsky <pavel.dubsky@qt.io>
2023-10-17 22:44:36 +02:00
Jonas Kvinge
1eddd7add0 macdeployqt: Fix codesigning with @loader_path
When the -executable parameter is specified, macdeployqt uses
@loader_path instead of @rpath. This case was not handled in
getBinaryDependencies() used for the code signing.

Fixes: QTBUG-118075
Pick-to: 6.6
Change-Id: Ie1e0d0781305e1849df9ec0d5fb1c3ce6713a62b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-10-17 19:23:42 +00:00
Mate Barany
0345f07dd1 Support body for an HTTP GET request
Add two overloads to QNetworkAccessManager to support GET requests
with body.

Modify QNetworkReplyHttpImpl as well as these requests should not
be cached.

If the request is redirected it is possible that its type changes
from POST/PUT to GET and in this case the message body is deleted.
However, if a GET request has a body it should keep it after it has
been redirected - modify QNetworkReplyHttpImpl to keep the message
body after it has been redirected.

Fixes: QTBUG-112871
Change-Id: Ib01898638ed94238a98291870a5c51d56030868a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2023-10-17 21:23:42 +02:00
Ahmad Samir
1097c21748 QGraphicsAnchorLayout: make a member container const
The m_edges container isn't changed after it's initialized in the
constructor; so make it const.

This amends commit 641bccce2a.

Change-Id: I387eb2562475bc4910700d48f67303b0a5f80ccd
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2023-10-17 22:23:42 +03:00
Ahmad Samir
408799de65 QCoreApplication: use the correct typedef of preRList
`QVFuncList` and `QStartUpFuncList` are identical typdefs
(`QtCleanUpFunction` and `QtStartUpFunction` are identical typedefs):
typedef QList<QtCleanUpFunction> QVFuncList;
typedef QList<QtStartUpFunction> QStartUpFuncList;

So from the compiler's POV QVFuncList and QStartUpFuncList can be used
interchangeably, but from a code reader's POV, this is confusing.

Use IILE to make the local variable const.

This amends commits 9429226524 and
a887891271.

Pick-to: 6.6 6.5 6.2 5.15
Fixes: QTBUG-117242
Change-Id: I67f6af89027fe36a1915e815acd3c9446f7dcd5d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-10-17 19:23:42 +00:00
Anton Kudryavtsev
18367d0a11 qmimeglobpattern: port some methods to QSV
It's private API, so it's safe

Change-Id: Ibf35262117c4ce4a1e548fff814a6e7bea362309
Reviewed-by: David Faure <david.faure@kdab.com>
2023-10-17 19:23:42 +00:00
Mårten Nordheim
8111a7d08f QNetworkInfo[NetworkManager]: Fix double-lookup
Change-Id: Ia44993fa229b223cfa40ed6cf922c4d5cfd3042b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-10-17 21:23:41 +02:00
Mårten Nordheim
14510bac9a Network: Use the new invokeMethod overload
Saves us from having to create a lambda functor object.

Change-Id: I5e790e693b57ae414ac6d6be84f18b76b3e8185c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-10-17 21:23:41 +02:00
Mårten Nordheim
45a3fa0101 Clean up qnoncontiguousbytedevice.cpp
Mostly applying clang-format and clang-tidy fixits for:
- Redundant code (e.g. bool == true/false)
- Use member initializer list
- std::move for parameters taken by copy

Change-Id: I3b9a7f01db67291f889b42346a95c55ad74f054c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-10-17 21:23:41 +02:00
Mårten Nordheim
3e6b42ae9d compressEvents: limit iteration
Slightly improves performance in the new benchmark

Change-Id: I2d71143ff7bc1f32ebb172f20be1843dec123e6c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2023-10-17 21:23:41 +02:00
Tor Arne Vestbø
422880c9db macOS: Enable Latin key combinations when Command (⌘) modifier is pressed
When the Command key is pressed AppKit seems to do key equivalent
matching using a Latin/Roman interpretation of the current keyboard
layout.

For example, for a Greek layout, pressing Option+Command+C produces a
key event with chars="ç" and unmodchars="ψ", but AppKit still treats
this as a match for a key equivalent of Option+Command+C.

We can't do the same by just applying the modifiers to our key map,
as that too contains "ψ" for the Option+Command combination. What we
can do instead is take advantage of the fact that the Command modifier
layer in all/most keyboard layouts contains a Latin layer. We then
combine that with the modifiers of the event to produce the resulting
"Latin" key combination.

If the unmodified key is outside of Latin1, we also treat that as a
valid key combination, even if AppKit natively does not. For example,
for a Greek layout, we still want to support Option+Command+ψ as a key
combination, as it's unlikely to clash with the Latin key combination
we added above.

However, if the unmodified key is within Latin1, we skip it, to avoid
these types of conflicts. For example, in the same Greek layout, pressing
the key next to Tab will produce a Latin ';' symbol, but we've already
treated that as 'q', thanks to the Command modifier, so we skip the
potential Command+; key combination. This is also in line with what
AppKit natively does.

Fixes: QTBUG-96371
Fixes: QTBUG-79493
Task-number: QTBUG-112736
Change-Id: I30d678c1c7860642d3eed29c7757133ff74c6521
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-10-17 18:51:17 +00:00
Tor Arne Vestbø
98889c2ffc macOS: Filter out and prioritise key combinations that produce the same key
An incoming key event with a set of modifiers can potentially match
a range of key combinations, depending on how the event's modifiers
are combined to produce "intermediate" representations of the event.

For example, given a normal US keyboard layout, the virtual key
23 combined with the Alt (⌥) and Shift (⇧) modifiers, can map
to the following key combinations:

  - Alt+Shift+5 (Fully expressed combination)
  - Alt+% (Shift consumed to produce %)
  - Shift+∞ (Alt consumed to produce ∞)
  - fi (Shift and Alt consumed to produce fi)

But in other cases the intermediate modifier combinations
produce the same key/symbol as other modifier combinations.

For example, pressing  Alt (⌥) and Shift (⇧) with the 'c'
key on a US layout will produce:

  - Alt+Shift+C (Fully expressed combination)
  - Shift+Ç (Alt consumed to produce Ç)
  - Ç (Shift and Alt consumed to produce Ç)

In this case, we don't want to reflect the standalone 'Ç',
as that has already been reflected in the more direct form
via Shift+Ç. Consuming the additional Shift modifier does
not produce any additional symbols.

The same can happen without the number of modifiers being
different, in case two modifiers produce the same symbol.
In this case we want to prioritize Command over Option
over Control over Shift.

There is similar logic in the Windows and XKB key mappers,
and the implementation in the Apple key mapper has been
adapted from the Windows key mapper.

Task-number: QTBUG-67200
Task-number: QTBUG-38137
Change-Id: I4f1aeebac78a5393f8da804b53cf588f7c802c1b
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-10-17 20:51:16 +02:00
Assam Boudjelthia
a1b28bba9d JNI: fix error float argument to 'va_arg' is promotable
If the native method contains a jfloat parameter, I get
the warning/error:
 Second argument to 'va_arg' is of promotable type 'JNITypeForArg<float>'
(aka 'float'); this va_arg has undefined behavior because arguments will
be promoted to 'double'

Change-Id: I8e8ee256b9bea01585b5f70554ba2fc537e2c94d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-17 21:51:16 +03:00
Samuli Piippo
38cc03c9af eglfs: extend configure test for egldevice
Amend 1aba24a2ed and add check for the
EGL_DRM_MASTER_FD_EXT now used as older egl headers might not have it.

Pick-to: 6.6 6.5
Change-Id: I98b860d05396c24b8eb0e73172ac395c89da8628
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Alex Bu <alex.bu@qt.io>
2023-10-17 21:51:16 +03:00
Marc Mutz
5797f29e8c QAtomicScopedValueRollback: fix UB (passing rel/acq_rel to std::atomic::load())
It's explicitly undefined behavior to pass release/acq_rel
memory_order to load(), so don't.

This is private API, so no ChangeLog needed.

Reported-by: Fabian Kosmale <fabian.kosmale@qt.io>
Task-number: QTBUG-115107
Pick-to: 6.6 6.5
Change-Id: Iee119303d790c31937238ef92d900a25020e9713
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-10-17 20:51:16 +02:00
Mårten Nordheim
744e9a69ab SignalDumper: fix UB (data race on ignoreLevel)
... by making it thread_local.

It is written and read by multiple threads at the same time, so it needs
to be protected. Since signal emission start and end happens in a single
thread, keep it thread_local rather than using an atomic.

Pick-to: 6.6 6.5
Change-Id: I98fc5438c512b45f936318be31a6fccbe5b66944
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-10-17 18:51:16 +00:00
Mårten Nordheim
ae0d231c96 SignalDumper: fix UB (data race on indentation level)
... by making it thread_local.

As a natural (and welcome) side-effect, this makes output look sane in
multithreaded scenarios.

As for why it should be thread_local instead of an atomic:
Since signal emissions and slot invocations on one thread are not
necessarily correlated with another thread, they should not affect
one another's indentation level. As in, emitting QIODevice::readyRead
on a background thread should not make QEventLoop::aboutToBlock on the
main thread be indented. The only exception to this is BlockingQueued,
where one thread is directly tied to another (QTBUG-118145). But slot
invocations are anyway not currently printed for Queued connection
(see QTBUG-74099.)

Pick-to: 6.6 6.5
Change-Id: Iea1fc522d37626df14af419a3455a732729edf74
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-10-17 18:51:16 +00:00
Alexey Edelev
2b6270af24 Add the missing QtGui/qtgui-config.h
QT_NO_OPENGL is defined in qtgui-config.h so we should include it before
checking the definition.

Fixes: QTBUG-115446
Pick-to: 6.5 6.6
Change-Id: I29b9d7d89fe4c079ca0cf767a1b1a63cc5621623
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-10-16 19:53:36 +02:00
Mårten Nordheim
13c4e11c49 http2: When a reply is removed from the queue, only remove one
We were using the .remove(Key) API on the map instead of
erase(iterator), so we were removing any reply of the same priority that
had not yet been popped from the queues.

Rewrote to drop loop and only work with iterators.
This issue was there since SPDY days, so not picking all the way back to
5.15, where HTTP2 anyway is not enabled by default.

As a drive-by, drop the #ifndef QT_NO_SSL, which was also there from
SPDY times, which was TLS-only.

Pick-to: 6.6 6.5 6.2
Fixes: QTBUG-116167
Change-Id: Id7e1eb311e009b86054c1fe3d049c760d711a18a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-10-16 19:28:26 +02:00
Volker Hilsheimer
80d4d55e25 JNI: add QJniArray class for easier working with arrays
Implements an iterator API and other standard member access functions
for sequential containers so that we can use ranged-for over an object
that is a jarray. Provides read-only access to individual elements
(which is mostly relevant for arrays of objects), or the entire data()
as a contiguous memory block (which is useful for arrays of primitive
types).

QJniObject call functions can return QJniArray<T> when the return type
is either explicitly QJniArray<T> or T[], or their Qt equivalent (e.g.
a jbyteArray can be taken or returned as a QByteArray). If the return
type is a jarray type, then a QJniObject is returned as before.

Arrays can be created from a Qt container through a constructor or the
generic fromData named constructor in the QJniArrayBase class, which
implements the generic logic.

Not documented as public API yet.

Added a compile-time test to verify that types are mapped correctly.
The function test coverage is added to the QJniObject auto-test, as
that already provides the Java test class with functions taking and
returning arrays of different types.

Change-Id: I0750fc4f4cce7314df3b10e122eafbcfd68297b6
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-10-16 18:43:16 +02:00
Laszlo Agocs
53f9768e64 Sync also the profile env.var between Quick and RHI backingstores
Amends ffb857e9d0.

Pick-to: 6.6 6.5
Task-number: QTBUG-118116
Change-Id: Ifb55130fd66b8ea1446363ae22f11cfe4f4d48bb
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2023-10-16 18:43:16 +02:00
Laszlo Agocs
a031a2507f rhi: d3d12: Reduce include statements
And some of them are not needed at all.

Pick-to: 6.6
Change-Id: Ia4778c7016573eff3eefc2f6838e458008161da6
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2023-10-16 18:43:16 +02:00
Laszlo Agocs
8a175f4ae2 rhi: d3d11: Revive non-flip swapchain model support
Make the QT_D3D_NO_FLIP env.var. have an effect again.

This env.var. has the following effects:

- SwapEffect is set to DXGI_SWAP_EFFECT_DISCARD

- Scaling is set to DXGI_SCALING_STRETCH (no other option with the
  blitting legacy model)

- Alpha works without having to deal with DirectComposition, the dcomp
  code path is therefore skipped completely in legacy mode

- Requesting a HDR mode behaves incorrectly (there's an unwanted
  conversion to SDR or something like that)

- Different window resizing artifacts. Instead of the big black/white
  bars, that is typical with the modern, efficient flip swapchains in
  non-Qt applications as well, there is a bit of shimmering on the
  right side esp. when resizing on the left side. The option of using
  the legacy is model provided mainly for users where this is
  important.

- Reduced performance due the using the old blitting model, although
  that probably won't be visible for many typical Qt applications on
  desktop PCs.

Only for D3D11, because D3D12 does not support non-flip swapchains.

Note: this is incompatible with QT_QPA_DISABLE_REDIRECTION_SURFACE.

The reason to reintroduce this option is to provide a way, even if
just as a developer-focused environment variable, to get a behavior
that is identical to other frameworks and non-Qt applications that
still use D3D11 with the legacy swapchain modes in their rendering
engines. This applies first and foremost to window resizing, where
the visual artifacts common with flip model swapchains may be
misunderstood to be caused by Qt. Having a way to opt-in to the
legacy model allows avoiding/clarifying Apples-to-Oranges
comparisons.

Pick-to: 6.6 6.5
Change-Id: I04e46f71a96fa56cace38703e0e9b93b43bfebc7
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2023-10-16 18:43:16 +02:00
David Faure
d5c427c145 Add missing | operator for QRegularExpression::WildcardConversionOptions
Pick-to: 6.6
Change-Id: I76ed4ee5ef45a279c584e09fbd6d83f1b9127769
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-16 18:43:16 +02:00
Mårten Nordheim
f44e04b14c QNetworkInfo[NetworkManager]: Avoid creating temporary QStrings
Previously we had some inline c-string literals. But since the parameter
for those is const-ref QString it has to actually allocate the storage
and convert the string to UTF-16.

By putting it as a function that returns a QString constructed
with u""_s, we instead create a cheap non-owning QString that just
refers to the string somewhere in memory.

As a drive-by: move other string-literals into functions as well.

Change-Id: I2f2ca5b979cfa772665fa83689837f991b0c656d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-10-16 17:41:21 +02:00
Orkun Tokdemir
4b1d96ea1b Revert "CMake: Update timestamp file for Multi-Config and Cross-Config builds"
Since https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8878 is
reverted, the related change in `qtbase` also should be reverted.

This reverts commit 8041bfba47 and 7a87149c25

Change-Id: Iae42755ffc7b2c97e9cda4c211319df767a421b0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-10-16 17:41:21 +02:00
Thiago Macieira
cad7164ee2 QStorageInfo/Linux: include QDir::Hidden in the search for labels
There's nothing wrong with device labels starting with a dot. Whether
udev would encode those as \x2e is unknown, but we may as well not tempt
fate in case it has changed or changes in the future.

Also including QDir::System in case udev places the actual device nodes
in /dev/disks/by-label instead of a symlink.

As a nice and intentional side-effect, QDirIterator no longer performs a
stat() in each of the entries, removing the double stat'ing that started
happening with the previous commit.

Pick-to: 6.6
Change-Id: I9d43e5b91eb142d6945cfffd1787681b4cf2bb58
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-16 08:41:21 -07:00
Thiago Macieira
df8514a764 QStorageInfo/Linux: simplify the code to deal with skipped entries
In addition to what parseMountInfo() filtered, we also filter entries
with zero total bytes (other than the root filesystem). This avoids
creating yet another QStorageInfoPrivate that may not be used, but most
importantly it avoids calling root() for that check, which would call
parseMountInfo() again.

Pick-to: 6.6
Change-Id: I9d43e5b91eb142d6945cfffd1787538dd3f285d0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-10-16 08:41:21 -07:00
Thiago Macieira
c82ed8b279 QStorageInfo/Linux: avoid parsing /proc/self/mountinfo N+1 times
Mine has 41 lines, of which 22 are returned by parseMountInfo with
filtering. That meant the file was parsed once to get the listing, then
22 times more to create a QStorageInfo for each entry. Now
QStorageInfo::mountedVolumes() opens the file and parses it only once.

Pick-to: 6.6
Change-Id: I9d43e5b91eb142d6945cfffd178752ef6c2122f2
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-10-16 08:41:21 -07:00
Thiago Macieira
9aaf12ebaa Work around GCC 13's bogus "out of bounds" check to QByteArray::_empty
Nothing here is empty and even if anything were, QStringBuilder properly
handles empty strings.

In static member function ‘static void QConcatenable<QByteArrayView>::appendTo(QByteArrayView, char*&)’,
    inlined from ‘static void QConcatenable<QStringBuilder< <template-parameter-1-1>, <template-parameter-1-2> > >::appendTo(const type&, T*&) [with T = char; A = QByteArrayView; B = const char (&)[20]]’ at qstringbuilder.h:398:37,
    inlined from ‘T QStringBuilder< <template-parameter-1-1>, <template-parameter-1-2> >::convertTo() const [with T = QByteArray; A = QByteArrayView; B = const char (&)[20]]’ at qstringbuilder.h:117:54,
    ...
qstringbuilder.h:178:19: error: ‘void* memcpy(void*, const void*, size_t)’ forming offset [1, 5] is out of the bounds [0, 1] of object ‘QByteArray::_empty’ with type ‘const char’ [-Werror=array-bounds=]

QStringBuilder::convertTo() creates the target as
        const qsizetype len = QConcatenable< QStringBuilder<A, B> >::size(*this);
        T s(len, Qt::Uninitialized);

We know len can't be zero because GCC is complaining about a memcpy()
when the offset has been changed from 0, meaning QByteArray was given a
non-zero size and therefore its data pointer is not &QByteArray::_empty.

Fixes: QTBUG-116763
Pick-to: 6.5 6.6
Change-Id: I85599ea5ca7a4b79a8bbfffd178af437984080fb
Reviewed-by: Shawn Rutledge (away) <shawn.rutledge@qt.io>
2023-10-15 18:36:25 -07:00
Thiago Macieira
eedb715ece qTzName: suppress warning that tzname is deprecated with UCRT
Use the pre-existing MSVC code path, which uses UCRT.

warning: 'tzname' is deprecated: Only provided for source compatibility; this variable might not always be accurate when linking to UCRT. [-Wdeprecated-declarations]

Pick-to: 6.6
Change-Id: I8f3ce163ccc5408cac39fffd178dc618f1a8f034
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
2023-10-15 18:36:04 -07:00
Samuel Gaist
c7eac23d96 doc: improve property example slot
The current example shows a minimal implementation. However, neither
this example nor the documentation explains what happens without the
guard. Although it's not mandatory, the large majority of the time
it's a good practice to have it. This patch improves this part.

Change-Id: I411a9d66bd7d8ba16aac87e28b5cab219fd71a5d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2023-10-14 20:19:56 +00:00
Pavel Dubsky
3373247873 Introduce QComObject base class
This base class implementation for COM objects provides IUnknown
interface implementation with reference counting which will allow to
keep all this functionality and implementation in the same place.

Pick-to 6.6 6.5

Change-Id: I8ec597b1040ac33295317e06338ffdcb61b78f85
Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-13 21:29:48 +02:00
Kai Köhne
cb841b449a Doc: Improve documentation for qInstallMessageHandler()
Mention that QtMessageHandler needs to be reentrant,
as well as other caveats. Mention QLoggingCategory,
so people do know that they don't have to necessarily
implement their own handler to filter messages (and that
not all messages reach the handler). Also mention
qFormatLogMessage().

Finally, give a more useful example for a custom
message handler that logs to a file. Note that the example
leaks a file handle at exit, but that is arguably not that
bad.

Pick-to: 6.5 6.6
Change-Id: I5be44167b266c9bbdbb0e94806bb024c9b352a32
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-13 20:39:55 +02:00
Orkun Tokdemir
7a87149c25 CMake: Update timestamp file for multi-Config builds
Since https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8840 is
merged, the timestamp file for {target}_json_file.txt should be updated
for `multi-config` builds too.

A possible error message before this commit when `qt6_extract_metatypes()` is called with a newer
or equal version than `3.28` `CMake` and `Ninja Multi-Config`.

```
ninja: error: 'src/corelib/Core_autogen/timestamp', needed by 'src/corelib/meta_types/Core_json_file_list.txt', missing and no known rule to make it
```

Amends 8042bfba47305352627d910930e52da496904c17

Pick-to: 6.2 6.5 6.6
Change-Id: Ib404bd058d5f4c75501fb714c2ad9608d6852822
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-10-13 19:57:29 +02:00
Mikolaj Boc
1c8b4ac67b Fix problem with queued signals on main thread
Queued signals from main thread were not handled if enqueued on
a different thread. This is because qt_jspi_can_resume_js was
called on a thread (worker), where the Module object does not have
the property used for determining whether JSPI is suspended.

Change-Id: Icbc4dbfcf46c1091eb71b23c7de50760c8a339ae
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-10-13 19:36:34 +02:00
Christian Ehrlicher
262031d364 Fusion style/QProgressBar: fix High-DPI issues
Fix some issues for QProgressBar with fusion style:
 - no progress text was shown in vertical mode
 - the color change for the text was not correct in rtl mode
 - the two rounded rects were not drawn correctly in some modes
Also simplify the code by also using a QTransform for rtl mode and not
only for the vertical mode.

Fixes: QTBUG-117904
Change-Id: I1dd89daf34e8808417750f2ca714252afdab1416
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2023-10-13 18:23:44 +02:00
Mårten Nordheim
fe653b70ae QNetworkInfo[NetworkManager]: Mark invalid if unconnected
On some configs (e.g. using Snap) the NetworkManager service is not
available without some manifest or similar. In this case, the
_interface_ we have is still valid but we can't connect to the
service. So we need to mark the interface as invalid in this case, so
that we can avoid trying to use this plugin.

Pick-to: 6.6 6.5
Fixes: QTBUG-117490
Change-Id: I3c5ebb492f9ca4dfdf4353d77705ba993279eb69
Reviewed-by: Ilya Fedin <fedin-ilja2010@ya.ru>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-10-13 18:00:37 +02:00
Alexandru Croitor
8170e9e85a CMake: Fix Gui package to auto look up IntegrityPlatformGraphics v2
The previous attempt to record a dependency on the
IntegrityPlatformGraphics target for the Gui target was insufficient.

Aside from a qt_find_package(PROVIDED_TARGETS) call, we also need to
use qt_internal_extend_target(Gui PRIVATE IntegrityPlatformGraphics)
to ensure the dependency is written into the Qt6GuiDependencies.cmake
file.

Replace the target_link_libraries call with qt_internal_extend_target,
and remove the qt_find_package all together. A qt_find_package call
in src/gui/configure.cmake already exists, so the one in
CMakeLists.txt is redundant and can be removed.

Finally the
  qt_internal_extend_target(Gui PRIVATE IntegrityPlatformGraphics)
call will also result in a
  target_link_libraries(Gui INTERFACE
  $<LINK_ONLY:IntegrityPlatformGraphics::IntegrityPlatformGraphics>)
because Gui is a static library when building on Integrity, so the
transitive requirement will still be passed along to user projects.

Amends c03eb94c8a
Amends 8116fdde1c

Pick-to: 6.6
Fixes: QTBUG-118051
Task-number: QTBUG-102883
Change-Id: Ic962df94a20071d3f2459e705dbafaca0319a638
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-10-13 18:00:37 +02:00
Luca Di Sera
31eb5e238b Doc: Add missing return type to QDBusReply::value
When QDoc reads an `\fn` command it saves it to a file to parse it with
Clang, with the objective of using the produced AST to perform certain
sanity checks on the documented element.

Generally, `\fn` commands that do not represent correct C++ code are
accepted as long as Clang is still able to build an AST Node that QDoc
can work with, not resulting in any issue in the output documentation.

For example, an `\fn` that doesn't state a return type might be able to
be parsed correctly enough by Clang to produce a sensible Node for the
function that QDoc is interested into.

The documentation for `QDBusReply::value` make
use of this possibility by not stating a return type.

Up to Clang 15 this was not an issue, and a correct-enough AST was
produced when the `\fn` commands for those methods were parsed.

On Clang 16, Clang chokes on the missing return type, being unable to
recognize the function definition and produce an AST that QDoc can work
with.
This has the effect of losing those documented element in the output
documentation.

To avoid the issue, a return type is now added to the relevant `\fn`
commands.

Task-number: QTBUG-111580
Change-Id: Ia70404c7ad548cb1e144bec99943cf72c990bb83
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2023-10-13 18:00:37 +02:00
Luca Di Sera
6e7f7f6f48 Doc: Add missing return type to QRgbaFloat::fromRgba*
When QDoc reads an `\fn` command it saves it to a file to parse it with
Clang, with the objective of using the produced AST to perform certain
sanity checks on the documented element.

Generally, `\fn` commands that do not represent correct C++ code are
accepted as long as Clang is still able to build an AST Node that QDoc
can work with, not resulting in any issue in the output documentation.

For example, an `\fn` that doesn't state a return type might be able to
be parsed correctly enough by Clang to produce a sensible Node for the
function that QDoc is interested into.

The documentation for the various `QRgbaFloat::fromRgba*` make use of
this possibility by not stating a return type.

Up to Clang 15 this was not an issue, and a correct-enough AST was
produced when the `\fn` commands for those methods were parsed.

On Clang 16, Clang chokes on the missing return type, being unable to
recognize the function definition and produce an AST that QDoc can work
with.
This has the effect of losing those documented element in the output
documentation.

To avoid the issue, a return type is now added to the relevant `\fn`
commands.

Task-number: QTBUG-111580
Change-Id: Id9d8a713caf7d6cbb4d2de1040ce5ea5092f7b14
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2023-10-13 18:00:37 +02:00
Anton Kudryavtsev
2dce499561 qtextformat: port while loops to range for
to improve readability

Change-Id: I11b44154d8db35b93a887bb4797af9a985749f24
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-10-13 18:24:01 +03:00
Mitch Curtis
b90b624ce0 QWindowsTheme: only set inactive accent color to Window if not set
Otherwise it incorrectly changes to a white-ish color when the window
becomes inactive, when native apps keep the accent color.

Fixes: QTBUG-116826
Change-Id: I3837e7ca93a494e60dbe5f1b7f8607b3dd16d29e
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-10-13 20:12:27 +08:00
Luca Di Sera
11424b3f51 Doc: Add missing return type to QList/QVarLengthArray::assign
When QDoc reads an `\fn` command it saves it to a file to parse it with
Clang, with the objective of using the produced AST to perform certain
sanity checks on the documented element.

Generally, `\fn` commands that do not represent correct C++ code with are
accepted as long as Clang is still able to build an AST Node that QDoc
can work with, not resulting in any issue in the output documentation.

For example, an `\fn` that doesn't state a return type might be able to
be parsed correctly enough by Clang to produce a sensible Node for the
function that QDoc is interested into.

The documentation for the various overloads for QList::assign and
QVarLenghtArray::assign makes use of this possibility by not stating a
return type.

Up to Clang 15 this was not an issue, and a correct-enough AST was
produced when the `\fn` commands for those methods were parsed.

On Clang 16, Clang chokes on the missing return type, being unable to
recognize the function definition and produce an AST that QDoc can work
with.
This has the effect of losing those documented element in the output
documentation.

To avoid the issue, a return type is now added to the relevant `\fn`
commands.

Change-Id: Ic1434aaf71c39840c64ce04fbd503c4542dc4f42
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2023-10-13 14:12:27 +02:00
Mårten Nordheim
479c2add32 QNonContigByteDeviceThreadForwardImpl: NSDMI
Makes it clearer what members depend on arguments to the ctor. And
what the initial value of all the members are.

Change-Id: Ie1cd2361955053eaf4c4e6887d23ac245738288d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
2023-10-13 11:58:51 +02:00
Mårten Nordheim
5c7c44cf83 Http: don't try to send request on a closed socket
We have code in the protocolHandlers that tries to handle this case, but
if we have an error before we create protocolHandler (read: proxy
complains about something) we will assert in debug, or
deref nullptr in release.

Pick-to: 6.6 6.5 6.2
Change-Id: I4bde9c8af0fa96dc11f77ca4d4b5cb84c31b54fa
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-10-13 06:23:21 +00:00
Ahmad Samir
94a3914d3d QtWidgets: finally Q_FOREACH-free
These source files have been ported away from Q_FOREACH but weren't
blacklisted, so un-blacklist them by removing "#undef QT_NO_FOREACH",
and removing them from NO_PCH_SOURCES.

These are the last remnants of the Q_FOREACH blacklisting in QtWidgets.

Task-number: QTBUG-115803
Change-Id: Ib73d668687f64d39fa48397d75a0f342e525c1ad
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-10-13 00:54:57 +03:00
Ahmad Samir
8ce54407f2 QGestureManager: port Q_FOREACH to ranged-for [6/6]
These two QSetS are local to the function, the loop bodies don't modify
them but they can't be made const due to the way they're filled. So use
std::as_const and ranged-for.

Un-blacklist the file, by removing "#undef QT_NO_FOREACH", and removing
the source file from NO_PCH_SOURCES.

Change-Id: I49b852aa865b0321d3e2f617466557d77143a32b
Task-number: QTBUG-115803
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-10-13 00:54:54 +03:00
Ahmad Samir
2309b38a64 QGestureManager: port Q_FOREACH to ranged-for [5/6]
getGestureTargets() first parameter is a QSet created locally at the
call site in deliverEvents(); and the loop body doesn't change it.

Change-Id: I3484f7ecc9d85b22b45a123ccf75316d5316e031
Task-number: QTBUG-115803
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-10-13 00:54:52 +03:00
Ahmad Samir
cce946b3aa QGestureManager: port FOREACH to ranged-for, local const QSets [4/6]
Those QSetS are local to the function, make them const, proving that the
loop bodies didn't change them, and the copy Q_FOREACH took wasn't
needed.

Task-number: QTBUG-115803
Change-Id: Iec2fc31fc060c59760a84dc45baf8fa16f62eb6d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-10-13 00:54:50 +03:00
Ahmad Samir
a7d9ad9617 QGestureManager: port Q_FOREACH to ranged-for [3/6]
The "conflictedGestures" QHash is local to the function, and the code in
the loop body doesn't change it. The "gestures" QList (the value in the
QHash key/value pair) isn't changed in the loop (both the enclosing
for-loop and the for-loop iterating over the QList itself):
- the QGestureEvent constructor takes by const& so it couldn't have
  changed the QList

So use a const QList& instead of a copy.

Task-number: QTBUG-115803
Change-Id: I4d7f2f833fe0119b9c1ffa91b0cdba9561025382
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-10-13 00:54:48 +03:00
Ahmad Samir
3f94513670 QGestureManager: port to ranged-for [2/6]
The enclosing iterator-based loop: the loop body doesn't modify the
`m_objectGestures` QMap (the original loop was using const_iterators),
so port to ranged-for by using asKeyValueRange().

The foreach loop: the loop body doesn't modify the `gestures` QList, so
a simple port to ranged-for.

Task-number: QTBUG-115803
Change-Id: I92ba7ff6ef878d7e4b7115a8fab87e95a6d93182
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2023-10-13 00:54:45 +03:00
Ahmad Samir
a3a53cdde4 QGestureManager: port Q_FOREACH to ranged-for [1/6]
The loop doesn't modify the QHash while iterating over it, so use
std::as_const.

Drive by change: Use asKeyValueRange() to get a key/value pair:
- No need to allocate a QStringList to hold the keys
- Prevent double lookup which happened when hash.value(key) was used
  inside the loop body

Task-number: QTBUG-115803
Change-Id: Ic0473c0971089f6ca75d3397209fe1c909e975a1
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2023-10-13 00:54:43 +03:00
Ahmad Samir
4bfe6ea251 QWidgetRepaintManager: port Q_FOREACH to ranged-for
The loop body doesn't change the QHash, so use asKeyValueRange() and
ranged-for.

Un-blacklist the file, by removing "#undef QT_NO_FOREACH", and removing
the source file from NO_PCH_SOURCES.

Task-number: QTBUG-115803
Change-Id: I22924d2addeed75867edf9f6cac53f1c6f266dcc
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2023-10-13 00:54:38 +03:00
Marc Mutz
368ea559eb QSpan: add C++23 c{,r}{begin,end}()
It was weird that they were missing. Now that C++23 added them to
std::span, add them to QSpan, too.

Pick-to: 6.6
Change-Id: I4a9b1fdeda66bc7b133c8f7b3b269656e5faffa3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-12 21:38:54 +02:00
Marc Mutz
05888490db QSet: de-pessimize binary operators
Overload the binary QSet operators |, &, + and - for rvalue LHSs, so
chained operations like e.g. in qgesturemanager.cpp:

        QSet<QGesture *> endedGestures =
                finishedGestures + canceledGestures + undeliveredGestures + maybeToCanceledGestures;

become as efficient as chained op+= calls.

Make the operators hidden friends as a drive-by.

[ChangeLog][QtCore][QSet] The binary operators &, |, + and - are now
hidden friends, and chaining them has been made a lot more efficient.

Change-Id: I55d2247b11d088eb1ef88608f89d2bf9e1daeb58
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-12 21:38:54 +02:00
Marc Mutz
4a7c76d4a5 Include what you need: <QPointer>
All these TUs relied on transitive includes of qpointer.h, maybe to a
large extent via qevent.h, though, given that qevent.h is more or less
the only public QtBase header that includes qpointer.h, something else
seems to be at play here.

Said qevent.h actually needs QPointer in-name-only, so a forward
declaration would suffice. Prepare for qevent.h dropping the include.

The algorithm I used was:

If the TU mentions 'passiveGrabbers', the name of the QEvent function
that returns QPointers, and the TU doesn't have qpointer.h included
explicitly, include it. That may produce False Positives, but better
safe than sorry. Otherwise, in src/, add an include to all source and
header files which mention QPointer. Exception: if foo.h of a foo.cpp
already includes it, don't include again.

Task-number: QTBUG-117670
Change-Id: I3321cccdb41ce0ba6d8a709cea92427aba398254
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-10-12 21:38:54 +02:00
Christian Ehrlicher
0b6d2d9187 Widgets/QColumnView: use pmf-style connect in QColumnView
Follow-up patch for 39d486171b - don't
create a temporary container for the connections but add them directly
into the final one.

Task-number: QTBUG-117698
Change-Id: I6ea3b1a5a834f2581f3929cca13c53f47b8c9805
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-10-12 21:01:09 +02:00
Luca Di Sera
42bc1f9d27 Doc: Add missing return type to QPromise::emplaceResult/emplaceResultAt
When QDoc reads an `\fn` command it saves it to a file to parse it with
Clang, with the objective of using the produced AST to perform certain
sanity checks on the documented element.

Generally, `\fn` commands that do not represent correct C++ code are
accepted as long as Clang is still able to build an AST Node that QDoc
can work with, not resulting in any issue in the output documentation.

For example, an `\fn` that doesn't state a return type might be able to
be parsed correctly enough by Clang to produce a sensible Node for the
function that QDoc is interested into.

The documentation for `QPromise::emplaceResult/emplaceResultAt` make
use of this possibility by not stating a return type.

Up to Clang 15 this was not an issue, and a correct-enough AST was
produced when the `\fn` commands for those methods were parsed.

On Clang 16, Clang chokes on the missing return type, being unable to
recognize the function definition and produce an AST that QDoc can work
with.
This has the effect of losing those documented element in the output
documentation.

To avoid the issue, a return type is now added to the relevant `\fn`
commands.

Task-number: QTBUG-111580
Change-Id: I7d41fc52720ff8762bf2cce229969b7250e44754
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2023-10-12 20:24:55 +02:00
Assam Boudjelthia
3b6d288e3b Android: Simplify Qt for Android hierarchy, less Java reflection!
This changes takes Qt for Android Java code away from the Delegate
classes that uses heavily Java reflection to invoke Activity/Service
calls and overrides. So instead of that, now, we have a QtActivityBase
and a QtServiceBase classes which handle the override logic needed for
Qt directly without reflection.

These Base classes extend Android's Activity and Service directly, and
are inside the internal Qt android package (under Qt6Android.jar).

For example, to handle onConfigurationChanged, instead of the current
way where we need this in QtActivityDelegate:

 public void onConfigurationChanged(Configuration configuration)
 {
     try {
         m_super_onConfigurationChanged.invoke(m_activity, configuration);
     } catch (Exception e) {
         e.printStackTrace();
     }
         handleUiModeChange(configuration.uiMode &
Configuration.UI_MODE_NIGHT_MASK);
 }

And then this in QtActivity:

 @Override
 public void onConfigurationChanged(Configuration newConfig)
     {
         if (!QtLoader.invokeDelegate(newConfig).invoked)
             super.onConfigurationChanged(newConfig);
    }
    public void super_onConfigurationChanged(Configuration newConfig)
    {
        super.onConfigurationChanged(newConfig);
    }

And having to keep it's Method handles around and then use Java
reflection
to call the override behavior done by Qt and the superclass methods.

instead of that, we can do it now in QtActivityBase like:

 @Override
 public void onConfigurationChanged(Configuration newConfig)
 {
     super.onConfigurationChanged(newConfig);
     handleUiModeChange(newConfig.uiMode &
Configuration.UI_MODE_NIGHT_MASK);
 }

Then, we would still have our user facing QtActivity class which extends
QtActivityBase and benefit from the same implementation of Qt logic done
in the base class.

An additional benefit to this approach is that now QtActivity will be
very lightweight and doesn't need to have all the boilerplate code as
before.

[ChangeLog][Android] Simplify Qt for Android public bindings
(QActivity, QtService and QtApplication) by implementing base
classes which use the delegate implementions directly and avoid
reflection.

Task-number: QTBUG-115014
Task-number: QTBUG-114593
Change-Id: Ie1eca74f989627be4468786a27e30b16209fc521
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2023-10-12 19:16:47 +03:00
Juha Vuolle
beac5a6d72 QJniObject minor doc typo fix
Change-Id: Ife7ec986fd8033f3fda4b1c53b23f4bc3d3ac97b
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-12 17:12:04 +03:00
Juha Vuolle
6ac6c9452c Android: remove unnecessary static_cast
Change-Id: Id52b6ba74ee203118287745e52e90c5b36b66cc5
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-10-12 17:12:04 +03:00
Juha Vuolle
c0bc0d0643 Android: fix double-freeing of a global references on app exit
The m_activityObject and m_serviceObjects are no longer plain
jobjects. Instead they are constructed with a jobject.
The constructor makes it a global ref, which the destructor
then frees. The destruction happens when the stdlib exit()
is called.

However, since the terminateQt() function already had released the
global ref, the destruction of the objects crashes the
application with a JNI APPLICATION ERROR in Android logs.

In addition since the the code only ever freed the reference to
a reference, the actual reference was leaked.

Change-Id: I6bb637dba2de59e89436685a9d63950d36438fa5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-10-12 17:12:04 +03:00
Assam Boudjelthia
4102db752e Android: extract various constants into one common class
Various constant keys were duplicated in QtActivityDelegate,
QtServiceDelegate and QtLoader classes, and this de-duplicates that.

Task-number: QTBUG-115014
Task-number: QTBUG-114593
Change-Id: I3479fbb58293b26b7625f8653289c6b6d987a59f
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2023-10-12 12:00:01 +03:00
Assam Boudjelthia
d9845e2ac8 Android: Clean QtActivity and QtService from uneccessary overrides
Following the previous change in the chain, this removes override calls
that have no implementation under Qt Delegates, so they can be removed
and
the default behavior would persist.

Task-number: QTBUG-115014
Task-number: QTBUG-114593
Change-Id: Ia7c76e9b56c63cba935cb3d2ae3b6260d3462e51
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2023-10-12 11:59:55 +03:00
Assam Boudjelthia
1da7acd93d Android: remove overrides for uneccessary and deprecated methods
Those overrides are deprecated and will print a warning during Gradle
build, moreover, these calls don't have any implementation by Qt that's
being triggered by the Qt Delegates classes, so they don't need to be
kept in the Activity/Service main classes' implementations.

Task-number: QTBUG-115014
Task-number: QTBUG-114593
Change-Id: If0c241206652c1a52e2396a24ec7ab63236e6308
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2023-10-12 11:59:47 +03:00
Assam Boudjelthia
90b3b17545 Android: remove uneccessary calls to QtNative from QtActivity
These forward calls to QtNative don't need to be present inside the
QtActivity implementation, all those calls are invoked by the Delegate
classes.

Task-number: QTBUG-115014
Task-number: QTBUG-114593
Change-Id: Id1bfa694687af3edc4e9b82b09cf13e1f8eba1de
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2023-10-12 11:59:38 +03:00
Assam Boudjelthia
d1760bc810 Android: Simplify the user facing Java bindings
Move QtLoader classes outside of the bindings package and into
the internal Android Java package (Qt6Android.jar that is), to simplify
Qt for Android project templates. This is because QtLoader classes are
used to trigger Qt libs loading and the users don't need to necessarily
know about it or find it in the project's source files.

The classes in question: QtLoader, QtActivityLoader, and
QtServiceLoader.

Task-number: QTBUG-115014
Task-number: QTBUG-114593
Change-Id: I61f68abf6ee83fc45bc47ed9af7457db4f7deabc
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
2023-10-12 11:59:32 +03:00
Alexandru Croitor
c03eb94c8a CMake: Fix Gui package to auto look up IntegrityPlatformGraphics
When building non-qtbase tqtc repos in CI, we don't load a lot of
Plugin Config files in static builds due to project names having a
tqtc- prefix. This is similar to the issue and workaround that was
done in 4c6292686259e4e232f29cb6fd6c79065e9fa96d for qtserialport.

The specific issue here is the following error:

CMake Error at Qt6Gui/Qt6GuiTargets.cmake:61 (set_target_properties):
  The link interface of target "Qt6::Gui" contains:

    IntegrityPlatformGraphics::IntegrityPlatformGraphics

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Call Stack (most recent call first):
  /home/qt/work/install/target/lib/cmake/Qt6Gui/Qt6GuiConfig.cmake:52
   (include)
  /home/qt/work/install/target/lib/cmake/Qt6/Qt6Config.cmake:157
  (find_package)
  CMakeLists.txt:15 (find_package)

To work around the issue, explicitly record a dependency on the
IntegrityPlatformGraphics target for Gui when building on INTEGRITY.

The underlying issue is sadly still not fixed.

Change-Id: I9a9cff05d036f224aab8083ad6bc8b8e568abd8b
Pick-to: 6.6
Task-number: QTBUG-102883
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
2023-10-12 10:55:28 +02:00
Mitch Curtis
303d991136 Allow QPalettePrivate to be used outside of qpalette.cpp
We need access to bitPosition in order to check if a role was set.

This fixes the following build error:

[...] qwindowstheme.cpp(1150): error C2220: the following warning is treated as an error
[...] qwindowstheme.cpp(1150): warning C4506: no definition for inline function 'QPalette::ResolveMask QPalettePrivate::bitPosition(QPalette::ColorGroup,QPalette::ColorRole)'

Amends 417878904b.

Task-number: QTBUG-116826
Change-Id: I815c7e961198ab93b6ed6132badc2ec693522472
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2023-10-12 15:31:32 +08:00
Christian Ehrlicher
d70b873c37 QSqlDatabase: check if QCoreApplication::instance() exists
Check if QCoreApplication::instance() and print a warning if not instead
creating and assertion later on.

Fixes: QTBUG-117621
Change-Id: Iffb4f7097edbbaf19cb584bff6e5ba1535bf88a0
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-10-12 06:16:46 +02:00
Marc Mutz
9a0ae6c13b QSpan: remove a stale static constexpr extent from a base class
It's not needed, and might trigger -Wshadow on some compilers. Only
the public QSpan class has the `extent` static data member, everything
else uses the template argument, `E`, directly.

Amends f82cf6333e.

Pick-to: 6.6
Change-Id: If378119aff1e352d1e90854b570720444cd532a0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2023-10-12 00:20:32 +02:00
Michael Weghorn
0699ef1301 a11y atspi: Update text-attribute links
The previous ones no longer lead to the
corresponding documentation.

Pick-to: 6.6 6.5
Change-Id: I3f56ad71fa3f936898a25f20f718c7f65a0385a2
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-10-11 22:20:25 +00:00
Anton Kudryavtsev
a83a818791 QTextDocumentPrivate::plainText: simplify code
Use QSV more to avoid manual memcpy
Also port loop to range-based for

Change-Id: I06f4b424853a4b3ee245c66ccc650d87740e2cb8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-10-12 00:44:56 +03:00
Thiago Macieira
0f0371c830 Remove Qt_6_PRIVATE_API ELF version from a symbol used by QFuture::then()
QFuture::then() uses QtPrivate::Continuation::create(), which in turn
uses private API from an inline function:

    f->d.setContinuation(ContinuationWrapper(std::move(continuation)), fi.d);

f->d is QFutureInterfaceBase (a public class), but its setContinuation()
takes QFutureInterfaceBasePrivate by pointer. Our ELF versioning scripts
mark everything that uses that class as private, resulting in:

 4806: 0000000000287d70    365 FUNC    GLOBAL PROTECTED     16 _ZN20QFutureInterfaceBase15setContinuationESt8functionIFvRKS_EEP27QFutureInterfaceBasePrivate@@Qt_6_PRIVATE_API

This commit adds an exception for this symbol, causing it to go back to
the regular "Qt_6" ELF version:

 5629: 00000000003d6a16    366 FUNC    GLOBAL PROTECTED     16 _ZN20QFutureInterfaceBase15setContinuationESt8functionIFvRKS_EEP27QFutureInterfaceBasePrivate@@Qt_6

This solution can probably be cleaned up a bit by moving the marker into
the header files parsed by syncqt, so they follow code motion without
having to remember to update the CMakeLists.txt. That requires some
surgery with syncqt, so not suitable for cherry-picking.

As a drive-by, fix the target_type check
for the _qt_extra_linker_script_content genex property

Fixes: QTBUG-117514
Pick-to: 6.6
Change-Id: I85599ea5ca7a4b79a8bbfffd178b92e73dbe11de
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-10-11 22:06:20 +02:00
Edward Welbourne
29af4b1833 Sort out an anomaly in tst_QDateTime::springForward()
It noted that an unspecified function claimed the offset it was
checking should be +1, while testing it against that or -1. The
function turns out to be QDateTime::addDays(), whose doc did indeed,
misleadingly, say that it lands after a gap it would have hit. It in
fact overshoots the gap in the direction of its change. Amend its
docs, likewise those of addMonths() and addYears(), to reflect the
true behavior.

Amend the test to look at the direction of the step its taking and
anticipate that the adjustment will be in the same direction; then
compare the actual adjustment to that.

Change-Id: I9ab918fac0ab2195ef014983f37fccc435bf0498
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-10-11 22:06:20 +02:00
Edward Welbourne
c23d00078c Let QDateTime::offsetFromUtc() work for invalid date-times
The implementation previously worked for non-short date-times, where
the offset has been remembered since construction. This included the
case of zoned times (and local times more than 2^55 msec away from the
start of 1970) that hit a spring-forward's gap; but excluded local
times that did the same (within 2^55 msec of the epoch).

This precluded an offset check in a spring-forward test, now added.

We can in fact determine the offset whenever we got a valid date and
time (we do so in the course of initializing the object, and when
asked for toMSecsSinceEpoch(), even when invalid), and we should not
use the value of the recorded offset if we didn't get a valid date and
time, so amend to always return 0 if we didn't get valid date and time
and always report the correct offset otherwise.

In the process, amend offsetFromUtc()'s computation to directly
resolve the date-time, rather than doing so via toMSecsSinceEpoch(),
which has to repeat decision-making offsetFromUtc() has already done
by the time it calls it. Also amend toMSecsSinceEpoch() to return 0 if
we didn't have a valid date and time to begin with, so it only
attempts to produce a useful result in the case where construction
attempted to resolve the date-time.

Change-Id: I6574e362275ccc4fbd8de6f0fa875d2e50f3bffe
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-10-11 22:06:19 +02:00
Edward Welbourne
4aba97e062 Adjust msecs instead of offset for spring-forward resolution times
The resolution selects a point in time outside the gap, which will be
represented by toMSecsSinceEpoch()'s return, despite the QDT object's
isValid() returning false. Previously we retained the
originally-calculated msecs, so as to keep date() and time() matching
what was asked for. However, this required adjusting offset, which was
not remembered for local times within 2^55 milliseconds of the start
of 1970. This lead to an inconsistency between the offset from UTC
reported for the resolution for a local time further from the epoch,
or for a time-zone, and the actual offset from UTC at the time
indicated by the return from toMSecsSinceEpoch().

Instead, retain the actually calculated offset (even if we aren't
going to remember it) and adjust the msecs to the value that ensures
toMSecsSinceEpoch() will get the selected resolution. This
incidentally means that, when toMSecsSinceEpoch() has to re-resolve
(for a local time within 2^55 msecs of the epoch), it avoids
revisiting the complications of hitting the gap.

In passing, change internal stateAtMillis() to take the QTimeZone it
is passed by const reference, to save a copy (noticed during debug).
Also tweak a comment in a test to be explicit about a default value.

[ChangeLog][QtCore][Possibly Significant Behavior Change] When
QDateTime is instantiated for a combination of date and time that was
skipped, by local time or a time-zone, for example during a
spring-forward DST transition, the invalid result's time() - and, in
rare cases, date() - no longer match what was asked for. Instead,
these values and offsetFromUtc() now match the point in time
identified by toMSecsSinceEpoch().

Change-Id: Id61c4274b365750f56442a4a598be5c14cfca689
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-10-11 22:06:19 +02:00
Christian Ehrlicher
217c607782 Widgets: pass QWidget pointer to standardIcon/Pixmap() if available
Pass the pointer to the QWidget the icon is painted on to
QStyle::standardIcon/Pixmap().

Change-Id: If9dbc3acb621fb60152f2e12fc0080f354397a99
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-11 21:53:26 +02:00
Christian Ehrlicher
60cff8e9aa Fusion style: misc fix painting vertical slider
The slider handle has a small bug not painting the underlying rectangle
with the correct direction which lead to a small visual glitch only
visible with a high-dpi screen.

Change-Id: Ie75e034b85542228ed7a8372dc7b9a419731630d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-11 21:53:26 +02:00
Santhosh Kumar
a608a7c298 Fix inactive palette in gtk3 theme
In gtk3 theme, the inactive color group had been set with incorrect
palette or not been set for some cases, which leads to glitch when
moving application window. This is because inactive group palettes were
applied during window movement and its expected to be set with correct
palettes.

This patch fixes this issue by setting correct palette for inactive
color group.

Fixes: QTBUG-112879
Pick-to: 6.6 6.5
Change-Id: I6658843626f322fee0ef99dfafb550956e3e0aee
Reviewed-by: Jonas Karlsson <jonas.karlsson@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-10-11 21:53:25 +02:00
Mårten Nordheim
06ed67d05c QNonContigByteDevice: Use PMF-style connect
clang-format and the optimized SIGNAL/SLOT notation are not
good friends.

Change-Id: Id07936b4654e567b59af5a8b1d7baad000484931
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
2023-10-11 20:58:13 +02:00
Tor Arne Vestbø
e44aee9848 Guard QAppleKeyMapper::fromNSString() with iOS define
It's only used from iOS.

Change-Id: I0d653cb76fc27085c74feb5d2628cb1a201ade05
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-11 20:32:05 +02:00
Tor Arne Vestbø
cd4000a97d Use QtGui to match QWindow based shortcuts, even when QApplication is used
If a QShortcut is registered with a QWindow as its parent, but QApplication
is used, we end up in QApplicationPrivate::createShortcutPrivate(), and
create a QtWidgetsShortcutPrivate that implements shortcut context matching
via qWidgetShortcutContextMatcher.

The problem is that qWidgetShortcutContextMatcher expects the windows
to be QWidgetWindows, which meant that plain QWindow based shortcuts
would always fail.

This can happen for example if a QApplication is used in Qt Quick
to provide dialog fallbacks, but QShortcuts are otherwise used
with plain QWindows, or QQuickWindows e.g.

We now defer the check of whether there's an active (widget) window,
and fall back to QtGui's simpleContextMatcher in case we don't find
a QWidget, QAction, or QGraphicsWidget shortcut owner to handle
the matching for.

Note: We don't support shortcut matching for QAction in QtGui,
but this is left for another day. There is also a discrepancy
between how QtGui and QtWidgets handles Qt::ApplicationShortcut.
The former will treat it as a match even if there is no active
QWindow, while the latter requires that there's an active widget
window.

Fixes: QTBUG-116221
Change-Id: I487995f2e660a40f6556828b84a521d81a58f1b6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-11 20:32:05 +02:00
Volker Hilsheimer
7d3417fbfc JNI: Warn if classes are resolved with wrong syntax
Amends 39294317e0, after which class names have to be slash-separated.

Change-Id: I5b8415b711f4deed9b6134eccd3232f299b1ef4d
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2023-10-11 19:32:15 +02:00
Axel Spoerl
c52ada54c5 Export QPalettePrivate
Q_GUI_EXPORT the private header to access it from outside Gui.

Task-number: QTBUG-116826
Pick-to: 6.6
Change-Id: I6aaabe2df7ebebd7b53662f47a52c748344067bc
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2023-10-11 17:54:45 +08:00
Thiago Macieira
964b9d7cd4 qC{Debug,Info,Warning,Critical}: add parentheses around macro argument
Amends ef9fe7a99a and fixes some rare
cases where the macro argument wasn't a single token, such as what was
found in PySide code:

      qCDebug(*category, "%s", %2);

Fixes: QTBUG-117153
Pick-to: 6.5 6.6
Change-Id: I85599ea5ca7a4b79a8bbfffd178a51023648f244
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-10-11 02:01:29 -07:00
Thiago Macieira
a5a288feb3 QStorageInfo/Linux: remove const to enable moving from MountInfo
Amends da95ad91b3. Caught by CodeChecker:

std::move of the const expression has no effect; remove std::move()

I'll instead remove the const.

Pick-to: 6.6
Change-Id: I8f3ce163ccc5408cac39fffd178ccec9fcc38e9c
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-10-11 08:39:43 +00:00
Thiago Macieira
25cc336700 QArrayData: remove contradicting const qualifier from needsDetach()
The documentation above says it's intentionally not const and that's how
I had designed it. It was added by accident on with the noexcept
qualifier on commit c129362b4d ("Add a
couple of noexcept").

Change-Id: I8f3ce163ccc5408cac39fffd178c7fd237c6e079
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-10-11 08:39:43 +00:00
Thiago Macieira
19f54b901f Fix the static_assert for 128-bit integer types
Testing for Standard Library features with compiler version macros was
incorrect. This commit fixes that to check the correct macros. That
fixes the use of Clang-cl / ICX because Microsoft STL doesn't have
support for 128-bit integers (because Microsoft's compiler doesn't) but
Clang does.

Amends 104a0a9ecd.

Fixes: QTBUG-117870
Pick-to: 6.6
Change-Id: I85599ea5ca7a4b79a8bbfffd178b9688e7c1bf42
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-11 08:39:43 +00:00
Tor Arne Vestbø
9ef757ed29 Add verbose debug logging for QKeyMapper::possibleKeys()
Generalized from the logging used in the Apple key mapper.

Change-Id: I61cc120e31b72995071756961d36f6a7fae14553
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-10-11 01:48:16 +02:00
Tor Arne Vestbø
f8f5e2c122 Make QKeyMapper::possibleKeys() return list of QKeyCombinations
Having the explicit type instead of the opaque int makes it clearer
what we're dealing with.

Task-number: QTBUG-116873
Change-Id: I19e42ed329e15ab25a958602ecfb99b1c9d52a99
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-10-11 01:48:13 +02:00
Liang Qi
8af35d27e8 xkb: fix build with libxkbcommon 1.6.0 and later
A few XKB_KEY_dead_* defines got removed from 1.6.0. See also
6073565903/NEWS (L9-L14)
https://gitlab.freedesktop.org/xorg/proto/xorgproto/-/merge_requests/70/diffs?commit_id=cb44799b72f611eb4c9d7cc185bc3b09e070be08

Pick-to: 6.6 6.5 6.2 5.15
Fixes: QTBUG-117950
Change-Id: I55861868f2bb29c553d68365fa9b9b6ed01c9aea
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-10-10 19:29:27 +02:00
Edward Welbourne
c6c0a7bd01 Use actual ± instead of +/- or [+-] in QDateTime docs and comments
Several places already did, and it reads better, so be consistent.

Change-Id: Ic272b2d342cec06ec657c3d0995258b975e0bf87
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-10 18:27:22 +02:00
Edward Welbourne
ffe8932ef3 Make systemTimeZone() and systemTimeZoneId() consistent
It's possible, as was (and still is) documented, at least on Windows,
for the backend to determine the system local time zone's properties
but not its IANA ID. (That involves an update to Windows introducing a
Windows zone ID unknown to the CLDR with whose data Qt was compiled.)
Formerly this lead to systemTimeZoneId() and systemTimeZone().id()
being inconsistent. Furthermore, either in this case or when the
system zone can't be determined, passing the return from
systemTimeZoneId() to the constructor got a valid QTimeZone that did
not faithfully represent the system's local time or the return from
systemTimeZone().

[ChangeLog][QtCore][QTimeZone] When unable to determine the IANA ID of
the system's local time zone, QTimeZone::systemTimeZoneId() now
returns empty instead of the "UTC" it formerly, and misleadingly,
returned. Passing the return to the QTimeZone constructor now
consistently produces the same as calling QTimeZone::systemTimeZone(),
whose id() now matches the return from QTimeZone::systemTimeZoneId().
This is independent of whether QTimeZone::systemTimeZone() is valid.

Change-Id: I55bbe3ea407ca38343a09da353d9336708747bf1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-10 18:27:22 +02:00
Shawn Rutledge
8ef7d2f68d androidjniinput.cpp: const and cleanup
Change-Id: I7af16e970d73a6d05671a78a094e583a9213c1fb
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
2023-10-10 18:27:21 +02:00
Shawn Rutledge
05de22e5f9 Fix hi-dpi mouse and tablet events on Android
Windows are not always fullscreen: e.g. the widget gallery example main
window isn't maximized, and a popup window may open anywhere on the
screen. So we always needed to offset by the window position. But it's
better to use QPlatformWindow::mapFromGlobal() since we are working with
native coordinates here.

Pick-to: 6.2 6.5 6.6
Fixes: QTBUG-109025
Change-Id: Id3d139fad610bbbc67a394599570a309196ae64c
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-10-10 18:27:21 +02:00
Tor Arne Vestbø
097037d2a0 Implement QAppleKeyMapper in terms of QPlatformKeyMapper
Change-Id: Icef9cbe2cbb50c856496d7d9a20784d94d66a079
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-10-10 17:12:13 +02:00
Yuhang Zhao
09953c4332 cmake: use a more appropriate feature guard
The factory cache registration functionality should belong to the
cppwinrt feature, so guard it with appropriate QT_FEATURE_ guard.

Change-Id: Icbadaa7ffb32a4e47fe3bbab90c37303fd787344
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-10-10 21:02:43 +08:00
Arno Rehn
a1e052a291 windeployqt: Don't copy files from unneeded QML modules
Previously, windeployqt would recurse into subdirectories when copying
QML modules, even if those subdirectories were a nested QML module that
was not needed for deployment.
Since most QML modules are nested in the QtQuick and QtQml modules, the
old code effectively always copied *all* QML modules.

This patch adds guards that prevent recursing into subdirectories if
those subdirectories represent QML modules.
These nested modules will still be deployed, but only if referenced from
the QML application (as determined by qmlimportscanner).

Fixes: QTBUG-117459
Pick-to: 6.6
Change-Id: I4c0dfc15956ff40a0e8caec3fa334df10cc92ccd
Reviewed-by: Timothée Keller <timothee.keller@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-10-10 13:19:34 +02:00
Juha Vuolle
3ee57b8387 Handle ACTION_POINTER_UP with tablet events
The ACTION_POINTER_UP is used when a non-primary pointer (touch, mouse
stylus, eraser) goes up. Without handling this action in these
cases, the table event remains in 'down' state (misses the
QEvent::TabletRelease) and as a consequence when it is next put on the
screen, eg. a line will be drawn to the new position (in case of a drawing
application).

In addition use getActionMasked() to get the action; non-masked
events would contain the index of the pointer too, and wouldn't
match with ACTION_POINTER_UP whose numeric value is 6. Rather the
actions would be in the lines of:
261, // ACTION_POINTER_DOWN(1), 6 with getActionMasked()
517, // ACTION_POINTER_DOWN(2), 6 with getActionMasked()
And so on.

Pick-to: 6.6 6.5
Fixes: QTBUG-86297
Change-Id: I1b50ca4d19b611aec8a5c280ed0521e2f11797b0
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-10-10 12:54:02 +02:00
Timothée Keller
614e0f1daa Revert "Windows QPA: Move transient children with a window move"
This reverts commit 530d092eae.

Reason for revert: Moving transient children as a whole is too broad, and forces unrelated windows to have their position completely dependent on a transient parent.

Fixes: QTBUG-117779
Pick-to: 6.6 6.5
Change-Id: I01312e26e95c8144c392eca33aec41f54aaa40b0
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-10-10 10:53:22 +00:00
Anton Kudryavtsev
89615c589a qdatetime: use qsizetype more
Change-Id: Ic44352fd3f64c50e67e743c54e65c0497ac607a3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-10 12:03:02 +03:00
Thiago Macieira
6b363556b8 QByteArray: Remove unnecessary <stdarg.h> header
We don't use va_list and don't have variadic functions in this file.

[ChangeLog][Potentially Source-Incompatible Changes] The header
qbytearray.h no longer includes the header stdarg.h.

Change-Id: I8f3ce163ccc5408cac39fffd178c7fb49d12b739
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-10-10 04:25:42 +00:00
Eirik Aavitsland
888be431da Avoid generating corrupt pdf output for out of range coordinates
The local qreal to string conversion would fail and produce
unsyntactic output if the integer part exceeded the range of an
unsigned int. Introduce check for that, and fall back to just output a
0 value instead in such cases.

Testing indicates that there is no point in supporting values beyond
4G, as pdf readers do not seem to accept higher values anyway.

As a driveby, also extend the check to catch all non-finite real
values, not only nan.

As a second driveby, simplify the splitting of a qreal into integer
and fraction parts by just using the std library function for that.

Fixes: QTBUG-117740
Pick-to: 6.6 6.5
Change-Id: I247b0612bd565fb2e6f47a182e74f19b8bb0d683
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2023-10-10 00:57:11 +02:00
Anton Kudryavtsev
ebf1538fa6 Qt::mightBeRichText: port to QAnyStringView
[ChangeLog][QtGui] Ported Qt::mightBeRichText() to QAnyStringView
(was: QString).

Change-Id: Ib5633ed45cba5f4f1211438397624574f7431908
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-10-09 22:19:24 +00:00
Thiago Macieira
2b7c2c3a71 QString/QByteArray: avoid data() handling _empty in sliced()
.data() in both classes has a null pointer check so it will return non-
null even if the object is storing a null pointer, for compatibility
with Qt 5 (controlled by QT5_NULL_STRINGS). We don't need this in
first()/last()/sliced()/chopped(), so we can skip the test and pass
whatever pointer it is directly to the class constructor. Both of them
handle null pointers creating an isNull() object.

This is a minor performance optimization and interestingly makes these
functions now retain isNull() with the result. I'm not adding test for
that as I don't want to hardcode that they will do so.

Change-Id: Ifeb6206a9fa04424964bfffd17888d14ec8244ec
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-10-09 14:03:12 -07:00
Santhosh Kumar
4cffb3b5fb Fix disabled button color in Linux (X11/Wayland)
The palette mapping table (as read from gtk widget) maintained in
QGtk3Storage misses information of QPalette::Button and
QPalette::ButtonText role for QPalette::Disabled color group. This
cause disabled button widget to be rendered with incorrect palette
(such as in dark color scheme, light palette had been used).

This patch fixes this issue by extending palette mapping in
QGtk3Storage for disabled color group of button role.

Fixes: QTBUG-113486
Pick-to: 6.6.0 6.6 6.5
Change-Id: Ied4b2650c92cc1cda58be69257945991013b276f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-10-09 21:52:07 +02:00
Topi Reinio
dc33b0ca7a Doc: Fix warnings and linking issues
Remove or replace links to examples that were removed or moved under
manual tests.

Replace code snippets that were quoting the now-missing examples.

Fix documentation of QSet::removeIf().

Fix typo in documentation macro: Unknown command '\examplecateogry'.

Add qtopengl, qtshadertools dependencies to Qt Widgets documentation
project to enable correct linking to those topics.

Mark all documentation sets in qtbase as free of warnings.

Pick-to: 6.6 6.5
Change-Id: I058cd5f2063aa933ea310bceff906f05422a7cb2
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2023-10-09 17:24:07 +00:00
Tor Arne Vestbø
64e1744a57 Implement QWindowsKeyMapper in terms of QPlatformKeyMapper
Change-Id: I060ca9613d49bb85a2cf8d4f808b2b5b1c0bdcd5
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2023-10-09 19:24:07 +02:00
Tor Arne Vestbø
d5c867ee29 Implement XCB key mapper in terms of QPlatformKeyMapper
Change-Id: I81af1200b7b1113062d66a76a185a6d15eab0ba9
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-10-09 19:24:07 +02:00
Friedemann Kleint
1ffe7fbff0 Fix documentation of QMetaClassInfo
Mention the modules using it instead of claiming it is not used
in Qt.

Pick-to: 6.6 6.5
Change-Id: I8c9490dfd89444509961c73eeff2f8584e0c5df4
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2023-10-09 17:24:04 +02:00
Antti Määttä
0bbb2f6981 Fix CTF with namespace build
Include moc must be outside the namespace.

Pick-to: 6.6 6.5
Change-Id: Ibdd539b5fdd8ab4aeb0019bcbb62d5702c310065
Reviewed-by: Antti Määttä <antti.maatta@qt.io>
2023-10-09 18:24:04 +03:00
Mårten Nordheim
0fa4af060e QTemporaryFile: Add support for std::filesystem::path
Since it hides QFile's overloads this was not supported for
QTemporaryFile.

[ChangeLog][QtCore][QTemporaryFile] Added support for passing
std::filesystem::path to rename and createNativeFile.

Change-Id: I909ff1d5b9c586824c9901d7dad278dfad09ffc3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-09 16:25:57 +02:00
Tor Arne Vestbø
7d663d2e08 Guard QWindowsContext::instance() during screen change on shutdown
Destructing the QWindowsScreenManager might result in a
WM_DISPLAYCHANGE, at which point our QWindowsContext instance
is likely gone. We need to guard against that.

Fixes: QTBUG-117473
Pick-to: 6.6 6.5
Change-Id: If32941c5c11231f7c27e9dde54f4315f18da1100
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Timothée Keller <timothee.keller@qt.io>
2023-10-09 15:25:54 +02:00
Tor Arne Vestbø
ab99cf6077 QKeySequence::toString(): Treat Modifier+Qt::Key_Unknown as empty string
We were already doing this for a key combination without modifiers,
but now we do the same for e.g. Control+Unknown. This matches the
behavior we have for QKeySequencePrivate::decodeString(), where
we return Qt::Key_Unknown if we can't resolve the key, even if
we have resolved some valid modifiers, e.g. "Meta+Trolls" as in
the tst_QKeySequence::parseString() test.

Change-Id: I238e29276e6ce356ae60c67585739587fa388f07
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-10-09 15:25:54 +02:00
Tor Arne Vestbø
e4994ccfe0 Teach QKeySequencePrivate about QKeyCombination
Being explicit about whether we're dealing with QKeyCombination or
a plain Qt::Key helps understand the code.

Keys are still stored as ints though.

Change-Id: I2cb7bf2c5fabcecbd4dd3e99ba6240fb1910dcc7
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-10-09 15:25:54 +02:00
Tor Arne Vestbø
8850e86981 QKeySequence: Remove unused private helper methods
The functionality is available in QKeySequencepPrivate still, if needed.

Change-Id: Iefa2e5b31a550fd2a419d2aee028ce4c1ddfb7a2
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-10-09 15:25:54 +02:00
Kai Köhne
6e33e3e899 Doc: Highlight some examples for 'User Interface Components' category
Task-number: QTBUG-117243
Pick-to: 6.5 6.6 6.6.0
Change-Id: Ie8e7a07e7bbfd5037ccf6a6477f801ea9ed9e3c4
Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io>
2023-10-09 13:26:17 +02:00
Kai Köhne
bb781bdb2d Doc: Highlight some examples for the "Graphics & Multimedia" category
Task-number: QTBUG-117211
Pick-to: 6.5 6.6 6.6.0
Change-Id: I9ebe20719ad96b0d9ced40745eb6ee09d3e6fb40
Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io>
2023-10-09 11:26:17 +00:00
Kai Köhne
1b5402d229 Doc: Fix link to renamed setIncludesSubDomains() method
Fix capitalization of setIncludesSubDomains(). While a it,
make the links explicit, so that qdoc generates warnings if they fail.

Pick-to: 6.5 6.6
Change-Id: I74542c288083ec58f866a616da32bd40fcb3f40a
Reviewed-by: Andreas Eliasson <andreas.eliasson@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-10-09 12:32:59 +02:00
Yuhang Zhao
d9820b0207 cmake: un-special case clang-cl for runtimeobject
clang-cl can correctly handle runtimeobject.lib for quite some time
already, no need to special case for it anymore.

Change-Id: I87aa98134ad847808b3129c5629ccf8fa1dce253
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-09 13:48:01 +08:00
Ahmad Samir
5522e33128 QMenuBar: compile with QT_NO_FOREACH
The loop doesn't change the member container while iterating over it,
but handleReparent() is called from eventFilter() and changeEvent(), so
take a copy to iterate over.

Task-number: QTBUG-115803
Change-Id: I58ff5bddf99f07a46348b7802432e0899b3170df
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2023-10-08 17:55:01 +03:00
Ahmad Samir
641bccce2a QGraphicsAnchorLayout: compile with QT_NO_FOREACH
The m_edges container isn't changed after it's initialized in the
constructor (in a later commit I'll make this container const, so as to
keep this commit backport-able), and it isn't changed by the loop. Port
all loops over m_edges to ranged-for.

Remove "#undef QT_NO_FOREACH" from the source file, as that was the only
usage of foreach in it. And remove that source file from NO_PCH_SOURCES.

Pick-to: 6.6 6.5
Task-number: QTBUG-115803
Change-Id: I9cfc0c95865cbc7415dbecc82388c64c65ded4be
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2023-10-08 17:54:54 +03:00
Anton Kudryavtsev
4f1bb8ee40 platform plugins: use string view types more
Change-Id: I793cfff1afca6b98a672615e33a19f8210e429dd
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-10-08 11:38:41 +03:00
Ahmad Samir
b358672556 QLocalSocket: port to QDeadlineTimer
Easier logic for such use-cases.

Change-Id: I4ce14bbaeda5441294f33993195396d9f47710dc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-07 21:07:06 +03:00
Ahmad Samir
6ecf43120f QHttpSocketEngine: de-duplicate some code
Change-Id: I4699e3ea0d4687a9772f6f90e6033f5582c1a346
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-07 21:07:06 +03:00
Ahmad Samir
738a5ad4f2 QDateTime: de-duplicate some code
Change-Id: I1c842029c2b597f97418b49c894127ab43dafbf7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-10-07 17:59:17 +03:00
Volker Krause
d25438ebbd Search extra library paths for Android dependency XML files as well
This fixes a regression compared to Qt5. In Qt5 absoluteFilePath()
unconditionally searched for all files in extra prefix dirs and the Qt
install prefix, in particular also the -android-dependencies.xml files.

After the changes in Qt6 up to now however those files are only searched
in the Qt install prefix. This broke external libraries also making
use of the -android-dependencies.xml mechanism, such as some KDE
frameworks.

Pick-to: 6.5 6.6
Change-Id: Ic53aab50c70f853f3b1d621d6de6edb3df223905
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-10-07 09:44:00 +00:00
Thiago Macieira
61d99530c8 moveToTrash/Unix: avoid QFileInfo to get an absolute file name
We know what engine we're using, so don't go the long way around via
QFileInfo and QFSFileEngine to get back to QFileSystemEngine in order to
calculate an absolute and clean path.

Since we're doing that, we may as well use QFileSystemEntry's ability to
give us the file name portion of this absolute path without having to go
via QFileInfo and QDir again. We just need to make sure that a dir name
isn't ending in a slash: absoluteName() would remove that for us, but
only if the entry isn't already absolute and clean.

Change-Id: I9d43e5b91eb142d6945cfffd17871389d359e750
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-06 18:43:30 -07:00
Thiago Macieira
fa97531952 moveToTrash/Unix: reorganize the #ifdef
Change-Id: I9d43e5b91eb142d6945cfffd178708f58b71e7ef
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-06 18:43:29 -07:00
Ahmad Samir
032ffb70a8 QAbstractSocketEngine: port to QDeadlineTimer
qnativesocketengine_win.cpp: don't check if timeout is < 0, because
remainingTimeAsDuration() doesn't return negative values.

All the changes done in one go, not function by function, as that causes
the least churn. You can think of them as a couple of very similar
changes repeated various times.

Drive-by change: replace `forever {` with `for (;;)`

Task-number: QTBUG-113518
Change-Id: Ie9f20031bf0d4ff19e5b2da5034822ba61f9cbc3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-10-07 02:28:12 +03:00
Mårten Nordheim
51c812af07 QHttpThreadDelegate: use new(std::nothrow) instead of try..catch
We usually compile without exceptions, so the try..catch is a noop.
So, if the `new` fails we would crash (or get UB) anyway. Instead
of that, use the nothrow version of `new` and check the result.

Pick-to: 6.6 6.5
Change-Id: I1902b717c70afcc44c1f3237370aae346262452a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-10-07 00:10:32 +02:00
Marc Mutz
72d51f1c42 QUuid: de-pessimize QDataStream operator
Use a stack buffer instead of a QByteArray to hold the 16 bytes for
the QUuid serialisation, replacing toRfc4122() with toBytes() and a
memcpy().

As drive-bys, drop the needless cast from char* to uchar*
(qToLittleEndian() has void* arguments, so char* is fine) and drop {}
around single-line if body.

Pick-to: 6.6
Change-Id: I6ffabcf07fc9a730a782e20e113999a0dcf15067
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-10-06 22:10:31 +00:00
Marc Mutz
3321101d8f Move qpointer.cpp → qpointer.qdoc
It contains no implementation. Proof: it includes no headers.

Pick-to: 6.6 6.5
Change-Id: I64b42ce799eec05a0faff2021e2b60460695e192
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2023-10-07 00:10:31 +02:00
Liang Qi
42d9c1913a xcb: replace a warning with debug info in qxcbconnection_xi2.cpp
Fixes: QTBUG-117820
Pick-to: 6.6 6.5
Change-Id: I3b89305e1a8d92a02166efee7067108572f7a97a
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2023-10-07 00:01:22 +02:00
Thiago Macieira
22029a76c3 qcompilerdetection: Add missing qtconfiginclude.h
The Q_DECL_{IMPORT,EXPORT} macros change with the configuration, so the
lack of our configuration this ended up producing inconsistent builds.

Amends 43ec3d8d01.

Pick-to: 6.6
Change-Id: Ifeb6206a9fa04424964bfffd17892394d19e648f
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-10-06 15:01:22 -07:00
Axel Spoerl
92d837e684 QDockWidget: Do not propagate title from a closed dock widget
When a dock widget is closed while floating, it still reports being
floating even though the QWidget::windowHandle()->isVisible() returns
false. This is documented behavior and will not be changed.

c153066baa relied on the isFloating() to
return false, if the dock widget is closed. When the window title was
changed by setWindowTitle(), the change was overridden by reading the
old value from the window handle.

=> Amend the patch and add a windowHandle()->isVisible() as a condition.

In c153066baa, an autotest for the title
propagation (QTBUG-113591) was added to floatingTabs().

=> Harden the setWindowTitle() test function. Move the tests related to
QTBUG-113591 and QTBUG-117764 to this function.

Fixes: QTBUG-117764
Pick-to: 6.6 6.5
Change-Id: Id37a9a22d4d13abad4ea55c74ea4e834bdb2bfab
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2023-10-07 00:01:22 +02:00
Liang Qi
44894c579c cmake: remove xcb dependency for accessibility-atspi-bridge feature
Qt a11y(ATSPI) support only depends on DBus and ATSPI, it should
also work fine on Wayland when xcb was disabled.

Task-number: QTBUG-117535
Pick-to: 6.6 6.5
Change-Id: Ibd7ebb32b94de1888920f0fe2b85ae3bd4d2c77a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-10-06 21:51:12 +02:00
Liang Qi
7e14e6c2d3 a11y: add runtime checking for xcb only calls
This amends d23562da1c .

Pick-to: 6.6 6.5
Task-number: QTBUG-117535
Change-Id: I33f97f3c26409a33c8a069f9dcdfe61bbd88e2ec
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-10-06 21:51:12 +02:00
Liang Qi
2ad3da8fce a11y: fix the build without xcb headers
This amends 6802065da8 .

Pure Wayland runtime and build envs without X11/xcb are more common.

Need to find solution for ATSPI_MODIFIER_SHIFTLOCK on Wayland later.

Pick-to: 6.6 6.5
Task-number: QTBUG-117535
Change-Id: I65d41546e3dbb86c3a939a496ed43ac1737cf539
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-10-06 21:51:11 +02:00
Ahmad Samir
9e5df4ae53 QStringConverter: clarify decode()/encode() API docs
These methods return a struct which is implicitly convertible to
QString/QByteArray respectively. Don't hide the return type from QDoc,
this simplifies telling users what those methods return exactly.

Fixes: QTBUG-117705
Pick-to: 6.6 6.5
Change-Id: Ibb22a1e54fffce8f5f20aaabe47983870ccfba1e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-06 22:51:11 +03:00
Mårten Nordheim
23996976cf http: fix leakage of network cache qiodevice
The QIODevice is owned by the caller of data(), so we should have
freed it.

Amends a6776de0c7

Fixes: QTBUG-117787
Pick-to: 6.6 6.5 6.2
Change-Id: Ic5575649038480f52cc13ee229980ee1c7cee728
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
2023-10-06 19:40:23 +02:00
Anton Kudryavtsev
d9370d0962 QByteArray: use constexpr more
Change-Id: I89bfb51659df798bc4dfa37d764b56ea8a289fbf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-10-06 19:18:54 +03:00
Christian Ehrlicher
076bf63a81 SQL/PostgreSQL: misc cleanup
Misc cleanup for the PostgreSQL driver:
 - use constexpr instead const for some constants
 - use new signal/slot syntax
 - unconditionally call PQfinish() - check is done inside the function

Change-Id: I47b83ef3436225f698fca24c68e5c9cde32c1163
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2023-10-06 15:48:46 +02:00
Tor Arne Vestbø
c74cfae7a3 Long live QPlatformKeyMapper!
The QKeyMapper class never got a platform integration companion.

As we might be adding more functionality here in the future, let's
fix that now, instead of adding more hooks directly to the platform
integration class.

The QKeyMapper will soon update its possibleKeys signature to
return QKeyCombination, but for now transform the result.

Change-Id: I88ef498180b2a8a7937a74627b7eb6b5156e872a
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-10-06 15:48:45 +02:00
Tor Arne Vestbø
d9bb8c0a17 Automatically reflect new input context input direction when locale changes
All platforms except Wayland fail to check for input direction change
when the locale changes, and only emitLocaleChanged.

We can simplify this for the platforms by checking if the new
locale caused a change in input direction, and if so emit
inputDirectionChanged on their behalf.

Change-Id: I84d8df9392db5e716f5c277d0cc9e17e5a21783f
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-10-06 15:48:45 +02:00
Timothée Keller
84d0ebabaa Windeployqt: fix typo
Change "qpaths" to "qtpaths" since the former is not a valid option.

Fixes: QTBUG-117817
Pick-to: 6.6 6.5
Change-Id: Ib8c8c80f31c1c54747340442c6bf3185c7c69001
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-10-06 12:08:31 +00:00
Liang Qi
70d3c15e8e xcb: set _KDE_NET_WM_DESKTOP_FILE and _GTK_APPLICATION_ID for window
in top level, which are in used very common for KDE and GNOME.

Pick-to: 6.6 6.5 6.2
Fixes: QTBUG-117488
Change-Id: I88fe7b4afe44e4ac8f07e60e990cbe68498e98d9
Reviewed-by: Nicolas Fella <nicolas.fella@kdab.com>
Reviewed-by: Ilya Fedin <fedin-ilja2010@ya.ru>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-10-06 09:42:46 +02:00
Christian Ehrlicher
4e8b54eb81 Preparations to deprecate QItemDelegate
QItemDelegate was superseded since Qt4 by QStyledItemDelegate but it
took until Qt6.7 to remove the last occurrences in qtbase.
 - remove unused includes / replace with qabstractitemdelegate.h
 - replace references in the documentation with QStyledItemDelegate
 - adjust the examples and tests to use QStyledItemDelegate

Pick-to: 6.5 6.6
Change-Id: I246755004ce2d01192a726ca0972106c237df0cc
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2023-10-05 21:08:45 +02:00
Anton Kudryavtsev
9187348505 qtextdocument::insertText: port to QSV
and add QChar overload to reduce allocations
Also port tests from char* literals to char16_t literals

Change-Id: I99381a2da08d9d35e6135c48bd92bd8d72533065
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-10-05 22:08:45 +03:00
Anton Kudryavtsev
0ccb8ab1db qtextdocument: replace fromLatin1 with L1 literal
to reduce allocations

Change-Id: Ie6f734269c9e880ff208629a625c88f4841e9533
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-10-05 22:08:45 +03:00
Anton Kudryavtsev
33d606412d qtextdocument: use qsizetype more
in Qt::mightBeRichText, Qt::convertFromPlainText
and emitFrameStyle to support large strings

Pick-to: 6.6 6.5 6.2
Change-Id: I7187bd81d3cbcc11ba898e015bd2a8ec64e3bf34
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-10-05 22:08:44 +03:00
Anton Kudryavtsev
e9e076df55 QString: use qsizetype more
It's last legacy int

Pick-to: 6.6 6.5 6.2
Change-Id: I691f7b15dead91166831cdf6c33a9f4d2d58b62e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-05 22:08:44 +03:00
Anton Kudryavtsev
05737f831c QString::insert: micro optimization
Don't call resize on QVLA, just wrap pointers in QSV
As drive-by, fix typo in comment

Change-Id: Id90236cfb53d861b8bd57fa9452aba4b8d9b20bf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-05 22:08:44 +03:00
Marc Mutz
1219dbcd12 QPointer: ensure construction from nullptr is constinit'able
Construction from nullptr wasn't, before, because it was using the
QPointer(T*) constructor, which cannot be constexpr. Add a constexpr
QPointer(std::nullptr_t) constructor to enable this use-case.

This requires to mark the (T*) constructor as Q_WEAK_OVERLOAD,
otherwise legacy construction from a literal 0 would be ambiguous.

No documentation changes needed, as the set of valid expressions
(apart from constinit'ing) has not changed. Mention the nullptr ctor,
though, without \since.

Add a test to confirm that contruction from derived still works.

Change-Id: If9d5281f6eca0c408a69f03fecba64a70a0c9cf0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-05 20:19:40 +02:00
Marc Mutz
c0ba4ad49d QtAndroidAccessibility: fix unneeded runtime initialization
Initializing QPointer with nullptr is currently still going through
the (T*) ctor, which is not constexpr, so is initialized at runtime.
This will change in Qt 6.7, but that doesn't help the older branches.

Use the default constructor, which is constexpr, and assert that no
runtime initialization happens by using Q_CONSTINIT.

Amends f929756578.

Not picking to 6.2, 5.15 because, while affected, they're in too
stable a mode for this, and they also lack Q_CONSTINIT.

Pick-to: 6.6 6.5
Change-Id: I41bb6f36d529effda008f166fd05a8896157edc9
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-10-05 20:19:40 +02:00
Marc Mutz
a0d931e482 qfuture_impl.h: remove unused qpointer.h include
The last QPointer user was removed in commit
07d6d31a4c. Prune the include.

Change-Id: Id48ffd2f8f5c1790bbdc54d66ac0c404b0af9cd2
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-10-05 20:19:39 +02:00
Mårten Nordheim
1bfdbe5c71 Inline Functor struct into FunctorCallable
It's currently its only user, so drop the extra code and inheritance.

Change-Id: I6e525a9629b7289cc770133936e089683b763289
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-05 19:50:33 +02:00
Marc Mutz
c3986032a8 QPointer: mark the dereference operator noexcept, too
The std types do that on their smart pointer types, so while it's not
100% correct (the function has the precondition !isNull()), follow
upstream and mark this operator noexcept, too.

Change-Id: Ie688598215afe2db4c0c26fcfa192fc7c8e22150
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2023-10-05 19:40:03 +02:00
Marc Mutz
4f191cf657 QPointer: plaster API with noexcept
Mark almost all public functions of the clas as noexcept.

Exceptions:

- assignment and construction from T*: allocates an ExtraData in
  QObjectPrivate

- dereference: the std types do that, but it's not 100% correct, so
  not proposed in this patch

As a drive-by, remove pointless inline keywords.

Change-Id: Ice91dfc429a4268546c0b8275da329be05f4edcb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2023-10-05 19:40:02 +02:00
Tor Arne Vestbø
fc1549c014 macOS: Silence warning about supporting secure state restoration
We don't support or implement state restorations via the AppKit
state restoration APIs, but if we did, we would/should support
secure state restoration. This is the default for apps linked
against the macOS 14 SDK, but as we target versions below that
as well we need to return YES here explicitly to silence a runtime
warning.

Pick-to: 6.6 6.5 6.2
Fixes: QTBUG-117745
Change-Id: I0145504a79e53499852832d23dc7d4d6838dfa1b
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-10-05 19:40:02 +02:00
Marc Mutz
2b8e1a706e QPointer: mark converting assignment operators noexcept
All operations they perform (copy/move construction + swap()) are
noexcept, so these functions should be noexcept, too.

Amends 93019dc0dee3dd3d568775250e3fae8eda072850 and
(FIXME)93019dc0dee3dd3d568775250e3fae8eda072850(ONCE MERGED).

Change-Id: I9010f87f93ce3efcefd8b28d848a3eadd6e74542
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-05 19:40:02 +02:00
Marc Mutz
b6c7335635 QPointer: fix missing converting move-assignment operator
When 6c504f2519 added the conversion
copy-constructor to fix an ambiguity, its commit message argued at
length why a move-assignment conversion operator was not possible. But
we actually have the existing converting move and copy ctors, so we
can just use copy-and-swap and move-and-swap, so do that.

As a drive-by, make the copy-assignment operator use copy-and-swap.

[ChangeLog][QtCore][QPointer] Added missing converting move-assignment
operator. This is forwards-compatible with Qt 6.6.0: compiling against
6.6.0 will just use the lvalue overload.

This is BC and SC, forwards and backwards (inline code, and going back
in time will just use the lvalue overload), so picking to 6.6.

Pick-to: 6.6
Change-Id: Ibbefb0927c08d8c716a952c6c592a02df2a89008
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-05 19:40:02 +02:00
Rym Bouabid
9d32288a38 Revamp Bindable Properties exp: Revisit documentation
Remove "Example" from the title.
Add \examplecategory Data Processing & I/O

Fixes: QTBUG-114689
Pick-to: 6.6 6.5
Change-Id: I695df195819cc371d404c4c5f01a0c4830d9c438
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-10-05 15:44:32 +02:00
Giuseppe D'Angelo
7d18ad49a3 QStringView: simplify the constructor from QString
We have to single QString out because of the isNull/isEmpty distinction.
Still, we can avoid having a constructor template on it constrained on
the argument being precisely QString. This is a historic remnant; in Qt
5 the constructor also worked with QStringRef.

Change-Id: I5457a83d5b77887f57ea9910a826f729ec276d28
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-05 02:40:02 +02:00
Mårten Nordheim
2c6b7ff501 QNetworkInfo[NetworkManager]: Make ctors explicit
Change-Id: I65a37bd108bd52b9ab754127e9f6c4929bf3eca1
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-10-05 01:35:01 +02:00
Laszlo Agocs
1d019de6b7 rhi: Fix intro doc snippet with Vulkan
The QVulkanInstance must outlive the QRhi (if Vulkan is used).
Otherwise subtle problems may pop up upon application exit.

Pick-to: 6.6
Change-Id: Ia7074c7f53633d51cf3bbdcc84e7f578214d9648
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-10-05 00:23:46 +02:00
Mårten Nordheim
b153181546 Mark potentially unused variable as maybe_unused
Fixes compile error with MinGW clang.

Amends de6f405313

Pick-to: 6.6 6.5
Change-Id: Idc1fac9d92369cfc79b5c770830bb43b3c5aae91
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-04 21:16:29 +02:00
Assam Boudjelthia
29919f3dc9 Android: Add Android 14 to QOperatingSystemVersion
Fixes: QTBUG-116643
Change-Id: I014ada85deda44226e68d230aebc3c3d5a62df00
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-10-04 22:04:46 +03:00
Anton Kudryavtsev
c24572d2a4 QString: proper compare of iterators
Canonical way is compare result of std::find_if against end by != operator, not <

Change-Id: Ifffbaf11416ea0738a1ccbb2f2f8482193390070
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-10-04 22:04:46 +03:00
Rym Bouabid
b956fec7ee Remove Custom Type Example and Custom Type Sending Example
The whole Q_DECLARE_METATYPE part is superfluous in these two examples,
as QVariant works with any type as long as it is copy-constructible.
And QVariant will call the equivalent of qRegisterMetaType, so that
doesn't need to happen, either.
Showing how to integrate the type with qDebug is fine in theory, but
also a repetition of content that can be found in other places.

Given that there isn't much else being shown in these two examples, it's
better to remove them from examples and move them to manual tests.

Some parts of "Custom Type Example" were used as snippets in other
documentations under qtbase/src/corelib. So, they were added in
customtypeexample.cpp file in the snippets folder.

Fixes: QTBUG-117001
Pick-to: 6.6 6.5
Change-Id: I45b16338912e3f7394cbb5169642bd31af32d5e1
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-10-04 21:04:45 +02:00