Commit Graph

61974 Commits

Author SHA1 Message Date
Friedemann Kleint
723e331f0a XBEL stream reader: Brush up
- Use mime types in the file dialog handling
- Use per class includes
- Use the configure system instead of QT_NO... defines

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: Iea915604e89d3005270f0eb83eca882855589a44
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-06-13 01:51:10 +02:00
Tim Jenssen
195c893424 QMacCGContext::initialize: Handle QPixmap without platform pixmap
Regression after 585150e3d9.

Pick-to: 6.5 6.6
Change-Id: Ie728904736dd41fb8dfa6ecc9f843beea95b4604
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-06-12 21:55:37 +00:00
Tor Arne Vestbø
3c12c3d58c Deprecate some older Apple platform defines
Clang's macro deprecation pragma was introduced in Clang 14,
shipped with Xcode 14.0.

We can't version check Q_CC_CLANG here, as qcompilerdetection.h
hasn't been included at this point. Nor would it have helped much,
as we would have had to do so for each individual define we wanted
to deprecate, since mentioning an undefined define in the deprecation
pragma is an error. And we can't wrap the pragma in another macro
that conditionally expands to _Pragma either, as the input argument
is a define that needs to be passed on as is, without expanding it.

So the simplest way to support < Xcode 14 is just to silence
the unknown pragma warning.

Pick-to: 6.6
Change-Id: Icf95042e6186deb212cd1793eb12ba32206ce34b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-06-12 23:55:36 +02:00
Amir Masoud Abdol
14b01b0aad Silence a warning in EGL check
There is a chance that an unused variable warning will be treated as an
error, and in that case, this check will fail, and as a result FindEGL
will fail.

Pick-to: 6.2 6.5 6.6
Fixes: QTBUG-114431
Change-Id: Iaac49589144dbe4172ec58c6705a9f899c25f01f
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-06-12 21:55:36 +00:00
Thiago Macieira
1a619ccb24 QtCore: Remove std::mutex and std::condition_variable fallbacks
They existed because INTEGRITY hadn't yet been updated to the C++11
Standard Library, with a minor for broken MinGW cross-compilation builds
that forgot to enable gthreads support in libstdc++. The former appears
to have been since fixed and the latter is a massive toolchain
configuration mistake.

Change-Id: I63b988479db546dabffcfffd1766b55132371f9b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-06-12 14:38:11 -07:00
Volker Hilsheimer
b908c5cf28 Move scroller/graphicsview example into tests/manual
The example seems incomplete, is undocumented (and unused in shippets,
in spite of tags being present), and generally full of comments that
give the impression that this is for manual testing rather than showing
best practices.

Pick-to: 6.5 6.6
Change-Id: Ie615420e493cc6bb461c5d9ff8d4ae82bb3591db
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-06-12 21:22:36 +02:00
Volker Hilsheimer
a89f575be3 Move storageview example into tests/manual
The code is mostly an implementation of a model based on QStorageInfo,
shown in an otherwise uninteresting tree view.

Pick-to: 6.5 6.6
Change-Id: Id6ce70d71ddc9bcd6e82a9ee12f5e1af159eac7a
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-06-12 21:22:36 +02:00
Volker Hilsheimer
ce13dc8c2f Remove flattreeview example
The relevant bits are a two-line snippet.

Pick-to: 6.6 6.5
Change-Id: Id1731e5bc6585b1d1fd684817b39d19ad0a8a9cc
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-06-12 21:22:36 +02:00
Mikolaj Boc
05c3342b43 Adapt WASM event dispatcher to use JSPI, if available
Detect if JSPI is available and suspend the execution of the program
if so, instead of using 'bare' asyncify.

For now:
1) This works only with emscripten 3.1.36 with mboc-qt patches from
emscripten repo
2) Apps have to specify the following linker options:
-sDYNCALLS=1
-sASYNCIFY=2
-sASYNCIFY_EXPORTS=dynCall_*

Fixes: QTBUG-113570
Change-Id: Ide7c51e36990df7e20c6c9b5a218366cb0db100e
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-06-12 15:46:31 +02:00
Edward Welbourne
97f68cd306 XBEL examples: construct the text of the separators cleanly
Create the fixed string once and reuse it. Also give a name to the
escape code that's its repeated character.

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: I3d6416070f1d5490ec137e251daff0e1637fb788
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-06-12 15:46:14 +02:00
Edward Welbourne
b610c7aa89 XBEL stream reader: shuffle order of functions
Put readBookmark() first of the constituent parts, as it's the most
intelligible (albeit currently undocumented) and gives some clue to
the purpose of readTitle(), which is next.

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: I91d3d6bf8adc3f3001c90274bb62a9da6bf05362
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2023-06-12 15:46:14 +02:00
Paul Olav Tvete
de9e978532 Fix for QQuaternion normalize when length > 1
If the length of the quaternion was slightly larger than 1,
the resulting quaternion would be invalid, causing
getAxisAndAngle() to fail.

Fixes: QTBUG-114313
Pick-to: 6.5 6.6
Change-Id: I8f0616e74590dd6cfee0ce913d214c8e280c4df4
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2023-06-12 15:46:07 +02:00
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