Commit Graph

60781 Commits

Author SHA1 Message Date
Ievgenii Meshcheriakov
7b9e7f8002 complexpingpong example: Modernize the code
Use C++ IO streams and qWarning() instead of (f)printf() for console IO.
Make user-visible strings translatable. Use invokeMethod() instead
of QTimer.

Fixes: QTBUG-111366
Pick-to: 6.5
Change-Id: I6990b964c2097267e04cd361b9cd8fc0a22a0135
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-03-28 19:42:01 +02:00
Timur Pocheptsov
21a6c86979 iOS: request authorization before presenting image-picker
Right now, image picker view is shown first (it does
not require access to photos, since it's essentially
Photos app getting access to photos ...). Then, we use
AssetsLibrary to get asset for an url (using ALAssetsLibrarie's
-assetForURL method). This may trigger a permission-related alert, asking to:
   a. Select more photos or ...
   b. Allow access to all photos or ...
   c. Deny access.

Showing this alert _after_ picker has selected an image  makes little sense
(and probably was never intended this way anyway). Instead, we now use
Photos.framework to check the authorization and, if needed, we request
an authorization (when the current status is 'Nondetermined'). If authorization
is 'Granted' as a result, we show picker view and proceed as normal/before.

Pick-to: 6.5
Task-number: QTBUG-109120
Change-Id: I0acfd7b0476346360d75a5e37f5845aaf2d6e3e0
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-03-28 18:37:36 +02:00
Tor Arne Vestbø
b4afba0c34 Windows: Send synthetic mouse release after move/resize using right API
The end of a move or resize might happen with the mouse still inside
the non-client area of the window, in which case we correctly resolved
the type to QEvent::NonClientAreaMouseButtonRelease, but we sent it
via QWindowSystemInterface::handleMouseEvent, which sets nonClientArea
of the event to false. This in turn resulted in QGuiApplication sending
a synthetic QEvent::MouseMove in case the position was out of sync,
instead of the correct QEvent::NonClientAreaMouseMove.

This should really be cleaned up on the QWSI level, as there is no
reason to have a dedicated API for handleFrameStrutMouseEvent, when
handleMouseEvent already takes an event type, but for now we fix the
immediate issue in the Windows platform plugin.

Pick-to: 6.5 6.2
Change-Id: I8a831f5f19adb0625b29b50ebce9c0c6514e93f3
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2023-03-28 16:31:18 +01:00
Mikolaj Boc
d34259d966 Stop propagation and default action on WASM window pointer event
The windows should not let events through to targets below (unless
they are Qt::WindowTransparentForInput, which is handled
independently). Therefore, stopPropagation and preventDefault are
now called regardless of whether the window has handled the event
or not. If the event is not handled explicitly, we still consume the
DOM event so that the windows/elements below don't get focus by
mistake.

Fixes: QTBUG-111706
Change-Id: Idc78ac5076e97992d9f6f13a1fa574d0df4178ac
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
Reviewed-by: Aleksandr Reviakin <aleksandr.reviakin@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-03-28 16:31:17 +01:00
Tor Arne Vestbø
f3e27d3688 Pick up initial state of foreign windows instead of reflecting QWindow
A foreign window can be used both for embedding a Qt window into a
native window hierarchy, or for embedding a native window into a Qt
window hierarchy. In the former case, we should not modify the foreign
window in any way. Since the platform does not know anything about the
intended use case at the time of the foreign window creation, it should
avoid modifying the foreign window in any way, and should instead pick
up the foreign window state and reflect that through QWindow.

Pick-to: 6.5
Change-Id: Id2e39d101277ecebd656d615cea3e7f734a4b0a6
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-03-28 16:31:17 +01:00
Tor Arne Vestbø
b64b0c7947 macOS: Don't try to create or manage NSWindow of foreign windows
A foreign window is a single NSView, and unlike our QNSView, where we
in addition manage a NSWindow for top level windows we should treat
the foreign window as just an NSView. It's not our place to neither
create nor dispose of any NSWindows attached to the foreign window.

Pick-to: 6.5
Change-Id: I88aa796c679be0489abf4999829d1378ba054bdc
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-03-28 16:31:17 +01:00
Tor Arne Vestbø
aab71c7bb8 Ensure QHighDpiScaling::set(Screen/Global)Factor() results in QScreen signals
Change-Id: I328b288b3fd83df0cc81c62bce1d946f90f1cd0d
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-03-28 17:31:17 +02:00
Tor Arne Vestbø
3a2277cb63 Align QWindowSystemInterface::handleScreenAdded() and handleScreenRemoved()
Having the logic of handleScreenRemoved() inside the QScreen destructor
was making it harder to follow the flow of adding and removing screens.

As screen management should always go though the QWSI functions, we keep
the logic there.

Change-Id: I456e77eb8fc10feae7b1f9994b25c9534ea4e430
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-03-28 17:31:17 +02:00
Tor Arne Vestbø
2187936978 Remove indirection via QScreenPrivate::setPlatformScreen()
The QHighDpiScaling code should call the explicit updateGeometry
function instead to re-evaluate the platform screen geometry in
light of the change to the scale factor.

Change-Id: Idac975c117c431356f4fb812c245348c4722a8b5
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-03-28 17:31:17 +02:00
Alexey Edelev
c4debab927 Introduce QTP0002 policy for android-specific target properties
The policy controls the behavior of the android-specific target
properties that specify paths.

The OLD behavior of this policy doesn't allow generator expressions
in the target properties that specify android-specific paths but
implicitly converts the specified paths to the valid JSON strings.

The NEW behavior of this policy allows using generator expressions
in the target properties that specify android-specific paths but they
must evaluate to valid JSON strings.

[ChangeLog][Android] Target properties that specify android-specific
paths now support generator expressions, but these generator
expressions must be evaluated to valid JSON strings. The behavior is
controlled by the policy QTP0002. The OLD policy behavior is deprecated
and the NEW behavior is preferred for use.

Fixes: QTBUG-107988
Change-Id: I8484c4b5d5ace25eb04f8bc8a79ddbaa9a79b19b
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-03-28 16:10:40 +02:00
Friedemann Kleint
a92a2a050a Update Qt logo
Pick-to: 6.5
Change-Id: I37e75193ab0e28db03ff83c72c9493bb52c36085
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2023-03-28 15:45:24 +02:00
Ahmad Samir
396e6daea4 CMake: add some docs for qt_find_package
For -developer-buildS qt_find_package caches which packages were found
on the first configuration, to make the build system pick up a newly
added qt_find_package call one needs to follow one of the methods
that are now mentioned in the docs.

Hugely based on commit message from commit
6847a19e3e.

Change-Id: I4a13d3c97a6172f504a57298c4b3edee30d21250
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-03-28 15:45:24 +02:00
Mikolaj Boc
80c1406371 Remove the redundant QWasmCompositor::requestUpdateAllWindows
Now that the browser compositor is used for rendering windows, the
method has become redundant, as windows that got resized during screen
resize will schedule their updates directly with the compositor.

This also fixes an assertion in QPlatformWindow::hasPendingUpdateRequest
as no windows without pending update requests will now have update
requests delivered.

Also offers a significant speedup with multiple restored window setups.

Fixes: QTBUG-112289
Change-Id: Ie5dff69c04d66c4aef8351adef0da8530daf7ab8
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2023-03-28 13:45:24 +00:00
Axel Spoerl
c4b62ee501 QComboBox: reset indexBeforeChange to -1 if index is invalidated
The member variable indexBeforeChange is member-initialized with -1 and
changed to the current row, if a valid index is set.
It is used to check, if the model has been reset to an empty model
and/or the index has been invalidated. The result is used to decide, if
the currentIndexChanged signal is emitted or not.

If a combo box had a valid index and it is invalidated afterwards
(e.g. because the combobox has no more entries), indexBeforeChange is
not reset to -1. The redundant signal emission is therefore prevented
only the first time.

This patch resets indexBeforeChange if the index is invalidated or the
last item is removed from the combo box.

It also adds a no-op check to tst_QComboBox::currentIndex.
The test data sets "check that setting the index to -1 works" and
"check that current index is invalid when removing the only item" check
the respective use cases.

As a drive-by, variable names and QObect::connect syntax have been
cleaned up in tst_QComboBox::currentIndex.

Fixes: QTBUG-108614
Pick-to: 6.5 6.2
Change-Id: Ib6dfa887d9247f2c47df065039d69ba57c32fa24
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-03-28 14:45:24 +01:00
Tor Arne Vestbø
c4f59f96b9 macOS: Simplify child window parenting in recreateWindowIfNeeded()
The logic for this should ideally be handled in setParent(), but
for now let's clean up the code a tiny bit.

Pick-to: 6.5
Change-Id: Id2370d6704625038ab6b4fa246dea5d1c037371c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-03-28 13:22:11 +01:00
Tor Arne Vestbø
a4bd121125 macOS: Create NSView as initially hidden, to match QWindow behavior
Initially attempted in 096b56f336,
but that broke QQuickWindow::grabWindow(), which at the time was
not prepared for grabbing non-visible windows.

This is no longer an issue, as QQuickWindow::grabWindow() has fallback
logic for non-renderable windows. QWidget::grab() also works fine,
as it grabs from the backingstore directly.

For top level windows we apply the visibility state to both the
NSWindow (orderIn/Out), and to the NSView (hidden=YES/NO).

Pick-to: 6.5
Change-Id: I617b292ca6bfba66e65b55941c5b002e415da88d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-03-28 13:22:11 +01:00
Tor Arne Vestbø
6736118b8c Guard QTabBar against nested event processing during moving tabs
If moving tabs results in nested event processing by the user's
code in response to the tab index changing, the mouse release
event might have been processed already, and the pressed index
is reset back to -1.

Pick-to: 6.5 6.2 5.15
Fixes: QTBUG-74478
Change-Id: I9696b10a6218456ab381ffe3a65ea471cfa42413
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-03-28 13:22:11 +01:00
Antti Määttä
5ad1ea092e CTF: Use Q_DISABLE_COPY for QCtfLib
Pick-to: 6.5
Change-Id: Ife1d0670486ac0820b53c9e015249115685e4997
Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
Reviewed-by: Hatem ElKharashy <hatem.elkharashy@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Antti Määttä <antti.maatta@qt.io>
2023-03-28 13:05:14 +03:00
Antti Määttä
ebdf20240c CTF: Fix QTRACE_LOCATION warnings during compilation
When compiling with CTF tracing, QTRACE_LOCATION not set warnigs are
printed constantly. Fix this by changing the log to info and default
log message level to warning.

Pick-to: 6.5
Change-Id: Ib167ec1b41ff0134fa9b3eba09394bb0bef54379
Reviewed-by: Hatem ElKharashy <hatem.elkharashy@qt.io>
Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Antti Määttä <antti.maatta@qt.io>
2023-03-28 13:05:14 +03:00
Christian Ehrlicher
e9512c46da QFusionStyle: adjust painting of separator in QSpinBox
When use a very high devicePixelRatio (for testing I used 5.23) one
could see that the separator in the QSpinBox was not long enough.

Pick-to: 6.5
Change-Id: I3a86c5bb695c95051b8b9294ca8a2749a8c3f9eb
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2023-03-28 10:45:01 +01:00
Joerg Bornemann
3b234eefef Doc: Clarify what's deployed by qt_deploy_runtime_dependencies
Mention that non-Qt libraries are deployed on Linux.

Pick-to: 6.5
Task-number: QTBUG-111741
Change-Id: Ia5737d7a2d53925939910b5f96933f4bb380ed05
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-03-28 11:34:14 +02:00
Morten Sørvig
9a39b3c796 Apply ScaleFactorRoundingPolicy to QT_SCREEN_SCALE_FACTORS
QT_SCREEN_SCALE_FACTORS is in many cases set on behalf of the user,
instead of by the user, so we should apply the standard app
scale factor policies to it, instead of interpreting it
as a user override.

Specifically, make it subject to the rounding policy set by
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(). This
means that applications which support integer scale factors
only will see integers only, also when QT_SCREEN_SCALE_FACTORS
specifies a fractional factor.

Users who want to override can set

  QT_SCALE_FACTOR_ROUNDING_POLICY=PassThrough

to restore the default Qt rounding behavior.

[ChangeLog][QtGui] The high-DPI scale factor rounding policy (settable with
QGuiApplication::setHighDpiScaleFactorRoundingPolicy() or
QT_SCALE_FACTOR_ROUNDING_POLICY) now applies to scale factors set
with QT_SCREEN_SCALE_FACTORS.

Fixes: QTBUG-95930
Fixes: QTBUG-99546
Change-Id: I936e96671fe2a0a43c3e8129f0768875cb011103
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-03-28 09:14:09 +00:00
Morten Sørvig
2d76f991d0 Fix QT_WIDGETS_HIGHDPI_DOWNSCALE
The source rect scaling implemented in 79bead6c was incorrect
for child windows with an offset, and was reverted in commit
d59b2fde, after causing QTBUG-107814.

Scale the window rect by the source device pixel ratio to
get the source rect. This source DPR can be different from
the (target) DPR when HIGHDPI_DOWNSCALE is enabled and
will then be a rounded DPR value.

Pick-to: 6.5
Fixes: QTBUG-111102
Task-number: QTBUG-107814
Change-Id: I59801bc22c47fc83d63ae4d96e509ab7fffeb760
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2023-03-28 09:14:09 +00:00
Marc Mutz
f8dba0395f QPromise: add support for addResult(braced-initializer)
The usual problem, the usual fix: default the addResult() template
argument to the class template argument, cf. e.g. wg21.link/p2218.

[ChangeLog][QtCore][QPromise] Added support for calls to addResult()
with braced initializers.

Fixes: QTBUG-111826
Change-Id: I9ad7294dbcefbc5d2609ca3d9e7304dbeb8b3f41
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-03-28 09:09:14 +00:00
Tor Arne Vestbø
f1e539518b Windows: Don't send non-client mouse events unless frameStrutEventsEnabled
During refactoring in 3850404114 the logic
was changed in a way that ended up sending non-client mouse events even
if frameStrutEventsEnabled() was not set on the platform window.

Pick-to: 6.5 6.2
Change-Id: Icbde51641020aeec99572d80859082fdcf656311
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2023-03-28 09:59:53 +01:00
Axel Spoerl
585bfe600a Fix pointer mismatch after QList::move() in tooltip example
The tooltip example moves shape items within a QWidget. Shape items are
stored in a QList of objects. When an item is moved, its pointer is
taken from the QList and stored in a member variable. To have the moved
item on the bottom of the list, QList::move() is called. This
operation re-arranges the list objects, and the member variable starts
pointing at a wrong object.

This patch changes the list from a list of objects, to a list of
pointers. Shape items are therefore allocated on the heap.
A destructor is added to free the heap with qDeleteAll.

The example's documentation is adapted accordingly and a snippet for
the destructor is added.

As a drive-by, int is replaced by qsizetype where it was used as an
index of a QList.

Fixes: QTBUG-104781
Pick-to: 6.5 6.2
Change-Id: I9be26fa7954be5f85729d24f166d66980af71801
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2023-03-28 08:59:53 +00:00
Axel Spoerl
df0b661bfc Explicitly propagate screen to QComboBoxListView constructor
QComboBoxListView is constructed without a parent. It therefore
inherits the current screen, which normally is the screen on which the
related QComboBox is located.

With two identical screens in Windows, that can lead to the popup
showing on the wrong screen. The issue occurs, when the other screen
is found before the right one.

This patch calls setScreen() in the constructor, to explicitly inherit
the screen from the combobox, if a valid pointer is passed.

Fixes: QTBUG-106099
Pick-to: 6.5 6.2 5.15
Change-Id: Ic6679cfd59291092294d2cc75632a5485c2529b7
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2023-03-28 08:59:53 +00:00
Fabian Kosmale
e7cb3cb041 QMetaType: Provide underlyingType for enums
Currently, Qt assumes that enums always have int as their underlying
type (both in QMetaEnum::keyToValue and in the QML engine). This change
makes it possible to to retrieve the underlying type from an enum's
metaype - or rather, a metatype of an integral type with the same size
and signedness. The use cases aobve don't really rely on the exact same
type. In most cases, we wouldn't even need the signedness, however that
is already available anyway, and it will come in handy once QML supports
bigint, and we need to decide whether we should return

While it would be possible for individual users of this function to
manually query the size and signedness, having a function returning a
metatype offers additional convenience - especially in QML, where the
conversion APIs generally operate on metatypes.

Task-number: QTBUG-27451
Task-number: QTBUG-84055
Task-number: QTBUG-112180
Change-Id: Icf733b42df0ea64017d69f4d94cb7c855d9e3201
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-03-28 10:59:53 +02:00
Joerg Bornemann
454b1de22c CMake: build the shared plugin when building the plugandpaint target
People expect that building the "main target" of an example builds all
necessary subtargets as well. Add a dependency from plugandpaint to
pnp_extrafilters.

Pick-to: 6.5
Task-number: QTBUG-112300
Change-Id: I036beb961fe474ff060f93c98f5e2bda58e66f71
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-03-28 10:45:55 +02:00
Ivan Solovev
502a7706b9 QFutureInterface: add a warning when an existing continuation is overwritten
... and also extend the documentation to explain this case explicitly.

Fixes: QTBUG-107545
Pick-to: 6.5 6.2
Change-Id: I9414cc677b037989de60e97871485018e5c8a569
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-03-28 09:45:55 +01:00
Liang Qi
e8622fb204 git: ignore ._* files
Pick-to: 6.5 6.4 6.2 5.15
Change-Id: Idbf7dcd76f176f098bfbeb516c51933c2b7a08b6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-03-28 10:44:57 +02:00
Thiago Macieira
5f23f7f416 QPluginLoader: modernize static plugin instance code
- don't create the QGlobalStatic if it doesn't exist yet
- remove int-based iteration in favor of range-based for

Pick-to: 6.2 6.5
Change-Id: Idd5e1bb52be047d7b4fffffd174fb99f4557defe
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-03-28 04:29:22 -04:00
Tor Arne Vestbø
90d7fd5822 macOS: Apply QWindow properties to NSWindow when setting content view
The main responsibility of QCocoaWindow::recreateWindowIfNeeded() is
to decide if the platform window is top level or not, and if so needs
an NSWindow or NSPanel accompanying it.

Once that decision has been made, and we've created an NSWindow or
NSPanel, and made the view the content view of this window, we need
to apply the QWindow properties to the newly created NSWindow or
NSPanel. But doing so in recreateWindowIfNeeded increases the
complexity and responsibilities of the function, so we move the
logic to [QNSWindow setContentView:] instead. This is analogous
to applying the properties during [QNSWindow init], but since we
are now the content view we can use the same code paths to apply
the initial properties as we use when they are updated later on.

Pick-to: 6.5
Change-Id: Idb4c812f4b22a029030bf4638357cf8628caea40
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-03-28 04:33:05 +01:00
Ahmad Samir
41201f9d65 QStorageInfo/Unix: fix narrowing conversion warning
"blocksize" is assigned the value of statvfs::f_bsize, the latter is
unsigned long.

Change-Id: I55453b861d0c127d1e8d8a367347de926a7cbbca
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-03-28 05:33:05 +02:00
Kai Köhne
5a182d35e2 Update license specification for PCRE2
PCRE2 is available under BSD-3-Clause, but with a relevant exception
that arguably applies to the way Qt uses it, too. So let's mention
this exception in the listed license.

Unfortunately, the exception is not part of the SPDX database, and
combining a standard license with a custom exception is not supported
yet. See [1] for a related discussion. Meanwhile, just defining a whole
license is a common workaround.

[1] https://github.com/spdx/spdx-spec/issues/153

[ChangeLog][Third-Party Code] Clarifying license of PCRE2 to be
BSD-3-Clause with advertisement exception for binary-like packages.

Pick-to: 6.5
Change-Id: Ib6d46806dc5a00ff2f795054ad9bf0ae62920501
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-03-27 10:55:28 +00:00
Hamish Moffatt
ce58c66ae8 QTaggedPointer: fix warning due to integer type conversion
Fixes: QTBUG-112222
Pick-to: 6.5
Change-Id: I4815d83c23e7616548ea84779d1c3d0774e77f69
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-03-27 15:55:24 +11:00
Andreas Bacher
5af5738980 SQL/IBASE: Time Zone support (firebird 4.x)
Add support for time zones in the IBASE driver, which was introduced in
firebird 4.x. TIMESTAMP WITH TIME ZONE data type is supported in order
to store and retrieve a QDateTime with the time zone.

Task-number: QTBUG-111879
Change-Id: I631b4262d17796a17630379b7d659f88244a23ad
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2023-03-24 23:43:54 +01:00
Ievgenii Meshcheriakov
8faf2511da dbus examples: Remove "Example" from example names
Task-number: QTBUG-111366
Pick-to: 6.5
Change-Id: Ia34c60ed4c0ffe5b01cc507dd5e45521c096b0bf
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-03-24 19:29:11 +01:00
Liang Qi
0a37f944bf tests: blacklist tst_QImageReader::setClipRect() and
setScaledClipRect() svg tests on Wayland

Task-number: QTBUG-112275
Pick-to: 6.5
Change-Id: Iaae1781df09b8402b349fd41111ea16ca26215f8
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2023-03-24 10:49:16 +01:00
Timothée Keller
4e5ced054d Windeployqt: prevent directory creation for dryruns
Added a check for dryruns when creating directories, to properly
reflect expected behavior.

Pick-to: 6.5
Change-Id: I72063e4d32302d304f8174701e38e275b404706b
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2023-03-24 10:09:56 +01:00
Yuhang Zhao
8902bc6356 windeployqt: allow user set translation directory
Add the "translationdir" option, which allows the user to choose
a different directory to deploy the translation files.

Pick-to: 6.5 6.4
Change-Id: Iacf2031abb6d992e6765c02f232f81317b784720
Reviewed-by: Timothée Keller <timothee.keller@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2023-03-24 17:07:06 +08:00
Marc Mutz
690761a4ad tst_QVariant: add a test contrasting Qt 5/6 isNull behavior
A null QString used to make a QVariant containing it null in Qt 5, but
this is no longer the case. Add a test that get_if works as expected.

Task-number: QTBUG-111598
Change-Id: I0f3511e1b33f4a9d67755269455680feda22ddca
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-03-24 06:40:27 +01:00
Marc Mutz
a9e8034e8c Implement [variant.get] for QVariant [2/2]: get()
This second patch of the series implements get().

Unlike other get() implementations in Qt, don't use my trick with the
constrained friend free function here. Instead, provide the four
overloads manually, like mandated by the standard library for
std::variant (and, indeed, tuple), such that these functions can also
be used on subclasses of QVariant.

[ChangeLog][QtCore][QVariant] Implemented the type-based std::variant
access protocol (get<T>()/get_if<T>()) to allow easier access to the
contained element than the previous solution of casting data(), as
well as to allow generic code to treat QVariant and std::variant the
same. The holds_alternative<T>() function is not provided, since it's
the same as get_if<T> != nullptr. The index-based variant access
functions (get<I>()/get_if<I>()) are also not provided, because,
unlike std::variant, QVariant does not have a bounded number of
alternative types, and QMetaType IDs are not (all) compile-time
constants.

Fixes: QTBUG-111598
Change-Id: Id7bc41f7d91761b3483ec5604f1a4685c8079844
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-03-24 06:40:19 +01:00
Marc Mutz
de3e970889 Implement [variant.get] for QVariant [1/2]: get_if()
QVariant supports non-default-constructible payloads, in principle
(QTBUG-105140). And fromValue() works with such types, but value()
insists on providing a wide contract and therefore accidentally
requires default-constructible.

We can now invent other "Qt-ish" API like optional::value_or() or a
value() that returns optional<T>, but we should first get the
interface in that generic code must use, and which at the same time is
the most versatile, because it gives write access to the element
stored in the variant: [variant.get], consisting of get_if(), get(),
and holds_alternative(). The latter is the same as get_if() !=
nullptr, so we won't provide it.

This first patch implements get_if(), adds test for it.

As a Hidden Friend supposed to be called with explicit template
arguments, we run into the problem that wg21.link/P0846 solved for
C++20. Add the usual work-around, and check it works.

The ChangeLog will be on the last patch.

Task-number: QTBUG-111598
Change-Id: I23f57ea2de3946944810c5552c68a7a3060a44f2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-03-24 06:40:11 +01:00
Thiago Macieira
8570e86fff QVariant: ensure the type custom is registered on construction
I must have broken this in the 6.5 work I did for QMetaType and
QVariant, but I haven't searched which commit exactly did it. Our
QVariant tests are old and thus only checked the type ID, which meant
that they caused the registration by the act of asking for the ID in the
first place; this commit adds a couple of explicit checks for the type
registered by name before the ID.

Fixes: QTBUG-112205
Pick-to: 6.5 6.5.0
Change-Id: Idd5e1bb52be047d7b4fffffd174f1b14d90fd7a3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-03-23 13:40:15 -10:00
Thiago Macieira
4d90c4e74a QTimer: fix new-style slot invocation for receiver in another thread
For single-shot timers, at least. QSingleShotTimer had either an
optimization or the only way to make new-style slot invocations by
storing the QSlotObject pointer and calling it directly. Instead of
doing that, let's just actually connect and let QObject handle the
actual delivery.

[ChangeLog][QtCore][QTimer] Fixed a bug that caused slots connected to
single-slot timers using the new-style connection mechanism to be
delivered in the wrong thread.

Fixes: QTBUG-112162
Pick-to: 5.15 6.2 6.5
Change-Id: Idd5e1bb52be047d7b4fffffd174eadb227ab65ee
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-03-23 13:22:23 -10:00
Ievgenii Meshcheriakov
f7167ae82f remotecontrolledcar example: Modernize the code
Also remove unused crashed() signal.

Task-number: QTBUG-111366
Pick-to: 6.5
Change-Id: Ia23552a6396c324c7591643afaa634879a2c185e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-03-23 20:14:46 +01:00
Laszlo Agocs
fa3bfa72da macOS: Skip DisplayLink updates when in live resize
...and the view is using a CAMetalLayer and a non-default contents
placement. (the default would be scaling/stretching of the content,
that hides a lot of out-of-sync size problems during resize, but
is not great for UIs so we never use that in practice)

This achieves two things:

- when presenting from the main thread with transactions (i.e. with
  parent patch in place), resizing the window will be even nicer,
  basically flicker free on the M1 Mini as well,

- when presenting from outside the main thread, resizing becomes
  a lot smoother, even if the window background is still visible
  from time to time due to the size not catching up and due to
  Qt having to use NSViewLayerContentsPlacementTopLeft.

Thus resizing Qt Quick-based windows, which use the threaded render
loop by default and cannot use presentsWithTransaction, becomes a
nicer experience than before, even if not always perfect.

This comes at the expense of not animating during the live resize
operation whenever the size is not changed (because only a resize
triggers updates then, the CVDisplayLink-based updates are skipped
in order to reduce flicker due to out of sync sizes)

To force the old behavior, set QT_MAC_DISPLAY_LINK_UPDATE_IN_RESIZE.

Task-number: QTBUG-107198
Change-Id: I796c3a74119510c62f7245b0ebbe78797d2df03e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-03-23 16:44:10 +00:00
Marc Mutz
25c5452c26 tst_bench_QCryptographicHash: swallow result() return values
As usual, assign them to a [[maybe_unused]] variable, to avoid
potential future [[nodiscard]] problems, and to indicate to
readers of the code that there's a result that's being returned,
we're just not interested in it.

Pick-to: 6.5 6.2
Change-Id: I2bd47ca98418092ca885d50a1a6417a21a612a85
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-03-23 16:14:12 +00:00
Marc Mutz
d0149e2404 tst_bench_QCryptographicHash: use QMetaEnum trick
... conveniently wrapped in a generator, to not have to keep an
algoname() function in sync with QCryptographicHash::Algorithm.

The MaxCryptoAlgorithm constant was already stale following the
addition of BLAKE2b/s algorithms in
5d69aa3ee1.

Also make the data-driven tests have an actual Algorithm column
(was: int) to minimize casting.

Pick-to: 6.5 6.2 5.15
Change-Id: I89a6098e512a72f623fd50a6f88fc351c7bb1418
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-03-23 16:14:12 +00:00