Commit Graph

57062 Commits

Author SHA1 Message Date
Volker Hilsheimer
92e696b4ba Use debug stream in QTest::toString's default fallback if possible
For built-in types, this is a compile-time assert - we should not have
any types in Qt for which we have neither debug streaming nor a
QTest::toString specialization implemented. A build of most of Qt
submodules passes with this change, after minor modifications to some
tests. We cannot declare QSizeHint::Policy as a metatype after the
QMetaType has already been instantiated for it, and the QDebug stream
operator for QElaspedTimer needs to be correctly declared within the
namespace.

Add a self-test function for a custom type, and update reference files
of the self-test.

Task-number: QTBUG-104867
Pick-to: 6.4
Change-Id: I2936db5933f4589fce45f47cf2f3224ed614d8c9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-13 15:14:35 +02:00
Eskil Abrahamsen Blomfeldt
3fee97c4ab Skip test which depends on window activations on Wayland
Wayland does not support window activation, so rather than skipping
tests based on platform name, we can use the platform capability
(which will also cover future platforms with the same issue)

Pick-to: 6.4
Task-number: QTBUG-104241
Change-Id: Ibf5f8968f3979b789ef68f92768419bef4500fb3
Reviewed-by: Inho Lee <inho.lee@qt.io>
2022-07-13 14:35:03 +02:00
Shawn Rutledge
8d9301b413 Add QInputDevice::name() to output in device_information manual test
Pick-to: 6.4 6.3 6.2
Task-number: QTBUG-104878
Change-Id: I4299228c90777d71f01c3e2607f8ad4af6e081ed
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-13 14:35:02 +02:00
Shawn Rutledge
6749d69a15 QXcbConnection::xi2ReportTabletEvent(): get device, check capabilities
In Qt 5, RotationStylus was a device type; in Qt 6, we have the
Rotation capability flag instead. The event does not tell us whether
rotation is valid or not, so to distinguish a valid zero value from
a zero that means it's absent, we need to check device capabilities.
Anyway it's better to get the QPointingDevice instance earlier and
call the newer version of QWindowSystemInterface::handleTabletEvent().

Fixes: QTBUG-104877
Change-Id: I896c02727d586381489f79fd4ebea3451adfa403
Pick-to: 6.2 6.3 6.4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-13 14:35:02 +02:00
Shawn Rutledge
03a691cecb Change "delivering touch to same window" warnings to debug messages
When you touch-tap a QPushButton, and that opens a popup, it's normal
that the touch release is delivered to the main window rather than the
popup: in fact QWidgetWindow::handleMouseEvent() expects to see a
synth-mouse release. No warning is needed. Amends
efc02f9cc3

There may be other cases when it should have remained a warning (it's
been there since 2692237bb1), but that's
hypothetical at this point.

Pick-to: 6.2 6.3 6.4
Task-number: QTBUG-103706
Change-Id: Ie8cc62af4d173ada5138fd099d9f02bd41f4cff4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-13 14:35:02 +02:00
Ivan Solovev
593b0a01c5 Remove QStringView metatype declaration
It was required back in Qt 5 times, so that we could use
qvariant_cast<> or QVariant.value() on it. Not required in Qt 6
anymore.

As a drive-by: cleanup some unneeded includes in qstringview.cpp

Task-number: QTBUG-102350
Pick-to: 6.4
Change-Id: Idbcdc5cfe62cf4a55b86e227106d7a997997e0ba
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-07-13 12:52:00 +02:00
Joerg Bornemann
8b5cce6911 CMake: Fix prefix propagation for relocated Qt installations
Consider qtbase built with CMAKE_STAGING_PREFIX=/foo on Windows.
If /foo was moved to /bar, non-qtbase repositories did get a staging
prefix with drive letter assigned.  This is undesirable when DESTDIR is
used on installation.

Change the implementation of qt_internal_new_prefix to remove the drive
letter from the "new prefix" if the "old prefix" did not have a drive
letter.

Change-Id: I6fb17e690b264920b0dd4204e3b3c30794c7e76e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-07-13 12:52:00 +02:00
Kai Köhne
f71aeea932 Doc: Hide weak overload template magic from documentation
Hide the 'template magic' to implement Q_WEAK_OVERLOAD from the
documentation. So far Q_WEAK_OVERLOAD void foo() lead to

  template <typename> void foo()

in the generated documentation, which is arguably confusing to the
uninitiated. And people interested in implementation details & exact
overload resolution will arguably just read the .h files themselves.

Fixes: QTBUG-104851
Pick-to: 6.4 6.3 6.2 5.15
Change-Id: I5e0b1b337b28e621e6a627241aa8037da0a879a7
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-07-13 10:51:59 +00:00
Fabian Kosmale
268ff00ef5 QThread: Initialize bindingStatus for adopted threads
If we create a QThread from QThread::current(), we want it to have a
correct value for its bindingStatus. Thus, initialize bindingStatus in
the ctor of QAdoptedThread.

Task-number: QTBUG-101177
Task-number: QTBUG-102403
Pick-to: 6.4 6.3
Change-Id: I3ef27ed62c5dc25eed05d551c72743a1b8528318
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-13 12:51:59 +02:00
Morten Johan Sørvig
7e0711e0c0 wasm: secondary thread blocking sockets example
Connects to echo_server via websockify, like the async version.

Pick-to: 6.4
Change-Id: I9ed560cd388cfddbd0d284d8d40fb7ddf964ba96
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2022-07-13 09:29:28 +02:00
Volker Hilsheimer
43ef22045c Windows: Turn on dark mode support by default
The implementation was already there, and handles theme changes at
runtime as well. However, it was disabled unless the QPA parameter
"darkmode" was set to either 1 (supporting only the frame) or 2 (the
Windows theme also supports dark mode when reading the palette).

With both Windows 10 and Windows 11 now having dark mode as a fully
supported feature that is easily accessible to end-users, we should
respect that setting by default.

So change the default: support both dark window frames and palette, and
let users turn this partially off by setting darkmode=1 or darkmode=0.

This does not mean accent colors etc are fully supported by the Windows
styles.

[ChangeLog][QtGui][Windows] Dark mode, both for the window frames and
for the palette, is now supported by default. It can be turned
off (partially or entirely) by setting the QPA parameter "darkmode=0"
(no dark mode support) or "darkmode=1" (darkmode support only for the
window frames).

Pick-to: 6.4
Fixes: QTBUG-72028
Change-Id: Ia55af101896c106cde21340b306aa81390e608a2
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2022-07-12 23:57:20 +02:00
Christian Ehrlicher
78a574f028 Doc: Adjust widget printing example to not use removed functions
QPrinter::pageRect() and paperRect() were deprecated in Qt5 and removed
in Qt6 without adjusting the snippet.

Change-Id: I7787283ccfeeb94bccf464bfee2bcf82f5d3d930
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-12 23:14:42 +02:00
Laszlo Papp
1d947bf6a4 QKeySequence: Update the doc to KeyboardModifiers
Change-Id: I38411d0240f13488bc37bf4c17964ec9cb07d5d6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-07-12 22:14:41 +01:00
Allan Sandfeld Jensen
4a4a0b6d1f Use QT_CONFIG feature checks for sharedmemory and systemsemaphores
Change-Id: I86d0e4c5f279486f5fd6ef086dd913e813d0186d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-12 22:47:16 +02:00
Mate Barany
dbb3fdafac qdbusxml2cpp: Finish migration to qsizetype
Inspect and change int types to qsizetypes where necessary.

As a drive-by, port from in-the-process-of-being-deprecated count()
to size().

Fixes: QTBUG-103549
Change-Id: Id51d7065eb681d61be517689f89ae488f72edb88
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-07-12 20:03:54 +00:00
Ivan Solovev
4262e3b6ef QMimeData: fix the usage of a deprecated function
Task-number: QTBUG-104857
Pick-to: 6.4 6.3 6.2
Change-Id: I85b4aced4db2f1a77e6d0734e082f129b8a263bf
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-07-12 20:43:03 +02:00
Ivan Solovev
12535b0c03 QtBase: #ifdef out definitions of deprecated methods
Some of the deprecated methods didn't have their definitions guarded by
 if QT_DEPRECATED_SINCE(MAJ, MIN)

This patch fixes such cases over all QtBase.

Task-number: QTBUG-104857
Pick-to: 6.4 6.3 6.2
Change-Id: I0106128f3a35a30c9f2949819f39076e773559e7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-07-12 20:43:03 +02:00
Robert Loehning
c0a5f17679 Fix building with "-sanitize fuzzer-no-link"
This partially reverts commit c25a5b4e1f.

We need qtemporaryfile.cpp in the bootstrap library, because qfile.cpp
uses QTemporaryFileName - even if QTemporaryFile has been disabled.

Re-adding qtemporaryfile.cpp does not increase the bootstrap library's
size significantly, because since c25a5b4e1f we have
     #define QT_NO_TEMPORARYFILE
in qconfig-bootstrapped.h, and that disables compilation of
QTemporaryFile but leaves QTemporaryFileName intact.

Pick-to: 6.4
Fixes: QTBUG-103805
Change-Id: I6947ca303edb36fc359bd5d07c1cbd88098905fb
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-12 16:32:38 +00:00
Volker Hilsheimer
0dadb951b5 qobjectrace test: Don't hardcode the number of threads
Use QThread::idealThreadCount instead. This requires that we use
QVarLengthArray, as MSVC doesn't allow us to allocate arrays with a
non-constexpr size on the stack.

By using as many threads as the system has cores, we are more likely
to detect race conditions reliably. On systems with fewer cores (in
particular on qemu platforms like QNX, where this test has been
failing a lot), we'll less likely end up with false negatives due
to timeouts.

Pick-to: 6.4 6.3 6.2
Change-Id: Ie8631aef544ca7b53c06a0729d05459016745486
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-07-12 17:16:37 +02:00
Laszlo Agocs
7de0f3e9cc rhi: Clean up some inconsistencies
Some of the offsets are already quint32 in the API (vertex input
attributes, dynamic offsets, offsets in draw calls), matching the
reality of the underlying 3D APIs, but many buffer-related functions
use int as of now, simply because that used to be the default choice,
and the same goes for sizes (such as buffer or range sizes). This is
not quite consistent and should be cleaned up if for nothing else then
just to make the classes consistent, but also because no 3D API use a
signed type for offsets, sizes, and strides. (except OpenGL for some)

When it comes to strides (for vertex inputs and raw image texture
uploads), those are already all quint32s. This is straightforward
because most of the 3D APIs use 32-bit uints for these regardless of
the architecture.

Sizes and offsets are often architecture-dependent (Vulkan, Metal),
but there is at least one API where they are always 32-bit even on
64-bit Windows (UINT == unsigned int, D3D11). In addition, we do not
really care about buffer or texture data larger than 4 GB, at least
not without realistic use cases and real world testing, which are
quite unlikely to materialize for now (esp. since we still have the
width/height of 2D textures limited to 16 or 32K in many cases even on
desktops, whereas 2GB+ buffers are not guaranteed in practice even
when an API seemingly allows it).

In any case, the important change here is the signed->unsigned
switch. A number of casts can now be removed here and there in the
backends, because the offsets and sizes are now unsigned as well,
matching the underlying API reality. The size can be potentially
increased later on with minimal effort, if that becomes necessary for
some reason.

Change-Id: I404dbc365ac397eaeeb3bd2da9ce7eb98916da5f
Reviewed-by: Inho Lee <inho.lee@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-07-12 17:16:37 +02:00
Volker Hilsheimer
7b6350fa77 QJniObject: Add template overloads for get/setStaticField
Allow specifying the Java class on which to set/get the field via its
corresponding C++ type, removing the need to explicitly provide the
Java type string.

Those were missing from a085a14d76, which
was noticed when porting QtConnectivity over to the new template APIs.

Pick-to: 6.4
Change-Id: I8f324c9fcc486b4c6c2f2b9051f7eca0cbec0e91
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2022-07-12 13:25:04 +02:00
Øystein Heskestad
1c563035c7 Disable unit testing setting up QTcpServer on special Apple interfaces
The iBridge interface is used for the keyboard touch bar, and the Apple
Wireless Direct Link interfaces are used by Apple for various purposes.
Setting up a server on these interfaces does not work.
Only the tst_QTcpServer::linkLocal unit test on macOS is affected by
this change.

Fixes: QTBUG-103892
Change-Id: I29701ce51d5e40dff6c59547a8639c1fba330d36
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-07-12 13:24:57 +02:00
Mikolaj Boc
fd45278eaa Specialize MetaObjectForType for non-pointer QObject-derived types
QMetaTypeInterfaceWrapper tries to find the metaObjectFunction using
the MetaObjectForType template. Using SFINAE, for a QObject, it should
resolve to a suitable specialization.

Such a specialization doesn't yet exist. It had to be created.

The following path returns nullptr for registered meta types:

  auto metatype = QMetaType(typeId);
  requestedTestType.metaObject() -> returns nullptr since a bad template
  argument is fed to MetaObjectForType<T> in
  QMetaTypeInterfaceWrapper<IneritingFromQObject>::metaType's static initializer.

Change-Id: I8b31c51e12cb19c333e00480b0177354b910ce1e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-07-12 13:24:57 +02:00
Sona Kurazyan
5e8cc498a1 QDomDocument: add a missing full-stop to a warning message
Change-Id: I3c44afa466cbcb12fc0b44ad8bd1b52ded5f4ddd
Pick-to: 6.4 6.3 6.2
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-07-12 13:24:57 +02:00
Sona Kurazyan
13ca1727f4 QDomDocument: fix the formatting of setContent() declarations
Change-Id: I4f6c29b2c6b8887aaf380b0c7963be2cd0b877e9
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-07-12 13:24:57 +02:00
Sona Kurazyan
6bc227a06a Port QXmlStremReader to QAnyStringView
Port the constructor and addData() method to QAnyStringView, but keep
the overloads taking a QByteArray to avoid extra copies when actual
QByteArray is passed. These overlaods need to be Q_WEAK_OVERLOADs, to
avoid ambiguities (e.g. for const char * arguments).

Additionally, add a test to make sure the patch doesn't break parsing
from a QLatin1StringView input.

[ChangeLog][QtCore][QXmlStremReader] Added constructor and addData()
overloads taking QAnyStringView.

Change-Id: I0efaab82a2123271c88407e380f3c67d1099a4a6
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-07-12 13:24:56 +02:00
Eirik Aavitsland
c78ec50529 Improve widget painting under dpr>1 by enabling smooth pixmap scaling
Smooth scaling of icons etc. give far better visual results,
particularly with fractional dpr scaling. So enable this generally in
QStylePainter, and make more of the relevant widgets use QStylePainter
instead of QPainter directly.

Differences can be seen in the widgets examples, e.g. textedit,
gallery, stylesheet (Pagefold), mdi.

Pick-to: 6.4 6.3 6.2
Task-number: QTBUG-96223
Fixes: QTBUG-101058
Change-Id: I3c34a455d097e5f6a6a09d3b020528b4fbda4d85
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-12 13:24:56 +02:00
Eirik Aavitsland
9e453dacc3 Fix printing of dpr>1 images on Windows
The win32 printing paint engine copies tiles of the source image into
temporary target images for printing. It does that using QPainter
painting. If there is a difference in DPR between source and target,
the painting will be scaled, leading to distorted results.

Fixes: QTBUG-99990
Pick-to: 6.4 6.3 6.2 5.15
Change-Id: Ie7368655ef3abeece49fb1a6421e2d6ea7ed5e95
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
2022-07-12 09:02:38 +02:00
Alexandru Croitor
f344f3d58e CMake: Don't propagate openssl headers for the tls plugin
There's no reason to. It's not a Qt module, it's just a plugin and
does not expose any public headers.

Amends d754e43721

Pick-to: 6.4
Task-number: QTBUG-96283
Change-Id: Idf56c82025b81fd6614ef7e1efeb015e89c84f93
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-11 22:23:09 +02:00
Alexandru Croitor
3d1464fc15 CMake: Process extra dependencies for plugin targets as well
We started recording extra dependencies for the QtNetwork TLS plugin,
but we never actually processed them to write out the necessary
find_package calls.
This broke static builds of qtopcua, because the OpenSSL::SSL target was
no longer created in the root scope, but only in some child ones like
src/opcua, whereas the target was referenced in generator expressions
in a different sibling scope src/declarative_opcua, leading to errors like

 CMake Error at lib/cmake/Qt6/QtPrlHelpers.cmake:116
  (file): Error evaluating generator expression:
    $<TARGET_LINKER_FILE:OpenSSL::SSL>
  No target "OpenSSL::SSL"
 Call Stack (most recent call first):
  lib/cmake/Qt6/QtModuleHelpers.cmake:837 (qt_generate_prl_file)
  lib/cmake/Qt6/QtScopeFinalizerHelpers.cmake:21:EVAL:1
     (qt_finalize_module)
  src/declarative_opcua/CMakeLists.txt:DEFERRED

Make sure to process the extra deps for plugins as well.

Amends d754e43721
Amends 3c23317552

Pick-to: 6.4
Task-number: QTBUG-96283
Change-Id: I11876e0844198b3a794bc06b6691ee694fd3b1c2
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2022-07-11 22:23:09 +02:00
Alexandru Croitor
0d1c16861a CMake: Clarify qt_record_extra_third_party_dependency docs
Pick-to: 6.4
Change-Id: I458a5b488741c639650c8b3b6668c82c80b5e93f
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-07-11 22:23:09 +02:00
Edward Welbourne
281cada9c1 Replace 0 with \nullptr in QTest::currentDataTag()'s doc
The function's return type is a pointer, not an integer.

Change-Id: Iab6686ac7e4e24b9b1bd0127346c5854cf593a57
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-07-11 21:41:51 +02:00
Joerg Bornemann
8cc58fbbc7 CMake: Propagate qtbase's original staging prefix to other Qt repos
If qtbase was configured with CMAKE_STAGING_PREFIX set to a path without
drive letter on Windows, we must ensure that this exact staging prefix
is propagated to non-qtbase repos.

We already had code that does this for CMAKE_INSTALL_PREFIX.  But since
9a74d94ff5 we build our cross-built
packages with CMAKE_STAGING_PREFIX instead of CMAKE_INSTALL_PREFIX.

Move said code into a function and use it for CMAKE_STAGING_PREFIX too.

This fixes Android non-qtbase release libraries not being stripped in
our Windows Android packages.

This amends commit 037fd545c4.

Fixes: QTBUG-104827
Pick-to: 6.2 6.3 6.4
Change-Id: I909f7f39bd0ef7b559619b69f756c042d6c528b0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-07-11 19:43:41 +02:00
David Skoland
281d915ba4 Add wasm exception for tst_qchar
Since wasm doesn't like filesystems that well, we omit this test in
tst_qchar for wasm, this allows us to still run the test without the
case where it needs to read the normalization file.

Change-Id: I37e54d97e119f94e1a9ca53917d0b93183321899
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-07-11 17:21:27 +02:00
Marc Mutz
d625876219 QLoggingCategory: fix Clang -Wgnu-zero-variadic-macro-arguments (headerclean)
Says Clang 10.0.0 in C++20 mode:

  qtwayland/src/compositor/compositor_api/qwaylandcompositor.h:37:1: error: must specify at least one argument for '...' parameter of variadic macro [-Werror,-Wgnu-zero-variadic-macro-arguments]
  Q_WAYLANDCOMPOSITOR_EXPORT Q_DECLARE_LOGGING_CATEGORY(qLcWaylandCompositor)
                             ^
  qtbase/src/corelib/io/qloggingcategory.h:111:45: note: expanded from macro 'Q_DECLARE_LOGGING_CATEGORY'
      Q_DECLARE_EXPORTED_LOGGING_CATEGORY(name)
                                              ^
  qtbase/src/corelib/io/qloggingcategory.h:107:9: note: macro 'Q_DECLARE_EXPORTED_LOGGING_CATEGORY' defined here
  #define Q_DECLARE_EXPORTED_LOGGING_CATEGORY(name, ...) \
          ^

Amends 7466422e9c.

Change-Id: Ica583cfb32e2b52a4f41f707d4b34a70063f0230
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-07-11 15:21:27 +00:00
Edward Welbourne
4d88c80fbd Improve formatting of QTest message on missing function
If there were no matches to the name given on the command line, the
message reported included a "Possible matches:" preamble for a list of
functions containing the requested function name. This looked
incongruous when no actual functions matched.

Turn that preamble into an optional parameter to qPrintTestSlots(),
that it'll output before the first match if it finds one, rework
qPrintTestSlots() to package its matching condition in a lambda and
return true if it found any matches.  Change this caller to output a
newline in place of the preamble (which ended in a newline), if no
match was found.

Change-Id: I9716ffa29c3c46e3c7e7fcf25a676c0356dab91c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-07-11 14:42:27 +02:00
Shawn Rutledge
092ef06e00 Fix directory listing in manual filetest; add recursive find
- QFileInfo::fileName() is not the name of a directory, so we need
  absoluteFilePath() to construct a QDir
- QDir::entryList() returns only the name suffix, not the whole path
- stop at any arbitrary depth, and add a find command which does full
  recursion

Amends 04a5a74685

Change-Id: I9870db092125a797e8b654e98954ac611dde1ab2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-11 14:42:27 +02:00
Fabian Kosmale
e19bd973e3 QMetaType: Do not warn about unknown types in isRegistered
isRegistered naturally has the potential to run into unregistered
types; in that case, we should not print any warning.

Pick-to: 6.4 6.3 6.2
Change-Id: I060b23199ed1d41f67ebe656ed3c396094edffd4
Reviewed-by: Stefan Gehn <stefan.gehn@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-07-11 08:21:35 +00:00
Morten Sørvig
4851eae5ba wasm: remove egl header includes
Not in use any more.

Change-Id: I4d4e7b5094544c042b5c500417427233d0b316f1
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2022-07-11 03:05:05 +02:00
Giuseppe D'Angelo
6f852935e0 QString: fix lifetime issues with QRegularExpression APIs
QString has several functions taking a QRegularExpression: indexOf(),
contains(), and so on. Some of those have an out-argument of type
QRegularExpressionMatch, to report the details of the match (if any).
For instance:

  QRegularExpression re(...);
  QRegularExpressionMatch match;

  if (string.contains(re, &match))
    use(match);

The code used to route the implementation of these functions through
QStringView (which has the very same functions). This however opens
up a lifetime problem with temporary strings:

  if (getString().contains(re, &match))
    use(match); // match is dangling

Here `match` is dangling because it is referencing data into the
destroyed temporary -- nothing is keeping the string alive. This is
against the rules we've decided for Qt, and it's also asymmetric with
the corresponding code that uses QRegularExpression directly instead:

  match = re.match(getString());
  if (match.hasMatch())
    use(match); // not dangling

... although we've documented not to do this. (In light of the decision
we've made w.r.t. temporaries, the documentation is wrong anyways.)
Here QRE takes a copy of the string and stores it in the match object,
thus keeping it alive.

Hence, extend the implementation of the QString functions to keep a
(shallow) copy of the string. To keep the code shared as much as
possible with QStringView, in theory one could have a function taking a
std::variant<QString, QStringView> and that uses the currently active
member. However I've found that std::variant here creates some abysmal
codegen, so instead I went for a simpler approach -- pass a QStringView
and an optional pointer to a QString. Use the latter if it's loaded.

QStringView has some inline code that calls into exported functions, so
I can't change the signature of them without breaking BC; I'm instead
adding new unexported functions and a Qt 7 note to unify them.

Change-Id: I7c65885a84069d0fbb902dcc96ddff543ca84562
Fixes: QTBUG-103940
Pick-to: 6.2 6.3 6.4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-07-10 23:40:24 +02:00
Volker Hilsheimer
54b276be0b testlib: Don't print QCOMPARE values if they lack string representation
Before 0681a2dd5a, QCOMPARE'ing types
for which no QTest::toString specialization exists did not output
Actual and Expected lines on failure, as that would only print <null>
for both values (which then look like the same value, confusingly).

Commit 0681a2dd5a changed that behavior,
and started printing the confusing <null> values.

Take care of the logic in the formatFailMessage function: if both values
are nullptr, then print only the variable names, but not the confusing
<null> text representation of the values.

Remove dead and duplicated code related to the formatting logic, add a
self-test function, and update the expected_cmptest files.

Fixes: QTBUG-104867
Pick-to: 6.4
Change-Id: I4be98e79f91196b14690a2cc0a68ffd50b431a45
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-07-10 03:08:32 +00:00
Laszlo Papp
07ada0b971 QTest: Support QKeySequence compare
Add a QTest::toString() override for QKeySequence. This is just calling
QKeySequence::toString(). The default format is PortableText, which
should be ascii. Deliberately avoided NativeText as it can return
unicode, e.g. on Mac.

This is necessary to get helpful information for test failures when
using QCOMPARE for QKeySequence instances.

Currently, the returned output would not only be not helpful, but even
misleading:

   Actual   (edit.keySequence()): <null>
   Expected (QKeySequence())    : <null>

After adding the override, the output is neither misleading nor
unhelpful:

   Actual   (edit.keySequence()): ""
   Expected (keySequence)       : "Return"

Some special characters would be escaped in the output, like the literal
double quote:

   Actual   (edit.keySequence()): "Ctrl+N"
   Expected (QKeySequence("\"")): "\""

Change-Id: Ib4b28fca30f6f2ad86c62530767f94a151332e0a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-09 21:08:10 +01:00
Yuhang Zhao
14ce67629b QSysInfo: update docs to mention the latest os
Update to the latest stable version.
Beta/preview versions not included.

Removed Amazon Linux AMI because it's no longer maintained.
Removed tvOS because it now shares the same version with iOS and iPadOS.

Pick-to: 6.4 6.3 6.2 5.15
Change-Id: I40e5286b132b8198bf315a2868f89428e8c2f23a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-07-09 23:07:18 +08:00
Laszlo Papp
1ea0d399b3 QKeySequenceEdit: Add a finishing key combinations property
Different shortcut editors seem to have different preferences. By
default, QWidget seems to utilise Tab, Backtab, Return and Enter for
navigation purposes. However, some shortcut editors would like to be
able to record these keys as part of combinations to use in the
application.

Therefore, leave it with the application developers to decide what key
combinations they would like to use for finishing the key sequence edit.
This should provide enough flexibility for application developers to
customize their shortcut editor behavior.

[ChangeLog][QtWidgets][QKeySequenceEdit] Added a property to allow
defining the finishing key combinations.

Fixes: QTBUG-103844
Fixes: QTBUG-103843
Change-Id: Id84644086ca7a4f11618d510e59698a43735b99b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-07-09 11:23:49 +00:00
Marc Mutz
2cfabed1ff Long live QDebug op<< QMetaType!
It's needed in QtHttpServer.

[ChangeLog][QtCore][QDebug] Can now stream QMetaType.

[ChangeLog][QtCore][QMetaType] Can now be streamed through QDebug.

Change-Id: I974d77d678137715472a3907ab1e50ba2dbaa087
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-07-09 06:40:08 +02:00
Marc Mutz
f2c9f8c837 Port QFontSubset API from int to qsizetype
Removing the impedance mismatch with the Qt containers.

Pick-to: 6.4
Task-number: QTBUG-104814
Change-Id: I141d9056249644b90c404219792e0fcd87960f7c
Reviewed-by: Lars Knoll <lars.knoll@gmail.com>
2022-07-08 22:14:53 +02:00
Marc Mutz
9d29c590f3 Port QTextureGlyphCache to qsizetype
Reduces impedance mismatch with other Qt containers.

Pick-to: 6.4
Task-number: QTBUG-104820
Change-Id: Ie8830a404240f34acc790296b608e1318c46535d
Reviewed-by: Lars Knoll <lars.knoll@gmail.com>
2022-07-08 22:14:52 +02:00
Marc Mutz
3f32e4a73a Port QDataBuffer to qsizetype
Reduces the impedance mismatch with "normal" Qt containers.

Remove useless inline keywords as a drive-by. Functions defined in the
class body are implicitly inline since C++98. C++ declarations are
long-winded enough as they are, no need to add more cruft.

Also make the ctor explicit, we surely didn't intend to allow implicit
conversion from qsizetype to QDataBuffer

Pick-to: 6.4
Task-number: QTBUG-104825
Change-Id: I563dcd825afd63937b87e87fbbd324daaeb49d08
Reviewed-by: Lars Knoll <lars.knoll@gmail.com>
2022-07-08 20:14:52 +00:00
Marc Mutz
04ab0905e3 Gui: mark types Q_PRIMITIVE_TYPE when they're held in QDataBuffer
QDataBuffer assumes that its template argument is a POD, iow: it's ok
to not run ctors and dtors and assign a value into uninitialized
memory.

In Qt, we call that Q_PRIMITIVE_TYPE. Asserting that the QDataBuffer
value_type is not QTypeInfo::isComplex, however, has shown that a
large number of types had not been marked as such, sometimes for good
reason, e.g. because their default constructor doesn't
value-initialize all members, but sets some of them to -1.

Since QDataBuffer doesn't memset the memory to zero, it doesn't
matter, as the code obviously has to have worked before, with
uninitialized memory, and all-zeros is just a special, if common, form
of uninitialized memory.

I also tried to assert is_pod in QDataBuffer (working around the fact
that that particular trait is deprecated), but found that almost none
of the types in question were, in fact, trivial. We should fix this,
because it means the compiler is generating code that's less efficient
than it could be, but that's for another patch.

All types marked as Q_PRIMITIVE_TYPE in this patch are private API, so
this doesn't affect users.

For PathSimplifier::Event, had to shorten the unnamed namespace to not
include the member functions, because Q_DECLARE_TYPEINFO cannot appear
in a namespace other than the Qt one.

Pick-to: 6.4 6.3
Change-Id: I4431a2f269ec1ac4804a87ea71f983eaa34ef867
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@gmail.com>
2022-07-08 20:14:52 +00:00
Marc Mutz
6b6b88774b QLine/F: mark as primitive type
QPoint/F are, then so are QLine/F, being a pair of points.

Found by static_assert()ing !isComplex in QDataBuffer.

Pick-to: 6.4
Change-Id: I358a38d79820c9262a86018253002bc991c5a6e4
Reviewed-by: Lars Knoll <lars.knoll@gmail.com>
2022-07-08 22:14:52 +02:00