Commit Graph

61912 Commits

Author SHA1 Message Date
Morten Sørvig
4c18ebbc1c wasm: expose windows before delivering updates
Don't show a blank frame on app startup.

The wasm update request system supports two types of update
requests: Expose and UpdateRequest. It can happen that both
types of request are made for a single window, in which case
the current code prefers UpdateRequest, since those must be
delivered in order to keep QWindow in a consistent state.

However, if the window is visible but not yet exposed then
delivering the update request will not make the window paint
anything, and we end up with a blank frame.

Ideally this should be handled elsewhere and QWindow::requestUpdate()
should not be called for non-exposed windows, but in the
case does happen then sending an expose here allows us to
recover.

Pick-to: 6.5 6.6
Change-Id: Ib53050c33ad1769ea9b9ad678896af15f87a7ecb
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-06-12 15:46:07 +02:00
Heikki Halmet
409aa8d097 Add feature to disable building tests
IFW requires static build of Qt which does not build tests on all
configurations. This allows building modules without them building tests. Previously IFW used 5.15 repos, those build tests in test workitem, not running into the issue.

This is only relevant if the tested repo i.e IFW implements it's own
test instructions.

Pick-to: 6.6 6.5 6.2
Change-Id: I1e03f3b577d7be314f92ed3989e5f6daf2a46da1
Reviewed-by: Toni Saario <toni.saario@qt.io>
2023-06-12 13:46:07 +00:00
Jani Heikkinen
808a63e761 Bump version to 6.7.0
Change-Id: I69954ccc5cfb44e7bf02b8fcab18e9320e7e8748
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
2023-06-12 14:46:07 +01:00
Oliver Eftevaag
fc9aae544b Dialogs example: add checkbox for ColorDialogOption::NoEyeDropperButton
If we wish to introduce a new color dialog option, then we might as well
use it in our example.

Change-Id: I7771d9d50e2ab0489fbeece8dea38a0b72b9b21e
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-12 15:11:26 +02:00
Marc Mutz
b209f943d2 Replace {add,sub,mul}_overload with q{Add,Sub,Mul}Overload
These APIs started out as private APIs in qnumeric_p.h, but have since
been made pseudo-public in qnumeric.h. The qnumeric_p.h versions just
forward to the qnumeric.h ones, so just use the latter.

This is in preparation of removing the {add,sub,mul}_overflow
versions, which, despite being defined in the unnamed namespace, don't
sport the q prefix, so potentially clash with global symbols.

The change is a simple textual search and replace, manually excluding
qnumeric_p.h.

Picking to 6.5 to avoid cherry-pick conflicts going forward.

Pick-to: 6.6 6.5
Change-Id: Ic0f7c92f7c47923317109e8a9dc06fa66bdff2c2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-06-12 13:11:26 +00:00
Marc Mutz
e86e275284 Short live q20::iter_reference_t
Another building block for QSpan.

Task-number: QTBUG-108124
Change-Id: Ic7205ec693d953f6b054282380e87e79dead8816
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-06-12 15:11:26 +02:00
Marc Mutz
62801532a3 Short live q20::type_identity
Trivial implementation. No test necessary.

Task-number: QTBUG-108124
Change-Id: I20ec14e49f4db6399502f953b569c889d30bb5a7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-06-12 15:11:26 +02:00
Fabian Kosmale
dcf7604230 QVariant::value/qvariant_cast: add rvalue optimization
If we have a rvalue reference to an unshared QVariant, we can avoid
potentially expensive copies, and use move semantics instead.

[ChangeLog][QtCore][QVariant] Added rvalue QVariant overloads of qvariant_cast<T>() and QVariant::value<T>().

[ChangeLog][Potentially Source-Incompatible Changes][QVariant] It is no
longer possible to take the address of a specialization of
qvariant_cast; consider using a lambda function instead.

Change-Id: Ifc74991eadcc31387b755c45484224a3200bb0ba
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-12 09:58:58 +02:00
Thiago Macieira
b1ee49b465 Q{Any,}StringView: optimize lengthHelperContainer for the runtime
Deduplicate it in the process by moving to qstringalgorithms.h.

In non-constexpr contexts, both GCC and Clang were giving up in
pre-calculating the length if the UTF-16 string literal was too big. For
the old code, that was 14 and 16 characters respectively. That number
can be raised by adding some Q_ALWAYS_INLINE and (for GCC's case),
replacing std::char_traits::find() with std::find(). If that limit is
exceeded, we call the newly introduced qustrnlen() function.

qustrnlen() is just qustrchr(), like qstrnlen() is just memchr(). But it
is introduced as a separate function so we could change implementation
if we ever wished to, plus QStringView is only forward-declared at this
point.

Change-Id: Ieab617d69f3b4b54ab30fffd175c560d926db1c3
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-06-11 15:43:02 -07:00
Thiago Macieira
95e6fac0a5 Short-live qIsConstantEvaluated()
This is not q20::is_constant_evaluated() because it does not replace
that for all compilers. Instead, it's our own version of it that may
return false even in constant contexts. However, for the majority of our
users, it will work even in C++17 mode.

Updated QStringView and QAnyStringView to use it, which are the only two
places in all of Qt that used std::is_constant_evaluated().

Change-Id: Ieab617d69f3b4b54ab30fffd175c50c517589226
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-06-11 15:43:01 -07:00
Thiago Macieira
631901f6d1 Q{Any,}StringView: remove the GCC-specific compile-time content
Because GCC isn't really working them out at compile time. First, for
both lengthHelperPointer(), they don't get called on string literals
such as

  return QStringView(u"Hello");

because the type hasn't decayed to a pointer, but is instead a
char16_t[6]. No one writes

  constexpr auto str = u"Hello";
  return QStringView(str);

Second, even when you do write that, GCC is emitting the code to search
for the null or non-ASCII byte at runtime, instead of pre-calculating
it. That's not worth it because the code is not vectorized, even at -O3
and with a long string. Instead, let it get the length at runtime with
QtPrivate::qustrlen(), which has vector code.

Drive-by fix the QAnyStringView::lengthPointerHelper() to be constexpr,
avoiding the same GCC warning that was fixed for QStringView in commit
4fd4082c3a.

Change-Id: Ieab617d69f3b4b54ab30fffd175c505cb66eac02
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-06-11 15:43:00 -07:00
Ahmad Samir
60f34fc9e3 QFactoryLoader: add assert and explicitly cast to int
Other parts of the code are expecting int.

Pick-to: 6.6 6.5
Change-Id: Iea73412c874adb2e6589e9b11607f313e1747d19
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-06-11 19:29:47 +03:00
Tor Arne Vestbø
5ea0256b07 rhi: Don't check m_format in QRhiSwapChain::hdrInfo()
The HDR info is independent of the current format anyways.
Removing the format check allows code to use hdrInfo() as
a signal for whether to set a HDR format, instead of having
to set the format, then query hdrInfo(), and then setting
SDR again if needed.

Pick-to: 6.6
Change-Id: I99b57335003d06af227f2a7078560c2a483b049b
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-06-11 08:50:04 +02:00
Tor Arne Vestbø
5302fb64af rhi: Only report HDR as supported if maxPotentialColorComponentValue > 1
Pick-to: 6.6
Change-Id: I4c951e8c651b2bee41aba8ff69f481a08d6a3561
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-06-11 08:49:58 +02:00
Tor Arne Vestbø
183629e3ef rhi: Add QRhiSwapChainHdrInfo::maxPotentialColorComponentValue
Knowing the maximum potential component value can be useful
to potentially (sic) opt out of an HDR code path if the maximum
color component value will be too low to make the additional
processing overhead worth it.

Pick-to: 6.6
Change-Id: Ib1e1b7a745b236e1d137a1e7daf1248f1572e184
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-06-11 08:49:53 +02:00
Tor Arne Vestbø
74319d05b1 rhi: Pick up HDR maxColorComponentValue from UIScreen if available
Although QRhiSwapChainHdrInfo uses 'max' for this value, it's used
by Qt Multimedia's QVideoWindowPrivate::render() as the current
maximum, so we need to reflect UIScreen's currentEDRHeadroom
rather than potentialEDRHeadroom (the absolute max), the same
way we reflect maximumExtendedDynamicRangeColorComponentValue
and not maximumPotentialExtendedDynamicRangeColorComponentValue
from NSScreen.

As we don't support HDRExtendedSrgbLinear on < iOS 16 there
is no point in providing a heuristic fallback based on the
iPhone 12 spec.

Pick-to: 6.5 6.6
Change-Id: If071bb64f269ce16886206df05eb9f27d260bf15
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-06-11 08:49:47 +02:00
Volker Hilsheimer
38a00d2c97 QMetaCallEvent::create: pass arguments by const ref
Amends 4d7ae8a74e70896a757f483865fe7095120fedc1.

Pick-to: 6.6
Change-Id: Id4379324c2399f2360b3553d297f38dd793af21c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2023-06-11 04:41:15 +02:00
Ahmed Essam
1f22fc995a Fix segfault when using qfuture continuations with move only types
When using move-only types, continuations args are set using takeResult
function, which has the side effect of invalidating the QFutureInterface
associated with the promise/futures by:

1. setting isValid to false
2. setting the state to NoState

And when the promise is destroyed, it tries to run the continuations if
`finished()` is not called, which is done by checking the Finished bit
in the state. But since the continuation has been run before, and the
state has been set to NoState it tries to run the continuation again
causing a segfault. Multiple solutions come in mind:

1. don't run the continuation if the state is NoState, but this would
   break the case when an empty promise is destroyed
2. check inside the continuation if it has been run before, and if so
   don't run it again, but this seems hacky since we don't want the
   continuation to be run twice, and it should break if it did.
3. when invalidating the promise leave the state as is, and change
   isValid only to false, which changes the current behavior, but is
   still compatible with the documentation which states only that
   isValid will return false if takeResult is called

I chose option 3

I also extended some tests to test for move only types, and added a test
that continuations run when a promise is finished. This simple case
would segfault before with move only types.

Fixes: QTBUG-112513
Pick-to: 6.5 6.6
Change-Id: Ie225ac4fdf618e4edfb0efd663d6c7fd6b916dbd
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-06-10 14:28:13 +00:00
Ahmad Samir
10575ffddb QTimerInfoList: improve class encapsulation
Replace the only usage of updateCurrentTime() outside of the class by a
getter that checks if there are pending timers. And make
updateCurrentTime() private.

Change-Id: I148639b01abd75990cfc7b25bb1f466e45ab0c71
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-06-10 14:35:34 +03:00
Ahmad Samir
48e06db2c5 QTimerInfoList: cleanup
- Initialize member in-class
- Remove redundant include
- Remove QTIMERINFO_DEBUG related code, it hasn't been compiled for a
  long time, so it has bit-rotted, and its purpose isn't clear any more

Change-Id: I874415e1edec7c4da03f697f5f9f8665d8b015a3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-06-10 14:35:30 +03:00
Ahmad Samir
be3dd0115b QTimerInfoList/Unix: use chrono::steady_clock::time_point
I.e. use chrono first, see linked task for more details.

Task-number: QTBUG-110059
Change-Id: Ie0908f9446957d4383fb7a70b67c16b78605a0f3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-06-10 14:35:26 +03:00
Assam Boudjelthia
c0e0b56055 Android: improve screen size and physical size calculation
Use new api calls for calculating pixel size and physical size
of multi-display setups after some existing apis have been deprecated
in Android API 30 and 31. Also, do the physical size calculation outside
of the supported modes loop.

As for the physical size, this patch still uses xdpi/ydpi for the
calculation instead of densityDpi as suggested in [1] because from
testing few scenarios, the results returned from xdpi/ydpi are more
consistent with physical device specs.

[1] https://issuetracker.google.com/issues/194120500

Pick-to: 6.6 6.5
Task-number: QTBUG-112742
Change-Id: I0c8ef5185c8b6463830b528374954c324a32d657
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2023-06-10 11:12:39 +03:00
Thiago Macieira
01872d06d9 tst_QFile: replicate the unixPipe test using FIFOs
Pipes are unnamed FIFOs, so they're basically the same.

The difference here is that open() blocks on opening a FIFO until both
ends of the FIFO are opened. This helps us in synchronizing the two
threads and thus ensuring that that the read() system call deep inside
QFile does, indeed, block.

We see this with strace -T on Linux:

[pid 662956] openat(AT_FDCWD, "/run/user/1000/tst_qfile_fifo.2575572361", O_RDONLY|O_CLOEXEC <unfinished ...>
... aux starts up ...
[pid 662957] prctl(PR_SET_NAME, "QThread") = 0 <0.000004>
[pid 662957] openat(AT_FDCWD, "/run/user/1000/tst_qfile_fifo.2575572361", O_WRONLY|O_CLOEXEC <unfinished ...>
[pid 662956] <... openat resumed>)      = 4 <0.000133>
[pid 662957] <... openat resumed>)      = 6 <0.000011>
[pid 662957] clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=500000000},  <unfinished ...>
[pid 662956] read(4,  <unfinished ...>
[pid 662957] <... clock_nanosleep resumed>NULL) = 0 <0.500183>
[pid 662957] write(6, "\2", 1)          = 1 <0.000033>
[pid 662956] <... read resumed>"\2", 1) = 1 <0.500311>

Pick-to: 6.6
Change-Id: I63b988479db546dabffcfffd1766d7a48819b149
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-09 20:30:07 -07:00
Thiago Macieira
65097e7667 tst_QFile: fix unixPipe() and socketPair() closing already-closed fd
Pick-to: 6.5 6.6
Change-Id: I63b988479db546dabffcfffd1766d75c11e46fda
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-09 20:30:06 -07:00
Thiago Macieira
921bf4a11a QProcess/Unix: capture the child process modifier exception's what()
Change-Id: I5f7f427ded124479baa6fffd175ffb017b6cd13c
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-09 17:32:35 -07:00
Thiago Macieira
90bc0ad41f QProcess/Unix: add failChildProcessModifier()
QProcess detects other types of failures from inside the modifier as
successful starts, because the childStartedPipe gets closed without an
error condition getting written. The new method allows a reporting as a
proper failure-to-start.

Added tests for both cases.

[ChangeLog][QtCore][QProcess] Added failChildProcessModifier().

Change-Id: Icfe44ecf285a480fafe4fffd174da2b10306d3c2
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-06-09 17:32:33 -07:00
Thiago Macieira
abd2ffc149 QProcess/Unix: update the close-file-descriptors feature with a minimum
So that one can pass a few extra file descriptors to the child while
still closing all the rest.

strace -f of this test showed on Linux:

[pid 117952] dup3(4, 0, 0)              = 0
[pid 117952] dup3(9, 1, 0)              = 1
[pid 117952] dup3(11, 2, 0)             = 2
[pid 117952] close(12)                  = 0
[pid 117952] dup2(100, 3)               = 3
[pid 117952] close_range(4, 2147483647, 0) = 0
[pid 117952] execve("testUnixProcessParameters/testUnixProcessParameters", ["testUnixProcessParameters/testUn"..., "file-descriptors2", "3", "100"], 0x561793dc87d0 /* 120 vars */ <unfinished ...>

Pick-to: 6.6
Change-Id: I3e3bfef633af4130a03afffd175e984bf50b558d
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-06-09 17:27:48 -07:00
Thiago Macieira
e71c226d6f QProcess/Unix: call the internal version of sigaction()
I've investigated the functions we call in the child side of a vfork()
for implementations that do more than simply place the system
call. Where wrappers exist, they are usually related to handling of Unix
signals or PThread cancellation. The implementations investigated are:
- Bionic (Android)
- FreeBSD
- glibc (Linux)
- MUSL (Linux)
- NetBSD
- OpenBSD

Relating to thread cancellation, NetBSD implements it with an internal
API that does not include Unix signals and Bionic doesn't implement
thread cancellation at all. Their wrapper functions are harmless.

The rest do use Unix signals to implement thread cancellations (called
SIGCANCEL everywhere except OpenBSD, where it's SIGTHR). Therefore, they
all block the application attempts to mask this signal or change its
handler (if they're not buggy). FreeBSD's and MUSL's do some locking in
their implementations[1][2] we really want to bypass, therefore we must
bypass their sigaction() wrappers.

The investigation also showed that the glibc[3] and NetBSD[4] abort()
implementations to be slightly unsafe, but we don't use them
ourselves. We're also adding QProcess::failChildProcessModifier() so
users won't have to resort to abort().

[1] https://github.com/bminor/musl/blob/master/src/signal/sigaction.c
[2] https://github.com/freebsd/freebsd-src/blob/main/lib/libthr/thread/thr_sig.c
[3] https://codebrowser.dev/glibc/glibc/stdlib/abort.c.html
[4] https://github.com/NetBSD/src/blob/trunk/lib/libc/stdlib/abort.c

Task-number: QTBUG-113822
Pick-to: 6.6
Change-Id: I9201d9ecf52f4146bb04fffd17651123800e15a4
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-09 17:27:47 -07:00
Thiago Macieira
062b2ac71b QProcess/Unix: reset the signal block if ResetSignalHandlers requested
This amends commit f9c87cfd44 to reset the
signal block mask too, not just the signal handlers. For this, SIGPIPE
is not treated specially.

Pick-to: 6.6
Change-Id: Ib5ce7a497e034ebabb2cfffd17627289614bf315
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-09 17:27:46 -07:00
Marc Mutz
78cdd9a64d QPixmapCache: deprecate replace()
The replace() implementation overwrites the passed Key key with a new
version, const_cast'ing away the const from the key passed by
reference-to-const. This is UB if the Key was originally declared
const.

Deprecate the function.

Also inline the const_cast, so compilers can readily detect the UB
even if users don't enable deprecation warnings. Due to the severity
of the issue (UB), immediate deprecation is warranted. There appear to
be no in-tree user of the API outside of tst_qpixmapcache.cpp.

[ChangeLog][Deprecation Notice][QtGui][QPixmapCache] The `replace(key,
pixmap)` function has been deprecated, because passing a `const Key`
to it results in undefined behavior. Use `remove(key, pixmap)`
followed by `key = insert(pixmap)` instead.

Pick-to: 6.6
Change-Id: Ic5060ce3271f2a1b6dc561da8716b452a2355d4c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-10 00:29:06 +02:00
Axel Spoerl
c4635c0d58 QStyleSheetStyle: Default to foreground for unset brushes only
If a foreground style has been defined in the style sheet,
QStyleSheetStyle populates its brushes for the color roles ButtonText,
WindowText, Text, and the widget's foregroundRole with the foreground
brush. PlaceholderText is set to the same brush with a modified color.

That sets their resolve bits in QStyleSheeetStyle's palette and
prevents these color roles from being inherited by the widget's
palette - in contrast to all other brushes.

This patch makes the brushes mentioned default to the widget's palette
if they are set there. It adds a test in tst_QStyleSheetStyle.

Fixes: QTBUG-93009
Pick-to: 6.6 6.5
Change-Id: Ie3df9dbd17b96fa72beee90792fc7eca1933cdbe
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-09 23:42:47 +02:00
Topi Reinio
1797f7946d Doc: Fix documentation for QProcess::UnixProcessFlag
Pick-to: 6.6
Change-Id: I6001b8c4e73d9785df8338d4d14fcf15f09eae15
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-09 18:24:31 +00:00
Topi Reinio
17ddf2a6a5 Doc: Fix documentation issues
The Qt Widgets Application example was moved to manual tests,
and no longer contains the snippet identifiers. Fix \snippet
and \quotefile commands to quote similar code snippets from
other examples or snippet files.

Fix also the following documentation warnings:

* No such parameter 'parsingMode' in QUrl::fromEncoded()
* Missing image: rsslisting.cpp

Pick-to: 6.6 6.5
Change-Id: Ibc989e83abc49837db08628facaf8e5f72b2f123
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-06-09 18:24:15 +00:00
Thiago Macieira
fbc491230f Q{Semaphore,ReadWriteLock}Private: reorganize the members
They are now ordered so that the mutex and the wait condition are in
different cache lines, to avoid false sharing situations, if the types
are holding the actual threading primitive structures, not mere pointers
to some other structure elsewhere.

For 64-bit systems:

OS                  | mutex |  cond | Remark
--------------------+-------+-------+------------------
Darwin              |    64 |    48 |
FreeBSD             |     8 |     8 |
INTEGRITY           |     8 |     8 | QMutex & QWaitCondition
Linux               |    24 |    48 | Always uses futex
MinGW (Winpthreads) |     8 |     8 | Always uses futex
MSVC (MS STL)       |    32 |    16 | Always uses futex
NetBSD              |    48 |    40 |
OpenBSD             |     8 |     8 |
QNX                 |     ? |     ? |

Change-Id: I63b988479db546dabffcfffd176698e4f0097e90
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-06-09 10:53:11 -07:00
Thiago Macieira
0f9894f79b QSemaphore: emit waking on the same word size as we wait on
futexSemaphoreTryAcquire_loop() always waits on 32-bit portions of
QSemaphore. The current implementations only look at the pointer address
and don't care what size the waiter used. That's not the case for the
Darwin/macOS implementation:

In xnu/bsd/kern/sys_ulock.c:ulock_wake[1]:

	if (opcode != ull->ull_opcode) {
		ret = EDOM;
		goto out_ull_put;
	}

[1] 5c2921b07a/bsd/kern/sys_ulock.c (L970-L973)

Change-Id: I63b988479db546dabffcfffd1766c5eae61187f0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-06-09 10:52:19 -07:00
Edward Welbourne
207954d5f0 Avoid using Darwin date formatting before 1583
It turns out that Darwin's date formatting uses the Julian calendar
for dates before 1582-10-15, when the Gregorian calendar first came
into use (in some countries, while many others continued using
Julian).  This leads to discrepancies between the (Gregorian) dates we
pass it for formatting and the (Julian) dates it actually prints, that
are the same number of seconds before 1970.

Previously the QLocale system backend for Darwin already had a kludge
to work round its handling of negative years, so it suffices to extend
that to years before 1583.

Fixes: QTBUG-54955
Pick-to: 6.6 6.5
Change-Id: I70f219b73bf20c0cd63bcda2b0e99042354872ca
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-06-09 18:01:01 +02:00
Tor Arne Vestbø
716df4965e macOS: Remove old friend declaration for qt_mac_is_metal
The function was part of the Cocoa style for checking the metal
look (not Metal the graphics API), but has long been removed.

Pick-to: 6.5 6.6
Change-Id: I366b952db4ae82b8ecc442f1ce61e7f53cacfe80
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-06-09 18:01:00 +02:00
Ahmad Samir
3e7d68a6f4 QtLinuxFutex, QBasicMutex, QSemaphore: use chrono for time arithmetic
Done-With: Thiago Macieira <thiago.macieira@intel.com>
Change-Id: I7c696d58ee596254f91bcd131fe884b6e6ef0852
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-06-09 17:45:14 +03:00
Yuhang Zhao
71c9b9f05b Re-fix QtLibraryInfo compilation issues
After the "CMake: make compile options consistent for Qt created libraries"
revert, this part of the code also get reverted, however, it's not
related to the revert reason: the user project's deprecation behavior
is changed. So restore this code. We need this code to make sure
we use the same parameters when compiling QtLibraryInfo, otherwise
some compilers may complain about it, such as clang-cl.

Pick-to: 6.6 6.5
Change-Id: Ie50d4f820be3a2e950dd87902d794f1d2681b7a5
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-06-09 14:45:14 +00:00
Mikolaj Boc
78acaf4fb6 Fix sending deferred delete events when posted before outermost loop
QDeferredDeleteEvent has the loopLevel field, which is a sum of
scope and loop levels found at posting. In sendPostedEvents however,
it is impossible to only use this information to find delete events
posted before the outermost loop (which should be handled by any loop)
based solely on this information, as the scope level essentialy removes
the information on loop level.

Break the loopLevel in two, storing both loop and scope levels in
QDeferredDeleteEvent, so that we can check whether an event was posted
before the outermost event loop (for which we need to compare only the
loop level).

QDeferredDeleteEvent was also made private as it should - it is an
implementation detail that wasn't hidden properly.

Change-Id: I0a607a0bd3a2deb5024acad67f740dbf4338574c
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
2023-06-09 16:31:35 +02:00
Volker Hilsheimer
30e5ff3ff2 Stabilize QFile::unixPipe/socketPair tests
We observe failures in CI on QNX because the measured timeout is ~995ms
rather than the expected 1000ms. Start the timer before the thread
starts to guarantee that at least as much time elapses as the thread
waits before writing the second byte to the pipe.

Otherwise, the thread might be sleeping already when the timer starts,
and then we can't rely on any measurements.

Pick-to: 6.6 6.5
Change-Id: I6072569a987f5e952b0953e0e394a223f891fd25
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
2023-06-09 15:42:06 +02:00
Alexey Edelev
65b0bc0eed Fix external header support in qtsync
We should sync external headers for 3rdpary projects
like freetype and harfbuzz-ng and keep the directory
structure.

Fixes: QTBUG-113416
Pick-to: 6.6 6.5
Change-Id: Ie66edb9a21cff37ca6c8c68b6d225de6d8bbad81
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
2023-06-09 13:42:05 +00:00
Marc Mutz
19aa5da9b5 tst_containerapisymmetry: check that std::size() works
It does.

Pick-to: 6.6 6.5
Task-number: QTBUG-112183
Change-Id: Ieddf7764dcb8e145e37e86b9fcd35c19d302ca4f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-06-09 12:32:48 +00:00
Volker Hilsheimer
bd29b03368 Remove links from the Text Object example
It's an example in Qt SVG that is to be removed.

Pick-to: 6.5 6.6
Change-Id: I6e8cf38885649ca10f70a70b8400873c97bf1698
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-06-09 14:32:48 +02:00
Marc Mutz
0e96dd3464 tst_QPixmapCache: QVERIFY a failed replace()
Between the find() == 0 obfuscation (since fixed) and this unchecked
replace(), it took me way too much time to figure out what was going
on: the key passed has been invalidated by the setCacheLimit(0).

Now that we QVERIFY that the replace() _fails_, it's much easier to
backtrack and figure out why it does so and why, consequently, the
following find() is also expected to fail.

As a drive-by, reorder two lines so the grouping becomes clearer
(blocks now both headed by setCacheLimit()).

Pick-to: 6.6 6.5 6.2 5.15
Change-Id: I434b65fc13c3fed6512036efeb98d738eeb2a13d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-09 12:32:48 +00:00
Marc Mutz
588ca25e4a QPixmapCache: add a comment on how failed insert() invalidates cacheKey
It wasn't obvious to me, at least, and I only found out about it when
I failed to construct a test failure based on this.

Pick-to: 6.6 6.5 6.2 5.15
Change-Id: I339132d7bb2cb8a76f0f1feec37891d6131c4d7b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-09 14:32:48 +02:00
Marc Mutz
e409d771d9 tst_QPixmapCache: check insert() reports failure
None of the existing tests failed when I started to return a valid key
from a failed insert(QPixmap), so add a test that would fail.

Pick-to: 6.6 6.5 6.2 5.15
Change-Id: I74f23d2ec4c04151f8f1266c0c503713d4642f3a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-09 14:32:48 +02:00
Marc Mutz
6032845ca2 tst_QPixmapCache: rewrite QVERIFY(x != 0) to QVERIFY(x)
This is just confusing. QPixmapCache::find() already returns bool,
comparing it to a literal zero just makes it hard to read.

Pick-to: 6.6 6.5 6.2 5.15
Change-Id: I43c000890377cca2111daa48799f10cc99aad8cf
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-09 14:32:48 +02:00
Edward Welbourne
8e1b60b331 There is no frank.xbel so don't tell qmake to find it
Both the DOM and XML stream versions of the XBEL bookmarks example had
a frank.xbel in their EXAMPLE_FILES, but there is no such file. So
asking qmake to include it is spurious.

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: Iec08042d181fc09c2c428685ce841a13161ab273
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-06-09 14:05:06 +02:00
Edward Welbourne
202b1dca5d XBEL example - modernize strings: use "..."_L1 for literals
The XML stream reader and writer accept QAnyStringView arguments these
days, so passing a QLatin1StringView is entirely sufficient. This
makes static functions to provide access to unique QString instances
redundant. Linkers are allowed to uniquify the literals the "..."_L1
reference.

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: I7f37e97631e11683b9ddd3842fc6233547bed5ff
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-06-09 14:05:06 +02:00