Commit Graph

15851 Commits

Author SHA1 Message Date
Marc Mutz
54c25c7c31 tst_QFactoryLoader: remove unused member variable
Commit 862f42e806 removed the last use
of the Android-only `directory` member, but didn't remove the member's
definition.

Remove it now, probably fixing a Clang -Wunused-private-field warning
on Android.

Pick-to: 6.6 6.5 6.2
Task-number: QTBUG-87438
Change-Id: I67a1d97f29a0dde20ff29fb9b5bbaa5611cb9e17
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-11-13 19:42:00 +01:00
Tor Arne Vestbø
df834fde52 tst_QWindow::setVisibleThenCreate(): Fix unused argument warning
Use the arguments to call the parent class implementation.

Pick-to: 6.5 6.6
Change-Id: I602a66447fb8681b3ec9ef8e2e281828612d178c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-11-13 18:16:50 +00:00
Tor Arne Vestbø
db33628452 Ensure foreign window can be reparented out of contained window again
A foreign window embedded into a Qt hierarchy must also support
being removed from that window hierarchy.

Pick-to: 6.6
Change-Id: Id4d08079ff19d67a8989937bc72602e8bd14b31b
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-11-13 19:14:59 +01:00
Marc Mutz
9bccfb56c2 Q(Persistent)ModelIndex: use new test framework for op==
All good, except missing noexcept.

Can't test ordered relational operators because the classes provide
only op<, not the full set, so this has to wait until we port
Q*ModelIndex to the new comparison framework.

Change-Id: I05e26c88f0bd8c035ef0461c7c50b218c513da08
Reviewed-by: David Faure <david.faure@kdab.com>
2023-11-13 17:35:54 +02:00
Ivan Solovev
bfb237d19a TestLib: provide helper functions to test relational operators
The patch provides two sets of functions:
* functions to perform compile-time check for all cv-ref combinations
* functions that actually verify the comparison results for all
  cv-ref combinations.

For now it does not test operator<=>(), even if compiled with C++20,
because Qt types do not yet implement it.

The patch uses the new helper functions to improve testing of date and
time classes, because they already provide a full set of relational
operators.

Change-Id: I8bd869c489543719ea856d6609cac53cbd4dc122
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-11-13 16:35:54 +01:00
Christian Ehrlicher
e4315204b1 QDial: don't crash when min==max and setting a value != min & max
QDial::bound() is crashing when min == max due to a division by zero.
Therefore check for this condition beforehand and return min.

Pick-to: 6.6 6.5 6.2 5.15
Fixes: QTBUG-104641
Change-Id: I612625af1ad18333d59a7771abfdec602301b58e
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-11-12 23:45:30 +01:00
Christian Ehrlicher
ab4bb5077c tst_qstandarditemmodel: fix memleaks
QStandardItemModel::takeItem/Row/Column() return items not owned by the
model anymore and therefore need to be cleaned up manually

Pick-to: 6.6
Fixes: QTBUG-116532
Change-Id: Ic8797f58184f56b9c4ef415ce8f2363c1b352388
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-11-12 11:21:50 +01:00
Christian Ehrlicher
0416e080cf QStandardItem: Fix reset parent in takeItem()
After the change for QTBUG-89145 the parent was not set to 0 when the
item was not attached to a model.

Pick-to: 6.6 6.5 6.2
Fixes: QTBUG-117900
Task-number: QTBUG-89145
Change-Id: I421e775130b03ce3eb2dd1dd05370e7391af087b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-11-12 10:21:46 +00:00
Assam Boudjelthia
f5e2302851 Android: don't call delegates outside of the Activity
The delegate classes shouldn't be used outside of the Activity/Service
classes, since they're practically private implementation, so don't use
them anywhere outside Activity/Service.

Since Qt Android apps still mainly support having one QtActivity/
QtService, QtNative heavily uses those objects to do various operations.
For that reason, we still need to use the delegate there. The aim is
to change that in future patches and do the operations where they make
more sense for example directly under QtActivityBase/QtActivityDelegate
or Service counterpart.

The QtServiceDelegate is used no where and have no special
implementation, so it's removed here.

Task-number: QTBUG-118077
Change-Id: I5e106318169be19fec8163e8e500ee573af0e1bc
Reviewed-by: Tinja Paavoseppä <tinja.paavoseppa@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-11-10 21:57:11 +02:00
Marc Mutz
b113b01a71 QStringConverter: harden encodingForName() against nullptr
The nameMatch() function has an implicit precondition that neither
argument is nullptr: it immediately dereferences both arguments.

Prevent the crash by checking for name == nullptr early, before
passing to nameMatch().

Add tests for null and empty.

As a drive-by, make variables in the test const (needed for the
QByteArray to avoid detaching, peer pressure for the others).

Amends a639bcda1e.

Pick-to: 6.6 6.5 6.2
Change-Id: I4a30f6c130310eb701ba7c7251168294489c34db
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-11-10 19:24:33 +02:00
Christian Ehrlicher
83e92e2557 QTabWidget/Bar: ignore hidden tabs for key events
Even a tab was hidden it could be accessed with the key navigation or
a scroll event which lead to painting artifacts.

Pick-to: 6.6 6.5 5.15
Fixes: QTBUG-101219
Task-number: QTBUG-63038
Change-Id: I58be694eef5f86cccecbe528891a39a4acdda15f
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-11-09 20:57:43 +01:00
Jarek Kobus
52eae99b51 QtConcurrent::run() test: Add tests taking static function
Change-Id: I75d862a756d0543d8925459b3871abb979ffd481
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-11-09 16:52:44 +00:00
Mårten Nordheim
26ded9dedf tst_QDockWidget: use local context for timer
If we use 'this' as context it might still try to invoke
the timer after we have left the function, leading to
stack-use-after-return.

To avoid doing an in-depth dive if it's okay to use mainWindow as the
context or not, I just added a new local QObject.

Amends 9ff40b59da

Pick-to: 6.6 6.5
Change-Id: I2c3bdc1eb06731d9c38979610303876c2748fb73
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-11-09 13:09:55 +01:00
Jan Grulich
63fa92f2ef QCryptographicHash: fallback to non-OpenSSL implementation for Keccak
Current versions of OpenSSL 3 don't support Keccak hashes as these are
going to be introduced with OpenSSL 3.2 so we should rather fallback to
the non-OpenSSL implementation instead of using SHA3.

Fixes: QTBUG-118814
Pick-to: 6.5 6.6
Change-Id: Iedeb81cd76d43d920fc10e1efdac261bc12a394c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-11-08 18:40:14 +01:00
Piotr Wierciński
d544c0ff58 wasm tests: Fix and clean manual Selenium test
Remove obsolete parent_window_limits_moves_of_children test of moving
child window in parent. Child windows no longer have decorations,
therefore they cannot be dragged by a title bar.
Fix child_window_activation test, which now uses correct coordinates
to probe for stacked windows.

Change-Id: If5ddd8d4486673a961572de7c57df72c3cea9350
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-11-08 18:24:18 +01:00
Jonas Karlsson
a8df174369 QHeaderView: relayout on resetDefaultSectionSize
We now call setDefaultSectionSize with the new default section size.
This clamps the value to min/max section size and it will resize
affected sections.

Pick-to: 6.5 6.6
Fixes: QTBUG-116013
Change-Id: I39849aca8d0672629ce0b3ca244038c27e045d4b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-11-08 18:24:17 +01:00
Ivan Solovev
e85a3cde2f QSharedMemory: fix attach() -> create() for non-legacy SystemV mode
The problem with non-legacy mode is that the backend uses the same
filename for the system semaphore file and for the shared memory file.

What happens is that when we try to call attach(), a semaphore is
created. Later in attach() we set unix_key, because ftok() returns
a valid handle (it uses the file which was created for semaphore).
After that, an attempt to actually attach to a shared memory fails, but
no clean-up is done.
So, a later call to create() sees that unix_key is already valid, but
it cannot properly clean it, because it does not actually refer to
any shared memory.

Fix it by cleaning up unix_key and nativeKeyFile if shmget() call in
attach() fails.

Pick-to: 6.6
Change-Id: Ibccc3ac307d8b2e07e1b9b24b55f97a859a03131
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-11-08 15:56:54 +01:00
Laszlo Agocs
7c3779006d tst_qrhi: Exercise a readonly storage buffer in the simple test
...not only in the tessellation-related ones (that are skipped
with D3D).

The checked-in .qsb file is generated with a patched shadertools
that fixes a bug regarding readonly storage buffers and HLSL.

Change-Id: Iafbad4e81875d7b4f877435b9b1e6078019d52ac
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-11-08 16:15:18 +02:00
Christian Ehrlicher
5a5c96c65d Add QPixmapIconEngine::isNull()
Reimplement the virtual function QIconEngine::isNull() for
QPixmapIconEngine. This lets QIcon::isNull() return true when no pixmaps
are loaded during QIcon::addFile() e.g. due to a wrong filename.

Pick-to: 6.6 6.5
Fixes: QTBUG-118667
Change-Id: I29f2c492e55b60638507fa398ef7af76f4e9ff48
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2023-11-08 11:11:48 +01:00
Christian Ehrlicher
90822833f3 QCheckBox: Don't emit checkStateChanged when nothing changed
QCheckBox::checkStateChanged() was emitted with msvc even though the
check state was not changed due to a faulty comparison.
Amends: 37b47ebf94

Pick-to: 6.6
Fixes: QTBUG-118716
Task-number: QTBUG-104688
Change-Id: Iafeabeb9214f6c7510ea4ed87fabb7dc0ba175a6
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2023-11-08 11:11:48 +01:00
David Faure
889c3e2e5b QMimeDatabase: update freedesktop.org.xml to shared-mime-info 2.3
... and update the unittest accordingly.

Compared to the 2.3 release there 2 fixes in freedesktop.org.xml,
due to issues discovered when running tst_qmimedatabase:
* Give higher priority to the more specific image/apng magic
https://gitlab.freedesktop.org/xdg/shared-mime-info/-/merge_requests/262
* Lower priority for text/x-mpsub's magic
https://gitlab.freedesktop.org/xdg/shared-mime-info/-/merge_requests/263

Task-number: QTBUG-118616
Change-Id: I56053b343619a8a711af28e6490c160d13169734
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-11-07 16:04:03 +01:00
Ivan Solovev
fb1dcbfcba QSharedMemory: fix attach() -> create() for legacy SystemV mode
The attach() -> create() sequence was not covered by unit-tests in
qtbase, but this approach is used inside QSharedImageLoader.

It turns out that 02c42b26e1 broke this
usecase for legacy mode, and the create() triggered an assertion
in QSharedMemorySystemV::updateNativeKeyFile(). Fix it by clearing
the nativeKeyFile if ftok() call in QSharedMemorySystemV::handle()
fails().

Add unit-tests for the attach() -> create() scenario.
These tests revealed that this scenario fails also in non-legacy mode
for SystemV, so add QEXPECT_FAIL for these cases for now. This will
be addressed in a separate patch.

Pick-to: 6.6
Change-Id: If133fa56c82eba902374dc48d2757046b3d40baf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-11-07 15:43:05 +01:00
Volker Hilsheimer
93a6cd8bdf JNI: allow QString as a parameter to native methods
Expect a jstring on the va_list, and implicitly construct a QString from
that.
As a drive-by, allow native methods to take parameters by reference, and
move implementation details into a Detail namespace.

Add test coverage.

Change-Id: I31214938ccaea3f4d539b432e29d12434dd98377
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-11-07 01:59:51 +08:00
Mårten Nordheim
10f5e4f809 QLocal8Bit::convertToUnicode[win]: Support stateless flag
By just setting state to nullptr.

Pick-to: 6.6 6.5
Task-number: QTBUG-105105
Change-Id: I6b4f8fe39f1ba51dcfaf98ce7e42c2acd4c4cf98
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-11-06 18:23:19 +01:00
Piotr Wierciński
105a8d90bc wasm tests: Fix manual Selenium tests
Manual tests using Selenium for browser automation were not properly
updated when we introduced changes to our DOM structure.
Update the testing framework so elements in shadow root may be
properly accessed.

Change-Id: I45f7d63a833bc48a3b68016ef937e56425bdff87
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2023-11-06 11:56:25 +01:00
Edward Welbourne
df73672f97 QTimeZone(qint32 offsetSeconds): use IANA ID when one is available
Principle of least surprise: prefer IANA IDs over synthesized ones.
This also aligns what id() returns more nearly with what
availableTimeZoneIds() reports. Amend some tests to match the new
behavior, extend one test to verify id-round-tripping (also for the
IANA zones) and another to verify single-digit offset IDs get
zero-padded.

Document the complications in how id() relates to what is passed to
the constructor. (It was already complicated; the present change just
aligns it better with IANA IDs, where possible.) Mention, in
availableTimeZoneIds(), that (and why) it only includes IANA's offset
IDs. Drive-by: fix a typo in another availableTimeZoneIds() overload's
doc.

[ChangeLog][QtCore][QTimeZone] When created from (only) a UTC offset,
or from (only) a non-IANA UTC-offset ID, a QTimeZone instance now uses
an IANA UTC-offset ID, where one is available with a matching offset.
Previously it used a synthesized UTC±hh[:mm[:ss]] one which would omit
trailing :00 for minutes or seconds, which the IANA ID may well
include.

Task-number: QTBUG-118586
Change-Id: Ifc4976f36361c830c88a8bef0e8b963fe5a2ab43
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-11-03 18:27:14 +01:00
Samuli Piippo
99cec50f56 tests: skip setPermissions test if running as root
Running this test as root doesn't make sense, and it is the reason
why QNX is failing.

Pick-to: 6.6 6.5
Change-Id: Ibbdce9090882cb9dd87d7fcd0802a481f9e7883c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-11-03 11:00:11 +02:00
Shawn Rutledge
83b592346b Modify the MDI manual test to allow multiple views of same document
- editing same document in different views is possible? yes
- resizing one QTextEdit calls QTextDocument::setTextWidth(), which
  affects the width in the other view too. You can resize either one,
  but you can't have two views with different layouts, of course.

Added a categorized log message in QTextDocument::setTextWidth()
for a sanity check.

Task-nunber: QTBUG-35688
Change-Id: I59c4d10143fda3a66b946237832274d67f9d9d45
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-11-02 20:49:32 -07:00
Ivan Solovev
02c42b26e1 QSharedMemory: fix semaphore creation in legacy mode
The legacy mode was using the new nativeKey to create a semaphore.
As a result, on macOS the name of the semaphore key file was the same
as the name of the shared memory key file.
This lead to a situation when the file was mistakenly deleted when
destroying any instance of the shared memory, not only the one that
created it.
Fix it by using QSystemSemaphore::legacyNativeKey() in legacy mode.

Add a test to verify that we cannot re-create a shared memory with the
same key. The test was failing on macOS without the fix.

Fixes: QTBUG-111855
Pick-to: 6.6
Change-Id: Ib0bc41791e889b1888bbb8aa9044c6b053b63a5a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-11-02 21:14:10 +01:00
Eskil Abrahamsen Blomfeldt
c5b3fd134b Skip mixedScript test on platforms with no Hangul font
This test depends on the system actually supporting Korean
text, otherwise it will just return a single glyph run with
the digit and the missing glyph symbol.

Pick-to: 6.5 6.6
Fixes: QTBUG-118649
Change-Id: I54e55414ae4ba0a6328c7c3a57ae8840d3b123b1
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-11-02 17:41:14 +01:00
Anton Kudryavtsev
4fad57e750 QStringView: add isLower and isUpper
[ChangeLog][QtCore][QStringView] Added isLower() and isUpper()

Change-Id: Ie6cd20bd375d42cbdfb17953b2307d025c31ec77
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-11-02 13:50:42 +03:00
Ivan Solovev
f5a5c59918 Extend QTestPrivate property tests - actual implementation [2/2]
This patch provides the actual implementation to detect binding loops
in property setters.

These test will help to catch all the existing binding loops that were
introduced when migrating to new bindable properties.

The logic of the new tests is taken from
tst_QObject::objectNameBinding(), but generalized to be applicable to
all bindable properties.

The original code from tst_QObject can now be removed.

The patch effectively reverts f791570b86
because a lambda returning a nullptr now means that the binding loop
test should be skipped, which is not a good default behavior.
Now when all the existing bindable properties are fixed, it's fine to
give a compilation error when adding new tests, if the class is not
default-constructible.

Task-number: QTBUG-116345
Pick-to: 6.6 6.5
Change-Id: I059d444d4bb023c050a22e5b1974565e4f581b5c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-11-01 22:05:38 +02:00
Volker Hilsheimer
e21d35b9f7 JNI: don't implement a signature for 'long' C++ type
On Android, `long` has the width of the system, while `jlong` is always
64 bit. If we support `long` as a signature type equivalent to `jlong`,
then it becomes possible to write code that fails to compile, or in the
worst case crashes at runtime, on a 32bit system.

Instead, support quint64, which is always the same size as jlong.

Change-Id: I60432ec7411e697b5f6e1f153216ceee0af7e0f1
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-11-01 15:58:40 +08:00
Ahmad Samir
e90705687f QMetaEnum: refactor keysToValue
- Show warning messages for malformed keys string
- Use QBAV instead of QL1SV, some methods in the public API may get
  QU8SV overloads in later commits
- Extend unittests; also rename the unittest, it's really testing
  key(s)ToValue()

Change-Id: Iec944ef4c2c5d18ab038cb933e954cf50c912523
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-10-31 19:36:00 +02:00
Tor Arne Vestbø
db17487c93 Fix tst_QWidget::hoverPosition blacklisting for x86_64
The blacklist just uses 'x86'

Pick-to: 6.6 6.5 6.2
Change-Id: I9279e4c497e566f59be54b5cc71a7671d3a3370f
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-10-31 10:27:19 +01:00
Tor Arne Vestbø
adf39eff44 Blacklist tst_QWidget::hoverPosition() on macOS 14 x86_64
It relies on moving the mouse, which is likely related to this
failing in CI.

Pick-to: 6.6 6.5 6.2
Change-Id: Ib4a3ba7a9e874c9c2ef2d6d16143adf072e47588
Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io>
Reviewed-by: Artem Dyomin <artem.dyomin@qt.io>
2023-10-31 00:16:28 +00:00
Mårten Nordheim
d8d5922f16 QLocal8Bit::convertFromUnicode[win]: handle trailing high surrogate
The win32 API doesn't give us much choice. _Some_ code pages have
support for returning some error if we pass a specific flag, but not
all of them.

Anyway, since the code pages might not support all that UTF-16 provides,
we can't reasonably make it error out on characters that cannot be
converted.

So, the most reasonable thing we can handle is a unpaired high surrogate
at the end of a string, assume that the rest of the string was fine, and
that the low surrogate will be provided in the next call.

Pick-to: 6.6 6.5
Fixes: QTBUG-118185
Task-number: QTBUG-105105
Change-Id: I1f193c9d8e04bec769d885d32440c759d9dff0c2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-10-30 21:25:35 +02:00
Mårten Nordheim
94214fe100 QLocal8Bit::convertToUnicode[win]: handle more than one octet state
Both to store and to restore.

Without this a 3 or more octet sequence would cause errors or wrong
output. This can be seen with GB 18030.

Pick-to: 6.6 6.5
Fixes: QTBUG-118318
Task-number: QTBUG-105105
Change-Id: Id1f7f5f2fba4633b9f888add2186f4d8d21b7293
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-30 21:25:35 +02:00
Mårten Nordheim
ef24784f88 QLocal8Bit::convertToUnicode[win]: Drop MB_PRECOMPOSED flag
A few code pages do not support this flag[0]. It's also deprecated[1]
and is what Windows prefers to generate by default. So let's drop it.

[0] https://learn.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-multibytetowidechar
See note at the end for the dwFlags parameter.

[1] It's mentioned in the header files, but not online...

Pick-to: 6.6 6.5
Task-number: QTBUG-118185
Task-number: QTBUG-105105
Change-Id: I798c387170c73a953be874de139868543b2d775e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-30 21:25:35 +02:00
Tor Arne Vestbø
435dc5a6df Blacklist tst_QTemporaryDir::QTBUG43352_failedSetPermissions on macOS 14 ARM
Not reproducible locally. Possible permissions issue in CI.

Pick-to: 6.6 6.5 6.2
Change-Id: Ibf2255da71aaa882a2d154db6523e1af27264d4c
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-10-30 20:25:35 +01:00
Tor Arne Vestbø
ddf7e5deca Blacklist tst_QWidget::showMinimizedKeepsFocus on macOS 14 in CI
It was already blacklisted for macOS 13, and has also been blacklisted
on macOS many times in the past.

See also a9005a70d5.

Pick-to: 6.6 6.5 6.2
Change-Id: I9dc87ef409dd1fcc0f47d5e776927e8912ab40e0
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-10-30 20:25:35 +01:00
Ivan Solovev
c4f7dba81e QDate: make conversion from/to chrono types constexpr and noexcept
Add method stdSysDaysToJulianDay(), which implements the conversion
from std::chrono::sys_days to Julian Day in a constexpr and noexcept
manner. Use it in the fromStdSysDays() method instead of addDays(),
and also in all constructors from std::chrono types.
This allows all constructors to be constexpr and noexcept.

Simplify toStdSysDays() so that it could also be constexpr and
noexcept.

Add compile-time roundtrip tests between QDate and std::chrono types.

Fixes: QTBUG-118221
Change-Id: Id35a669430162f1932ad8d28b553af2fd7f5c6de
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-30 21:25:34 +02:00
Tor Arne Vestbø
be7e5f94a1 macOS: Check NSWindow as well when determining if setVisible can bail out
In be268ae197 we made QCocoaWindow::setVisible
idempotent by checking if NSView.hidden needed update.

This failed to take into account the case when a window is moved from
being a child window to a top level, where the window is still visible
and the NSView's hidden state doesn't change, but we need to order in
the NSWindow that we're now managing.

We now check NSWindow.visible as well, if we're a top level window.

Pick-to: 6.5 6.6
Change-Id: I94434d6ebfe2c9ece6eac7f83f17ead250ccc07a
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-10-30 18:28:57 +00:00
Edward Welbourne
4389b0c429 Report as available every QTimeZone(qint32).id() result
The QTimeZone(id) constructor accepts these IDs, but
isTimeZoneIdAvailable() did not admit to this. Although we cannot
sensibly list all 183,047 of them in availableTimeZoneIds(), we should
not claim they are unavailable. The custom QTZ constructor needs to
know when the ID it's been given is an IANA one (to refuse to use it),
so it has to be able ask the backends for "is this IANA", so the UTC
backend still has to report these IDs as invalid, leaving the QDT
frontend to include the check for these offset zones.

Extend isTimeZoneIdAvailable() test to include every offset-zone's ID
within QTZ's recognized range of offsets. Although the actual range
accepted by offsetFromUtcString() is wider, bounded by ±24:59:59, the
constructor from offset seconds (rather than offset string) is bounded
by ±16 hours.

Pick-to: 6.6 6.5
Fixes: QTBUG-118586
Change-Id: Id9b378aee122ec841635584367022fcb47041fdd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-30 12:43:14 +02:00
Laszlo Agocs
c6138bf9de Skip QVulkan autotests on Android
This is for the emulator, but have no means to differentiate more
precisely now.

The individual skips are unified in a single place.

Fixes: QTBUG-118234
Change-Id: I5676d11a565b88401d03bf51a10e03d53223df04
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-10-30 12:43:14 +02:00
Christian Ehrlicher
8eaf01ef81 QCommonStyle: cleanup standardIcon()/standardPixmap() [2/2]
Factor out the four code paths for standardIcon() (windows, mac,
application and resource theme) and use those functions also for
standardPixmap() so the returned pixmap is correctly scaled with the
current devicePixelRatio.
Part 2: move functionality into own functions

Task-number: QTBUG-118122
Change-Id: I0763c4db9e7aecf4c52bf0f5770bd3dd87c4a8a4
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
2023-10-29 12:06:24 +02:00
Edward Welbourne
58fd829cdf Use localized time-zone abbreviations or offset
The actual formatting of date-time strings is handled by the calendar
backend, but the code's in qlocale.cpp as it uses some of its tools.
When feature timezone is unavailable, we're stuck (as before) with
using QDateTime::timeZoneAbbreviation(), but when it's available we
can use QTimeZone::displayName() to get the localized form of the
abbreviation and offset string.

Make matching changes in QDTP so that it recognizes these localized
abbreviations. We now have another candidate for what local time might
be called, to add to those that must be checked.

This naturally implied some changes to tests. It turns out ICU
believes en_US uses GMT+1/GMT+2 for CET/CEST. Replace some MS
QEXPECT_FAIL()s by including the non-abbreviations we do in fact use
on MS in the lists of "abbreviations" to accept.

[ChangeLog][QtCore][QLocale] When a datetime format includes the
timezone (or offset), the appropriately localised form is (to the
extent the timezone backend in use supports this) used where,
previously, a haphazard choice of system and C locale was used. This
applies to both serialization and parsing.

Task-number: QTBUG-115158
Change-Id: I04f9c1055c3b9008320bb8b758490287fd8be5cd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-27 10:52:48 +02:00
Thiago Macieira
935562a77b QTemporaryFile(Name): don't make the path absolute on generation
I need to use QTemporaryFileName in a context where absolute paths are
not allowed because they change the behavior of the system call (the
-at() POSIX system calls); see next commit. This required a fix to a
seemingly unrelated test, which depended on the absolute path, because
QPluginLoader and QLibrary assume a file name with no path components
imply "search the standard places".

[ChangeLog][Important Behavior Changes][QTemporaryFile] This class will
now return relative file paths in fileName() if the file template was
also a relative path (it used to always return an absolute path). The
temporary files are still created in the same directory; this change
only affects the length of the path the function returns.

Change-Id: I79e700614d034281bf55fffd178f65f2b3d602d8
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-10-26 11:36:46 -07:00
Volker Hilsheimer
f419a8d67f Android: add an appless test that recreates QGuiApplication
Make sure this works and doesn't cause any QJniEnvironment or other
JNI object lifetime issues.

Change-Id: I08b55982266dfb1821517449f6eb9f2796cea9b7
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2023-10-26 20:04:51 +02:00
Edward Welbourne
1e74f67e54 Work round ICU disagreeing with TZDB about zone transitions
Since the TZ backend resorts to ICU for display names, we got
inconsistent results if they disagree about when transitions happened.
Also, ICU uses the current (or only recent history) names for the
zone, so one currently not doing DST (Africa/Tripoli) doesn't get a
report of its DST name at a historical time when it did DST (but ICU
doesn't know about it). Since the ICU backend, in any case, doesn't
override the displayName(qint64, ...), we can simply use the QTZP base
version instead of overloading in the TZ back-end, so we only delegate
to ICU when it might actually help. This also saves duplicating some
locking and lazy-initialization code.

In the process, turn a unique lock into a scoped lock within a
suitable scope. Also, make a comment more grammatical and less
verbose.

Change-Id: Iaaed1fb6a380be8b4258c43cbc4bacd5784345fb
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-10-26 19:56:07 +02:00
Giuseppe D'Angelo
358745d7de QSP/QWP: introduce owner_before, owner_equal, owner_hash
While at the moment we don't have aliasing support in QSharedPointer,
introduce owner-based comparisons and hashing. This also fulfills some
use cases in lieu of operator== for QWeakPointer (which got deprecated
by bb23a05905).

I'm using C++26/P1901's spelling of owner_equal, instead of
Boost.SmartPtr's spelling (owner_equal*s*). Given the niche use case,
the lack of interoperability with Qt's own containers, as well as the
Standard comparison objects' semantics (std::owner_less,
std::owner_equal), I don't think we should be giving these a Qt-ish name
as it would be pretty useless.

[ChangeLog][QtCore][QSharedPointer] Added owner_before, owner_equal,
owner_hash.
[ChangeLog][QtCore][QWeakPointer] Added owner_before, owner_equal,
owner_hash.

Done-with: Fabian Kosmale <fabian.kosmale@qt.io>
Change-Id: I8b792ae79f14cd518ba4a006edaa17786a8352a0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-10-26 19:24:40 +02:00
Edward Welbourne
4650a4433b Suppress deprecation warnings in test of QDTE::timeSpec property
The tests are suitably #if-ed to be omitted once the property is gone,
but the compiler can still warn.

Change-Id: I20efcf9bb40fe6d7ad7e21b64e5400f71c0a0b15
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-26 16:57:01 +02:00
Piotr Wierciński
4f168621d2 wasm: Fix test runner for asynchronous tests
Test runner was not properly handling tests which
return the control back to browser event loop.
It was treating such tests as if they exited with
code 0, marking them as succesfull even if they were
eventually failing or hanging.
This commit adds a callback to TestCase so the runner
is notified when a test truly has finished.
As a side effect, two tests need to be disabled for now
as they are failing for wasm, which was not properly
detected previously.

Change-Id: I0eb9383e5bb9cd660431c18747b9e94413629d1e
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-10-26 13:43:39 +02:00
Joni Poikelin
799bfe94e8 Fix smooth scaling of Format_Mono and Format_MonoLSB
Fixes: QTBUG-117713
Pick-to: 6.6 6.5 6.2
Change-Id: I2fb071a4d2229da50dfacb0a92c51c3e4ea57a74
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2023-10-26 07:48:02 +03:00
Tor Arne Vestbø
d44413d526 Explicitly focus automatic default button in QDialogButtonBox inside dialog
QDialogButtonBox has logic to automatically resolve a default button,
in case one is not already set via QPushButton directly, or via e.g.
QMessageBox::setDefaultButton().

Unfortunately, this default button can in some cases be overridden by
the first button in the dialog button box. The reason this happens
is that the first button is the focus proxy of the button box, so
when the button box gains focus, it will transfer it to the first
button. And since QPushButtons inside a QDialog have their autoDefault
property set to true by default, this focus transfer will also reset
the default button to the focused button.

This arbitrarily happens for any role that happens to be earlier in
the QDialogButtonBox::ButtonLayout than the AcceptRole, and can be
very confusing for the user, so we try to avoid the situation by
explicitly setting the automatic default button as the focus
widget of the button box, unless one is set already.

This is also what QMessageBox::setDefaultButton() does internally.

The only case we're not covering is when the user sets a push button
as default via QPushButton::setDefault(), but we conservatively
assume that the user then also calls setFocus() on the button.

Pick-to: 6.5 6.6
Change-Id: Ibdac0a51ba9439321d4fd7a1dac1ed695e11d693
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-26 00:14:33 +02:00
Thiago Macieira
2fefc8c63c QString/QByteArray: add lvalue and rvalue overloads of left/mid/right
The first/last/sliced API may be what we suggest users use, but the vast
majority of the installed codebase uses left/mid/right because they've
been available since time immemorial.

An additional benefit of this is to make left() and right() available as
inline methods.

Change-Id: Ifeb6206a9fa04424964bfffd1788383817ed906c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-10-25 12:01:58 -07:00
Thiago Macieira
f4101f9953 QString/QBA: add lvalue and rvalue overloads to first/last/sliced/chopped
Those ought to have been the original implementation, when they were
added in commit 38096a3d70, for Qt 6.0.

Because these classes are exported, we need to provide the previous only
implementations for MSVC. All other compilers would provide inline or
emit local, out-of-line copies.

Change-Id: Ifeb6206a9fa04424964bfffd178836a2ae56157d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-10-25 12:01:58 -07:00
Thiago Macieira
2fd0996324 QArrayDataPointer: add an allocating constructor
It's by far the most common use, so having to call two things is just
cumbersome.

Change-Id: I79e700614d034281bf55fffd178f454c4e31929e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-10-25 12:01:58 -07:00
Edward Welbourne
887e18990d tst_QLocale: base europeanTimeZone test on 2013, actually used in test
The test that needs this bool is using 2013, so test that year for a
match. (Africa/Tunis toyed with DST in 1990, the year used before, but
thought better of it.) In the process, move the initialization to the
member-initialization of the class and make the member const.

Change-Id: Ib87636cdb0b038fad0cdef9fbe49e96f7bf79d1f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-10-25 18:32:06 +02:00
Morten Sørvig
fde6bdfc5a wasm: add QIODevices for accessing JS data
BlobIoDevice: Supports reading data from a JS Blob,
which can be a File (on disk) or some other object
which can provide data. The native access functions
are async and using this class requires that asyncify
is available.

Uint8ArrayIODevice: Supports reading and writing to
a Uint8Array / ArrayBuffer. Similar to the existing
QByteArray::fromEcmaUint8Array() API, except that it
supports incremental accesss.

Change-Id: Ic5de3534ff75eb6c745287b73b15ccd92d74ac2c
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-10-25 17:56:55 +02:00
Volker Hilsheimer
342b37f388 Revert "QAtomic: remove the copy ctor and assignment operator"
This reverts commit 6a93ec2435.

Reason for revert: Breaks qtdeclarative build, submodules need
to be clean before we deprecate or remove APIs.

Change-Id: Id0726b9bfad6072065b380b44b6ff6dffda79e45
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2023-10-25 15:56:54 +00:00
Tor Arne Vestbø
1af821825a macOS: Fix tst_MacGui::nonModalOrder()
The test is testing whether the order of creating a child window
of a modal dialog and showing the parent dialog matters. But to
allow child windows of a modal dialog to become active that child
also needs to be a dialog. That's a limitation on macOS, where
only NSPanel subclasses can override worksWhenModal.

Fix the test, and rewrite it using more modern idioms, avoiding
the need for long waits in the test.

Pick-to: 6.6 6.5
Change-Id: Ifb640d0288a3c7ed37f2c61294e34cd96fba49ca
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-10-25 17:41:32 +02:00
André Klitzing
fd9c567156 Use SSL_CTX_set_dh_auto if DHparam is empty
[ChangeLog][QtNetwork][QSslDiffieHellmanParameters] An empty
Diffie-Hellmann parameter enables auto selection of openssl
backend.

Fixes: QTBUG-117666
Change-Id: Ic2e0529d48542752ca801bcb4d609988e5ddff25
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-10-25 17:23:13 +02:00
Giuseppe D'Angelo
6a93ec2435 QAtomic: remove the copy ctor and assignment operator
These special member functions have no purpose.

We never *documented* their semantics. Any code using them is
unconditionally wrong (which semantics was it assuming?), so we can
accept the SIC (type A). If a user needs such a copy, they would have to
reason on the intended semantics (relaxed? acquire/release?) and be
explicit in their code. Especially for assignment, they would need
understand the consequences of the memory ordering that apply on _each_
atomic object involved and not on the assignment operation as a whole
(there are no such semantics).

Testing this change on qtbase has already found bugs.

From a purely technical point of view: we don't guarantee lock-free
atomics nor we require them from the underlying platform. An atomic is
therefore allowed to be implemented as a mutex protecting a value, and
mutexes are not copiable. std::atomic follows the exactly same pattern
(not copiable nor copy-assignable) for exactly the same reasons, and Qt
atomics are implemented on top of std:: ones.

[ChangeLog][QtCore] The copy constructor and assignment operators of
Qt atomic classes (QAtomicInteger, QAtomicPointer) have been removed.
Their usage in user code should be considered a programming error, as no
memory ordering semantics were ever documented for these operations (and
therefore relying on any specific semantic would be relying on
undocumented, unportable behavior). This matches the API of the
std::atomic class in C++. Note that you can still use explicit
load/store operations to transfer a value across two Qt atomic objects,
and therefore use the memory ordering specified for the load/store
operations.

Change-Id: Iab653bad761afb8b3e3b6a967ece7b28713aa944
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-25 04:47:47 +02:00
Ahmad Samir
e1dcc858b2 QStringList: improve benchmark code
Make the strings in the stringlist-to-be-joined unique, which matches
actual use-cases better than joining a list of identical strings,
especially with QString's implicit sharing, if it's copies of the same
QString, it's sharing the underlying data.

Pick-to: 6.6 6.5 6.2 5.15
Task-number: QTBUG-116859
Change-Id: I1da93885e938045322ba8337df5e4e96985f892f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-25 03:19:20 +03:00
Mårten Nordheim
13fbedd162 QStringConverter[win]: expose+test control of code-page
Then we can easily test how fromLocal8Bit() and toLocal8Bit() behave
with different code-pages.

Pick-to: 6.6 6.5
Task-number: QTBUG-118318
Task-number: QTBUG-118185
Task-number: QTBUG-105105
Change-Id: Ib1cd3bccd27d598f4c80915557e332befcd96354
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-24 22:30:03 +02:00
Thiago Macieira
a61d752951 tst_QHashFunctions: suppress warning about casting from float to _Float16
Amends c86cf385d6.

tst_qhashfunctions.cpp:109:59: warning: converting to ‘qfloat16::NativeType’ {aka ‘_Float16’} from ‘float’ with greater conversion rank

Pick-to: 6.6 6.5
Change-Id: I79e700614d034281bf55fffd178f91775966658f
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-10-24 08:44:36 -07:00
Ahmad Samir
ceee7acf43 qcore_unix: port qt_safe_poll to QDeadlineTimer
Remove qt_poll_msecs() since the "forever" state can be simply expressed
with a QDeadlineTimer::Forever arg, instead of passing a nullptr
timespec, and the negative timeouts treated as "run forever" is also
encapsulated by QDealineTimer.

Use the QDealineTimer(qint64) constructor in the call sites where
the timeout could be negative, so that it creates a Forever timer (the
QDeadlineTimer(chrono::duration) constructor uses
setRemainingTime(duration) which handles negative timeouts by creating
expired timers).

Remove qt_gettime() (and do_gettime()).

Drive-by changes:
- Fix a narrowing conversion warning, qt_make_pollfd() takes an int
- Remove an unused include

Change-Id: I096319af5e191e28c3d39295fb1aafe9d69841e6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-24 18:29:45 +03:00
Volker Hilsheimer
89f0f34db5 tst_QSslSocket: Remove compile-time #ifdef check
Since we use runtime plugins now and the test doesn't use any
symbols from openssl

Amends 486b1aec16

Pick-to: 6.6 6.5
Change-Id: Ib66d1ca15835c41fe138c7830ce3edd0bdce0d5f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-10-23 18:00:52 +02:00
Edward Welbourne
51cfc973b3 Add a QDateTimeEdit::timeZone property
This shall ultimately replace its timeSpec property, which had already
been turned into a derived property of an internal timezone.

[ChangeLog][QWidget][QDateTimeEdit] Added timeZone property to enable
a datetime edit widget to control the timezone used. This makes the
timeSpec property redundant; this old property shall be deprecated
from 6.10.

Fixes: QTBUG-80417
Change-Id: I3cdb686bd2dada0e5067f5b4c1828b73892e424a
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-10-23 18:00:52 +02:00
Volker Hilsheimer
72ad419116 JNI: Fix reference leak in QJniArray
When the array type is QJniObject or a subclass, then we need to
explicitly release the local reference returned by GetObjectArrayElement
in the QJniArray::at implementation. Do this by constructing the
QJniObject via fromLocalRef, which does exactly that.
Amends 80d4d55e25.

Add a test case that stresses the local reference pool, and fix the old
test case (which operates on a QJniArray<jobject>) to also release the
local references.

Change-Id: Ie293b1db9f1b6825376bbf12338b22dfc3f8c6e9
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-10-23 15:10:28 +02:00
Øystein Heskestad
fd48ce0b73 Add support for containers > 4 Gi elements in QDataStream
The format is changed from 6.7 to support more than UINT32_MAX - 1
elements. The format used to have a quint32 size. Now if the size is
larger or equal to 0xfffffffe (2^32 -2) the old size is an extend
value 0xfffffffe followed by one quint64 with the actual value. The
32 bit size with all bits set is still used as null value.

Fixes: QTBUG-105034
Change-Id: I62188be170fe779022ad58ab84a54b1eaf46e5d9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-23 15:10:28 +02:00
Laszlo Agocs
0d413506a1 Skip Vulkan on Android in QRhi autotest
Fixes: QTBUG-118220
Change-Id: I78b4b8b85f316f087ab7a01c1ee0c4fad46c632a
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-10-23 12:33:56 +00:00
Ahmad Samir
f2e19d37de QStringList: add lastIndexOf() overloads
[ChangeLog][QtCore][QStringList] Added lastIndexOf() overloads that take
a QString/QStringView/QLatin1StringView and a Qt::CaseSenitivity
parameters. Prior to this calling lastIndexOf() would call the methods
inherited from the base class. This change is source compatible and
existing code should continue to work.

Task-number: QTBUG-116918
Change-Id: Ia50c884c00021bf581c23c12e0e0c22700dae446
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-22 14:37:57 +03:00
Ahmad Samir
c205f05128 QStringList: add filter(QL1SV) overload
[ChangeLog][QtCore][QStringList] Added filter(QLatin1StringView)
overload, which is more optimized when searching for a Latin-1 string
literal as no conversion to QString is necessary.

Task-number: QTBUG-116918
Change-Id: Ieb92f4cfd545b070258dbc5c701ddfb2e6f3fc64
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-22 14:37:52 +03:00
Ahmad Samir
3dffd5aa0b QStringList: add indexOf() QString/QStringView/QL1SV overloads
[ChangeLog][QtCore][QStringList] Added indexOf() overloads that take
QString/QStringView/QLatin1StringView, and a Qt::CaseSensitivity
parameter. Prior to this using QStringList::indexOf() called the methods
inherited from the base class.

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

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

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

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

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

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

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

Change-Id: I7bb1262706d673f0ce0d9b7699f03c995ce28677
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-22 14:37:33 +03:00
Thiago Macieira
3e330a79ec QStorageInfo/Linux: rewrite the label retriever to use device IDs
Instead of the previous realpath() comparison resulting from the symlink
processing. parseMountInfo() was extracting the device number from
/proc, so this information was already readily available.

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

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

Pick-to: 6.6
Change-Id: I9d43e5b91eb142d6945cfffd1787552af3d09676
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-10-21 15:21:24 -07:00
Thiago Macieira
9df2b7ffa4 tst_QStorageInfo: make storageList() test table-driven
Otherwise we have no way of knowing which QStorageInfo entry was being
tested.

Previous:
FAIL!  : tst_QStorageInfo::storageList() 'other.isValid()' returned FALSE. ()

Now:
FAIL!  : tst_QStorageInfo::storageList(/run/user/0/gvfs) 'other.isValid()' returned FALSE. ()

Change-Id: I8f3ce163ccc5408cac39fffd178d786e596ece81
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-21 15:21:19 -07:00
Tor Arne Vestbø
70d7c6a937 Avoid creating child windows twice when already visible
When a child window is made visible without its parent having been
created yet, we defer creating and making the child visible until
the parent is created.

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

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

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

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

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

Change-Id: I49018551dd22a8f88cf6b9f878a5166902a26f58
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-21 16:50:16 +03:00
Volker Hilsheimer
66b5803ab9 Adapt QRawFont to use QFont::Tag
Add an overload for fontTable (we can't deprecate the const char *
overload as it will be used for string literals, even if the tag-
overload would work), and use the tag type in the test instead of
QByteArray.

Task-number: QTBUG-117046
Change-Id: I104f11a25e9c453a5d1081b6cf320bdc186b7e80
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-10-20 21:37:15 +02:00
Volker Hilsheimer
61ceff89f7 Replace MAKE_TAG macro with QFont::Tag
Task-number: QTBUG-117046
Change-Id: I26e0af634fed87199bb49d57e3aa3f4e3fea0e39
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-10-20 21:37:02 +02:00
Volker Hilsheimer
bde443801f QFont: add a tag type for features and other advanced properties
Instead of overloads and generic string literals with runtime checks,
use a dedicated Tag type for specifying the font feature. The Tag type
can only be instantiated with a string literal of exactly 4 characters
(plus the terminating null)l; longer or shorter literals result in a
compile time error.

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

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

Task-number: QTBUG-117046
Change-Id: I31038c7c6fd2b843a105b032f021e506b0b60822
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-10-20 21:36:52 +02:00
Mårten Nordheim
486b1aec16 tst_QSslSocket: remove #if openssl check for a definition
The declaration was moved out of the #if QT_CONFIG(openssl) block at
some point, but the definition was not. This caused compilation errors
when building without OpenSSL configured.

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

Pick-to: 6.5 6.6
Task-number: QTBUG-91150
Change-Id: Ic7886a9fc69781e4f21417075516106ccb6c7bf5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-10-20 18:46:29 +03:00
Edward Welbourne
e72a898c50 Clarify the behavior of QDateTime around 24-hour transitions
For those that simply repeat or skip a whole calendar day, life is
fairly simple. However, Alaska's 24-hour transition at 15:30 LMT Sitka
(incidentally combined with a change of calendar) is a bit trickier.
Also fix a typo I noticed in passing.

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

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

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

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

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

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

Fixes: QTBUG-79923
Change-Id: I11d5339abef9e7125c4e0dc95a09a7cd4f169dab
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-19 14:45:56 +02:00
Marc Mutz
38994ab9ac tst_QMetaEnum: add round-trip testing to valueToKeys()
... adding a bit of test coverage of keysToValue().

This is not intended as a reproducer for QTBUG-118240, because that
is concerned with inputs valueToKeys() cannot produce.

Task-number: QTBUG-118240
Pick-to: 6.6 6.5 6.2 5.15
Change-Id: I5d772be4231717cdbb5d033b1f11ae31e4c57c0b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2023-10-19 12:22:42 +00:00
Mitch Curtis
18152699e4 Increase QTest failure message limit
QPalette specifically has quite a large amount of output (1363
characters) when toString
is called on it. We should make sure that we can fit that in our
failure messages. This patch does that by increasing the limit from
1024 characters to 4096.

Fixes: QTBUG-5903
Fixes: QTBUG-87039
Pick-to: 6.5 6.6
Change-Id: I1dc5078ad05858bb6542c3a06c6b84711af79e4f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-19 10:57:21 +08:00
Thiago Macieira
a3f2ddc230 tst_QProcess::startStopStartStopBuffers: depend less on OS configuration
The comment in this function made it clear that it really depended on
the size of the pipe buffer in the OS. I don't see a way to make a pipe
default to a different size on Linux -- it always defaults to
PIPE_DEF_BUFFERS (16) and that value is only increased as a result of
fcntl(F_SETPIPE_SZ), which we don't do. But we can be defensive and
simply write until the OS can't take any more data.

Drive-by update the comment on Windows to be clear that bytesToWrite()
does work, but only while the child process is still running.

Pick-to: 6.6
Task-number: QTBUG-80953
Change-Id: I9d43e5b91eb142d6945cfffd17866d22a4127e5e
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-10-18 12:40:54 -07:00
Ahmad Samir
5a2aa12147 tst_qdbusmarshall: disambiguate unittest data tag names
Drive-by change, initialize a QList with std::initializer list instead
of old style operator()<<.

Change-Id: If5745a4554772661df438e757518f8cb55a8a55c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-10-18 20:53:12 +03:00
Thiago Macieira
d3edc8a62d tst_QStorageInfo::{tempFile,caching}: change APFS from XFAIL to SKIP
Amends commit 78d0b6e975 ("Ignore failing
test for free space on APFS") and merges it with the btrfs code, which
seems to have the same problem. But unlike Linux systems with btrfs,
Apple systems don't usually have another filesystem available so we
don't bother to try and find another.

Change-Id: I8f3ce163ccc5408cac39fffd178d7b4c13f0dfd1
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-10-18 10:01:45 -07:00
Thiago Macieira
ae03ffaffd tst_QStorageInfo::{tempFile,caching}: try a to find a non-btrfs storage
These tests skip when we're writing to a btrfs filesystem because, for
some reason, the amount of free space does not update synchronously with
file writing. But instead of giving up if $TMPDIR is a btrfs, let's try
and use the $XDG_RUNTIME_DIR, which is usually a tmpfs.

This will work in the CI for the openSUSE set ups, where / is btrfs,
/tmp is not a separate tmpfs, but /run/user/1000 is available.

FAIL!  : tst_QStorageInfo::tempFile() The computed value is expected to be different from the baseline, but is not
   Computed (free)                : 25510780928
   Baseline (storage2.bytesFree()): 25510780928
   Loc: [tst_qstorageinfo.cpp(234)]

Pick-to: 6.6
Change-Id: I8f3ce163ccc5408cac39fffd178d7af1c67ec988
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-10-18 10:01:45 -07:00
Mikolaj Boc
0607c25f3e Make WASM IDB settings use the fallback mechanism correctly
Change-Id: Ibb65efc0faa5ec6e6c60782747c9295e4fc5ff21
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-10-18 19:01:45 +02:00
Ahmad Samir
8a6a9295eb tst_QStringList: refactor a unittest to be table-driven
Change-Id: I9a102a42eba42f1bec71cc680f6de6dbeaf7ad58
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-10-18 20:01:45 +03:00
Volker Hilsheimer
944200b5a9 JNI: Reduce amount of temporary QJniEnvironment instantiations
Almost all operations on a QJniObject require a QJniEnvironment,
including the construction and destruction of a QJniObject. Instead of
instantiating a temporary QJniEnvironment object in each call, store the
one from the constructor in the private, and reuse it.

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

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

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

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

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

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

Change-Id: I2f1ba855ee01423e79ba999dfb9d86f4b98b1402
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-10-18 15:02:22 +02:00
Thiago Macieira
c94bed69b7 moveToTrash/Unix: refactor to use openat()/mkdirat()/renameat()
This ensures much better security against race conditions and attacks,
at the expense of a few more system calls.

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

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

On subsequent runs:

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

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

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

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

Change-Id: I9d43e5b91eb142d6945cfffd1786d417142ac728
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-10-17 19:08:25 -07:00