Commit Graph

61373 Commits

Author SHA1 Message Date
Thiago Macieira
df2131426e tst_QProcess: move setChildProcessModifier test to a Q_OS_UNIX section
There's no need to say it's getting skipped on Windows. moc *can* parse
the #ifdefs these days.

Pick-to: 6.5
Change-Id: Icfe44ecf285a480fafe4fffd174d95c709ff6a74
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2023-05-15 00:12:43 +02:00
Thiago Macieira
49eb9021e3 QProcess/Unix: use open() + fchdir() to change directories
This means we have more system calls (2 more in the parent), but we
can now detect non-existent or inaccessible directories before fork().

Pick-to: 6.5
Change-Id: Icfe44ecf285a480fafe4fffd174d1003581bff59
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-15 00:12:43 +02:00
Thiago Macieira
6b561ccf44 QProcess/Unix: use pid_t for the pid
Qt 5 and earlier versions used to share this member with Windows, where
we needed to store a pointer. We had the Q_PID public type, which was
removed in commit b73d5a0511 (6.0). That
commit made the QProcess::processId() public API use qint64, which is
fine. But we don't need to store more bits than the OS actually
requires.

This further reduces QProcessPrivate's size to 688 bytes on 64-bit Unix,
with 5 bytes of tail padding.

Pick-to: 6.5
Change-Id: Icfe44ecf285a480fafe4fffd174d3fa9345872c0
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2023-05-15 00:12:41 +02:00
Thiago Macieira
29b2fe40dc Revert commit "don't ever force fork() instead of forkfd()"
This reverts commit d6bf71123d and the
docs from commit 82b75570f0
("QProcess/Linux: fix file descriptor leak in case of failed child
start").

Despite the title of the commit being reverted, the actual consequence
is slightly different: we always use the forkfd() function, but we
change whether we force the use of the fork() library function by use of
the FFD_USE_FORK flag.

Commit 97645478de (5.15) first added the
FFD_USE_FORK flag with a hack to detect whether the setupChild() virtual
might have been overwritten. A configure-time feature to force the flag
was added in commit 2ed99ff5ca (6.0).
Before the 6.0 release, commit d6bf71123d
removed the conditional use of FFD_USE_FORK, with the changelog message
saying "pthread_atfork() callbacks are consistently not invoked".

We've also since added vfork()-like behavior. We tried it for Qt 5.15
and reverted shortly afterwards because we had got the memory semantics
wrong. Commit e1a787a76e (6.5) finally got
it right, for Linux, which revealed another set of problems with
functions used in the child process modifier.

Therefore, we're going to make vfork() and clone() usage opt-in if the
child process modifier is active. This commit is the first part:
disabling their use by default. The flag to opt in will come in Qt 6.6.

[ChangeLog][QtCore][QProcess] Reverted a change from Qt 6.0 that made
the childProcessModifier() callback be run in a child created by means
other than a real fork() library call, a situation in which certain
other library functions would be unusable, unreliable, or cause
deadlocks. A flag to opt in to the solution with better performance will
be added to Qt 6.6.

Task-number: QTBUG-104493
Fixes: QTBUG-111243
Fixes: QTBUG-111964
Pick-to: 6.5
Change-Id: Icfe44ecf285a480fafe4fffd174d3e66843e5a29
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-15 00:12:41 +02:00
Thiago Macieira
2b98dd7645 QProcessPrivate: repack and reorganize the members
Reduce the number of #ifdef blocks and use quint8 for the enums that
don't need more than 8 bits anyway (none of them do). Plus move the
std::function callback to an indirect block, as most users of QProcess
won't set them and this type is 4 pointers with libstdc++ and libc++.

After this, QProcessPrivate on 64-bit Unix is 688 bytes, of which:
- 392 bytes from QIODevicePrivate
- 295 bytes of own data
- 3x56 bytes per Channel (which have 5 bytes of tail padding each)
- 1 byte of tail padding and no middle padding

Pick-to: 6.5
Change-Id: Icfe44ecf285a480fafe4fffd174d188a0821d060
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-15 00:12:39 +02:00
Thiago Macieira
7dba2c8761 QDnsLookup/Unix: make sure we don't overflow the buffer
The DNS Records are variable length and encode their size in 16 bits
before the Record Data (RDATA). Ensure that both the RDATA and the
Record header fields before it fall inside the buffer we have.

Additionally reject any replies containing more than one query records.

[ChangeLog][QtNetwork][QDnsLookup] Fixed a bug that could cause a buffer
overflow in Unix systems while parsing corrupt, malicious, or truncated
replies.

Pick-to: 5.15 6.2 6.5 6.5.1
Change-Id: I3e3bfef633af4130a03afffd175e4b9547654b95
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2023-05-14 19:47:03 +00:00
Thiago Macieira
0fc0e821f1 QDnsLookup: remove the #if QT_CONFIG(thread) check
There's no fallback anywhere, so this class simply doesn't work if
threading isn't supported. Writing it is an exercise left for whoever
cares for that configuration.

Change-Id: I3e3bfef633af4130a03afffd175e6f68a3f4673f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-14 12:47:01 -07:00
Thiago Macieira
471f134cdd QDnsLookup: remove the explicit metatype registration for the Reply type
It's unnecessary in Qt 6 if we use the new-style connect or if the type
was fully defined in the compilation of the unit containing the moc
output.

Change-Id: I3e3bfef633af4130a03afffd175e6f4e87adf5e1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-13 16:15:02 -07:00
Thiago Macieira
d26709cd8c Network: Remove Q_DECL_METATYPE_EXTERN for single-.cpp metatypes
These were added in commit 20e6a049fe as a
massive sweep of all Q_DECLARE_METATYPE, without thought as to whether
they were actually needed or not. If they are used as a metatype in a
single .cpp file, they don't need to be.

Incidentally removes the entirely incorrect Q_NETWORK_EXPORT of
QDnsLookupReply.

Pick-to: 6.5
Change-Id: I3e3bfef633af4130a03afffd175e6f378f09a3aa
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-13 16:15:01 -07:00
Thiago Macieira
c257e518c1 QProcessPrivate: remove the member variable "crashed"
It was only used to later set exitStatus = CrashExit, so simply do it
early.

Drive-by removal of a magic numeric literal in the middle of the source
code. It's still magic, but at least we avoid accidentally making typos.

Pick-to: 6.5
Change-Id: Icfe44ecf285a480fafe4fffd174d4176a5d87641
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-13 20:25:27 +00:00
Thiago Macieira
45a03fc506 QNativeSocketEngine: move some code from the _p_p.h to _p.h file
So I can use it in qdnslookup_unix.cpp.

Change-Id: I3e3bfef633af4130a03afffd175d506949968990
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-13 13:24:24 -07:00
Marc Mutz
3b0536bbe8 tst_ContainerApiSymmetry: make assign_impl() robust w.r.t. overallocation
The parameter passed to reserve() is just a hint. The container
implementation is free to choose a larger capacity, and some do
(e.g. QList in prepend optimization mode).

Fix the test by querying the container for its post-make<>()
capacity() and taking a larger-than-expected initial capacity() into
account when later re-checking the capacity().

Change-Id: Id8f26f14e8df9d685ca2387ec4a52d74fea7cb9d
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-13 16:58:36 +02:00
Marc Mutz
fb58df3260 tst_ContainerApiSymmetry: make a comment more precise
It took me a sec to figure out the relation between the comment and
the code line following it. Make it easier for the next guy and add a
bit more infos.

Amends 7cbdc8abbd.

Change-Id: I4ff2d9a52aef643a92339df32cc86f686a689a9a
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-05-13 16:58:27 +02:00
Marc Mutz
4eea3f857c tst_ContainerApiSymmetry: follow file's style for assign() tests
We use a single line per test slot everywhere else, ignoring even
line-length limitations, to keep the function names aligned for easier
parsing.

Amends 7cbdc8abbd.

Change-Id: Iaf2941aae88392d407d688fc4a7537fcdc0a5851
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-05-13 16:58:19 +02:00
Marc Mutz
edc953948c tst_ContainerApiSymmetry: fix mutable lambda anti-pattern
STL algorithms, in general, don't specify how often the function
objects passed to them are copied during the run of the
algorithm.

While generate_n is above any reasonable suspicion of copying the
function object after the first invocation, passing a mutable lambda
containing the counter is still an anti-pattern we don't want people
to copy.

Fix in the usual way, by keeping the counter external to the lambda.

As a drive-by, replace post- with pre-increment.

Amends dc091e7443.

Pick-to: 6.5 6.2
Change-Id: I9c44e769fd41e5f7157179a2be4c3534424cf913
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-05-13 16:58:10 +02:00
Thiago Macieira
3cc39197f8 tst_QAnyStringView: fix warning of unused variable by using it
Pick-to: 6.5 6.2
Change-Id: Ieab617d69f3b4b54ab30fffd175c78ddb5fb919d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-05-12 20:54:13 +00:00
Alexey Edelev
f71eb4a642 Avoid littering CMake logs with QTP0002 warnings
It doesn't make any sense to setup and get policy when we build either
Qt or standalone tests, since the value will be ignored anyway. So
skip the policy setup for Qt builds to avoid littering the CMake logs
with QTP0002 warnings.

Amends c4debab927

Change-Id: Iacae8f9ecbb6c9da2f3af77b2016454c8d4194e6
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-12 17:55:21 +02:00
Tor Arne Vestbø
798456c0a3 Add QIconLoader debug logging to aid fallback logic investigation
The icon loader machinery is a bit opaque, so let's add some logging
to understand the interactions.

Pick-to: 6.5
Change-Id: Ic400b6043607795ad92771f9d9f189699f185366
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-05-12 16:20:29 +02:00
Alexey Edelev
a3cb388eaa Check if next property in the list is not empty before adding a comma
Property merging genex only checks if previous value is not empty, but
doesn't check if an actual value that we concatenate is not empty too.
Add the check to make sure we don't have trailing comma in the json
lists.

Fixes: QTBUG-112885
Pick-to: 6.5
Change-Id: I1a5265ddf1b12f763650daf3c6e3538ed52a1674
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2023-05-12 14:20:28 +00:00
Peter Varga
2550568a92 Enable [[noreturn]] attribute for non-MSVC compilers on Windows
Avoids -Wsometimes-uninitialized warnings with clang-cl.

Also do not allow to return qt_message_fatal() if built with other
compiler than MSVC.

Amends 97b32fa0b6

Fixes: QTBUG-113351
Change-Id: I9ce87057e764af1e25de93388ae983891df66d2e
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-12 15:33:52 +02:00
Morten Sørvig
417b61b015 wasm: fix qtloader.js container element regression
As of Qt 6.5 the html document should not create canvas
elements directly, but instead create div container
elements and let Qt create and manage the canvas elements.

However, qtloaders.js has not been updated to match this
and is still creating canvas elements when given div
elements.

Remove the canvas creation code and invert the primary
and fallback case: config.containerElements is now passed
to instance.qtContainerElements. config.canvasElements
is copied to config.containerElements, if set.

Change-Id: I7372db93ee4de5b23a0a5d992597a3fbd9711a33
Pick-to: 6.5 6.5.1
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
2023-05-12 10:15:03 +00:00
Amir Masoud Abdol
305f61a807 Remove the -sysroot option from configure
The `-sysroot` does not have any effect, and it can be removed.
I added a warning in case someone is still using it.

[ChangeLog][configure] The -sysroot option was removed. Use
CMAKE_SYSROOT or CMAKE_TOOLCHAIN_FILE instead.

Task-number: QTBUG-112951
Change-Id: Ib180b891ca8228ef1ebf9be43f2f6b8b5b5b0ee7
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-05-12 09:46:24 +02:00
Thiago Macieira
cdd0e8fa67 QSlotObjectBase: move the which parameter to the 4th position
This places the first through third parameters on the exact positions
that they will be used to perform the operations in the switch, saving
the compiler from generating a few instructions to move data around. All
ABIs Qt supports that pass any function parameters in registers at all
pass at least 4.

We keep the return type as void (instead of returning bool, for the
Compare case) so the compiler can apply tail-call optimizations for
those two typical cases.

PMF case: https://gcc.godbolt.org/z/9oP5boKfj
Function case: https://gcc.godbolt.org/z/e9vEzd5dj
Functor case: https://gcc.godbolt.org/z/s8Ejjra7P

Change-Id: I3e3bfef633af4130a03afffd175d3e3009c56323
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-11 21:53:22 -07:00
Thiago Macieira
05ebf3e54b IPC: QNativeIpcKey: fix big-endian builds
We weren't using the LSB in big-endian builds because the bitfield was in
the wrong order: it was either using the MSB (in 32-bit builds) or
something in the middle for 64-bit. So use quintptr in the bitfield to
ensure proper sizing and correct the order.

Additionally, we now store the d "pointer" as a quintptr, so as to avoid
storing the actual pointer to QNativeIpcKeyPrivate with the LSB set.

Change-Id: Idd5e1bb52be047d7b4fffffd17506adb77d52805
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-11 21:53:21 -07:00
Thiago Macieira
e2a76797e0 QLatin1StringView: un-inline Latin1-UTF8 compare_helper
Commit c630b231ec ("Untangle
QLatin1StringView from qstring.{h,cpp}") moved QLatin1StringView from
qstring.h, causing compilations that included qlatin1stringview.h but
not qstring.h to produce a warning.

By un-inlining, we get an improved comparison functionality without
memory allocation too. So win-win.

 qlatin1stringview.h:325:23: warning: inline function ‘static int QLatin1String::compare_helper(const QLatin1StringView&, const char*)’ used but never defined

This is BC because the actual function that used to be inline continues
to be so, and the old implementation is fine, albeit slower.

Change-Id: Ieab617d69f3b4b54ab30fffd175c4e11d4a3b6dd
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-11 21:53:21 -07:00
Thiago Macieira
4f00e6c8b9 QReadWriteLock: inline the constructor and destructor
Change-Id: Ieab617d69f3b4b54ab30fffd175b2500dd860431
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 19:56:23 -07:00
Thiago Macieira
6ac0406464 QDnsLookup: treat NOTIMP replies as server failures
"Not implemented" is not "invalid reply".

Pick-to: 6.5
Change-Id: I3e3bfef633af4130a03afffd175e2687e7585f36
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 17:05:27 -07:00
Thiago Macieira
af9fa21a70 tst_QDnsLookup: don't fail if the server refused to answer
This happens often for me for ANY queries via Dnsmasq (home router) or
via whatever the corporate DNS servers are in the office.

Pick-to: 6.5
Change-Id: I3e3bfef633af4130a03afffd175e2656ae5e2c3e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 17:05:26 -07:00
Thiago Macieira
9f7b341aae tst_QDnsLookup: create a dedicated test for IDN
Instead of using initTestCase and QFETCH_GLOBAL, which make the rest of
the tests repeat themselves with IDN data, which isn't necessary.

Pick-to: 6.5
Change-Id: I3e3bfef633af4130a03afffd175e2537ba89dc04
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 17:05:25 -07:00
Amir Masoud Abdol
68b625901f Network: link directly to libresolv instead of dlopen()ing it
There's little need for us to dynamically load it. The reasons why that
was necessary aren't in the public history (Qt 4.5 already had it[1]). I
remember writing the code in 2007-2008, I just don't remember why.

On modern Linux and FreeBSD, there's no libresolv.so any more and those
symbols have been rolled up into libc.so. It's still necessary on Darwin
systems, so this commit introduces WrapResolv.

It also resolves the unity build issues relating to libresolv symbols.

[1] https://code.qt.io/cgit/qt/qt.git/tree/src/network/kernel/qhostinfo_unix.cpp?h=v4.5.1

Task-number: QTBUG-109394
Change-Id: Ic5799e4d000b6c9395109e008780643bac52122b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 17:05:25 -07:00
Thiago Macieira
ff9da1db0b QMutex: add QDeadlineTimer-based tryLocks
This simplifies the code greatly, because we don't need to use
QtPrivate::convertToMilliseconds any more, as QDeadlineTimer has
nanosecond precision.

Internally it becomes simpler too because lockInternal was already using
QDeadlineTimer. I just had to use the parameter instead and update the
two non-futex implementations to take it again. This may even be fixing
a mistake in case sem_timedwait(2) got interrupted.

Change-Id: I6f518d59e63249ddbf43fffd1759fed9f50b3606
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 12:31:57 -07:00
Thiago Macieira
63704529b7 QReadWriteLock: add tryLockForXxx overloads taking QDeadlineTimer
This propagates inside the internals, ending up in wait_until calls in
the internal std::condition_variable. For systems with proper support
for monotonic waiting (Linux, FreeBSD), this should improve performance.

We could even remove the hasExpired() check and pass a time point in the
past too. Right now, there's a minor performance drawback for
tryLockForXxxx(), because we will make at least two system calls to get
the time.

Change-Id: I6f518d59e63249ddbf43fffd1759fc5b2e40256a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 12:31:57 -07:00
Thiago Macieira
fcae43237b QReadWriteLock: inline the lockForXxx functions
We can now do that because tryLockForXxxx(-1) is fast for the
uncontended case too.

Change-Id: I3d728c4197df49169066fffd1756ddd06caf7b52
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 12:31:56 -07:00
Thiago Macieira
34914099a1 QReadWriteLock: remove the untimed tryLockForXxxx functions
They're unnecessary now because the timed function is fast enough.

Note: the default argument will move to the QDeadlineTimer functions
before the Qt 6.6 release.

Change-Id: I3d728c4197df49169066fffd1756ddc0e4f796d3
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 12:31:56 -07:00
Thiago Macieira
834c755977 QReadWriteLock: force the loop to exist in a separate function
This allows the fast, uncontended case to exist in a function that does
much less work and therefore needs to save less state in its
prologue. This is interesting too for LTO because the compiler can then
inline the fast, uncontended path where the locks were used.

Pick-to: 6.5
Change-Id: I3d728c4197df49169066fffd1756dc04d8a5f04a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 12:31:56 -07:00
Thiago Macieira
0c0778fb36 QReadWriteLock: remove the private function from the symbol table
Just move it to the private class. This also allows this function to get
inlined in QWaitCondition::wait().

Pick-to: 6.5
Change-Id: I6f518d59e63249ddbf43fffd1759fc99c28c7ca8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-11 12:31:55 -07:00
Ievgenii Meshcheriakov
859ef05633 QDBusConnectionPrivate: Fix handling of queued messages
Handle any queued messages before attempting to dispatch
any newly received messages. This ensures that messages are
processed in the order they were sent.

Add a regression test for this bug using code adapted
from the bug report by Pascal Weisser. Because of the
nature of the bug, this new test does not always fail
even when compiled with affected versions of Qt though.

Fixes: QTBUG-105457
Pick-to: 6.2 6.5
Change-Id: I2725f3450ad537d63d6660e21645ac2c578e1768
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-11 19:58:12 +02:00
Amir Masoud Abdol
b0f78c22bd Make sure that -Zc:__cplusplus, and -permissive- only apply to MSVC
As described in the bug report, in cases where host Qt is built using
MSVC, these flags may leak to user projects if they are set to be
configured by a different compiler, e.g., Clang.

Pick-to: 6.5
Fixes: QTBUG-112737
Change-Id: Iad922e24cc7e7f835e08ed37271dfbedc6e38dbe
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-11 19:58:11 +02:00
Volker Hilsheimer
9c9c5d9828 Fix QMetaObject::invokeMethod for free functions and std::bind
Amends 3bf5b5f894, after which free
functions and std::bind could no longer be used as callables in
QMetaMethod::invokeMethod.

For free functions to work we need to decay to function pointers when
choosing what type QtPrivate::Callable aliases.

And std::bind has operator() overloads and the return type cannot be
deduced. So simplify the definition of the ZeroArgFunctor - we know
the function prototype if we know the return type.

Add testcase for calling std::bind and free function, and remove the
now unneeded helpers for functor argument and return type deduction.

Change-Id: I54aac5cb6d660267e6b2f5ab05d583e8826cdf9a
Reviewed-by: Zoltan Gera <zoltan.gera@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 19:36:55 +02:00
Tor Arne Vestbø
af8e75f54f Revert "QIconLoader: use system fallback theme as the first fallback option"
This reverts commit 4710fb3528.

The theme it responsible for defining a set of good fallbacks,
and we should respect that order. We should also respect any
override the application developer does of the fallback theme,
and not unconditionally fall back to the system fallback theme.

Change-Id: I77f1a74c71a2a7db70464666b1a96a00fb4a1d8f
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-05-11 14:59:58 +02:00
Edward Welbourne
9f1252da28 Fix QTimeZone::offsetData() for the case without transitions
A zone without transitions, such as any UTC-based one, would
previously return invalid data for the offset data at a given
time. The method was documented to be "the equivalent of calling
offsetFromUtc(), abbreviation(), etc" but these methods do return
sensible data for a zone with no transitions. Furthermore, the backend
data() method on which it depends is implemented by all backends,
including the UTC one, with no transitions.

Fix offsetData() to also return data when no transitions are
available. Improve docs.

Adapt the checkOffset() test to test offsetData() as well as the
various functions to get parts of it. In the process, change that test
to use a QTimeZone row instead of its name as a QByteArray, so that we
can also have rows for lightweight time representations.

Change-Id: I241ecf02a26a228cca972bca5e2db687fe41feb4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-05-11 13:46:42 +02:00
Edward Welbourne
cded6afa35 tst_QDateTime::springForward(): take account of differences among zones
Some zones that fell into one or another of the supported groups had
different start times or even dates for their transitions, causing the
tests to fail in those zones. Adapt the test data to them.

In the process, arrange for part of the test to report more: verifying
a value is 1 or -1 sadly leaves no report of what it was when it
wasn't. So use the scope-guard report pattern to do that on failure.

Change-Id: I01cc4a90e3b45867ba0edb2d6c46397d465046ff
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-11 13:46:42 +02:00
Edward Welbourne
e3efcc8044 Rework tst_QDate::startOfDay_endOfDay(), exploiting modern QTimeZone
QTimeZone is no longer dependent on feature timezone, only its
backends are. We can also pass it as test data, rather than only its
name. So replace the zoneName column with a plain zone column, make
the UTC row for the epoch use QTimeZone::UTC instead of "UTC" and make
only the remaining rows depend on the feature, and then only for their
test using the backend zone.

The test itself was doing some convoluted twists to check local time
handled the relevant dates and times as expected. Where local time is
the zone the test relates to, this can just as well be handled by
adding a separate row for it - which we can even do without feature
timezone.

Otherwise, testing an expectation that local time *doesn't* have
anything odd going on for the selected days was somewhat unreliable,
as other zones that coincide with the tested zone for that particular
date would fail. So just drop that unreliable side of the local-time
testing.

Change-Id: Id58b2d4cf7649567f1831154a605f31139e987d3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-11 13:46:42 +02:00
Edward Welbourne
aeec731262 Correct startOfDay_endOfDay:BajaMexico test case
This follows up on commit ca4aa06523
with a correction to the start of day, which should of course be
01:00, not invalid.

Unsurprisingly, the MS backend doesn't know anything about that, so
gets this wrong; kludge round it. In the process, adapt the kludge to
the Sofia test-case to work the same way.

Change-Id: If18e6d005783a0854c56092e695177898ec61712
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 13:46:41 +02:00
Tor Arne Vestbø
1ea0625ca8 macOS: Replace [QNSView drawRect:] assert with warning
AppKit will in some cases call this method, even if we are layer backed,
just because we implement it. We should remove the implementation, but
doing so requires us to also move from displayLayer to updateLayer for
the layer backed drawing, which requires more testing.

Pick-to: 6.5
Fixes: QTBUG-113500
Change-Id: I70bde34fdb433105d85ccea0514a5342e2c1e725
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-05-11 12:47:56 +02:00
Marc Mutz
6da9662143 QRunnable: fix Coverity dead-code warnings in create()
Coverity complained about the call to warnNullCallable() being dead
code for most instantiations of the create() function template. It's
right, of course, even though warning in a template that clearly has
instantations where it's not dead code isn't exactly helpful.

Nonetheless, take the opportinity to avoid the dead code warning at
the expense of a bit or un-DRY-ing:

- because we now use them more than once, cache the result of
  is_*function_* predicates in constexpr variables

- then scope the is_null variable such that its use is not subject to
  dead-code removal anymore (at instantiation time; it may still be
  removed by the optimizer)

As drive-bys, add a comment about the reinterpret_cast, and make the
custom template predicates variable- instead of class templates.

Coverity-Id: 407640
Change-Id: I272223042c2aae9d814e82c466e1d29e1c42bfa1
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2023-05-11 12:47:55 +02:00
Marc Mutz
5ddfa8bbe6 QGenericRunnable: remove common prefix from nested classes
Helps keep the code fit into line length limitations.

Change-Id: I2e861c6f0a991cc36991572c4386040b8e11ca40
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-11 12:47:54 +02:00
Marc Mutz
acd675c38c Move QGenericRunnableHelper info QGenericRunnable
Because we can, and it prevents all the machinery from being exported
by the Q_CORE_EXPORT on QRunnable.

Change-Id: I80e0690956bff612f2048eefb2b64bc198835f1f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2023-05-11 12:47:54 +02:00
Marc Mutz
fdc29b9714 Move handling of helper from create() to QGenericRunnable
Keeps the helper contained in QGenericRunnable.

Change-Id: I52d075efc55c5eb78fe97ade261b58fc75e2a6c1
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-11 12:47:53 +02:00
Marc Mutz
e3442c05bd QStyleSheetStyle: avoid #define ceil()
There's only one user of this function-like macro and already broke
unity-build, so make it a lambda instead and scope it close.

Remove the previous work-around (#undef at end of TU).

Pick-to: 6.5
Change-Id: I0bd7cd41b89a6f32144d2040ff2b4a18d0045d21
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2023-05-11 12:47:53 +02:00