Fix various violations of the coding style or general inconsistencies.
No claim for completeness.
* indentation and line breaks
* consistent scopes for case statements where needed
* add curly-brackets for if-statements where needed
* removed {} where not needed
* const'ify a few obvious local variables
* remove random empty lines
* use auto when type is obvious from cast
Deliberately not touching nested if-statements that could be merged into
one.
Pick-to: 6.3
Change-Id: Ie22b36568f33e18d5f15c751c7fd76e1490133b9
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
qSwap() is a monster that looks for ADL overloads of swap() and also
detects the noexcept of the wrapped swap() function, so it should only
be used when the argument type is unknown. In the vast majority of
cases, the type is known to be efficiently std::swap()able or to have
a member-swap. Call either of these.
For the common case of pointer types, circumvent the expensive trait
checks on std::swap() by providing a hand-rolled qt_ptr_swap()
template, the advantage being that it can be unconditionally noexcept,
removing all type traits instantiations. Don't document it, otherwise
we'd be unable to pick it to 6.2.
Effects on Clang -ftime-trace of a PCH'ed libQt6Gui.so build:
before:
**** Template sets that took longest to instantiate:
[...]
27766 ms: qSwap<$> (9073 times, avg 3 ms)
[...]
2806 ms: std::swap<$> (1229 times, avg 2 ms)
(30572ms)
after:
**** Template sets that took longest to instantiate:
[...]
5047 ms: qSwap<$> (641 times, avg 7 ms)
[...]
3371 ms: std::swap<$> (1376 times, avg 2 ms)
[qt_ptr_swap<$> does not appear in the top 400, so < 905ms]
(< 9323ms)
As a drive-by, remove superfluous inline keywords and template
ornaments.
Task-number: QTBUG-97601
Pick-to: 6.3 6.2
Change-Id: I88f9b4e3cbece268c4a1238b6d50e5712a1bab5a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
We already have a precedent for this: the QueueCreateInfoModifier
callback. Following the pattern, add a EnabledFeaturesModifier that
can alter the VkPhysicalDeviceFeatures that is passed to
vkCreateDevice().
[ChangeLog][QtGui][QVulkanWindow] QVulkanWindow can now invoke a
callback to alter the VkPhysicalDeviceFeatures object used to create the
Vulkan device. This allows enabling 1.1, 1.2, and extension features.
Fixes: QTBUG-99803
Change-Id: I5ede0c6bc3430cbb304d4961eb9e44faad5ce4d7
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
[ChangeLog][QtGui][QVulkanWindow] QVulkanWindow is now enabling all
Vulkan 1.0 features reported as supported from the physical device.
Pick-to: 6.2 6.3 5.15
Task-number: QTBUG-99803
Change-Id: Ib9cfcd449904c67b07e0e2d4ade5bcaeb4cb0ce6
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
It's used by the lancebench and the lance tool, and it will probably be
useful for writing some high-dpi related unit and baseline test cases,
so move it to the shared folder.
Change-Id: I969bab51c9504be13b4c192b4f29f69cd9102868
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
We need it for shadertools.
Change-Id: I9e9c76e535e5cd698564b48beedb7380b08173e2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Simeon Kuran <simeon.kuran@gmx.at>
The mold linker is a new linker for Linux that provides faster link
times compared to BFD ld, ld.gold and lld.
It can be found at https://github.com/rui314/mold
To build Qt with mold, ensure that the binary in your PATH and then
configure Qt with with either
cmake /path/to/qtbase -DINPUT_linker=mold
or
/path/to/qtbase/configure --linker mold
The change was tested with gcc 9, clang 10, clang 12, mold
1.0.0. Only qtbase and qtdeclarative (and dependencies) were tested.
Pick-to: 6.2 6.3
Task-number: QTBUG-99270
Change-Id: I2e64a1f4257c37ff5b64a9326e548b9b46e07c80
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
The current behavior for handling the angle delta of a wheel event
changes index the instant there is a change in angle delta. This works
fine for mouse wheels that send events with 120 angle delta units and
there is also already behavior defined for devices with pixel deltas,
but there is nothing good for handling events from high resolution mouse
wheels that don't have pixel deltas.
This patch makes it so that the current index doesn't change until the
accumulated angle delta for the X or Y axis reaches 120.
[ChangeLog][QtWidgets][QTabBar] Scrolling with a high resolution mouse
wheel changes the current index at a rate more like a normal mouse
wheel.
Task-number: QTBUG-97844
Pick-to: 6.3
Change-Id: I2e7fd88984a253f6ef8a0008deb7233e4cb4d84a
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Not to have warnings about invalid (nullptr) parameters.
Change-Id: I5fdfa7e99df0f3c9907055cf244efa5a56b21c11
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Minor glitch in wording, but it's been bugging me for months.
The meaning of "try to remove [a file]" implicitly says you might be
unable to do so; while the attempt might help with your situation, the
experiment might merely be a diagnostic, e.g. because if you can't
remove the file, that would imply things that would help you solve
your problem. For contrast, "try removing [a file]" says removal
might actually solve the problem for which this action is proposed as
a fix.
Change-Id: Ic995cfdef1523094bb368dcda8bd0d2bbd2e9434
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
We do not test actively test setups where a separate graphics and
present queue is used because there is no combined queue at all. (it
won't be tested because we neither want to nor have the possibility to
do so)
However, QVulkanWindow (unlike, say, QRhi's Vulkan backend) attempts
to support this. It turns out the argument passed to vkQueuePresent is
wrong: the present is to be submitted to the present queue. So fix
this up.
Pick-to: 6.3 6.2 5.15
Fixes: QTBUG-73470
Change-Id: Ic9b589aba52e3326637216b98a074e27fdc3e3b9
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Use CMAKE_STAGING_PREFIX instead of CMAKE_INSTALL_PREFIX when
cross-compiling. This separates the host path used in staging
prefix and the target path used in the install prefix for the
device. This prevents for example Windows paths from being used
in a device that does not support those. It also tells qmake
not to sysrootify paths when building with it.
Embedded linux and QNX builds are mostly affected and need this
to use correct RPATHs and to unsysrootify qmake. Mobile platforms
(Android and iOS) are not affected since they package binaries
separately. WASM and INTEGRITY are static builds and device paths
are not used.
Cross-compiled auto tests keep staging prefix in RPATHs due to
the behavior implemented in commit 20292250d4
which keeps the QEMU test runs working as before.
Pick-to: 6.3 6.2
Change-Id: If464ccd8cd9318a853df9afcb2aa709fbb2c1837
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
The UB that the C and C++ standards talk about do not apply if we use
intrinsics. We can rely on the processors' architectural behavior
instead.
There are two ways to detect a conversion that cannot be represented in
the result. One would be to check if the #IE bit got set in the MXCSR,
but in order to do that we'd need two issue an STMXCSR+LDMCXSR pair to
clear the bit first and then another STMXCSR at the end to see if it got
set. Those instructions are 4 uops long and necessarily target memory,
so that's a bit slow.
This commit implements the second way, which is to check if the result
of the conversion is the "undefined" value. Unfortunately, that value is
a valid, precise value that double can hold for all data types except
unsigned 64-bit, so we need to recheck if that was the actual value
stored in the original double.
This implementation targets 64-bit exclusively because that avoids
having to deal with the 64-bit intrinsics not even being defined in 32-
bit code (converting a double to 64-bit integer in 32-bit is messy). The
unsigned implementation is only implemented with AVX512F because of the
unsigned conversion instructions that were introduced then.
Change-Id: I89446ea06b5742efb194fffd16bb9f04b2014bab
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Commit 289f909621 ("Test conversion of
ulonglong variant to JSON") was trying to ensure the result becomes a
double. So there's no reason to make a test in the _data() function.
Drive-by fix the UB condition on Windows (ulong is 32-bit, so 1ul << 63
is UB).
Change-Id: I0e5f6bec596a4a78bd3bfffd16ca4f8f5219f785
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
It was Linux-only and now even Linux is complaining:
tst_qmetatype.cpp:421:26: warning: ‘int pthread_yield()’ is deprecated: pthread_yield is deprecated, use sched_yield instead [-Wdeprecated-declarations]
Change-Id: I0e5f6bec596a4a78bd3bfffd16cb1eadfa301f16
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
All primitive types are initialized and have been since at least commit
33cd680ddb ("New QMetaType
representation").
Change-Id: I0e5f6bec596a4a78bd3bfffd16cb1fe22dc5c8f5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Because that's what it is.
Change-Id: Ib42b3adc93bf4d43bd55fffd16c144ef04d68d83
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This makes it easier to set global painter options
which affect all style painting.
Change-Id: I6a38204ed2d874255e92345e6a6a50d27939fb24
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Arguably, when talking about «null-string» constructor, it might be
useful to read about which strings are considered null, and which
methods one can use to test that.
Change-Id: Ie30144f33000aac53f4041cfb99da28a79dad946
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
When some test function fails (even as expected), it can leave the
event dispatcher in an inconsistent state where the posted events
queue might not be empty. As a result, this may break the internal
logic of the next test function that is run.
So, calling eventDispatcher->processEvents() after each completed
function resets the event dispatcher to its initial state, which
fixes the problem.
Pick-to: 6.2 6.3
Change-Id: I5a54f892d09a6eca73c8fc82875ce3b9ce4a3242
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Qt 5 uses begin() so the fix there will be to use cbegin().
Found by Clang -ftime-trace pin-pointing repeated instantiations
of QList<int>::data().
Pick-to: 6.3 6.2 5.15
Task-number: QTBUG-97601
Change-Id: I6410e5b303766fdbc7e158a9ac1263adec973099
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
We know decltype(d), so we don't need to jump though the ADL-enabling
that qSwap() does. Just call QExplicitlySharedDataPointer's
member-swap directly.
Found through Clang -ftrace-time over PCH'ed libQt6Gui.so build:
**** Templates that took longest to instantiate:
[...]
4050 ms: qSwap<QExplicitlySharedDataPointer<QColorTransformPrivate> > (87 times, avg 46 ms)
which is gone afterwards.
Task-number: QTBUG-97601
Pick-to: 6.3 6.2
Change-Id: Ie054848922a50dbf746781491cb28e598c0e12bc
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Doing Present(0, 0) is not necessarily sufficient to get rid of
blocking. It may very well start blocking after a few frames.
This does not apply to a non-flip-discard swapchain (when running
with QT_D3D_NO_FLIP=1), but for flip-discard we should also try using
DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING and DXGI_PRESENT_ALLOW_TEARING in
case a swap interval of 0 is wanted.
Pick-to: 6.3
Fixes: QTBUG-99949
Change-Id: I9cb13b139ba04e41b4f25b94bcd3d1e973496414
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
We set the wakeUps atomic to prevent multiple WM_QT_SENDPOSTEDEVENTS from
being posted. However, this might happen right after the event processing
thread cleared the atomic, but before it processed the previous
WM_QT_SENDPOSTEDEVENTS message. In that case, we end up with a set
atomic and an empty event queue, resulting in the event loop to block
even though there are posted QEvents.
To prevent that, always reset the atomic when we handle the
WM_QT_SENDPOSTEDEVENTS message. In that case, we either call
sendPostedEvents, or startPostedEventsTimer. The former already resets
wakeUps; reset it in the latter as well.
Fixes: QTBUG-99323
Pick-to: 6.2 6.3 5.15
Change-Id: I931c02be9c42b02e8ca20daba5059cd8185f0a37
Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
Add two tests for some problematic scenarios where the behavior is not
consistent across platforms and depending on which event dispatcher is
used:
1) reliably waking up the dispatcher when posting events from a worker
thread.
That test fails 100% of the time on Windows no matter what type of
application is created. It passes reliably on Linux and macOS for both
core and gui applications.
2) waking up the dispatcher when we post an event from within an
event handler.
That test fails 100% of the time on Windows, both with core
and GUI event dispatchers. On macOS, the test fails 100% of the time
with the core dispatcher, and passes 100% of the time with the GUI
dispatcher. On Linux, it passes only if a Glib based event dispatcher
is used; the default Unix event dispatcher (which is also the one
used on macOS for core applications) fails.
Task-number: QTBUG-99323
Pick-to: 6.2 6.3 5.15
Change-Id: I2489533b9f0032488707777be0512bb933669a7d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
Recommending a Qt 4 book in Qt 6 documentation tells us something about
how much we maintain the list :)
The other books might still be good sources. Anyhow, the chances of a
customer looking exactly in this place to learn good books about icons are
not very high. So let's just ditch the page, and use external links instead.
Pick-to: 6.3
Change-Id: I8013a5ab9d3416fe795f4aaed647e26db79508a1
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
The compiler generated special functions are just fine.
Pick-to: 6.3 6.2
Change-Id: I64fba1fac59f55d2a82ab18e32c1a2b854df72f0
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
The 'misc' data field was not copied in the assignment operator.
That field is normally not used, so this bug went undiscovered for a
long time. But in certain cases, the bug would cause an image size
mismatch to be reported as just a normal mismatch.
Fix the source of the problem by following the rule of zero - the
compiler generated special functions are just fine for this value
type.
Done-With: Volker Hilsheimer <volker.hilsheimer@qt.io>
Pick-to: 6.3 6.2
Change-Id: I8fc8d32d1b83b78cd4ef3f4ec9a8f22661b0e025
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
In Qt 5 times, the core of QList::realloc() was out-of-line by design,
because it was independent of T.
Now that QList is QVector, its equivalent detachAndGrow() function on
QArrayDataPointer is inline and instantiated for each type anew. We
therefore need to be careful to not use detach()ing QList operations
in non-generic code inline code (in public, but also private,
headers), because (common) PCH builds force this code to be compiled
over and over again. Generic code is only instantiated when used in a
TU, so that's ok. But for non-generic code, the only option is to
de-inline.
If there is an effect on compile-times, it's hidden in the run-by-run
noise of building QtGui, but at least this entry is gone afterwards
from clang -ftime-trace:
**** Templates that took longest to instantiate:
[...]
4676 ms: QList<QPoint>::operator[] (261 times, avg 17 ms)
Added 'inline' to the definition of the setPoint(int, QPoint)
overload, since MinGW used to complain about it missing.
Task-number: QTBUG-97601
Pick-to: 6.3
Change-Id: Ie6f67da7ef39a16c98a7451d37b6d96531656392
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
One of them has managed to percolate up to the top of the Clang
-ftime-trace list of expensive template instantiations when building
libQt6Gui.so with -pch:
**** Templates that took longest to instantiate:
7882 ms: std::is_trivially_destructible<QPropertyBindingSourceLocation> (135 times, avg 58 ms)
The checks aren't really necessary, because the compiler would
complain about the union's deleted dtor if any of the members were not
trivially destructible. Keep it around, though, but in the .cpp file.
Task-number: QTBUG-97601
Pick-to: 6.3 6.2
Change-Id: I74a513a907735bde298e0bd9557d10abbcee5c91
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
If the SIMD code has already determined that the byte content differs,
we don't need to actually subtract the bytes we loaded from memory in
vector operations to return a sorting result.
Change-Id: I0e5f6bec596a4a78bd3bfffd16c908b2902e1b1b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
So we don't accidentally make modifications to one and not the other.
Change-Id: I0e5f6bec596a4a78bd3bfffd16c94f1025aea521
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
If the lengths aren't equal, the strings can't be equal either, so we
can skip the entire comparison. Some of the front-end functions that
call these entry points already check for this, actually.
Change-Id: Ib42b3adc93bf4d43bd55fffd16c8ceb9594512f2
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
The compareStrings() entry points take QStringView and QLatin1String,
which are both ordered [size, pointer], so match that in the ucstricmp()
parameters. This further reduces the prologue of the compareStrings()
functions before reaching the case-sensitive comparison.
There's no need to do the same for the case-sensitive functions because
they're getting inlined.
Change-Id: I0e5f6bec596a4a78bd3bfffd16c8ffc980c8af0c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Case-insensitive comparisons are not common, but both GCC and Clang
inlined the ucstricmp() functions into QtPrivate::compareStrings(), with
the side-effect that a lot of unnecessary setup code saving CPU
registers was executed in the prologue of those functions.
After this, Clang 13 emits both compareString() functions without any
push/pop to save registers on x86-64; GCC 11 still emits a few, but
fewer than before (it's emitting some unnecessary overhead for the
loops).
Change-Id: I0e5f6bec596a4a78bd3bfffd16c8fc2c0be9165f
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This is very old code, predating the public Qt history (Qt 4.5). It
predates all other SIMD code in qstring.cpp, actually. Now that we do
have implementations for MIPS DSP, ARM Neon and x86 SSE2, this content
has very little value. It would be relevant for other architectures Qt
still supports (POWER and RISC-V come to mind), but I guess the
compiler's auto-vectorizer functionality can do a better job than this
content.
Change-Id: I0e5f6bec596a4a78bd3bfffd16c90733fb0d8f22
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Add a "HURD" CMake platform specification, so it can be properly
checked in the build system.
Set QT_DEFAULT_MKSPEC to the existing hurd-g++ mkspec.
Hurd supports $ORIGIN in RPATH, so enable it.
Hurd uses X11, so add it to the X11_SUPPORTED list.
Enable few more feature checks that apply to Hurd as well: either
because they are provided by GNU libc itself, or because they are
implemented on Hurd.
Check and set the ELF interpreter, as it is a common functionality of
the GNU toolchain.
Change-Id: Id347033560bbc5a2a4e2c3abb493c948c002b40e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
As a drive-by this fixes the qtbase build to also have the
CMAKE_AUTOGEN_VERBOSE option set.
Pick-to: 6.2 6.3
Change-Id: I32324fb1e8e16299c5f34517edbc7ff335d84e14
Reviewed-by: Toni Saario <toni.saario@qt.io>
Get rid of the function-static main window, which would be destroyed
after QApplication if the test is run with a subset of test row (that
does not include the TestEnd state test).
Make the MainWindow a class member of the test class instead, and rename
it from "mainW" to "mainWindow" to avoid shadowing by "mainW" widgets in
other test functions.
Amends 55928821d1.
Task-number: QTBUG-99630
Pick-to: 6.2 6.3
Change-Id: I83efce5b54afc3a0027a7c0e63efee6a235af585
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Amends commit 837a29b0b92c72b7b9d66a427c24a9fa8037f4f4's fix for
shadowing to take account of the loss of const-qualification of
uiLanguages where it was then used in a ranged-for loop.
Pick-to: 6.3 6.2
Change-Id: Ic4021bd9917cb27832a197126cc80a7f384a14a2
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
To make it explicit
Pick-to: 6.3 6.2 5.15
Task-number: QTBUG-92909
Change-Id: I8f8dc99628168a566158acef72ae2a5e001eef88
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>