Commit Graph

13819 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
Marc Mutz
800ebd84f5 QVarLengthArray: cope with vector<unique_ptr>'s copyability
Despite being move-only, std::vector<unique_ptr> advertizes
is_copyable:
  https://quuxplusone.github.io/blog/2020/02/05/vector-is-copyable-except-when-its-not/

Our combined reallocation and resizing function, reallocate_impl(),
runs afoul of this when it uses std::is_copyable in a constexpr-if to
implement resize(n, v) without running into problems with move-only
types: the trait is true, but actual instantation runs into a
static_assert in the STL implementation.

To fix, move the problematic resize functionality out of
reallocate_impl() and into the resp. resize_impl overloads. The shrink
functionality remains in reallocate_impl(), because there are many
more users, and it only requires destructible<T>, which isn't
constraining at all.

Amends a00a1d8806.

Fixes: QTBUG-109745
Pick-to: 6.5 6.4
Change-Id: Ibc5b9cf5375108eb3d8f6c8a16d4fd02dadd73b1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-01-16 22:44:13 +01:00
Marc Mutz
ce104cac50 QPermission: replace T data<T>() with std::optional<T> value<T>()
As discussed in API review, the default-constructed T() returned from
a mismatched data<T>() call is indistinguishable from a real T with
default state.

To make them distinguishable, return optional<T>. Call the new
function value<T>(), mimicking QVariant::value<T>(), and suggested in
API review, because data() is usually used to return raw pointers, not
values.

Remove the qWarning() on requestedType and actualType mismatch, as the
new function can be used in std::get_if/dynamic_cast-like if-then-else
chains, in which failure is part of the normal operation, and a
warning message misplaced:

  if (auto loc = perm.value<QLocationPermission>())
     ~~~ use *loc ~~~
  else if (auto con = perm.value<QContactsPermission>())
     ~~~ use *con ~~~
  ~~~ etc ~~~

Pick-to: 6.5
Change-Id: I799a58e930307323ebce8f9ac50a42455e9c017f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-01-13 21:07:18 +01:00
Mikolaj Boc
2e97ccc8d0 Add QString<->emscripten::val conversion functions
Following the QRect, add functions converting the QString to native
emscripten::val and back: fromJsString, toJsString

Change-Id: I2d0625ede3bbf7249e2e91b8de298b5b91df8ba2
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-01-13 21:07:14 +01:00
Marc Mutz
8f8d8f71dd tst_QPermission: add more tests
The new test:

- checks the properties of stateful Q<Typed>Permissions work

- ensures that piping a Q<Typed>Permission through QPermission
  maintains state

- also ensures that assignment of a Q<Typed>Permission to a
  QPermission works (via QPermission(Type) + move ctor)

Pick-to: 6.5
Change-Id: I340e49b1ecc665702ccab26d9050ca158b0e7885
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-01-13 17:10:43 +00:00
Marc Mutz
595360506d QSqlRecord: add missing C++11 move SMFs
[ChangeLog][QtSql][QSqlRecord] Added move constructor, -assignment
operator, and swap().

Task-number: QTBUG-109938
Change-Id: I54f2666defbf56f5ba2faea6358722ebd7cac157
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2023-01-13 17:20:55 +01:00
Mikolaj Boc
ae3ffc1d4b Remove tst_QTextBoundaryFinder::thaiLineBreak
The test body has been inside an #if 0 for long, remove the test
altogether. The part that loads libthai does not check anyhing
meaningful.

Task-number: QTBUG-109954
Change-Id: I8ce006a14e4cf926b668e958d4b2343f965a5fb6
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2023-01-13 17:20:55 +01:00
Edward Welbourne
25e10d9636 Give tst_QStorageInfo a QCOMPARE_op() makeover
It had various QVERIFY()s of != and >= checks: convert these to
QCOMPARE_NE() and QCOMPARE_GE() checks.

Change-Id: Ida6f7dca726187f7837da0d805549d9c582f946a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
2023-01-13 15:08:25 +01:00
Volker Hilsheimer
c3a5fe2fd7 QFormLayout: don't access out-of-bounds layout data
When rows are hidden (implicitly or explicitly), then their layout data
does not get fully updated. If rows get hidden after the layout data has
been calculated once, then we must make sure that their indices are
reset. Otherwise we might access array indices that are out of bounds
when the layout data structure gets resized to fit only visible rows.

For good measure, skip entirely over hidden rows when accessing the
layout data when arranging the widget.

Fixes: QTBUG-109237
Pick-to: 6.5 6.4
Change-Id: I4d6943b6a110edb61f60ce78d31f0fc64b5cc03d
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-01-13 14:38:16 +01:00
Volker Hilsheimer
51272017a7 QCalendarWidget: Add reset functions for minimum/maximumDate
QDateTimeEdit has such reset functions for the minimum/maximum
range properties, this makes QCalendarWidget consistent with the
simpler editors.

Fixes: QTBUG-62448
Change-Id: Iabb89f599e4996f00488a885a5b8a009471838b3
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-01-13 12:26:06 +01:00
Edward Welbourne
73e7ffb2fd Verify land-preservation in locale construction
For most territories, if we specify only that territory, we should get
a locale specific to that territory. There are exceptions for various
reasons, but check that it's true in most cases, at least. In the
process, convert two QVERIFY(... == ...) into QCOMPARE(..., ...)

Task-number: QTBUG-64940
Change-Id: I7590f20f37b0b459aafb3d1d08f6eb77932fa027
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-01-12 19:03:17 +01:00
Marc Mutz
a478d730f8 Add minimal QPermission auto-test
To be extended as neeeded.

Pick-to: 6.5
Change-Id: I57d2f55f67de073fe3e4916b7ba655342cf661dc
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-01-12 08:48:46 +01:00
Thiago Macieira
c66adaa1f1 tst_Selftests: rewrite this with templates instead of macro
Otherwise it's undebuggable.

Change-Id: I3c79b7e08fa346988dfefffd171ee81fefde63b0
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-01-12 00:00:20 -07:00
Thiago Macieira
d0408b5f13 tst_QAlgorithms: don't use random numbers in the test row names
Just describe the row instead. We'd lose the original input in case of
failure, so I added a class to print that value on destruction. Example:

FAIL!  : tst_QAlgorithms::countLeading64(0) Compared values are not the
same
   Actual   (qCountLeadingZeroBits(value)): 63
   Expected (expected)                    : 64
   Loc: [tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp(374)]
QWARN  : tst_QAlgorithms::countLeading64(0) Original value was 0x1

Pick-to: 6.4 6.5
Fixes: QTBUG-109958
Change-Id: I69ecc04064514f939896fffd1738b1119cd80cf8
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-01-11 11:16:20 -08:00
Mikolaj Boc
22e96ca50d Use consistent collation testability criteria in corelib/text
tst_qstringapisymmetry needs to use the same collation testability
criteria as tst_qcollator, that is, the locales that may be tested
without ICU and not on Mac nor Windows are only the system locale and
C locale.

Task-number: QTBUG-109954
Change-Id: I69f19ae28b3a16b3827c1eee62ae59fcfdf45209
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-01-11 08:47:59 +00:00
Axel Spoerl
cccdd89ac8 Revert "Fix tst_QWidgetRepaintManager on XCB"
This reverts commit 4096667d66.

Reason for revert: <Screen shot workaround is flaky.>

Change-Id: I6e01cc584c094d0d0b8c1544b9daf72d648dd002
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-01-10 23:03:30 +00:00
Mikolaj Boc
a071bd674a Correctly determine if posix collator is used in tst_qcollator
qcollator_posix.cpp is included if ICU is not used and the OS is not
Win nor macOS. Reflect that fact in tst_qcollator instead of using
alternative means which breaks with new platforms that use the
posix collator.

Task-number: QTBUG-109954
Change-Id: I592500ce9626efbcc9377cecf6641967f978c6da
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-01-10 23:25:42 +01:00
Mikolaj Boc
df030e06a8 Adapt the qstringbuilder test for batching
There are numerous conflicting symbols in the tst_qstringbuilder\d
variants when batching those together. Remove the linkage from symbols
by putting the common include stringbuilder.cpp in an unnamed
namespace.

Task-number: QTBUG-109954
Change-Id: Ic2a745795b57482c90c9def7667a1145cdb19854
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-01-10 20:09:35 +01:00
Axel Spoerl
4096667d66 Fix tst_QWidgetRepaintManager on XCB
Due to an XCB library change, QXcbBackingStore::toImage() cannot be
safely assumed to return an image identical to QWidget::grab().
The test functions fastMove(), moveAccross() and moveInOutOverlapped()
relied on QXcbBackingStore::toImage() and failed.
They were backlisted on Linux/XCB.

This patch obtains a screen shot instead of an image from the backing
store on XCB platforms. It processes events until the screen shot
matches QWidget::grab(). It makes the test fail only if the comparison
times out.
The patch also removes the BLACKLIST file, containing only the test
functions mentioned above.

Fixes: QTBUG-109036
Pick-to: 6.5 6.4
Change-Id: I26dd5b89dc62b313db066a285f6ad7d4d92baaf2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-01-10 05:45:02 +00:00
Marc Mutz
70e070ecbd tst_QSqlRecord: replace manual memory management with unique_ptr
Also replace the C array with a std::array and (some) indexed loops
with ranged-for loops. Most loops need the index in one way of
another, so can't easily be converted to ranged.

Pick-to: 6.5 6.4 6.2
Change-Id: I7fa05f22de9df6c68ec5797c9583476a3881532c
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2023-01-09 22:21:12 +01:00
Volker Hilsheimer
58afdea1b3 tst_Gestures: Don't accumulate global state
(Un)Register the custom recognize in init() and cleanup() instead of
initTestCase() and cleanupTestCase(), so that a new recognizer is used
for each test function.

In the test functions, use a scope guard to unregister the locally
registered recognizers to make sure that in the case of a failing test
and early return, the recognizer is removed.

Pick-to: 6.5 6.4 6.2
Change-Id: I4fe9509f35474514ef55191d799e6707199fe853
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-01-09 19:37:53 +00:00
Eskil Abrahamsen Blomfeldt
49a63d3759 Fix infinite layout loop with negative line width
Setting a negative line width does not make much sense, but in
earlier Qt versions, this work the same as if the line width was 0
(just give you the minimal layout given wrapping constraints).

But since 991c056438, we check if
current width > line width at an earlier point, and because 0 > -1,
we would exit immediately before adding any characters to the text
line.

To restore the behavior in earlier versions, we set the minimum
possible line width to 0.

Pick-to: 6.5
Fixes: QTBUG-109474
Change-Id: Iceadd5135681f61b30de8221853834983941c5a4
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
Reviewed-by: hjk <hjk@qt.io>
2023-01-09 14:48:39 +01:00
Tor Arne Vestbø
e0bb9e81ab Don't override QDialog::setVisible() to implement native dialogs
Clients who called the base-class implementation in QDialog would
as a result start hitting the canBeNativeDialog code path at the
start of QDialog::setVisible(), which would show the native dialog,
but without updating the QWidget visibility state.

To keep things 100% compatible, we shuffle the implementation of
QDialog::setVisible() into QDialogPrivate, which allows us to
override it in QMessageBoxPrivate and QErrorMessagePrivate.

The existing subclasses of QDialog that override setVisible have
been left as is, to not cause any unintended behavior change.

Pick-to: 6.5
Change-Id: Icafe31a7b84a75049365e4e04b80492de08614d2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-01-09 14:14:53 +01:00
Tor Arne Vestbø
349fda471e Fix QErrorMessage test when using native dialogs
When the test is showing the error message over and over, it's not
waiting for the native dialog to actually become visible, and as
a result, hiding it has no effect and won't result in a call
to processResponse, where we got rid of the native dialog.

To fix this we explicitly release the native dialog when
encountering this corner case.

Add logic to QErrorMessage to test both native and non
native dialogs.

Pick-to: 6.5
Change-Id: I19ac3f463997aed1e66f646fdfcbb4d2459116d1
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-01-09 14:14:49 +01:00
Tatiana Borisova
676a2fe36f Fix RTA test build for INTEGRITY
In case of QT_FEATURE_timezone=OFF test should not be built

Change-Id: If667b9edb1d670b9ed8a62f301a7e5e21e7d2b4c
Reviewed-by: Kimmo Ollila <kimmo.ollila@qt.io>
Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
2023-01-09 11:47:37 +01:00
Ivan Solovev
a8261e327d QPromise: improve documentation snippet
The multi-thread snippet in the documentation, when copied as is,
could actually crash because of the race condition between the main
thread and the thread that generate results for the promise.
This is fixed by explicitly calling QPromise::start().
Actually, the underlying snippet already has this call, it just was
not included in the documentation.

This patch modifies the documentation snippet to include calls to
both QPromise::start() and QPromise::finish().

Fixes: QTBUG-109230
Pick-to: 6.5 6.4 6.2
Change-Id: Ic25f31a6b3b16ba6bc06a0b199289c8c5d50bab6
Reviewed-by: Sona Kurazyan <kurazyan.sona@gmail.com>
2023-01-09 10:03:48 +01:00
Kaj Grönholm
df00f9ea86 Support serializing the QShader for qsb version
Support serializing shaders with specific qsb version. The default
behavior remains the same, using the latest version.

Task-number: QTBUG-101062
Pick-to: 6.5
Change-Id: I090a88c1ccb3be4ac5eee1da4058afaa8bf3111c
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-01-07 18:24:47 +01:00
Ahmad Samir
26b5325767 QFileInfo: use currentDateTimeUtc()
Instead of the more verbose currentDateTime(QTZ::UTC).

Pick-to: 6.5
Change-Id: Ie759f4270b12fca39c458bf85c8296f5342033db
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-01-06 17:57:52 +00:00
Sona Kurazyan
9e61cc4f72 Fix crash when cancelling a QFuture that has continuation with context
To support cancellation of continuations attached via the parent future,
we store a pointer to continuation future's data in parent. This
requires preserving the lifetime of continuation future's data while the
parent is still alive (see 24dedaeaa1).
This is achieved by capturing the promise in the continuation's lambda,
which is only cleaned up after the parent's data is destroyed. This is
already the case for continuations without context, but was overlooked
for continuations with context: they transfer the ownership of the
continuation promise to lambda passed to QMetaObject::invokeMethod(),
which destroys the lambda's context after it's run. As a result, the
continuation's promise (and data, if there are no other copies of it)
is also destroyed, leaving the parent pointing to deleted continuation
data.

To fix this, capture a copy of continuation future's ref-counted data in
the continuation's lambda. This will guarantee that the continuation
data remains alive until the parent is destroyed and the continuation
is cleaned up.

Fixes: QTBUG-108790
Pick-to: 6.5 6.4 6.2
Change-Id: Ief4b37f31e652988d13b03499505ac65c7889226
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-01-06 14:00:56 +00:00
Øystein Heskestad
e088e01ace Accept U+2212 as minus sign in negative year unit test
Not all locales use ASCII hyphen-minus U+002D as minus sign. On macOS
using the nb_NO locale the U+2212 character is used instead when
displaying negative years. Verify that one of the two characters is
found.

Fixes: QTBUG-109853
Change-Id: I424539cc8d427ac199b4528e44bef98e45312d07
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-01-06 14:51:05 +01:00
Christian Ehrlicher
65a5efae69 SQL: more documentation and test cleanups
Remove some stuff no longer supported and refine others.

Pick-to: 6.5
Change-Id: I29730d5acfcf4a7ef3f569f101d3a4f72dd8b3aa
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-01-06 05:42:01 +00:00
Amir Masoud Abdol
2b2065bf35 Slow Deprecation of FILENAME_VARIABLE, replacement by OUTPUT_SCRIPT
As discussed in the latest CMake API Review, we are deprecating the
FILENAME_VARIABLE variable name everywhere, and replacing it with
OUTPUT_SCRIPT.

[ChangeLog][CMake] The FILENAME_VARIABLE option of
qt_generate_deploy_script and qt_generate_deploy_app_script is now
deprecated, use OUTPUT_SCRIPT option instead.

Change-Id: Ic8be33eefbc48540166ea0fcf1d1948b052d4b8a
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2023-01-05 21:56:21 +01:00
Ahmad Samir
2ed4e5d37d Fix two compiler warnings
Comparing singed/usigned ints.
Use override keyword.

Change-Id: I03d2c4359e0600360ebcfece593a3b125e5c9c53
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-01-05 21:01:22 +02:00
Ahmad Samir
b5701ca5a2 RCCFileInfo: get lastModified file time in UTC directly
These are time stamps, and they use toMsecsSinceEpoch(), no point
getting the time in Local time zone then converting it.

Change-Id: I2db2db5f9ebc062e65514a592fa7fa00cf1d179d
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-01-05 14:46:38 +02:00
Volker Hilsheimer
a2e38207da Blacklist the QAccessibility::focusChild test on the wayland platform
Task-number: QTBUG-109763
Change-Id: I2ef258a34743568dbbb90a802ea387e52c8cc613
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-01-04 18:38:00 +01:00
Ahmad Samir
41867c25f8 Use QFileInfo's file times in UTC for file timestamps
This is inherently faster than getting it in UTC from the underlying
native API stat call, then converting it to the Local Time Zone just to
compare them. The same goes for any use-case where you get a QDateTime
then the first thing you do is call t.to{Msec,Secs}SinceEpoch().

Change-Id: Ic13bcfd99b937c9f10f102ea7741832950a553c6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2023-01-04 19:15:52 +02:00
Volker Hilsheimer
fb8701cb8b QListView: Prevent infinite loop when wrapping text of item with null-icon
If an item in a list view has a null icon, then the decorationSize gets
calculated as -1, -1. The style would then try to wrap the text to a
lineWidth of -1, ending up in an infinite loop in viewItemTextLayout.

To prevent that, don't set the HasDecoration flag of the style option
when the icon is null, and don't fall back ot the decorationSize unless
the flag is set.

Add a test for this particular item configuration. This also fixes the
widget baseline test with styles that don't provide all standard icons.

Pick-to: 6.5
Change-Id: I691db6abede9a9b2ad300f3ee7fbfdae5fb6097f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
2023-01-04 13:42:06 +01:00
Axel Spoerl
df62cefdcb Skip tst_QWidget::optimizedResizeMove and ..._topLevel on wayland
Wayland omits optimizations tested in tst_QWidget::optimizedResizeMove()
and optimizedResize_topLevel() under certain circumstances, e.g. on
Ubuntu 22.04 / Gnome. This makes the test functions fail.

This patch skips the test functions on wayland platforms, if an
omission is detected.

This amends 2ec7a6322f.

Fixes: QTBUG-109746
Pick-to: 6.5 6.4
Change-Id: If0df6b1cf451a7f0dccfc1bb7411e895d7ae29a3
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-01-03 19:21:39 +00:00
Liang Qi
f09f516ac1 tests: skip tst_QComboBox::cancelClosesPopupNotDialog() on Wayland
QWindow::requestActivate() is not supported.

This amends c95de359b4.

Task-number: QTBUG-107153
Pick-to: 6.5 6.4
Change-Id: I45f53b5e9de85049ca41cc139a78a82450f53bed
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-01-03 12:07:43 +01:00
Axel Spoerl
71e67dec95 Stabilize tst_QSpinBox::sizeHint()
The test function used to flake on Linux occasionally.
8e6ede7cd1 provided a fix. While it
seemed to work, further analysis has shown that the root cause is
event sequence in case of multiple paint events.

This patch re-engineers the test function:

1. Allocate test widget on the stack instead of the heap.
2. Send layout requests posted by QHBoxLayout constructor and
QLayout::addWidget() before showing the widget.
3. Remove calls to QCoreApplication::processEvents().
They are unnessecary, because
- the size hint request counter is supposed to increase (by any number)
- QTRY_VERIFY processes events anyway until the counter increases or it
times out.

Pick-to: 6.5 6.4 6.2
Change-Id: I54998483725cbdd4899ba6f5469d7dae0980ab1d
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2023-01-03 10:57:21 +01:00
Alexey Edelev
0a746a30a5 Remove QT_USE_SYNCQT_CPP
Option has not effect anymore.

Pick-to: 6.5
Change-Id: I199ff15ac68b785ba1787d44494c0b2dff3b1ad0
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2023-01-02 23:16:30 +01:00
Tor Arne Vestbø
ad31b5f4c7 Don't use native dialogs for tst_QApplication::closeAllWindows()
The test shows an application modal QMessageBox, but assumes that doing
so will be non-blocking, which for macOS is not the case (yet). Instead
of making the dialog window-modal, which would potentially affect the
logic of the test, we disable native dialogs. This should be fine, as
the purpose of the test is to test the is_closing logic of
closeAllWindows, which lives on a layer above the native dialogs.

Pick-to: 6.5
Change-Id: I6d627984a6ca452b876f34404b669fce41a00851
Reviewed-by: Doris Verria <doris.verria@qt.io>
2023-01-02 23:12:30 +01:00
Ahmad Samir
bab660d124 QStringConverter: add QLatin1::convert{To,From}Unicode()
With the methods that use helpers from qstring.cpp defined in the
latter.

Change-Id: I11d6b0bfb95efe34e56d33d2ecbfe8f4423a9e6c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-12-30 16:36:24 +02:00
Marc Mutz
f68a2316d8 Long live QPromise::addResults()!
Makes the pre-existing QFutureInterface functionality available via
the public QPromise API.

[ChangeLog][QtCore][QPromise] Added addResults() to report multiple
results at once.

Change-Id: I18e6ef2781df422020b9022d78d6c45107b01668
Reviewed-by: Sona Kurazyan <kurazyan.sona@gmail.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-12-30 07:03:51 +01:00
Giuseppe D'Angelo
227b9cd084 QTypeInfo: remove further usages of isPointer / isIntegral
In preparation to their deprecation / removal.

Change-Id: Ia073a9f7caabbc06063a1e416b23cdb12788b283
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-12-30 01:51:27 +01:00
Giuseppe D'Angelo
e8f5f20319 QMetaType: fix value-initialization in a corner case
If a type is trivially default constructible, QMetaType (and QVariant)
think that it can be built and value-initialized by zero-filling a
region of storage and then "blessing" that storage as an actual instance
of the type to build. This is done as an optimization.

This doesn't work for all trivially constructible types. For instance,
on the Itanium C++ ABI, pointers to data members are actually
value-initialized (= zero-initialized, = initialized to null) with the
value -1:

https://itanium-cxx-abi.github.io/cxx-abi/abi.html#data-member-pointers

This means that a type like

  struct A { int A::*ptr; };

is trivially constructible, but its value initialization is not
equivalent to zero-filling its storage.

Since C++ does not offer a type trait we can use for the detection that
we want to do here, and since we have also decided that Q_PRIMITIVE_TYPE
isn't that trait (it just means trivially copyable / destructible), I'm
rolling out a custom type trait for the purpose.

This type trait is private for the moment being (there's no
Q_DECLARE_TYPEINFO for it), and limited to the subset of scalar types
that we know can be value-initialized by memset(0) into their storage
(basically, all of them, except for pointers to data members).

The fix tries to keep the pre-existing semantics of
`QMetaType::NeedsConstruction`. Before, the flag was set for types which
were not trivially default constructible. That included types that
aren't default constructible, or types that cannot do so trivially.
I've left that meaning unchanged, and simply amended the "trivial" part
with the custom trait. A fix there (to clarify the semantics) can be
done as a separate change.

Change-Id: Id8da6acb913df83fc87e5d37e2349a4628e72e91
Pick-to: 6.5
Fixes: QTBUG-109594
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-12-30 01:51:08 +01:00
Axel Spoerl
c69e727274 Use minimum size for in tst_QDockWidget::createTestWidgets
tst_QDockWidget::createTestWidgets did not set a minimum size for
test widgets. Upon unplugging, that can lead to a size correction in
connection with 8687c3f938cac56c4a2518576a5c9fac150d8de1, if the widget
gets too narrow to correctly display window handles. Test functions
checking the size after unplugging can fail in that case.

This patch sets a minimum size to each test widget created. The minimum
size corresponds to QStyle::PM_TitleBarHeight.

Task-number: QTBUG-106531
Pick-to: 6.5 6.4 6.2
Change-Id: I3e552b37416d57d8ed30e0b9de4eec55f07ea158
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2022-12-29 13:53:40 +00:00
Marc Mutz
92e913a541 tst_QStringApiSymmetry: fix a typo and deal with the fallout
Turns out we don't support QStringView/QUtf8StringView comparison, and
the only reason the corresponding test succeeded was because it
contained a typo (QStringView instead of QUtf8StringView).

Fix the typo and disable the now-failing test.

Pick-to: 6.5 6.4 6.2
Change-Id: I2210a247aac66743851e53578172a563ee1e96f7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-12-29 12:20:27 +01:00
Axel Spoerl
8e6ede7cd1 Stabilize tst_QSpinBox::sizeHint() by explicitly calling setLayout()
The test function places a QSpinBox in a QHBoxLayout, which has a
QWidget parent. The spin box is expected to be shown with the widget.
While the widget is the layout's parent, the layout is not explicitly
set. That makes the test function flaky in some cases.

This patch adds QWidget::setLayout() to explicitly set the layout on
the widget.

Pick-to: 6.5 6.4 6.2
Change-Id: I3a1cc77c302c5ba96d3628d035139f9718dda9e5
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2022-12-26 22:49:53 +01:00
Wang Fei
936cae6b53 Add QFileInfo::readSymLink() to read the raw link path
The existing symLinkTarget() always resolves the symlink target to an
absolute path; readSymLink() provides access to the relative path when
that is how the symlink references its target.

[ChangeLog][QtCore][QFileInfo] Added readSymLink() to read the symlink's
raw target, without resolving to an absolute path.

Fixes: QTBUG-96761
Change-Id: I360e55f1a3bdb00e2966229ea8de78cf29a29417
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-12-23 06:26:44 +01:00
Christian Ehrlicher
ebd94489a3 SQL: remove unneeded test functions
testWhiteSpaceNames() returns true for all current database drivers so
it's useless and can be removed. safeDropView() and getPSQLVersion()
is not called anywhere, getMySqlVersion() is only used for a check for a
MySql version we no longer support.

Change-Id: I8d02f17f475821e81d309ee96897e772cdfb895d
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2022-12-22 19:26:51 +01:00
Volker Hilsheimer
2d87c4d881 QTextImageHandler: Resolve Nx images correctly for file or qrc URLs
The qt_findAtNxFile helper in qicon.cpp expects a local file name that
can be probed with QFile::exists. If the src attribute of an <img>
element specifies the location of the image as a file:/ or qrc:/ url
rather than as a local file name, then we need to strip the scheme
off the file path, and in the case of a qrc URL leave the :/ prefix
before calling the qt_findAtNxFile helper.

Amends, and partially reverts, 760df72565.
We can't avoid testing whether the source in the HTML is provided as a
URL before interpreting it as a file name.

Pick-to: 6.5 6.4 6.2
Fixes: QTBUG-109212
Change-Id: I7ea7a5bfde79bab90a8025c42e754129813dd0fc
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-12-22 19:19:33 +01:00
Marc Mutz
8420d3e0b2 tst_QString: test with QT_RESTRICTED_CAST_FROM_ASCII, too
QtBase didn't contain any checks for QT_RESTRICTED_CAST_FROM_ASCII, so
a recent addition to the QString::append/insert/prepend overload set
made calls with C string literal arguments ambiguous without the CI
noticing. We had a similar problem with QString::multiArg.

To increase test coverage, we now run tst_qstring two times:

- without any define
- with QT_RESTRICTED_CAST_FROM_ASCII (lots of changes necessary)

Most removals are expected, because they disable tests that check the
implicit conversions from QByteArray and const char*, but the
relational operators with QLatin1String objects might warrant fixing.

In some places, when the conversion wasn't the functionality under
test, replaced C string literals or QByteArrays with QLatin1String.

We should also test with QT_NO_CAST_FROM_ASCII, but that's even larger
surgery.

QString doesn't have a ctor from std::nullptr_t, so QString s =
nullptr; doesn't compile in C++17 mode, but does in C++20 mode, due to
the const char8_t* ctor.

Pick-to: 6.5 6.4 6.2 5.15
Change-Id: I0c5a31719a4b8dd585dd748e0ca0d99964866064
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-12-22 11:16:02 +00:00
Thiago Macieira
6e68b4d838 tst_qlogging: Skip backtrace tests under ASan
ASan inserts a lot of function calls in between our calls, so they end
up in the backtrace and cause unexpected results.

Similar to c672f148db.

Fixes: QTBUG-109559
Pick-to: 6.4 6.5
Change-Id: I69ecc04064514f939896fffd1732dd2bc0317ae4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-12-21 23:22:59 -03:00
Thiago Macieira
b242457d34 tst_qlogging: don't skip all tests under static builds
We only need to skip the backtrace ones, because there's no library
called "Qt6Core".

Pick-to: 6.4 6.5
Change-Id: I69ecc04064514f939896fffd1732dd680058ba6e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-12-21 23:22:59 -03:00
Thiago Macieira
5aa66034c2 tst_qlogging: fix preprocessor directives
Reorganize them and fix the comment.

Pick-to: 6.4 6.5
Change-Id: I69ecc04064514f939896fffd1732dd57203cb21f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-12-21 23:22:59 -03:00
Volker Hilsheimer
c9cf4037ca QTextImageHandler: Add test coverage for resources and URLs
If an image source in HTML is specified via local file name or resource
path (i.e. without qrc prefix), then the correct image is loaded.

With file:/ or qrc:/ schema however, the image is either not loaded at
all, or the 2x image is not loaded. The qt_findAtNxFile helper in
qicon.cpp gets a URL path, but expects a file path (that can be tested
with QFile::exists).

Task-number: QTBUG-109212
Pick-to: 6.5 6.4 6.2
Change-Id: Ibcf687c69b3e53a10f21d718d28c8177a02d6be6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-12-22 00:48:08 +01:00
Volker Hilsheimer
d8e213a9e6 Enable and fix the test for QTextImageHandler
Amends 52ce0c177e, which added the test
without adding it to the parent directory.

Refactor the test code to be data driven, add the image files as
external test data files, and adjust the test code to find the files.

Use the QTextImageFormat from the document rather than a manually
crafted one, as otherwise we don't test a real usecase.

This also makes the test more flexible for adding qrc, resources, and
file URLs.

Task-number: QTBUG-109212
Pick-to: 6.5 6.4 6.2
Change-Id: Id0771037b961d95ec3cadd0cd6467d2448f22884
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
2022-12-22 00:48:08 +01:00
Bartlomiej Moskal
02f1e72d5a Android: Set EnterKeyNext as default type for QLineEdit
Behavior of EnterKey for virtual keyboard need to be changed for
QLineEdit. Before this commit, ImeOption was set to IME_ACTION_DONE.
Because of that, setting any text in QLineEdit automatically accept
QDialogs. That was annoying, when more than one QLineEdit need to be
set.

[ChangeLog][Widgets][Android] EnterKey type is now changed from
EnterKeyDefault to EnterKeyNext for virtual keyboard in QLineEdit. It is
done only if the focus can be moved to widget below.

Fixes: QTBUG-61652
Change-Id: I98a7686f9f675fccf0112b8d27d48ad8fd7a887f
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2022-12-21 04:11:58 +01:00
Marc Mutz
78db5cb643 tst_QByteArray/tst_QString: use new QtMiscUtils::toAsciiUpper()
... in lieu of <cctype>'s toupper(), which is locale-dependent, and
out-of-line.

The code doesn't run into the toupper(i) issue in the Türkiye locale,
because we don't run tests in that locale and because 'i' is not a
valid format specifier, but don't let the next reader of the code
guess when the use of toAsciiUpper() provides unambiguous guidance.

Task-number: QTBUG-109235
Pick-to: 6.5
Change-Id: I8988f5190441e1ae5cb57370952cda70ca6bb658
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-12-20 14:16:31 +01:00
Ville Voutilainen
413798cc01 Skip tst_qconcurrentrun completely if running under an emulator
Task-number: QTBUG-106906
Pick-to: 6.5 6.4
Change-Id: I1836f5be42528c71470c2cd6509f7125feb47691
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-12-19 15:31:10 +00:00
Ville Voutilainen
f7559904d0 Autoclose a FILE* if we open it
Task-number: QTBUG-105736
Change-Id: I2bc10b54b77436cad914ec21fd85678c54de4305
Pick-to: 6.5 6.4 6.2
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-12-19 15:31:10 +00:00
Ulf Hermann
5a0dcda171 CMake: Allow contents of resources to be replaced by empty files
This makes it possible to process QML files using qmlcachegen, and
retain the file nodes in the resource file system, but remove their
actual content from the binary. To do so, you need to mark your files
with the QT_DISCARD_FILE_CONTENTS source file property.

Fixes: QTBUG-87676
Fixes: QTBUG-103481
Fixes: QTBUG-102024
Fixes: QTBUG-102785
Change-Id: I93d5a2bfca1739ff1e0f74c8082eb8aa451b9815
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-12-17 20:43:51 +01:00
Axel Spoerl
5edb71c6d4 Fix QWidget::restoreGeometry when restored geometry is off screen
If a widget's geometry is restored to a screen, which is smaller than
the one it was saved from,
- the widget could appear (partly) off screen
- the widget's title bar and resize handles could be inaccessible

This patch refactors and documents checkRestoredGeometry.
In a first step, the restored geometry's size is checked against
a given screen size. It is corrected if necessary.
In a second step, the restored geometry is moved inside the screen,
if necessary.
It makes the function a static member of QWidgetPrivate in order to
expose it for auto testing and adds a respective test function to
tst_QWidget.

Fixes: QTBUG-77385
Fixes: QTBUG-4397
Task-number: QTBUG-69104
Pick-to: 6.5 6.4
Change-Id: I7172e27bfef86d82cd51de70b40de42e8895bae6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-12-16 22:58:11 +01:00
Marc Mutz
4ccb10dc91 QXmlStreamWriter: fix a thinko in doWriteToDevice(QSV)
Check for state.remainingChars to signal an encoding error only after
the last chunk has been processed. Splitting surrogates at chunk
boundaries is normal operation, not an error. Only if this happens at
the end of the whole input should we raise an error.

Amends fa2153bd10.

Pick-to: 6.5
Change-Id: Id92e37becaed25bbc11e0c22dedc4d41fb23f92a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-12-16 22:58:11 +01:00
Marc Mutz
6b5419f435 Extend tst_qxmlstream::readBack() to all Unicode characters
... not just those in the BMP.

The use of char32_t makes the isValid helper function easier to
read. Its passing to write() is enabled by the recent port to
QAnyStringView, which has a char32_t ctor.

Split into per-plane executions of the test function to avoid
running into timeouts on asan builds down the road.

As a drive-by, replace use of QPair with a proper struct, and
make the intervals symmetrically inclusive the bounds.

Pick-to: 6.5
Change-Id: I2c6858d7e6a88f448eac1b1e124d7d7b82828d4c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-12-16 22:58:10 +01:00
Thiago Macieira
686c02224c QUuid: add the ability to specify the byte order for 128-bit IDs
Some more modern protocols like Bluetooth LE transmit data in little
endian. QtBluetooth will benefit from this.

Change-Id: Id8e48e8f498c4a029619fffd1728c94ddd444537
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-12-16 19:29:10 +01:00
Thiago Macieira
0f932b9a5d QUuid: add a trivial structure to support exactly 128 bits
This is inspired by QBluetoothUuid's quint128, but with a better
name. It also matches systemd's sd_id128.

Change-Id: Id8e48e8f498c4a029619fffd172893dc1545adda
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-12-16 19:29:09 +01:00
Laszlo Agocs
4d36a83b6d rhi: vk: Fix up some legacy queue (family) index inconsistencies
Relevant mainly if we want to consistently expose these as the
theoretically correct uint32_t/quint32 from Qt Quick's
QSGRendererInterface. (not that int is not sufficient for
indexing the typical 3-4 families and 2-16 queues per family)

Some checks are not actually needed since the family index
must always be valid after create().

Pick-to: 6.5
Task-number: QTBUG-108895
Change-Id: I474ccea51a81e7a096281604ff79b7db4cdd2484
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-12-16 17:49:28 +00:00
David Edmundson
c7425aa295 dbus: Fix path to moc file in generated qdbusxml2cpp
qdbusxml2cpp takes a filename to use for generated output. It may be in
the form 'name.cpp' or just 'name'.

For the moc file we need to convert this from a path to a name of a file
in the same relative folder. It's not uncommon for this name to contain
dots as sometimes a dbus interface name is used directly.  For the cases
where a suffix is not provided the whole name should be used.

Pick-to: 6.5
Change-Id: I3bf4ae8b2b9121184c2786009e8b5abcc5e3e410
Reviewed-by: Mate Barany <mate.barany@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-12-16 17:21:57 +00:00
Marc Mutz
7d0f08094a tst_qxmlstream: swap WHEN and THEN in readBack()
WHEN writing an invalid character, THEN we expect the writer to report
an error.

The old code had it the wrong way around. It checked that WHEN the
writer reports an error, THEN the character was invalid.

The formulations are equivalent, but the latter is mixing up cause and
effect, making it less clear what's being checked (QXmlStreamWriter,
not isValidSingleTextChar()), so swap.

Pick-to: 6.5 6.4 6.2
Change-Id: I703de9ddde98d9913977a913f671472930735900
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Mate Barany <mate.barany@qt.io>
2022-12-16 18:21:57 +01:00
Marc Mutz
7fa6670fa4 tst_qmlstream: re-use QBuffer instance in readBack()
This improves the runtime of this particular test function by
almost 17% on my machine.

Pick-to: 6.5 6.4 6.2 5.15
Change-Id: Icd77cdda92374b92121988c99e56787d405fa2d9
Reviewed-by: Mate Barany <mate.barany@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-12-16 18:21:57 +01:00
Ville Voutilainen
c672f148db Skip QProcess tests when run under ASan
These tests exhibit weird crashes when run under ASan, but sometimes
they fail sometimes they don't. Pending more insight, just skip this
test under that configuration.

Fixes: QTBUG-109329
Change-Id: I49d940de419f7166aab0da0b8c2b44297c4b6d74
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-12-16 19:21:56 +02:00
Alexandru Croitor
5e00c0c5e5 CMake: Remove direct qt_android_generate_deployment_settings call
in our tests.

They are not needed anymore since
d20f4ae706 got merged and the
QT_ANDROID_PACKAGE_SOURCE_DIR property is read at generation time
rather than configure time.
This means the
qt_internal_add_test ->
qt_internal_add_executable ->
_qt_internal_android_executable_finalizer ->
qt_android_generate_deployment_settings
calls take care of generation the right value for the property even
with CMake 3.16.

Remove the direct qt_android_generate_deployment_settings calls,
in preparation for their deprecation in public api.

Pick-to: 6.5
Task-number: QTBUG-88506
Task-number: QTBUG-88840
Task-number: QTBUG-108508
Change-Id: Ief1d0f9f620bd37beeedde26dedb66f728fa4a6f
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-12-15 20:23:28 +01:00
Ben Fletcher
509fd9f2bb RHI: Buffer readback fixes and unit test
Fixes issues with readback of storage buffers modified on GPU for D3D
and Metal.  Adds unit test for storage buffer readback.

D3D
*  Fixes issue where QRhiBufferReadbackResult::completed callback could
be called twice on buffer readback completion.

Metal
* Fixes issue where buffer readback occurred prior to command buffer
being committed.

Change-Id: If55ac005f4438d66d2f65ea2e1ee0d5686c884ff
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-12-14 17:29:53 -08:00
Jani Heikkinen
d238833a05 Bump version to 6.6.0
Change-Id: I957e8a980542f16d3a3b493b41406bbeb884c2dc
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2022-12-14 20:19:01 +02:00
Eskil Abrahamsen Blomfeldt
ca64365e3a Don't hide object replacement char except in rich text
The object replacement character (U+FFFC) is used to represent
inline objects such as images in rich-text. To enable this,
we have special handling of it in QTextEngine. For classes
where inline images are not supported, it will just be hidden
from the visual text, which is unexpected.

Instead of always special-casing it, we make this dependent
on whether the document layout has registered any object handlers.
If they have not, then there will be no visual representation of
the object, and it is better to show the glyph for it.

For anything based on QTextDocument, there will always be the
image handler, so U+FFFC will still have special handling there,
but for non-rich labels and plain text editors the glyph will
be shown instead.

Note that there was also a bug in QLineEdit, where the object
replacement character was always replaced by a space. This was
introduced in 2007, in a patch which replaced a !ch.isPrint()
with a check for "the most obvious non-printable characters"
to reduce the number of characters that were not shown. However,
U+FFFC is a printable character and would thus not have been
filtered by the !isPrint() condition, so I think this was a
mistake at the time. However, due to the special-casing of
the character in Qt, it would not have had any effect until
now.

This also changes the QTextLayout::cursorToXForInlineObject()
test to actually test proper inline objects, as this was
previously using a hack which depended on the inline object
code to be used even for plain QTextLayouts with no handlers
for these.

[ChangeLog][Text] The object replacement character (U+FFFC)
is now only filtered out in rich text controls, where they
represent inline objects. In other controls, its glyphs will
be shown as with other text.

Pick-to: 6.5
Fixes: QTBUG-101526
Change-Id: I7fcaf2b10918feb41589e1098016efbf79a0e62d
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-12-14 19:19:01 +01:00
Marc Mutz
c262a1805a QBuffer: test and document open() behavior
QBuffer::open() was only documented as \reimp, so its behavior
regarding WriteOnly was never actually described.

Add a test and document the outcome.

Pick-to: 6.5 6.4 6.2 5.15
Change-Id: I75c49cd3f6a1961bcaece4a92a4e479bb3300d36
Reviewed-by: Mate Barany <mate.barany@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-12-14 19:07:19 +01:00
Heikki Halmet
ed623e6375 Remove blacklisting for OpenSUSE LEAP in gestures
Change-Id: Ia58d906582fa80016578468e6dd85da3c79274bb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-12-14 15:47:25 +00:00
Ahmad Samir
419c99f835 QByteArrayApiSymmetry: silence two clang warnings
tests/auto/corelib/text/qbytearrayapisymmetry/tst_qbytearrayapisymmetry.cpp:1174:80:
warning: overflow in expression; result is -9223372036854775808 with
type 'long long' [-Winteger-overflow]
const qlonglong longMaxPlusOne =
    static_cast<qlonglong>(Bounds::max()) + 1;

tests/auto/corelib/text/qbytearrayapisymmetry/tst_qbytearrayapisymmetry.cpp:1175:81:
warning: overflow in expression; result is 9223372036854775807 with type
'long long' [-Winteger-overflow]
const qlonglong longMinMinusOne =
    static_cast<qlonglong>(Bounds::min()) - 1;

I usually build with GCC, but building with Clang for clazy-standalone,
so I saw these two warnings 500+ times, enough already. :)

Change-Id: Idd86af568ffe89ae49b2a3f9bbeedf312de5e631
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-12-13 14:41:29 +02:00
Bartlomiej Moskal
4ceee3911a Android: fix Android assets handler not listing dirs with only sub dirs
It looks like AAssetDir_getNextFileName is not enough.
Directories that contain only other directories (no files)
were not listed.

On the other hand, AAssetManager_openDir() will always return a
pointer to initialized object (even if the specified directory does not
exists), so we can't just leave only it here.

Using FolderIterator as a last resort. This approach should not be too
time consuming.

As part of this fix, add some unit tests to cover/ensure assets
listing/iterating works as expected.

Fixes: QTBUG-107627
Pick-to: 6.4 6.2 5.15
Change-Id: Id375fe8f99f4ca3f8cad4756f783ffafe5c074df
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-12-13 12:04:40 +00:00
Volker Hilsheimer
f89c948c0c QHeaderView test: Remove unused variables
Silence warnings such as:
variable 'sum_lookup_visual' set but not used [-Wunused-but-set-variable]

Change-Id: If38515d9753cf7b79a250985890a139e96e92329
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-12-12 20:10:11 +01:00