Commit Graph

14898 Commits

Author SHA1 Message Date
Marc Mutz
fd17eaca83 tst_QVariant: check fromValue() with a non-default-constructible type
... by just using fromValue() instead of the QVariant(QMetaType,
void*) ctor.

Code coverage isn't reduced, because fromValue() will, of course, call
that exact ctor itself.

Amends df0085d3a2.

Pick-to: 6.5 6.4 6.2
Task-number: QTBUG-105140
Task-number: QTBUG-111598
Change-Id: I02464803090fa7078947625616e6fc20e623ef31
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-03-03 20:05:27 +01:00
Jan Arve Sæther
5773c3ac28 Move anchor layout example to manual tests
Pick-to: 6.5 6.5.0
Change-Id: I9c9a9dbcdaf705a31208b80b71e978938a492142
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2023-03-02 17:24:53 +00:00
Liang Qi
cd0301a78e tests: skip tst_QScreen::grabWindow() on XWayland
Pick-to: 6.5
Task-number: QTBUG-104595
Change-Id: Icb56a587dfbad84533616160817a3d43411146f1
Reviewed-by: Kalle Viironen <kalle.viironen@qt.io>
Reviewed-by: Simo Fält <simo.falt@qt.io>
2023-03-02 15:58:37 +01:00
Christian Ehrlicher
2adb22fba5 tst_QSqlDatabase: avoid some runtime warnings
Make sure to properly close the cloned database connections and allow
one test for sqlite

Change-Id: Ia4eb4a684a3c432844e4b2a77bff69655b53f9b2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-03-02 15:02:02 +01:00
Laszlo Agocs
d57ff481fc Lancelot: add drawPixmapFragment test
Task-number: QTBUG-111416
Pick-to: 6.5
Change-Id: Ife91bbc0bf09e3fcc5c4d8dc06e352eadee1b810
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2023-03-02 12:51:14 +01:00
Øystein Heskestad
e13b57d06a Move xmlstreamlint example into tests/manual
This example is useful but not a typical starting point for an
application.

Task-number: QTBUG-110647
Pick-to: 6.5
Change-Id: Ic4af8ed648c587b91110a7403fa80c619549289d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-03-02 12:20:18 +01:00
Marc Mutz
52c7f699ac QDebug: fix std::string/view stream operators; add u8 versions
Make them templates, for two reasons:

- so they can accept std::pmr types and, in general, any basic_string
  with custom allocators and char_traits

- to break overload ambiguities with the Qt string view types

Also, add the missing C++20 char8_t overloads.

Also, avoid creation of a QString in the sizeof(wchar_t) == 2 case
(Windows). Add a comment to optimize for the sizeof(wchar_t) != 2 case
later.

Found in API review.

Pick-to: 6.5
Change-Id: I30139520f582a38863a0936f8eca4b1ed33e37c8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-03-02 06:33:35 +01:00
Jan Arve Sæther
a84b2e5973 Move Weather Anchor Layout example to manual tests
Pick-to: 6.5
Change-Id: I8782a83b5c12b4f57bf9ef9063818cb124bddd56
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2023-03-02 05:55:57 +01:00
Harald Sitter
5317ff74fd a11y: even checkable buttons are pressable
otherwise there is no way to synthesize a "click" through the a11y API.
toggleAction only leads to a toggled() signal but the user may be more
discerning and only listen to clicked() (or QAction::triggered) to react
to **user** events not all toggle events. as such pressAction is always
superior to toggleAction when user input is meant to be synthesized
through a11y tooling.

Change-Id: I7f024d57087b545d3cfd1805026ea538b0b3e166
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2023-03-01 22:05:23 +01:00
Marc Mutz
b8966021ff tst_QMutex: use constexpr variables instead of 'enum-trick'
C++20 doesn't like arithmetic with enums anymore. While this hasn't
caused immediate pain, yet, fix it pro-actively for an imminent patch.

As a drive-by, fix the missing space at start of comment.

Pick-to: 6.5 6.4 6.4.3 6.2
Change-Id: Id08bb227c587bc7b900c593a7b6d2655ca32eefd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-03-01 19:14:39 +01:00
Marc Mutz
e7c792ba71 tst_qvarlengtharray: add test for QVLA(n) ctor
Also add one for types that are neither copy- nor move-constructible.
In contrast to resize(n), the QVLA(n) ctor worked for such types, so
make sure it stays that way.

Pick-to: 6.5 6.4 6.4.3 6.2 5.15
Change-Id: If54fbc9dd6a4808175c4bcb0ffb492b33c879746
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-03-01 18:14:39 +00:00
Marc Mutz
6990f23813 Long live QMessageAuthenticationCode::resultView()!
Use it in a few places.

[ChangeLog][QtCore][QMessageAuthenticationCode] Added
QCryptographicHash-style resultView().

Change-Id: I745d71f86f9c19c9a9aabb2021c6617775dab1cf
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-03-01 17:20:41 +01:00
Thiago Macieira
5f32c9edce tst_QTimer: suppress the cross-thread timer stopping warnings
Both QTimer's and QObjectPrivate's destructors print a warning if the
current object lives on another thread and has an active timer:

QWARN  : tst_QTimer::moveToThread() QObject::killTimer: Timers cannot be stopped from another thread
QWARN  : tst_QTimer::moveToThread() QObject::~QObject: Timers cannot be stopped from another thread

This timer is used to ask the thread to quit, which in turn allows us to
destroy this QObject without a cross-thread warning. Because it's
already fired once and done its duty, we can make sure it's not active
by simply making it single-shot.

Pick-to: 6.4 6.5
Change-Id: Ieec322d73c1e40ad95c8fffd17465067b27c044b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-02-28 20:19:52 +00:00
Volker Hilsheimer
3f2d02e2f4 QAbtractItemView: deselect before click opens editor
A click on the selected item should deselect all other items before
editing starts.

Remove the part of the test case that assumes that we can have multiple
items selected in ExtendedSelection mode, and click on an item to start
editing while maintaining selection. That can never happen.

Pick-to: 6.5 6.4 6.2
Fixes: QTBUG-111131
Change-Id: I0312eed4614502cfb77eca26d3f7615427493d7d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-02-28 17:19:24 +00:00
Jan Arve Sæther
afbfe30093 a11y: Test and document relations better
The documentation for the RelationFlag enum was not very clear on what
was the "first" and "second" object.
And the fact that the AT-SPI backend (which these enum values originates
from) inverses "first" and "second" makes it harder to understand what
how it all fits together.

So when (with this change) Qt documents 'QAccessible::Labelled' as
    "The returned object is labelled by the origin object"

AT-SPI documents ATSPI_RELATION_LABELLED_BY as:
    "The origin object is labelled by the returned object"
(Documentation for AT-SPI is rewritten so that it shares the same
terminology)

Notice that the two objects are exchanged, which means that even if they
use the same 'Labelled' relation, the semantic gets 'inversed'.

This is already the case today, so we cannot change it. Therefore, to be
clear, the relation mapping will remain to be like this:

Qt Relation     | Maps to AT-SPI                | Qt explanation
----------------+-------------------------------+--------------------------------------------------------------------------------
Label           | ATSPI_RELATION_LABELLED_BY    | The returned object is a Label for the origin object
Labelled        | ATSPI_RELATION_LABEL_FOR      | The returned object is Labelled by the origin object

Controller      | ATSPI_RELATION_CONTROLLED_BY  | The returned object is the Controller for the origin object
Controlled      | ATSPI_RELATION_CONTROLLER_FOR | The returned object is Controlled by the origin object

This mapping can already be seen in qAccessibleRelationToAtSpiRelation()

For the record, these future relations should then be mapped to like
this:

Qt Relation     | Maps to AT-SPI                | Qt explanation
----------------+-------------------------------+--------------------------------------------------------------------------------
Described       | ATSPI_RELATION_DESCRIPTION_FOR| The returned object is described by the origin object
DescriptionFor  | ATSPI_RELATION_DESCRIBED_BY   | The returned object provides a description for the origin object

FlowsTo         | ATSPI_RELATION_FLOWS_FROM     | The returned object has content which flows logically to the origin object
FlowsFrom       | ATSPI_RELATION_FLOWS_TO       | The returned object has content which flows logically from the origin object

Change-Id: Ib245ec95564e4886dc6dbbb68abec2b23cd0e534
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2023-02-28 17:53:10 +01:00
Andreas Eliasson
8ecd81ae86 Doc: Remove duplicate words
Change-Id: Ia7a38a1035bd34d00f20351a0adc3927e473b2e7
Pick-to: 6.5 6.4 6.2
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
2023-02-28 16:53:10 +00:00
Ben Fletcher
9ffa16baf0 rhi: Add support for half precision vertex atttributes
Runtime support is indicated via QRhi::Feature::HalfAttributes.

OpenGL support is available in OpenGL 3.0+, OpenGL ES 3.0+, and in
implementations that support the extension GL_ARB_half_float_vertex.

Other RHI backends (Vulkan, Metal, D3D11, and D3D12) all support this
feature.

Note that D3D does not support the half3 type.  D3D backends pass half3
as half4.

tst_qrhi auto unit test included.

Change-Id: Ide05d7f62f6102ad5cae1b3681fdda98d52bca31
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-02-27 09:23:05 -08:00
Volker Hilsheimer
f75b29fbbd QListView: Reset style after using a temporary proxy
Amends 0242be9060, and removes unwanted
side effect of having a modified style behavior for later functions.

Pick-to: 6.5 6.4 6.2
Change-Id: If3dff0d7ab9e6c6c10e7a92d0a3eaff98fa1457f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-02-27 10:10:04 +01:00
Marc Mutz
a62aa18178 tst_QMessageAuthenticationCode: check that setKey() reset()s
It's documented as such.

Pick-to: 6.5 6.4 6.2 5.15
Change-Id: I7299d289117e52dcefe3c4ab917d7ecad6dd02be
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-02-26 07:51:29 +01:00
Ahmad Samir
caa21ffc65 tst_benchlibcallgrind: silence a compiler warning
Change-Id: I68cc530fa8eaf941a6ddb7e6987ff37ec270bc4d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-26 03:14:46 +02:00
Marc Mutz
0411d98192 QCryptographicHash: auto-calculate MaxHashLength
Add Algorithm::NumAlgorithms and use it to iterate over all
statically-available algorithms, querying their hashLengthInternal().

This avoids having to statically_assert(<= MaxHashLength) everywhere,
and auto-adjusts the buffer size in SHA1_ONLY builds.

Yes, the extra case labels for NumAlgorithms are a nuisance, but at
least the compiler will remind us when we forget, unlike a missing
static_cast(<= MaxHashLength) that might easily be forgotten.

Adjust the test (which iterates over the QMetaEnum for
QCryptographicHash::Algorithm, so finds NumAlgorithms and tries to
pass it to the hash() function which responds with a
Q_UNREACHABLE(). Only test hashLength() == 0 for that enum value.

Pick-to: 6.5
Change-Id: I70155d2460464f0b2094e136eb6bea185effc9d5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-25 16:50:03 +01:00
Edward Welbourne
cb54da2366 Support Cyrillic's equivalent of 'E' as exponent separator
Only Ukrainian is actually recorded in CLDR as using U+0415 as
exponent separator; all other Cyrillic-using locales officially use
plain ASCII 'E'. However, it seems reasonable, in all Cyrillic
locales, to recognize both (given that they look very similar).

Task-number: QTBUG-107801
Change-Id: I70a1e60a2d9fe7e254e01d32c5bad909ea4b8c76
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2023-02-24 13:37:07 +01:00
Edward Welbourne
4931fe9b02 Fix parsing of numbers to cope with non-single-character tokens
In some locales signs and the exponent are not single character
tokens. Replace QLocaleData::numericToCLocale() with a tokenizer that
will cope with this. At the same time, cache the locale data needed in
support of that, so that we don't repeatedly recreate QString()
objects just to compare them against input tokens.

The caching class is inspired by Thiago's proposal for fixing the
performance, which also inspires the optimization of the C locale in
the tokenizer used here.

Add some testing that round-tripping numbers via strings works for the
locales with signs and exponents that use more than one character.

Task-number: QTBUG-107801
Change-Id: I9fd8409a371ed62ed969d9ebc8b09584e752f7fb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-24 13:37:07 +01:00
Edward Welbourne
e204de690b Add missing shbang line to shell script
If it's executable, it should specify how it's to be executed.

Change-Id: If5671712da3e1fbc42b15d22c1253129910091bc
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-02-24 13:37:06 +01:00
Thiago Macieira
1d167b515e QHash: fix GrowthPolicy::bucketsForCapacity
It was confusing entry capacity with the bucket capacity. The value
maxNumBuckets() returned was the maximum number of entries. This issue
was harmless: we would just fail to cap the maximum to an allocatable
size. But the array new[] in the Data constructors would have capped the
maximum anyway (by way of throwing std::bad_alloc).

So instead of trying to calculate what the maximum bucket count is so we
can cap at that, simplify the calculation of the next power of 2 while
preventing it from overflowing in our calculations. We continue to rely
on new[] throwing when we return count that is larger than the maximum
allocatable.

This commit changes the load factor for QHashes containing exactly a
number of elements that is exactly a power of two. Previously, it would
be loaded at 50%, now it's at 25%. For this reason, tst_QSet::squeeze
needed to be fixed to depend less on the implementation details.

Pick-to: 6.5
Change-Id: I9671dee8ceb64aa9b9cafffd17415f3856c358a0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-23 10:36:36 -08:00
Thiago Macieira
e836c4776f tst_qmessagehandler: fix QtTest warnings about duplicate row names
Pick-to: 6.5
Change-Id: Ieec322d73c1e40ad95c8fffd17464fcb2ca96f5f
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2023-02-23 10:33:39 -08:00
Thiago Macieira
644c06b48f Logging: fix crash when decoding a symbol that isn't a function
Saw this on my FreeBSD VM. The backtrace() function thought the nearest
symbol to something was "_ZTSNSt3__110__function6__baseIFbPvS2_EEE",
which decoded to

 typeinfo name for std::__1::__function::__base<bool (void*, void*)>

The function pointer type inside parameter threw the decoder for a loop
and caused it to crash with the failed assertion in qbytearray.h:

 inline char QByteArray::at(qsizetype i) const
 { Q_ASSERT(size_t(i) < size_t(size())); return d.data()[i]; }

I noticed this
 - because tst_qtimer hung
 - because qFormatLogMessage deadlocked acquiring QMessagePattern::mutex
 - because the logging recursed
 - because qCleanupFuncinfo failed an assertion while formatting the
   backtrace (my QT_MESSAGE_PATTERN has %{backtrace})
 - because QTimer::~QTimer -> QObject::killTimer printed a warning
 - because tst_QTimer::moveToThread produces warnings

Pick-to: 5.15 6.2 6.4 6.5
Change-Id: Ieec322d73c1e40ad95c8fffd17464f86e9725991
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2023-02-23 10:33:39 -08:00
Mikolaj Boc
3486583ec3 Fix the files_main test
The test does not build due to fbf2a3's change to QWasmLocalFileAccess
API. Align it with the new API.

Change-Id: I8e70e471c1f7dd812d3b2cf8e1bf33fd58310e81
Reviewed-by: Aleksandr Reviakin <aleksandr.reviakin@qt.io>
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
2023-02-23 14:16:06 +01:00
Mikolaj Boc
2fffa21111 Add multitouch test cases to qwasmwindow test
Three touch points that move/resize three windows simultaneously are
tested

Change-Id: I17d0c8c6c5c90f5121a098e5b67174167cd5aaa5
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2023-02-23 09:17:44 +01:00
Thiago Macieira
e69d80e14d qalgorithms.h: fix mistake that MSVC has constexpr bitops in C++17 mode
<bit> exists in C++20 and is properly both constexpr and optimized. But
in C++17 mode, we don't have constexpr bitops and instead elect to have
performance at runtime instead. But somewhere along the line, either
when they were added, when C++20 <bit> support was, or in any of the
bugfixes for other compilers, the nesting of #ifdef got messed up and we
declared that we had constexpr builtins for MSVC in C++17 too.

The macro QT_HAS_CONSTEXPR_BUILTINS isn't supposed to be used by anyone
else... but we ended up not being able to use it ourselves either. So
I'm renaming it to a more precise label.

Pick-to: 6.5
Change-Id: I9671dee8ceb64aa9b9cafffd1741b9b4060c9753
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-02-22 11:06:49 -08:00
Marc Mutz
05f913d57d qstrncpy: NUL-terminate even when src is nullptr
The goal of this function is to ensure that dst is _always_
NUL-terminated. The only exception is if there's no space to write
even one NUL byte, of course, but not when src is nullptr but dst
would have space.

Update the docs to the new behavior and make them more precise.

Fix a test that assumed qstrncpy() would not write to dst for
(dst, nullptr, 10).

[ChangeLog][QtCore][qstrncpy()] Now NUL-terminates the target
buffer even when the source pointer is nullptr, provided the
target buffer has space for at least one byte.

Pick-to: 6.5 6.4 6.2 5.15
Change-Id: I7806d8c71e260f8f02b79af7b6ce94f23599dd69
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-22 19:24:16 +01:00
Mikolaj Boc
a596ea0fe2 Support always on top/bottom window flags on WASM
The window stack will now upkeep three groups of windows, always
on bottom (1), regular (2), always on top (3). Windows belonging to
(3) will always appear on top of (2) and (1), and windows from (2) will
always appear on top of (1).

The first window created in the application gets the (1) status, which
is in line with the root window mechanism used before.

Activation has now been decoupled from the top position on the window
stack as a window in (1) or (2) may be active, in spite of the top
window belonging to a higher group.

Fixes: QTBUG-110098
Change-Id: I51f4d2d47163fab26ce5ef28f7a4f23a522c7f91
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2023-02-22 18:07:35 +01:00
Ahmad Samir
96e031edd7 QDateTimeParser: add more unittests for the unquote() static helper
Test documented behavior and serv as a baseline for future changes.

Change-Id: I36a914694d5244c89f28f3e403e11d65492a5eef
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-02-22 17:41:20 +02:00
Mikolaj Boc
a85b658469 Polish the qwasmwindow manual test
Change-Id: I9d21404bcf6da7650ec63ef41d5134bb89485a84
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-02-22 13:47:14 +01:00
Christian Ehrlicher
37032b1590 SQL tests: remove unused tests
They were leftovers from QTDS driver removed with Qt6

Change-Id: I34863912bd41e0b4ca54bf443001f1cb3f20511a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-02-20 20:28:38 +01:00
Rami Potinkara
eb0d7b5dcf Android: SKIP cases failing on Android 12 CI with 16GB RAM
SKIP tst_QRhi::tessellation(Vulkan)
SKIP tst_QOpenGLWidget::reparentHidden()
SKIP tst_qvulkan cases

Task-number: QTBUG-108844
Task-number: QTBUG-111235
Task-number: QTBUG-111236
Task-number: QTQAINFRA-5391
Task-number: QTQAINFRA-4733
Pick-to: 6.5
Change-Id: Id227367477173b6ad4cf9433af8eab5976596e70
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-02-20 20:10:48 +02:00
Fabian Kosmale
b124171309 QObjectBindableProperty: Avoid use-after-free in notifyObservers
We so far refetched the first observer after evaluating bindings, as
binding evaluating might change the list of observers.
However, that approach did not take into account that the 'this' pointer
might no longer be valid after binding evaluation: In case of a
QObjectBindableProperty (or a QObjectCompatProperty), binding evaluation
might cause a reallocation of the binding storage, and consequently the
invalidation of the QPropertyBindingData.
Fix this by refetching the QPropertyBindingData from the storage (if a
storage has been provided, which is always the case for the affected
classes).

Fixes: QTBUG-111268
Pick-to: 6.5 6.4 6.2
Change-Id: Ie7e143a0bbb18f1c3f88a81dd9b31e6af463584f
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-02-20 18:07:16 +01:00
Laszlo Agocs
c6b7737436 rhi: d3d11: Drop the built-in TDR test
This does not really belong here as a built-in feature, esp.
considering that such testing is relevant for other backends
as well.

Change-Id: Ifbe3b8c6a430aacb9fcbdabf0e3761b14c48decc
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2023-02-20 18:06:32 +01:00
Mikolaj Boc
6d57ec2bd8 Autopep qwasmwindow.py
Change-Id: I96a5f17a8c2e4f544d8a2d5a5a3685fec54ee0cb
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2023-02-20 15:18:19 +01:00
Fredrik Ålund
0efd8854c4 A QtSql driver for Mimer SQL
The QtSql for Mimer SQL sqldriver makes it possible to work with the
Mimer SQL database on different plattforms. There are drivers for
several other databases in QtSql and a driver for Mimer SQL will
benefit many users.
To build the Mimer SQL driver, download Mimer SQL from
https://developer.mimer.com

[ChangeLog][QtSql]
Added a QtSql plugin to work with the Mimer SQL database

Fixes: QTBUG-111219
Change-Id: Id6ba5de4de01189d0516ffbfa89efcb0d013115f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-02-20 14:18:18 +00:00
Ahmad Samir
360f69b74b QString: build tst_QString::arg() without ASCII casting [13/13]
Drive-by change: use UTF-16 instead of UTF-8 for Eastern Arabic
Numerals, both are not human-readable but UTF-16 is one code point
instead of the two for UTF-8, less \x.

Pick-to: 6.5
Change-Id: I721f3989b7d776ddc4f9d337b21dca9d398fcc0d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-20 14:44:31 +02:00
Ahmad Samir
ff7848318f QString: build tst_QString::contructor() without ASCII casts [12/13]
Constructing from const char* etc is already covered by
constructorQByteArray.

I took a guess that the "// b(10)" comment is about testing constructing
a QString from a QChar[] that has an explicit \0 charcater. I tried
finding what the initial intent was but the trail went cold at the
"Initial import from the monolithic Qt" commit.

Pick-to: 6.5
Change-Id: I15bcdb24e55286eb6cd3056af0714a1eed581635
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-20 14:44:31 +02:00
Volker Hilsheimer
fb09c82a2c QGesture: make sure we copy timestamp value for event clones
Otherwise, double-click recognition will fail.

Use QEvent::clone when possible, or set the timestamp explicitly when
not.

As a drive-by, remove some long-dead code in affected code lines.

Fixes: QTBUG-102010
Pick-to: 6.5 6.4 6.2
Change-Id: I882bf6e8090bf6f182b7a0a3c62aa3a4c8db2e14
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2023-02-17 23:41:04 +01:00
Friedemann Kleint
97bfacf1e2 tests: Remove remains of qmake conversion from CMakeLists.txt files
Pick-to: 6.5
Change-Id: I8d106554bb86ac1ec9bb7a4083de4c376bcbab1d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-02-17 21:56:49 +01:00
Ahmad Samir
eb4641210c QString: change unittests to compile with QT_NO_CAST_FROM_ASCII [7/13]
I.e. the second arg to QCOMPARE isn't what's being tested.

Drive-by changes:
- More _L1 usage, less blocky and easier to read
- QCOMPARE's second arg can be a View, it is smart enough and can
  compare them just fine
- Replace a "//15 chars" comment with a QCOMPARE check

Pick-to: 6.5
Change-Id: I4f4b84b16b543df37b0ba2f9dd781b045b2ed397
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-17 22:34:49 +02:00
Tor Arne Vestbø
c26c91b208 macOS: Pick up QWizard background from keyboard assistant via NSBundle
As of macOS 10.14 the keyboard assistant background is shipped as part
of the compiled asset catalog of the app, so looking it up via a URL
will fail.

Instead we look it up via NSBundle's dedicated image lookup function,
which handles both cases.

The logic has also been moved to qwizard.cpp, since the additional
plumbing via QPlatformNativeInterface was unnecessary.

The keyboard assistant itself no longer shows the background image
as of macOS 12, so we might consider doing the same, but the design
of the assistant has also changed significantly, so as long as our
QWizard layout looks like the old keyboard assistant we keep the
background as well.

Pick-to: 6.5 6.2
Change-Id: I7d42dd79b285f3518837458864bca6bc353b3b6d
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-02-17 18:02:25 +01:00
Ahmad Samir
4499600fc7 QString: split toNum unittests
- Port macros to QTest data rows in separate unittests
- Move DOUBLE_TEST-related data to toDouble() unittest
- Drop one redundant unittest:
    QTest::newRow("const-charstar") << (const char*)0;

Pick-to: 6.5
Change-Id: Ie809895e9f5d58c2d3ec419689f409b55e24fcf7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-17 10:36:05 +02:00
Ahmad Samir
fdf112fd1d QString: unittests: clean-up creating a QChar[]
Pick-to: 6.5
Change-Id: I3864d145c05ae4268fe576f84723acc5eba3c2cb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-17 10:36:05 +02:00
Ahmad Samir
4f1d3426ac QString: change test data to compile with QT_NO_CAST_FROM_ASCII [3/13]
Pick-to: 6.5
Change-Id: I5127831d5f9dcf200d0892b1ab58760180dda610
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-17 10:36:05 +02:00
Ahmad Samir
5a2ebc9f40 QString: build count/contains() unittests with no ASCII casting [11/13]
Drive-by change: Test more count/contains() overloads.

Pick-to: 6.5
Change-Id: Ife3afe9aab68e18cc1587c11108a18a413c339c3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-17 10:36:05 +02:00
Ahmad Samir
2ade07b39e QString: change test data to compile with QT_NO_CAST_FROM_ASCII [9/13]
Pick-to: 6.5
Change-Id: I20dcf2d69c1446faef79bd24a78b1b86feec4ccb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-17 10:36:04 +02:00
Ahmad Samir
448683809b QString: change test data to compile with QT_NO_CAST_FROM_ASCII [8/13]
Pick-to: 6.5
Change-Id: I72ebb7bb19e35a10aa85ea7da6ee6b1b332050a5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-17 10:36:04 +02:00
Ahmad Samir
19b52ad2e5 QString: change test data to compile with QT_NO_CAST_FROM_ASCII [6/13]
Pick-to: 6.5
Change-Id: Ib747bd69f15c3e1d2deaa5a0168fcbcddbbb8f8e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-17 10:36:04 +02:00
Ahmad Samir
fcb9ef5062 QString: split some double/Nan/Inf unittests
And switch to using test data rows (rooting out two macros in the
process).

Pick-to: 6.5
Change-Id: Ib31e6b59f90f0983c0efc4bef7cb246aedfcab5b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-16 23:38:25 +02:00
Ahmad Samir
5c56fc6d2c QString: change test data to compile with QT_NO_CAST_FROM_ASCII [5/13]
Drive-by change: change C-style cast, (qlonglong)0, to C++ style cast
qlonglong(0).

Pick-to: 6.5
Change-Id: Ie7a36c17ac9c14f0606fcb4b112eba3f0180232e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-16 21:17:52 +02:00
Ahmad Samir
4f30d4f456 QString: change test data to compile with QT_NO_CAST_FROM_ASCII [4/13]
Pick-to: 6.5
Change-Id: I086d20547912da45282b88e290fdae9d2029c6bf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-16 21:17:43 +02:00
Ahmad Samir
6542f4174e QString: change test data to compile with QT_NO_CAST_FROM_ASCII [2/13]
Pick-to: 6.5
Change-Id: If3b5eaf9964b3834c116522bc9a6bb89cd5b1626
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-16 21:17:10 +02:00
Ahmad Samir
6e5c6ef739 QString: change test data to compile with QT_NO_CAST_FROM_ASCII [1/13]
Change test data to compile with NO_CAST_FROM_ASCII uncoditionally where
casting from ASCII isn't what's being tested by a unittest.

The goal is to add a variant of tst_qstring that is compiled with
QT_NO_CAST_FROM_ASCII so that the unittests cover that code path too.

The commits are split into smaller chunks (where there is a common
link between changed code, that code is put in a commit, otherwise I
kept the number of changed lines below ~150) to make reviewing them
easier.

Pick-to: 6.5
Change-Id: I14256f1bde7749a3023753dbb7ed8be72cb6bc14
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-16 21:17:04 +02:00
Marc Mutz
93060e1b0e tst_ContainerApiSymmetry: fix -Wsign-compare
Amends 7cbdc8abbd.

Change-Id: Ieed5e771bb716475d6e0fe9566627f664e04a432
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-02-16 16:48:45 +01:00
Volker Hilsheimer
557dcd8a87 QAbstractItemView: don't start editing on Ctrl-Click
Amends 17c1ebf8bf, after which dragEnabled
item views toggled selection on click rather than on press. If the edit
trigger included SelectedClicked at the same time, then Ctrl-Clicking a
selected item would start editing the item, instead of toggling
selection.

Fix this by ignoring clicks with modifier when evaluating whether
editing should start.

Extend the mouseSelection test case by including a column for the
editTrigger, and cover the respective combinations.

Fixes: QTBUG-111131
Pick-to: 6.5 6.4 6.2
Change-Id: I9605f9b3d5a49e292551a34c3c4c7a5f9ecb2a89
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-02-16 15:28:18 +01:00
Thorbjørn Lindeijer
3e7226f107 Fix QStatusBar::removeWidget to hide the right widget
`QStatusBar::removeWidget` was hiding the wrong widget (the next one),
since the `removeAt` call changed the item that the `item` variable
is referencing.

This fixes a regression in Qt 6.3.0 (7166a82844).

Pick-to: 6.5 6.4
Change-Id: I9977b47e6208f8d451ff1037bcb9f4e8414cb431
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl>
2023-02-16 12:40:07 +01:00
Assam Boudjelthia
df47d7d1ff Android: use test QFileInfo fileName() instead of completeBaseName()
using fileName is more correct in this case.

Task-number: QTBUG-98974
Pick-to: 6.5 6.4 6.2 5.15
Change-Id: I7c547bfc1c2321d4817dc087d3e962dbc2a0b7fd
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2023-02-16 03:02:25 +02:00
Ivan Solovev
b34bea5e96 QFuture: fix continuation cleanup
Not clearing the continuationData could lead to use-after-free when
there is an attempt to cancel an already finished future, which belongs
to an already-destroyed promise.

This patch fixes it be explicitly resetting continuationData to nullptr
in the clearContinuation() method, which is called from the QPromise
destructor.

Task-number: QTBUG-103514
Pick-to: 6.5 6.4 6.2
Change-Id: I6418b3f5ad04f2fdc13a196ae208009eaa5de367
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-15 15:12:12 +01:00
David Edmundson
ec8e6ed200 Fix connections in QWidgetWindow
A recent update moved handleScreenChange out of being a private slot.
Porting to the new syntax fixes the warning and moves to a compile-time
check.

Pick-to: 6.5
Change-Id: Ibd85c6caf7dca051d669250a94a82fbddbd3435d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-02-15 15:12:12 +01:00
Mikolaj Boc
3dc6fdc6d8 Fix the handling of dead keys and test the mechanism
An effort has been made to support more keyboard layouts that provide
dead keys (US international, Mac-specific dead keys).

The dead key is translated now at the event conversion phase, not
when it is actually used for modifying keys, which simplifies the logic.

Unittests have been created to check the translation mechanism.

Fixes: QTBUG-86272
Change-Id: I07f7d63f5a37f8469c693b034b400da99379f519
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2023-02-14 23:18:42 +01:00
Thiago Macieira
6d17697913 QFileSystemWatcher/Win: remove the pre-QFileInfo path normalization
It's completely unnecessary, since QFileInfo will query the file system
anyway and that has a much better view of what is normalized and what
isn't. More importantly, this fixes the mistake in failing to normalize
properly in removePaths(), which removed the ending slash of a root
directory such as "C:\\". That caused the path to become "C:", which
QFileInfo interprets as "current path on drive C:".

[ChangeLog][QtCore][QFileSystemWatcher] Fixed a bug that prevented
removePaths() from removing the root of a drive on Windows.

Fixes: QTBUG-110986
Pick-to: 5.15 6.2 6.4 6.5
Change-Id: I9671dee8ceb64aa9b9cafffd17419b6d69670876
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-14 11:27:24 -08:00
Mikolaj Boc
0e520e5814 Skip the tst_QStringConverter::threadSafety test on WASM temporarily
The test needs investigation. Skip it for now so that we can enable
CI for WASM but leave a note to investigate it.

Task-number: QTBUG-109954
Change-Id: I9448312c2c16ec4f31279dcbe4e2213681cabe8a
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-02-14 20:24:15 +01:00
Fabian Kosmale
9483fcd68a QObject: Handle pointers to incomplete types in auto-connections
The code for the QMetaMethod queuedConnectionTypes overload relied on
QMetaMethod::parameterMetaType and QMetaType::flags() to detect whether
we're dealing with a pointer (and then use the VoidStar metatype instead).
However, if the type was incomplete when the slot was defined, and the
type was not registered when connect was called, we would not find a
metatype for the argument.
However, in that case we might still be able to handle the method, by
checking whether the type name of the arguments ends with a "*".
This patch does that, fixing a regression from 5.15.

Pick-to: 6.5 6.4 6.2
Fixes: QTBUG-108537
Change-Id: I54cc48a3343444480ab9094fe1ebaaa5aa75cee0
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-02-14 19:24:22 +01:00
Mikolaj Boc
d846ea423d Add a manual test for wasm window resizing/moving
This tests resizing and moving in various setups. The test driver
communicates with the actual modules to assert various
postconditions.

It's semi-automated so that minimum interaction is required.

Change-Id: I745d689c6ffa6aa6d478b795dd433f5b067241f1
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2023-02-14 17:48:09 +01:00
Laszlo Agocs
c20336fe03 Update recent rhi autotest to skip on D3D12 as well
Change-Id: I4da78cd0cd1fd5015bc28bf01e59884abafa6995
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-02-14 17:48:09 +01:00
Ben Fletcher
dc0b2466f8 RHI: Metal SPIRV-Cross buffer size buffers
When SPIRV-Cross encounters a GLSL storage buffer runtime sized array,
it generates MSL code which expects a "buffer size buffer" containing a
list of storage buffer sizes to be bound.  This patch adds RHI backend
support for Metal "buffer size buffers" on compute and graphics
(including tessellation) pipelines.  Includes unit tests.

An accompanying patch to qtshadertools is required.

Change-Id: I9392bfb21803e1a868d7de420fedc097a8452429
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-02-14 17:48:09 +01:00
Laszlo Agocs
870a3011ed rhi: Add a displacement / tessellation manual test
There is something odd when running on Metal: note how the uv
is vec3 instead of vec2, in order to make the vertex-tesc-tese
data to look like this:

struct main0_out
{
    float3 out_uv;
    float3 out_normal;
    float4 gl_Position;
};

if out_uv was float2 we'd get some strange rendering results,
perhaps due to something related to alignment. But have no means
to investigate this further.

Change-Id: I79d4edb2ddde3971c599c4326d98e99a49aa7122
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-02-14 17:48:09 +01:00
Mate Barany
fd70555b33 Deprecate usage of qt_ntfs_permission_lookup
With the introduction of a new atomic variable the users should use the
class QNtfsPermissionCheckGuard or the helper functions
- qEnableNtfsPermissionChecks()
- qDisableNtfsPermissionChecks()
- qAreNtfsPermissionChecksEnabled()
to enable/disable permission checks instead of manually managing the
variable qt_ntfs_permission_lookup (which is a non-atomic variable and
as such prone to data races).

Also moved the variable qt_ntfs_permission_lookup to qfile.h to make it
clash with the user-side declarations the documentation suggested to
use (and it is probably also a better fit thematically anyway).

[ChangeLog][QtCore][Deprecation Notice] Deprecated the variable
qt_ntfs_permission_lookup to avoid race conditions while enabling or
disabling permission checks. It can be replaced by the RAII class
QNtfsPermissionCheckGuard or with the functions
qEnableNtfsPermissionChecks(), qDisableNtfsPermissionChecks() and
qAreNtfsPermissionChecksEnabled().

Fixes: QTBUG-105804
Change-Id: I93a563864ffb3f9945551c34004d8ca393603b25
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-02-14 13:23:19 +01:00
Assam Boudjelthia
249d613a60 Fix few QFileInfo and QDir calls
Return the file engine impl of QFileInfo::completeBaseName() and
QDir::absolutePath() and QFileInfo::fileName() (based on
QAbstractFileEngine::BaseName) if the file engine impl is valid.

Amends f77668ffec.

Pick-to: 6.5 6.4 6.2 5.15
Task-number: QTBUG-98974
Change-Id: I28a8c75a6f25e30012b0791c12dbde51bfe8f62c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-14 00:18:29 +01:00
Volker Hilsheimer
52ce4d2d29 QMenu: guard for destruction when emitting action signals
If a slot connected to a QMenu-action destroys the QMenu, then
we must not touch data members in subsequent code, and instead return
immediately.

We cannot use QBoolBlocker here, as that would reset the data
member of QMenuPrivate even when trying to return early.

Fixes: QTBUG-106718
Pick-to: 6.5 6.4 6.2
Change-Id: I6b5ea471b1bf1f9864e1384382100f8f6c01346f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-02-13 18:20:25 +01:00
Matthias Rauter
a2dab1bda9 Fix build issue in manual example qtabbar/stylesheet
Pick-to: 6.5
Change-Id: Ibeb1a83ea74bea53e76990d7448552e33f3d875a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-02-13 17:00:40 +00:00
Sebastian Beckmann
f11e5435c7 QAbstractItemView: Don't unselect on click on empty area in SingleSelect
dfb4697e4a made a change to selection
behavior that resulted in a regression where clicking on an item view
but not on an item would cause the current item to get unselected.
Changes the behavior to not update in this case.

Added a new test that specifially checks for this scenario and ensures
that the current item is still selected, even after the user clicks on
empty area.

Fixes: QTBUG-105870
Pick-to: 6.2 6.4 6.5
Change-Id: I191c3878819b99897083039fba0ab43908da5429
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-02-11 12:47:24 +01:00
Marc Mutz
49fca96d88 tst_qvarlengtharray: fix MyBase trackers for swap()
I don't begin to understand the semantics of the trackers here, but
whatever they are, they break with the fallback std::swap() 3-moves
implementation and lose track of alive objects, so provide an ADL swap
that does the right thing.

Amends dd58ddd5d9 (I think).

Pick-to: 6.5 6.4 6.2 5.15
Change-Id: I1cd49c95dca2d103a26c2c7ac0a896929135a6c8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-02-10 23:31:37 +01:00
Marc Mutz
224930726b Long live QScopedPropertyUpdateGroup
A RAII wrapper around Qt::{begin,end}PropertyUpdateGroup().

[ChangeLog][QtCore][QScopedPropertyUpdateGroup] New RAII class
wrapping Qt::beginPropertyUpdateGroup() and
Qt::endPropertyUpdateGroup().

Fixes: QTBUG-110710
Change-Id: If2619e9584dd9d57985d63e3babca75421499ab9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-02-10 18:27:08 +00:00
Eskil Abrahamsen Blomfeldt
fc33fea999 Don't do font merging for PUA characters
The "Private Use Area" are subsets of Unicode which are not
considered regular characters, but reserved for fonts to provide
custom glyphs.

If these were used and the main font did not have support for them,
we would look them up in other fonts and sometimes display an
arbitrary selection of glyphs, based on whatever existed on the
platform. This is unexpected and different from how native apps
work on Windows, for instance.

[ChangeLog][QtGui][Text] Font merging (automatic assignment of
alternative fonts) is no longer applied for characters in the
Private Use Areas of Unicode.

Pick-to: 6.5
Fixes: QTBUG-110502
Change-Id: Id2c63786aafda59bf170e0d7263eb78a391fe46d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-02-10 14:56:34 +01:00
Ahmad Samir
b5a54d488c QDir: use QCollator when doing locale-aware sorting
And don't use toLower() as QString::compare() and QCollator::compare()
can compare case-insensitively.

Change-Id: I999d787cb77e10a101da75d1bf0a5baf096a5c9b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-10 01:19:21 +02:00
Ahmad Samir
eb60e94020 QString: don't detach in replace_helper()
I.e. don't detach in the replace() overloads that delegate to
replace_helper() if this string is shared, instead create a new string
and copy characters from this string to it, along with the "after"
string, then swap it with this.

Do the same thing if "before" is shorter than "after" and there isn't
enough capacity to do the replacement without reallocating.

Use std::copy* and std::move*, which will both fallback to
memmove/memcpy, but they have C++ API, which is more readable.

[ChangeLog][QtCore][QString] Using replace() on a currently shared
QString is now done more efficiently

Task-number: QTBUG-106184
Change-Id: If74ffa1ed47636dc23d543d6dc123d8f2b21d537
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-09 22:52:01 +02:00
Ahmad Samir
5f73f48556 QString: optimize insert(qsizetype, QUtf8StringView)
Utf8 data is variable-width, ideally we want to write characters at most
once, so insert directly into the QString buffer if inserting at the end
(by delegating to append(QUtf8SV)), and use an intermediate buffer to
hold the converted data before inserting anywhere else.

Task-number: QTBUG-108546
Change-Id: Iabfaeecaf34a1ba11946bd67951e69a45d954d6d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-09 16:49:54 +02:00
Ahmad Samir
cc6324665e QString: don't detach in insert()
Instead of detaching when the string is shared, or if the the insertion
would cause a reallocation, create a new string and copy characters to
it as needed, then swap it with "this" string. This is more efficient
than detaching which would copy the whole string before inserting, as
some characters would be copied multiple times.

Use detachAndGrow(), otherwise QStringBuilder unitests fail:
PASS   : tst_QStringBuilder1::initTestCase()
FAIL!  : tst_QStringBuilder1::scenario() 'prepends < max_prepends' returned FALSE. ()
   Loc: [tests/auto/corelib/text/qstringbuilder/qstringbuilder1/stringbuilder.cpp(61)]
PASS   : tst_QStringBuilder1::cleanupTestCase()

The issue is that now when inserting, if the string is going to
reallocated, we create a new string, so the freeSpaceAtBegin()
optimization doesn't work the same way.

void checkItWorksWithFreeSpaceAtBegin(const String &chunk, const Separator &separator)
{
    // GIVEN: a String with freeSpaceAtBegin() and less than chunk.size() freeSpaceAtEnd()
    String str;

    int prepends = 0;
    const int max_prepends = 10;
    while (str.data_ptr().freeSpaceAtBegin() < chunk.size() && prepends++ < max_prepends)
        str.prepend(chunk);
    QVERIFY(prepends < max_prepends);
    ...
    ...

each str.prepend() would have reallocated.

[ChangeLog][QtCore][QString] Calling insert() on a currently shared
string is now done more efficiently.

Task-number: QTBUG-106186
Change-Id: I07ce8d6bde50919fdc587433e624ace9cee05be8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-09 16:49:26 +02:00
Ahmad Samir
26fec96a81 QString, QByteArray: don't detach in removeIf/erase/eraseif()
If the object is shared, instead of detaching, copy characters from
"this" to a new object except for the chacters that would be erased,
this is more efficient than detaching (which would copy the whole data
then erase).

- Extend tst_QString::removeIf() to catch a corner-case (that I saw
  with tst_QByteArray::removeIf()).

- Add q_uninitialized_remove_copy_if, which works like
  std::remove_copy_if but for uninitialized memory like
  q_uninitialized_relocate_n (but copies rather than relocates/moves).
  With the same static_assert from q_relocate_overlap_n that the type
  destructor is non-throwing.

Added q_uninitialized_remove_copy_if in this commit rather than a
separate one so that it's unittested by its usage in eraseIf().

[ChangeLog][QtCore][QString, QByteArray] Removing characters from a
currently shared string or byte array is now done more efficiently

Task-number: QTBUG-106181
Task-number: QTBUG-106183
Change-Id: Icc0ed31633cef71d482b97e0d2d20d763163d383
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-09 16:46:39 +02:00
Volker Hilsheimer
48a1a5564f Examples: move widgets/codeeditor into manual tests
It's not a very well written example, using (largely unneed) hacks to
implement what it does. It's also misleading - the syntaxhighlighter
example is a better showcase for building a useful code editor.

Move it to manual tests.

Fixes: QTBUG-111025
Pick-to: 6.5
Change-Id: I405d41688235bf3e9a08373e716769f26d02fec6
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-02-09 00:23:34 +01:00
Volker Hilsheimer
3fe0bf6e1b Move findfiles example into manual tests
The example follows bad and outdated practices:

- running time consuming and I/O heavy workload in the GUI thread
- calling processEvents to keep the UI responsive
- showing results only at the end of a search rather than continuously

Perhaps this example can be rewritten at some point to apply modern
practices (at least use a thread and emit signals), but it seems
to have low overall educational value.

Moving it to be a manual test for now.

Fixes: QTBUG-111002
Pick-to: 6.5
Change-Id: Id630fd4599096448ea4f96bcbf977b11a039796f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-02-09 00:23:34 +01:00
Christian Ehrlicher
66a1a71f1f Fix QVariant(QString) <-> enum conversion
A QVariant(QString) was not convertible to an enum not registered with
Q_ENUM() which worked fine in Qt5.
The same problem exists for QVariant(enum) to QString.
Fix it by not bailing out when no metatype for the enum was found and
try to convert it to a qlonglong instead (which is then correctly
converted to the enum type).

Fixes: QTBUG-109744
Pick-to: 6.5 6.4
Change-Id: Ie7bb016a860455b69508f0f46b36474c9c294f3a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-08 23:20:42 +01:00
Dennis Oberst
7cbdc8abbd QVarLengthArray: add STL-style assign()
Implemented assign() methods for QVarLengthArray to align
with the criteria of std::vector, addressing the previously
missing functionality.

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

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

Fixes: QTBUG-106200
Change-Id: If671069808ff561b0f4c77b6c7f7aca360a0c663
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-02-08 21:13:08 +01:00
Fabian Kosmale
7a415a051a Avoid accessing deleted binding data in grouped updates
This fixes a use-after-free in QPropertyDelayedNotifications::notify.

Before this patch, evaluateBindings or a notify from a property index
might have caused the originalBindingData to become reallocated.
However, at that point, we've already restored the original bindingData
in evaluateBindings, so we won't track updates, and thus won't adjust
originalBindingStatus, which will then point to already freed data.

To remedy this, we no longer do the notification with data fetched from
originalBindingData, but instead use the information we have in the
proxyData.
We also need to enure that referenced bindings do not get deleted; for
that we keep the PendingBindingObserverList alive for the whole duration
of the endPropertyUpdateGroup.

As we now have the PendingBindingObserverList, we use it for the
notification logic, and only notify change handlers in
QPropertyDelayedNotifications::notify. That will allow a follow-up
cleanup of QPropertyObserverPointer::notify, and aligns the logic for
grouped updates with the logic for "nornal", non-grouped updates.

Amends f1b1773d0a.

Task-number: QTBUG-110899
Pick-to: 6.5 6.4 6.2
Change-Id: Iae826e620d9614b7df39d86d8a28c48c8a5c4881
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-02-08 16:54:26 +01:00
Fabian Kosmale
f69bcf8d80 Deprecate QPropertyAlias
That use case for the class never materialized, and it was actually
meant for internal use. However, we put it into the public header, so
we cannot remove it (and while undocumented, someone actually used it at
some point, compare e4d62651c2).

Mark it as deprecated instead so that it can be finally be removed in Qt
7.

Change-Id: I058c5831a44610121fbec6eaddebd8b33d4a16c9
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-02-08 16:54:25 +01:00
Mate Barany
84f0596c0c Avoid potential data races caused by qt_ntfs_permission_lookup
qt_ntfs_permission_lookup is a global, non-atomic variable which
could cause problems in case of multiple threads. Introduce a
new atomic variable to handle permission lookups but instead of
manual incrementation/decrementation, implement a class to manage
the variable.

Since the atomic variable is not directly available to the user,
implement helper functions to increase/decrease/check the status
of the variable.

Task-number: QTBUG-105804
Change-Id: If6cbcdd653c7f50ad9853a5c309e24fdeb520788
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-02-08 12:59:19 +01:00
Alexey Edelev
214c3a033a Add simple project generation based on existing source files
Introduce the qt-cmake-create script. The script generates the simple
CMakeLists.txt based on the source files located in the current or
specified directory. The initial version can generate a CMake code for
the following file types:
  - .c .cc .cpp .cxx .h .hh .hxx .hpp - generates the qt_add_executable
    call with prerequisites.
  - .qml .js .mjs - generates the qt_add_qml_module call with
    prerequisites.
  - .ui - adds the found ui files to the existing executable. Requires
    C++ files be present in the directory too.
  - .qrc - generates the qt_add_resources call and adds the resources
    to the existing executable. Requires C++ files be present in the
    directory too.
  - .proto - generates qt_add_protobuf call with prerequisites.

The QtInitProject.cmake script contains the 'handle_type' function that
allows extending the script capabilities and establish simple relation
chains between the file types.

Note: The initial implementation doesn't deal with sub-directories, so
all files from sub-directories will be added to and handled in the
top-level CMakeLists.txt file. This can be extended by user request.

Task-number: QTBUG-104388
Change-Id: I5abd9e07da109e867ff95986572ed2bf02ef9d3d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-02-08 12:59:19 +01:00
Paul Olav Tvete
52150469a8 Resurrect wiggly example as a manual test
In addition to being an iconic part of Qt's history, wiggly is also
widely used for verifying on embedded hardware.

Change-Id: Ica86626d98ade2570eebe787860293380c21f96a
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2023-02-08 09:35:56 +01:00
Thiago Macieira
b41c44d966 qdbusxml2cpp: don't emit Q_DECL_DEPRECATED for the adaptor
The adaptor is a server-side implementation that must exist anyway and
is called by the QtDBus runtime. We don't want warning on the server
side because it must call those methods to implement the client API.

Since we have the XML introspection saved in a class property anyway,
the runtime won't be inspecting the method tags to see if
Q_DECL_DEPRECATED is there, to add to the XML (which it isn't
generating).

Pick-to: 6.5
Change-Id: I9671dee8ceb64aa9b9cafffd17416596135d26ca
Reviewed-by: David Faure <david.faure@kdab.com>
2023-02-07 16:32:23 -08:00
Thiago Macieira
f67b32e735 qdbusxml2cpp: invert Q_DECL_DEPRECATED and inline in the output
Commit 93dad2bf91 (6.0) changed
Q_DECL_DEPRECATED to use the [[deprecated]] attribute, which must appear
before inline and other keywords.

To keep it next to Q_NOREPLY, I also moved the "inline" into the next
string.

Added missing tests for both.

Pick-to: 6.2 6.4 6.5
Fixes: QTBUG-110979
Change-Id: I9671dee8ceb64aa9b9cafffd1741656e86f40453
Reviewed-by: David Faure <david.faure@kdab.com>
2023-02-07 16:32:22 -08:00
Thiago Macieira
0128c3742e tst_qdbusxml2cpp: test the old-style QDBusReply interface output too
Pick-to: 6.2 6.4 6.5
Change-Id: I9671dee8ceb64aa9b9cafffd17416487c07f148a
Reviewed-by: David Faure <david.faure@kdab.com>
2023-02-07 16:32:21 -08:00
Fabian Kosmale
55ca636180 Fix proxy-data handling
This addresses two different issues:
- Firstly, we were casting the resolved binding data pointer to
  QPropertyProxyBindingData, instead of the d_ptr of
  QPropertyBindingData. Fix this by introducing a helper function,
  and consistently using it to access the proxy data.
- Secondly, we were not resetting the originalBindingData when the
  pointed to object was destoyed. Fix that, too.

Pick-to: 6.5 6.4 6.2
Task-number: QTBUG-110899
Change-Id: I7691c9df5cc26e761f6b0e5f16d152f7f2183208
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-02-07 22:27:37 +01:00
Mate Barany
9a8b9473d5 Update CLDR to v42
New languages (and one local for each) added with v42
- Haryanvi
- Moksha
- Northern Frisian
- Obolo
- Pijin
- Rajasthani
- Toki Pona

It also appears that Canada has changed its date format. Modify the
relevant test case to reflect this change.

Task-number: QTBUG-110333
Pick-to: 6.5
Change-Id: Ia8975c2866cd54c9e565543d05bacd52f4987909
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-02-07 19:04:11 +01:00
David Faure
eae031d5c3 Fix QDir benchmark to do meaningful things
* Include the creation of the QDir inside QBENCHMARK, otherwise
  the it can hit the cached code path where subsequent runs return
  results much faster.

* Same for the opendir()/readdir() test: if opendir() isn't called
  again, readdir() will just return null right away.

These two issues led to nonsense results like 0.00025 msecs per
iteration, doing nothing is really quick.

While at it, port the cleanup code to QDir::removeRecursively()

Pick-to: 6.5 6.4 6.2
Change-Id: Ic1bdd92d41efe1f6d0eaaa33eca066cb7d19fc93
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-07 13:33:01 +01:00
Laszlo Agocs
84fb0de413 rhi: Add D3D12 support
- The optional nice-to-haves DebugMarkers, Timestamps, PipelineCache
  are not yet implemented (features reported as false, to be
  implemented later, although buffer/texture resource name setting
  already works as-is, regardless of DebugMarkers).

- Mipmap generation for 3D textures is missing. Won't matter much
  given that 3D textures are not used in Qt for anything atm. For
  generating mipmaps for 2D (or 2D array) textures, the MiniEngine
  compute shader and approach is used. 3D support for the mipmap
  generator may be added later. 1D textures / arrays are supported
  except for mipmap generation, and so the
  OneDimensionalTextureMipmaps feature is reported as false.

- Qt Quick and Qt Quick 3D are expected to be fully functional.
  (unforeseen issues are not impossible, of course)

- Uses minimum feature level 11.0 when requesting the device. It is
  expected to be functional on resource binding tier 1 hardware even,
  although this has not been verified in practice.

- 2 frames in flight with the usual resource buffering
  (QRhiBuffer::Dynamic is host visible (UPLOAD) and always mapped and
  slotted, other buffers and textures are device local (DEFAULT).
  Requests 3 swapchain buffers. Swapchains are mostly like with D3D11
  (e.g. FLIP_DISCARD and SCALING_NONE).

- The root signature generation is somewhat limited by the SPIR-V
  binding model and that we need to map every binding point using the
  nativeResourceBindingMap from the QShader. Thus the root signature
  is laid out so each stage has its own set of resources, with shader
  register clashes being prevented by setting the visibility to a
  given stage.

  Sampler handling is somewhat suboptimal but we are tied by the
  binding model and existing API design. It is in a fairly special
  situation due to the 2048 limit on a shader visible sampler heap, as
  opposed to 1000000 for SRVs and UAVS, so the approach we use for
  textures (just stage the CPU SRVs on the (per-frame slot) shader
  visible heap as they are encountered, effectively treating the heap
  as a ring buffer) would quickly lead to having to switch heaps many
  times with scenes with many draw calls and sampledTexture/sampler
  bindings in the srb.

  Whereas static samplers, which would be beautiful, are impossible to
  utilize safely since we do not have that concept (i.e. samplers
  specified upfront, tied to the graphics/compute pipeline) in the
  QRhi API, and an srb used at pipeline creation may change its
  associated resources, such as the QRhiSampler reference, by the time
  the shader resources are set for the draw call (or another,
  compatible srb may get used altogether), so specifying the samplers
  at root signature creation time is impossible.

  Rather, the current approach is to treat each sampler as a separate
  root parameter (per stage) having a descriptor table with a single
  entry. The shader visible sampler heap has exactly one instance of
  each unique sampler encountered during the lifetime of the QRhi.

- Shader-wise no different from D3D11, works with HLSL/DXBC 5.0
  (i.e. existing .qsb files with DXBC in them work as-is). But unlike
  D3D11, this one will try to pick 6.7, 6.6, ..., down to 5.0 from the
  QShader, in that order.

- Uses D3D12MA for suballocating. As a result it can report vmem
  allocation statistics like the Vulkan backend, and it does more
  since the DXGI memory usage (incl. implicit resources) is also
  reported.  This is optional technically, so we also have the option
  of going straight with the heavyweight CreateCommittedResource()
  instead.  That is what we do if the adapter chosen reports it's
  software-based or when QT_D3D_NO_SUBALLOC=1 is set.

- PreferSoftwareRenderer (picking the WARP device) and the env.var.
  QT_D3D_ADAPTER_INDEX work as with the D3D11 backend.

- It is not unexpected that with large scenes that generate lots of
  draw calls with multiple textures/samplers per call the performance
  may be slightly below D3D11 (probably mostly due to descriptor
  management). Similarly, the reported memory usage will be higher,
  which is partly natural due to creating heaps, descriptor pools,
  staging areas, etc. upfront. Will need to be evaluated later how
  these can be tuned.

Change-Id: I5a42580bb65f391ebceaf81adc6ae673cceacb74
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-02-07 13:33:01 +01:00
Ville Voutilainen
9286d46ee2 Skip socket and server tests on Ubuntu 22.04 and QEMU
Task-number: QTBUG-107696
Change-Id: Ic9cecd0c8624e7e8211633ef8a8ce0339662b4f6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-05 18:50:30 +00:00
Axel Spoerl
b464119dd4 Unblacklist stable tst_QWidgetRepaintManager
Failing test functions fastMove, moveAccross, moveInOutOverlapped seem
to be stable in the meanwhile. This patch removes the blacklisting.

Task-number: QTBUG-109036
Pick-to: 6.5
Change-Id: I9a2b015572e4d8a4eac196d3985c052030fd84e2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-02-03 18:44:55 +01:00
Edward Welbourne
b62ac40987 Move qtLocalTime() to qtenvironmentvariables.cpp as qLocalTime()
The new name better matches the names of existing functions there.
A comment on the old code noted that such a move should really be
done, so as to correctly share the environment-mutex locking.

In the process, move the (now three) time-related internal functions
from qglobal_p.h to a new qtenvironmentvariables_p.h since that's the
natural place for them given where they're defined (and the fact that
they're for internal use only).

Change-Id: Ib028baebaf31a806a2c0c97caaaba0a466c11cea
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-03 14:45:31 +01:00
Mårten Nordheim
78c5ca4c85 Update the public suffix list
Pick-to: 6.5
Task-number: QTBUG-110333
Change-Id: I741feee3a19d0a104496f543d35a1f311a7228d6
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-02-03 12:56:59 +01:00
Thiago Macieira
9d2f3e63b8 QMimeDatabase: add a test to ensure we can detect Unix specials
Pick-to: 6.4 6.5
Change-Id: I570832c9ac8b4e03bde8fffd173f7e743f42f22b
Reviewed-by: David Faure <david.faure@kdab.com>
2023-02-02 12:17:25 -08:00
Thiago Macieira
40dd38813c QMimeDatabase: don't stat() something that isn't a local file
We must check that the path is an actual file on the filesystem before
using native APIs. This regression was introduced by commit
047d8f36de.

[ChangeLog][QtCore][QMimeDatabase] Fixed a regression from 6.4.0 that
made certain QMimeDatabase functions that inspected file contents to fail
on Unix systems, if the file was not a native file (e.g., a Qt resource).

Fixes: QTBUG-110707
Pick-to: 6.4 6.5
Change-Id: I570832c9ac8b4e03bde8fffd173f7b4c6b164192
Reviewed-by: Igor Kushnir <igorkuo@gmail.com>
Reviewed-by: David Faure <david.faure@kdab.com>
2023-02-02 12:17:24 -08:00
Thiago Macieira
bfe42ebdeb tst_QMimeDatabase: rename test to indicate what it really is
This test is calling mimeTypeForFileNameAndData(), so it doesn't
actually use the files.

Change-Id: I570832c9ac8b4e03bde8fffd173f77f138ef3434
Reviewed-by: Igor Kushnir <igorkuo@gmail.com>
Reviewed-by: David Faure <david.faure@kdab.com>
2023-02-02 12:17:24 -08:00
David Faure
c609b8dba0 QSortFilterProxyModel: port to PMF connects for performance reasons
BEFORE:
   0.21 msecs per iteration (total: 56, iterations: 256)
   801,946 CPU cycles per iteration (total: 801,946, iterations: 1)

AFTER:
   0.084 msecs per iteration (total: 87, iterations: 1024)
   300,259 CPU cycles per iteration (total: 300,259, iterations: 1)

Change-Id: I5b2703c217bb25e18f1d9f6a1eda19c60e1edcb0
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2023-02-02 20:43:59 +01:00
Ulf Hermann
41248f2590 moc: Allow calling ctors on pre-allocated data
When calling a ctor this way, an object is created in the memory pointed
to by _a[0] using the other arguments for the ctor.

This allows separate allocation and initialization of an object through
the metaobject system.

Fixes: QTBUG-108879
Change-Id: Ifb154373ee42faab281cfb62aa14334980ec6b7d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-02-02 15:57:09 +01:00
Ahmad Samir
b291217457 QString: remove some redundant unittests
The QChar::toLatin1() args in:
str.replace(index, len, QChar(after[0]).toLatin1())
s2.replace(ch.toLatin1(), after, cs)

will be converted to QChar, so it's always calling the same QString
overload, I argue that we're not testing QChar implicit conversions
here.

Change-Id: I3962cab2b34684f970638575e6bd15dd1067a8c6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-02 15:57:18 +02:00
Marc Mutz
3f33ed249b Q{Contacts,Calendar}Permission: bool readWrite → enum AccessMode
The fact that read-access is always included makes a bool readWrite
property a little awkward to document and explain. An AccessMode enum
with values ReadOnly and ReadWrite is much easier, and will also lend
itself more easily as a constructor argument than a boolean.

Found in API review.

Pick-to: 6.5
Change-Id: I4f20dbe9f19c7bdb52248a6e544e36d731d5a2ee
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-02-02 14:34:02 +01:00
Friedemann Kleint
441c152d85 QtNetwork: Split out QNativeSocketEnginePrivate
The aim is to have fewer files including <windows.h>.

Pick-to: 6.5
Task-number: QTBUG-109394
Change-Id: Id9cc08f54b5daf6d7e317fad27036dc2efaacbb8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-02 13:19:06 +01:00
Ahmad Samir
d4f72b4de6 QStandardPaths/unix: ignore relative paths in all $XDG_* env vars
This is a continuation of commit 5c9d671bfb.

[ChangeLog][QtCore][QStandardPaths] Improved conformance to the
Freedesktop basedir spec by ignoring any relative paths in XDG_*
environment variables.

Fixes: QTBUG-58043
Change-Id: I7c34143ced97d6d3de6ecbf13bccf9e935462d1e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-01 19:46:02 +00:00
Axel Spoerl
593ffd3859 Add right and middle mouse button to tst_QLabel::mouseEventPropagation
The test function used only the left button to test mouse event
propagation.

This patch adds the right and middle buttons to the test data.

Task-number: QTBUG-110055
Pick-to: 6.5 6.4
Change-Id: I02683168216843919e889987a8b0e8a0f1592d3a
Reviewed-by: Doris Verria <doris.verria@qt.io>
2023-02-01 17:41:58 +00:00
Friedemann Kleint
1fad7aa73e QtGui: Remove define Q_TEST_QPIXMAPCACHE
It causes clashes in CMake Unity (Jumbo) builds.
Change the function to be Q_AUTOTEST_EXPORT'ed helpers.

Pick-to: 6.5
Task-number: QTBUG-109394
Initial-patch-by: Amir Masoud Abdol <amir.abdol@qt.io>
Change-Id: I2e4032e07e1c39432cae1eb2dfff94be33846c09
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-02-01 18:09:05 +01:00
Ahmad Samir
28c974ba97 QMimeDatabase: use unique QTest data tag names
Change-Id: I5f0b270df344b0a8511d48f3cde34643f3115445
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-02-01 18:54:21 +02:00
Thiago Macieira
b22ae069ac QRegularExpression: fix count() when the RE matches a surrogate
When the match finds a surrogate pair as the first true Unicode character,
then we need to skip both code units of the pair in order to restart the
search. PCRE2 does not allow us to search for individual UTF-16 code
units.

That actually means that counting "." gives us the count of Unicode
characters.

Fixes: QTBUG-110586
Pick-to: 5.15 6.2 6.4 6.5
Change-Id: I194d0a32c94148f398e6fffd173d5b5be8137e19
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-01-31 19:38:01 -08:00
Eskil Abrahamsen Blomfeldt
bfe080debb Update Harfbuzz to version 6.0.0
Note: This requires an update to the tst_qtextlayout test, because
the test assumed that the Arabic string would always yield a run
of two glyphs. This was a side effect of how Harfbuzz handled
Qt's test font, which has zero font tables and cannot be used for
shaping. With the Harfbuzz update, the Arabic text here yields a
single cluster instead, which actually makes more sense, so the
test has been made a bit more robust to support both cases.

Pick-to: 6.2 6.5
Task-number: QTBUG-110338
Change-Id: I93d4cf8e3046dc93224e144d4c81d86bef4918d1
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-01-31 08:20:03 +00:00
Ahmad Samir
26f8ea1224 QString: don't detach in replace(QChar, QChar, case)
If the string is shared, instead of detaching, create a new string and
copy the characters from this string, replacing the ones matching "before"
with "after", to the new string.

Change-Id: I2c33690230d40f3121e60e242666460559258b7b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-01-30 23:52:42 +02:00
Ilya Fedin
763884cfb7 Pass short time format to GetTimeFormat from GetLocaleInfo
TIME_NOSECONDS doesn't really switches to short time format,
just removes the seconds from long time format

Fixes: QTBUG-110627
Pick-to: 6.5 6.4 6.2 5.15
Change-Id: Ie799958f3942c657f00bc8196588258661ddc1d9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-01-30 23:10:25 +04:00
Shawn Rutledge
78ba5056e6 Make tst_QFocusEvent::checkReason_ActiveWindow pass on macOS
It seems that on macOS 13.2 and newer, it requires explicit activation,
just as on the offscreen and minimal platforms.

Pick-to: 6.5 6.4 6.2
Task-number: QTBUG-110703
Change-Id: I519eec872505ea3673111ae300c2494113f85c36
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-01-30 13:19:41 +00:00
Jani Heikkinen
2fa21f4821 Revert "Revert "Add binary compatibility file generated against 6.4.0""
This reverts commit cebcb7991a.

Reason for revert: We need to enable BIC tests again

Pick-to: 6.5
Change-Id: Ibabe2c50547972d040d933a1027833426b018e81
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2023-01-23 14:51:55 +00:00
Marc Mutz
577276d12c tst_QUrlQuery: fix Clang 15 -Wself-move
Says Clang 15:

  tst_qurlquery.cpp:193:11: warning: explicitly moving variable of type 'QUrlQuery' to itself [-Wself-move]
    moved = std::move(moved);
    ~~~~~ ^           ~~~~~

It's amazing how little it takes to throw this warning off guards:
just use an alising reference instead of the same variable. Makes you
wonder whether the time spent on detecting such trivialities in the
compiler is really well spent.

Amends fc8dad2f10.

Pick-to: 6.5
Task-number: QTBUG-109842
Change-Id: I165af2a786aa0ba28b8dcd039a500f3494bc29a9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-01-23 10:12:35 +01:00
Ahmad Samir
5d356ae2bd Fix two variables' "may be used uninitialized" compiler warnings
Change-Id: Ie6063d7124b16681b3e39d465da21dd67206ebc3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-01-22 21:19:36 +02:00
Thiago Macieira
7e64ecacb6 IPC: switch the default key type on Unix to POSIX realtime
Instead of the System V one. An important difference is that
QSharedMemory does not clean after itself.

Updated the configure summary output to include this information.
Drive-by update to sorting order and I removed cpp-winrt from the
listing because there's a warning at the end if it is not set.

Change-Id: I12a088d1ae424825abd3fffd171e0eadcfd33426
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-01-22 13:02:11 -03:00
Thiago Macieira
0740ab56d7 IPC: add support for multiple backends to QSharedMemory
Simultaneously.

Change-Id: If4c23ea3719947d790d4fffd17152760989b9bc6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-01-22 13:02:11 -03:00
Thiago Macieira
32a06e9830 IPC: add support for multiple backends to QSystemSemaphore
Simultaneously.

Change-Id: If4c23ea3719947d790d4fffd17152a29e6c217d3
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-01-22 13:02:10 -03:00
Thiago Macieira
4141c5e221 IPC: fix cleaning up after tst_QSharedMemory tests
If a previous test in the same process or previously leaked a shared
memory or semaphore handle, tests could fail and cascade down. They
could also interfere with one another. So prevent this issue by
assigning a monotonically-increasing identifier per test function or row
tested and improving how we clean up those we did create.

This shows we need the API to explicitly clean up.

Change-Id: I12a088d1ae424825abd3fffd171db61d6b68a411
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-01-22 13:02:08 -03:00
Thiago Macieira
6bc3a89c90 IPC: clean up #ifdef in tst_qsharedmemory.cpp
Change-Id: I12a088d1ae424825abd3fffd171db0debf823a12
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-01-22 13:02:07 -03:00
Thiago Macieira
2c286561bb IPC: add native key support to QSharedMemory
And deprecate the non-native key support API. Qt 7 may not even store
the old, non-native key.

Documentation in a new commit, when the dust settles.

Drive-by updates to the tst_QSharedMemory::attach row names, to fix
grammar and remove spaces and apostrophe.

Change-Id: I12a088d1ae424825abd3fffd171d3025c77f94d2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-01-22 13:02:04 -03:00
Thiago Macieira
3ae052d3bb IPC: add native key support to QSystemSemaphore
And deprecate the non-native key support API. Qt 7 may not even store
the old, non-native Qt.

Documentation in a new commit, when the dust settles.

Change-Id: I12a088d1ae424825abd3fffd171d2b549eeed040
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-01-22 13:02:04 -03:00
Thiago Macieira
7a37083817 IPC: Long live QNativeIpcKey key
Common to both QSharedMemory and QSystemSemaphore, this will hold the
native key and will replace the concept of non-native key in those
classes.

Change-Id: Id8d5e3999fe94b03acc1fffd171c03197aea6016
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
2023-01-22 13:02:00 -03:00
Thiago Macieira
7809caa924 IPC: move makePlatformSafeKey to qtipccommon.cpp
This removes the second portion of the #if mess of shared code between
QSharedMemory and QSystemSemaphore for SystemV.

Change-Id: Id8d5e3999fe94b03acc1fffd171c073c2873206e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-01-22 13:01:55 -03:00
Thiago Macieira
fc14f1a467 IPC: move the feature check to the ipc/ dir for tst_qsharedmemory
Change-Id: Id8d5e3999fe94b03acc1fffd171c22d2e8752ffb
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-01-22 13:01:54 -03:00
Thiago Macieira
53e8982434 IPC: Move QSharedMemory and QSystemSemaphore from kernel/ to ipc/
It's not a lot of files, but it's actually more in the same dir than
mime/ does right now. I'm about to add two more files, though I'll also
merge a few more later.

Change-Id: Id8d5e3999fe94b03acc1fffd171bfe2ea36a35a7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-01-22 13:01:53 -03:00
Axel Spoerl
7689d4ad2f QWidgetTextControl: Ignore unconsumed mouse release events
QWidgetTextControlPrivate::mouseReleaseEvent() has early returns
implemented, e.g. when link has been right clicked or no selection
anchor has been found. These early returns, however, still consume
the event.

This leads to events getting lost instead of getting propagated:
As an example, a QLabel with rich text uses QWidgetTextControl. While
it propagates mouse press events back to its parent, mouse release
events get lost. A QLabel with plain text propagates both events
back correctly.

This patch adds QEvent::ignore() to the early return.
Since no test class exists for QWidgetTextControl, it adds a test in
tst_QLabel.

Fixes: QTBUG-110055
Pick-to: 6.5 6.4
Change-Id: I950f8c3f135793b01c59832835bb429db2282169
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-01-21 17:04:14 +01:00
Amir Masoud Abdol
90aafa0470 Fix the broken test after the retirement of qt_parse_all_arguments
As we are now processing the arguments with
cmake_parse_arguments(PARSE_ARGV, we don't need to pass the escape
characters anymore.

Task-number: QTBUG-99238
Change-Id: Iea9cda4fe0ae56043cc4d7db29ce53d9d737d645
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-01-20 19:42:40 +01:00
Christian Ehrlicher
87662bcf10 SQL tests: Fix for PostgreSQL 12 and above
The 'WITH OIDS' was deprecated some time ago and removed with
PostgreSQL 12 so we have to adjust our test table creations. Don't know
why it was used in the first place at all.

Pick-to: 6.2 6.4 6.5
Change-Id: I6e18ac01e64368b1dd64e02bcb75fa70e05467a3
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-01-20 15:51:17 +01:00
Marc Mutz
51e5a2376a QVarLengthArray: fix off-by-size() bug in growBy()
The growBy() function takes the _increment_ of the size(), so needs to
add size() to increment for the call to realloc().

Add a test which hangs (vanilla build) or explodes (valgrind build)
without the fix.

Amends 26b227e128.

Done-with: Eirik Aavitsland <eirik.aavitsland@qt.io>
Pick-to: 6.5 6.4
Fixes: QTBUG-110412
Change-Id: I7ea91342fdcb779825c88013a3f86ba6d90ef530
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-01-20 14:48:20 +01:00
Assam Boudjelthia
a375f2e275 Fix build errors in manual tests
various fixes like missing includes, linking, obsolete API usage, etc.

Pick-to: 6.5
Change-Id: I786bff396933b87cd39559ac8964d386ef368df1
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-01-20 15:48:20 +02:00
Thiago Macieira
8772005a4b tst_QUrlQuery: replace a few QVERIFY(~~ != ~~) with QCOMPARE_NE
Pick-to: 6.5
Change-Id: I69ecc04064514f939896fffd17376aae3b8072b5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-01-20 00:19:22 -03:00
Thiago Macieira
fc8dad2f10 QUrlQuery: add missing move constructor
It wasn't added when this class was created in 5.0 because we couldn't
add move constructors and still keep the ability to compile Qt with
C++98 compilers. We've forgot to correct this shortcoming since 5.6.

Fixes: QTBUG-109842
Pick-to: 6.5
Change-Id: I69ecc04064514f939896fffd17376b8243b73c52
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-01-20 03:19:21 +00:00
Thiago Macieira
3d584b1093 QUrlQuery: fix operator== for emptied object case
If an object had elements and then was emptied, it will have a non-null
d pointer, which wasn't taken into account in the comparison.

Fixes: QTBUG-109840
Pick-to: 6.5 6.4 6.2
Change-Id: I69ecc04064514f939896fffd17376aa18184653c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-01-20 03:19:19 +00:00
Peter Varga
5686824229 tests: remove PlatformInputContext::filterEvent()
This overridden function is not used and also can't be triggered by a
synthetic input event in an auto test.

Change-Id: Id8b69b440a90c18cf5870e34804fae3e6607e49f
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2023-01-18 13:21:06 +01:00
Qt CI Bot
2e8b75477f Merge integration refs/builds/qtci/dev/1673982362 2023-01-18 00:51:53 +00:00
Thiago Macieira
a14a3a5487 QUrl: restore empty-but-not-null for components that are present
This got lost during the QStringView port that happend in Qt 6.0
(commit 548dcef089) because
QString::operator+=(QStringView) does not copy the nullness of the right
side, whereas QString::operator+=(const QString &) does.

Pick-to: 6.2 6.4 6.5
Fixes: QTBUG-84315
Change-Id: Ide4dbd0777a44ed0870efffd17399b772d34fd55
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-01-17 16:51:53 -08:00
Thiago Macieira
a7c3b747db tst_QHostInfo: use python3
Because Python 2 reached end of life. I wonder how this even works on
macOS, as my Monterey doesn't even have "python" any more.

Pick-to: 6.2 6.4 6.5
Change-Id: Ibddb9b0ada5a4bbaa64bfffd173b239c6c4b66f3
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-01-17 10:43:17 -08:00
Ahmad Samir
a67e7e3bb7 QLocale: add unittests for qstrtod of "NaN" and "nan"
The tests pass.

Drive-by change: Amend qstrntod API docs, the addition is heavily
inspired by cppreference's strtod docs.

Change-Id: Ic8e138e117a3249c752ae5ef2a8a21feb010befa
Task-number: QTBUG-74325
Pick-to: 6.5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-01-17 20:41:48 +02:00
Alexey Edelev
3002816d77 Restrict the minimum supported ICU version to 50.1
ICU 50.1 was released May 11th, 2012. Despite of the restriction, all
currently supported operating systems will continue to be supported.
All mismatches described in QTBUG-99715 are fixed in this version.
Restricting to 72.1 (latest version as per January 2023) or 63.1 (2018)
would still exclude e.g. RHEL 9.0, which ships version 56.1.

Task-number: QTBUG-109505
Pick-to: 6.5
Change-Id: Ic5cd7927d6f5fb60a89423c305796a9ed311bfa2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-01-17 15:15:11 +00:00