When the the replacement has the same size as the replacee, but that
size is zero, the whole operation is a no-op, and there's no need to
detach().
[ChangeLog][QtCore][QByteArray] A replace(pos, n, after) call no
longer detach()es when n == after.size() == 0.
Pick-to: 6.3 6.2
Change-Id: I1e8d7c7fb6383f8bfea3212e49fca8a128535564
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Don't call first() on a potentially empty list of families. Fixes
a crash on startup on QNX for me.
Change-Id: I551d21dac8cfd104b774d6442bdbe1db35f8b75c
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
These directories are common on desktop operating systems. "Public" is
used for sharing files with other users and "Templates" lets you add new
files to the file creation desktop menu (for example in a file
manager). An example use in a Qt application would be KDE's KIO having
default icons for both directories.
This is where they point to:
Windows: C:/Users/Public, C:/Users/<USER>/AppData/Roaming/Microsoft/Windows/Templates
macOS: ~/Public, ~/Templates
Unix: ~/Public, ~/Templates
Task-number: QTBUG-86106
Task-number: QTBUG-78092
Change-Id: Ifca60c7d2a6dc2109ec290e8fb109ee2d5ca4d38
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Extract function terminate_on_exception() that de-duplicates the
#ifdef'ery around the try/catch and the handling of the pthread
cancellation pseudo-exception.
Apart from de-duplicating complex code, it will also help suppressing
a ubsan false positive, which is why we're picking it all the way to
5.15.
Pick-to: 6.3 6.2 5.15
Change-Id: I99ad2c0618b8dc30801931df09400c6611d9f9e4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Replaces a three-liner with a more elegant, idiomatic one-liner.
Pick-to: 6.3
Change-Id: I57fbe5d808dffa44f6fceffb97c47f0c84ccd3df
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Two functions' implementations were marked as inline, when their
definitons weren't. This is non-sensical, bordering on dangerous, so
remove the inline keyword.
Pick-to: 6.3 6.2 5.15
Change-Id: Iece21f9552aede273fa1f5a7aef0c94307fa5142
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
- There is no mounted partition, where we can create/delete files at runtime.
Tests should be excluded for now.
Pick-to: 6.2 6.3
Change-Id: I1c4db13d35da7d570c4bf787299d829e08951195
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Added Unix to the title of the enum
QStandardPaths::StandardLocation docs Linux paths table as this
also aplies to Unix based OS's such as QNX.
Fixes: QTBUG-63695
Pick-to: 6.2 6.3
Change-Id: I37b1bb6167984ccf7877baf2e6e764337121a947
Reviewed-by: Tommi Mänttäri <tommi.manttari@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
... as opposed to QByteArray::toHex('\0'), which doesn't.
Picking to all LTSs because it's in a test.
Pick-to: 6.3 6.2 5.15
Change-Id: I392d5714c4865e530a246ed30a13cdac26b98e0b
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The qgenericatomic.h occurrences are getting in the way of splitting
up qglobal.h, so inline the define.
Task-number: QTBUG-99313
Change-Id: I0d6e3553c5ed4ac9e426bef2fe07d2672d73c671
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Both multi-arg as well as QStringBuilder support QStringView these
days, so there's no need for a temporary QString, even one
fromRawData(), with all its extra codegen, when QStringView can do the
job just fine.
Change-Id: Ie9031aef85c5f0b535e94d9e414b7bd71ad909f7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
- There is no possibility to unpack *.zip archive anywhere on test device or save any file.
Currently we don't have mounted file system.
Task-number: QTBUG-99123
Pick-to: 6.2 6.3
Change-Id: I8c8d272a92b4475a7548bd10d32fc4203672926b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Just a leftover from code that has been replaced long ago.
Task-number: QTBUG-95237
Pick-to: 6.3 6.2 5.15
Change-Id: I8b1b0f319683ecfb2c93cc51a047616fe29770f7
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
When fallbacks are disabled for QSettings then it should not be
falling back to any child groups or keys that might exist in a
fallback set of settings.
Fixes: QTBUG-85295
Change-Id: I563999293a103702035c8d3b027b59b94ca43c0e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Browsers like Safari do not support the hardwareConcurrency property.
Will hard code it to 2, as iOS only supports that amount.
Pick-to: 6.3 6.2
Change-Id: Icb35d3b698b28d8191a554167dc8cc262b806fb2
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
On macOS 12.1 the NSEventPhaseCancelled phase can in some situations
report deltas, which causes the scroll to "jump". This happens for
example when initiating a momentum-scroll, and then putting two
fingers on the trackpad to cancel the momentum phase, which starts
a new NSEventPhaseMayBegin phase. When then lifting the two fingers
again, we get an NSEventPhaseCancelled event with deltas, but the
deltas seem like uninitialized data (has a x-value, after doing
a purely vertical scroll e.g.).
Task-number: QTBUG-97841
Pick-to: 6.3 6.2 5.15
Change-Id: I14e765b6111e53e7d3d0da219d4ac7fefe5243d0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Set ${FWCryptoTokenKit} when the framework has been found.
This is useful for WIP card reader support in QtConnectivity.
Task-number: QTBUG-97946
Change-Id: I0e85e0fd2e0fc45fb3069bbdaa2d8b2c927a6c2d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
If Xcode wasn't configured with any simulators the build would fail
since we had no device to build for. But we don't need to build for
a specific device, we can build for the generic simulator device,
just like we do for the non-simulator build. This likely didn't
work properly at the time it was first implemented, but now seems
to work fine, and is less fragile than the current solution.
Running tests still enumerates the available simulators,
as that needs a concrete device to run on.
Fixes: COIN-777
Pick-to: 6.2 6.3 5.15
Change-Id: I50e31c1b350cf83ce348275b467051263dea88a9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This is going to screw up the git blame functionality (which is why they
were forward-declared instead of implemented on-site) but the
alternative is that Qt Creator thinks qstring.cpp had almost no
functions inside.
Pick-to: 6.3 6.2
Task-number: QTCREATORBUG-25594
Change-Id: Ib42b3adc93bf4d43bd55fffd16c1986f1a3c1574
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Added section about having the State Machine Framework moved to its
own module.
Pick-to: 6.2
Pick-to: 6.3
Task-number: QTBUG-89285
Change-Id: I95d065230708d5b505d04309fd6ca21007d878dc
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Juha Vuolle <juha.vuolle@insta.fi>
The event dispatcher implementation is now in QtCore,
except for the call to QWindowSystemInterface::sendWindowSystemEvents().
Implement QWasmWindow::requestUpdate() using emscripten_request_animation_frame(),
instead of the previous registerRequestUpdateCallback() function
which now is removed.
Pick-to: 6.3
Change-Id: I7a13eb5391d48dba0f2afe4704ef3188b8daa74b
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
The QtCore event dispatcher will be used from QtGui
as well. Add virtual function where window system events
processing can be added.
Pick-to: 6.3
Change-Id: Ia6eda9ae18b2e91189ef9f60b6621d19a83313de
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
The test helper is expected to crash, but when built with asan, it
just fails.
Skip the test in that case.
Pick-to: 6.3 6.2 5.15
Change-Id: I583142f5ec623895df62498100c1a30539b149ab
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
The hasPrefix() function would only use the second 'lookahead' parameter
to check if there was more unparsed text after the current character.
When it's obvious from the codebase that it should actually look ahead
of the current character being processed, and compare againt that future
character.
Html comments were also not handled quite right. Partially because of
the broken hasPrefix() function, but also because it would advance the
current index tracker by 3 instead of 2. Remember that the beginning of
an html comment is <!-- meaning that there are only supposed to be 2
dashes required, not 3. The result would be that something like this
<!----> would not automatically close, because the current index tracker
would jump over the first 3 dashes when it begins a comment, and the
remaining unprocessed string would be ->
Also, because of the broken lookahead in hasPrefix(), a comment could
actually be started with just <!- not requiring a second dash at all.
Pick-to: 6.3 6.2 5.15
Fixes: QTBUG-99147
Change-Id: I8f4d4a1107eaf2dae16d16b7b860525d45a1c474
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
If a popup is open, Qt delivers events to the popup child under the
mouse, so we need to correctly translate the local position of the
context menu event to that child's coordate system.
This is already done correctly for regular mouse events, so use the same
logic here.
Fixes: QTBUG-99371
Pick-to: 6.2 6.3 5.15
Change-Id: Ief24c755e76d4d1aa2304b06662ed26ae309f684
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
We didn't delete the new'ed up QMetaTypeInterfaces, causing asan to
complain.
Fix by storing them in strong references alongside their users in a
statically-allocated container.
We use shared_ptr to hold them, because QMetaTypeInterface doesn't
have a virtual destructor, so deleting objects of the TypeInfo types
(plural!) derived from QMetaTypeInterface though a pointer to the base
class is UB. The shared_ptr constructor, however, is templated, so it
stores the correct call (~TypeInfo()) in its type-erased deleter.
We can't use std::make_shared(), because that doesn't support
aggregate initialization until C++20, so we manually new up the
TypeInfos.
5.15 is not affected.
Pick-to: 6.3 6.2
Change-Id: Ic7ec88c34e02a9e0dd3421848c0c0885f4756702
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
We now have a more reliable test for the case with freeSpaceAtBegin(),
so remove the old test, after we verified it actually doesn't even
test that case.
Task-number: QTBUG-99330
Pick-to: 6.3 6.2
Change-Id: Ic108a722cd2fef1e63a05085a76d7572d1f8c875
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
This test case fails on qemux86_64-webos-linux environment and based
on comment on the test case, it probably cannot be expected to pass on
webOS.
Fixes: QTQAINFRA-4717
Change-Id: Ifb34b0c85da2d180a59529791d1109185fef2665
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
We store the primary pointing device in a static variable to avoid the
lookup for each mouse event. However, when QApplication is destroyed,
then the device is destroyed, and the pointer needs to be reset so
that QApplication can be created again by the same process without the
first mouse event crashing the program.
Use QPointer to prevent the pointer from becoming dangling.
Fixes: QTBUG-99319
Pick-to: 6.2 6.3
Change-Id: Ie534c5eee48afb83e3a4adf70fc6cb4a2c310a7a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
When the system input method decides to trigger an insertNewline
message it might come from a synthetic NSEvent of type AppKitDefined,
which does not respond to the keyCode message. Accessing the keyCode
would result in an exception being thrown.
We guard for this scenario by moving the keyCode access into the
key-press and -release specific parts of the KeyEvent constructor,
making the KeyEvent usable with generic NSEvents (even if that
means it will only pull out the timestamp and modifiers).
We also prefer to use the currently interpreted NSEvent, if one is
available, when preparing the synthetic newline event. This ensures
that we get a valid timestamp and modifiers, since the synthetic
AppKitDefined event that the system IM generates does not provide
valid values for these.
Fixes: QTBUG-99186
Pick-to: 6.2 6.3
Change-Id: I050ae2aa2d8ded1be3541f746e6c052f3546e27c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
The test waits a bit hoping that all paint events are delivered after
showing the widget so that we can count the rectangles that are getting
updated when scrolling.
Waiting for 20ms is too short unless the system is completely idle.
Based on testing on a local VM, 150ms produces reliable results.
Pick-to: 6.2 6.3
Change-Id: I7729e94eae41476be67291a2f664cff784f96c7d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
QByteArray::resize() is now documented to not shrink capacity(), so
remove the extra reserve(0) work-around.
Change-Id: I3d5d944b9f01f8f84b31599548773198903aad4c
Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
The construction of the byte array doesn't actually yield
freeSpaceAtBegin() (anymore?), so the comment above it is misleading
(and the test didn't manage to catch QTBUG-99330, either).
Before removing the misleading test, verify that this assumption is
actually correct across all platforms.
Task-number: QTBUG-99330
Pick-to: 6.3 6.2
Change-Id: I2f497321abc26c4148ced5ac12a5880b9ff5ba9f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
The comment indicated that the author expected any overflow to be
caught by a bounds check in the subsequent function, however, signed
overflow is UB, so anything can happen.
Fix by using our API for safe additions instead.
Pick-to: 6.3 6.2 5.15
Change-Id: I41909defffa5305b02fdfcf6d5808e0d9fd5924f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
When startProgress, endProgress, and progress were all 0 (as provoked
by tst_QPropertyAnimation::startWithoutStartValue()), we'd calculate
0/0 and ubsan complained:
qvariantanimation.cpp:284:60: runtime error: division by zero
Fix by detecting progress - startProgress == 0 and setting
localProgress = 0.0 in that case. This is a logical result, even
though it might not be what IEEE754 rules would have yielded.
A more comprehensive change that aims to reliably keep localProgress
∈ [0,1] and thus avoid the infinities when endProgress ==
startProgress, is outside the scope of this patch, which deals only
with the UBSan error.
Pick-to: 6.3 6.2 5.15
Change-Id: I5258b054a2060006795f49fb1cd7604aea3ed46b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
defaultMimeType() cannot be moved out of the class and defined in
qmimedatabase.cpp, because it is called from QMimeType::isDefault() in
qmimetype.cpp.
Return m_defaultMimeType constant by reference rather than by value from
the inline helper function. This eliminates useless copying of QString
when calling code needs only a reference, and so improves performance.
Even though m_defaultMimeType is initialized with a QStringLiteral and
its QArrayDataPointer has d == nullptr, QArrayDataPointer's ref() and
deref() still have to compare d with nullptr to decide that no reference
count manipulation is needed. Compilers might be unable to reorder these
checks with surrounding code because they guard reference count
manipulation. Branch misprediction could further harm performance.
Optimizing these checks out can be difficult for compilers.
Change-Id: I3ffa0fdc5ad948452301dd9688073b5323a7983b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Amends 9b320edb53.
The above commit made the mistake of relying on the 30yr+ old
fundamental relation
size() - capacity() == freeSpaceAtEnd()
which, however, Qt 6's prepend()-optimization (freeSpaceAtBegin())
broke. Because of that, while size() - capacity() may be large enough
to hold the new data, if freeSpaceAtBegin() > 0, then freeSpaceAtEnd()
may not.
Fix by inspecting freeSpaceAtEnd() instead of capacity(). The
following reserve() call is unaffected, since it internally already
adds freeSpaceAtBegin() to the requested size, which is why the
unconditional reserve() in 9b320edb535a0fbe118933d2e983b73f90c32685^
worked while 9b320edb535a0fbe118933d2e983b73f90c32685's capacity()
check did not.
Fixes: QTBUG-99330
Pick-to: 6.2 6.3
Change-Id: I520f36216011423f97a24484263acd40d8b1fa43
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
In the changed code no QLatin1String overloads exist, so replacing
QLatin1String with QStringLiteral improves performance by eliminating
allocations.
Change-Id: I77530fe72c309b0609f40b1dc34189bd3454c813
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This should be more efficient than passing QStringLiteral.
Change-Id: Ia96633c9db6cb287dd9c196e739047b8a46abb4d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
When mimeTypeForFile()'s `mode` argument equals none of MatchMode
enumerators, an assertion fails or the default MIME type's name is
returned if assertions are disabled. Simplify and optimize this code by
assuming MatchDefault in the unsupported-mode case.
Change-Id: Iada36e0c96c378aefaa3a9d4a170222f764e94b6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Emscriptens implementation of fprintf does not provide
mutal exclusion when called from multiple threads, for
the emsdk versions Qt 5.15, Qt 6.2, and current dev
is using.
Pick-to: 5.15 6.2
Change-Id: Ied92730b735b11e4e5e85442de48fc25cbad0611
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
If code has no external references, then with a static build of Qt the
linker is free to strip those object files from the final executable.
This is what happened with QCocoaWindowManager, which had no exported
symbols, and no callers from other files.
To prevent the linker from stripping the object file and to ensure that
the constructor function gets called during startup, move that
function declaration to the QCocoaIntegration code, which is always
loaded.
Fixes: QTBUG-99280
Pick-to: 6.2 6.3
Change-Id: Icdafea372a1b42c6ecdb43e36aeb0a04a70e3d4e
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
We can detect if QML module has the embedded into the plugin QML files
using the 'prefer' record from qmldir files. No need to duplicate QML
files inside the android_rcc_bundle if 'prefer' record starts
with ':/'.
Pick-to: 6.3
Fixes: QTBUG-95984
Change-Id: Iee4f2248e3c0239c4f95a5db6e8fb3f16be636c5
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>