Commit Graph

55189 Commits

Author SHA1 Message Date
Edward Welbourne
7e59139f5c tst_QSqlQuery coding style: clean up loops
Prefer pre-decrement over post-decrement, turn a while into a for,
Don't put a while's body on the same line.

Change-Id: I5653a9bcec7901d205a91927c4b08e3dc13e0ca6
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:30 +01:00
Edward Welbourne
e94b579679 tst_QSqlQuery coding style: clean up comments
Reflowed some over-long ones, fixed some typos, capitalise starts of
sentences (and end them with suitable punctuation). Removed one as
redundant, made another pair redundant by changing the code (use an
overt NaN instead of commenting that it's happening). Prefer C++-style
when single-line. Don't pretend to be QDoc comments, or have other
eccentricities about start-markers.

Change-Id: I5a30e1b22a08866124f09060bb35f5bd27cd443b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:30 +01:00
Edward Welbourne
5b7b8e123b tst_QSqlQuery coding style: use vertical spacing to group lines
Much of the test code simply had a blank line after each check. Keep
the ones that separate groups of related statements, but remove the
ones that separated members of such groups. In some cases swap a blank
line and a code line to put the code with things it relates to.

Change-Id: Ie33863080d407898b2b2f044599398980ab9793d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:30 +01:00
Edward Welbourne
f8d31aa7de tst_QSqlQuery coding style: clean up declarations
Split some long declarations of two variables in one line into two
separate declarations. Made more things const, made some consts
constexpr. Skip a variable entirely when it's only used once (and not
giving us some other benefit). Moved some declarations closer to their
variables' first uses.

Replace some Capitalised variable names with lower-case ones.

Change-Id: I3b8dac46530ba1c2e6100cb007b5487253304526
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:30 +01:00
Edward Welbourne
915469e4de Prefer QLatin1String::arg() over adding more than two strings
It saves the conversion to UTF-16 until the formatting. Split up long
lines, purge spaces just inside parentheses, and otherwise tidy
affected lines. Don't use backslash-newline for line continuation
within string literals; juxtaposition is cleaner.

Change-Id: I9c3d3e33f5ecbdb530538679147f7bc32afbeb05
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:30 +01:00
Edward Welbourne
afe23239cb Prefer u"..." and u"..."_qs over QStringLiteral() or QString("...")
It's terser and cleaner to read. Likewise for
QString::fromLatin1(). QCOMPARE() can take a QStringView, hence u"..."
as its expected string; other uses need u"..."_qs.

Change-Id: Iaf96569ff3ce69c890badfb6e40f702a78b100b3
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:30 +01:00
Edward Welbourne
203f4b93cf Prefer QString::asprintf() over QString::arg when formatting numbers
Marc alleges it is more efficient.
Corrected part of a message to be more accurate in the process.
Save some casting by using suitable format specifiers.

Change-Id: Ic31a4e17b8910d35781a494ec860c7a08f08f33b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:30 +01:00
Edward Welbourne
e63b3b48ac Prefer QLatin1String::arg() over QString::arg() for ASCII literals
When the format is an ASCII string, there's no point widening it to
UTF-16 before the actual formatting step. Also, don't construct the
format string using string arithmetic, when passing another parameter
to arg() will do just as well. In the process, restructured
generic_data(), split long lines and conform spacing to Qt coding
style on affected lines. Simplified initialization of two string
fragments by using QL1S instead of QString, too.

Change-Id: Ib101dcf9296cc532291518bcef8e0a8de597b8a0
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-17 15:51:29 +01:00
Andreas Buhr
4e77f5ce0a Set version for tst_qguiapplication and tst_qcoreapplication
In tst_qguiapplication and tst_qcoreapplication,
the application version should be set. On Android, this
is done using QT_ANDROID_VERSION_CODE.

Pick-to: 6.2 6.3
Change-Id: I6b473ad25092fb24df9400e0ab8fbb8ea4edbb6a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-02-17 15:51:29 +01:00
Pasi Petäjäjärvi
963d60ead4 CI: Blacklist updateFocusChainWhenChildDie for QNX
Tests are run for QNX in qemu similar to b2qt currently (using offscreen
plugin and software rendering). So the issue is same.

Pick-to: 6.2 6.3
Task-number: QTBUG-100930
Change-Id: Ie973c6c611ac48703fd7cce53925940b80858bc8
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-17 16:08:37 +02:00
Patrick Griffis
8c77825bb7 Respect AT_SPI_BUS_ADDRESS env var on Linux
Change-Id: Ic277b5ebe2d752360cebdb2ff728ca219f9d7124
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
2022-02-17 07:56:41 -06:00
Kai Köhne
669f0e92aa CMake deployment: Make it more explicit what platforms are supported
That only Windows and macOS are supported is mentioned, but deep down in
the description. Let's make it more prominent.

Pick-to: 6.3
Change-Id: Ia34a10f2fcbe0b2f86b5a0c5585277e169b11fa6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-17 13:55:58 +00:00
Kai Köhne
fc9d1a3c89 Doc: Remove cmake-variables qdoc group
The group is not used anymore. It also prevents qdoc to properly put
the variables in the breadcrumb menu (under "CMake Variables in Qt6 Core")

Pick-to: 6.3
Change-Id: I1afe3b1cb7be8dcdda9a6c6e1235e4457800179d
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-02-17 06:54:43 +00:00
Noah Davis
43caaca740 QGnomeTheme: Allow Space, Return, Enter and Select to press buttons
GTK buttons can be pressed with Space, Return and Enter, so this should
be considered native behavior for GTK based desktop environments.
Qt::Key_Select is also included here because QAbstractButton has been
pressable with Qt::Key_Select for a long time.

Change-Id: I2c279ad05d1a10e5968a18996b8b40a83d2251fa
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-16 18:46:06 -05:00
Liang Qi
760815599b tests: skip tst_QX11Info on Wayland
Pick-to: 6.3 6.2
Change-Id: I927ee28f61719ff1b67f73dc31dfcae9b73d8329
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-17 00:34:50 +01:00
Liang Qi
ae1197fc56 tests: XFAIL tst_QGuiApplication::genericPluginsAndWindowSystemEvents()
on Wayland

Task-number: QTBUG-100891
Pick-to: 6.3 6.2
Change-Id: Iadf12364ded4549988ad75a9487c7e96e963a956
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-17 00:34:50 +01:00
Liang Qi
c1b6886959 tests: XFAIL 4 tests in tst_QWindow on Wayland
Task-number: QTBUG-66818
Task-number: QTBUG-100887
Task-number: QTBUG-100888
Task-number: QTBUG-100889
Pick-to: 6.3 6.2
Change-Id: I05ba11e54c115380bbbb629fcba5cdd658dd5654
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-17 00:34:50 +01:00
Liang Qi
d55c049c7c tests: XFAIL tst_QScreen::grabWindow() on Wayland
Task-number: QTBUG-100792
Pick-to: 6.3 6.2
Change-Id: I1dc257abdc34c586c4c1eda96a43ea75395b1e4a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-17 00:34:50 +01:00
Liang Qi
ae9fefe3c8 tests: XFAIL tst_QInputDevice::multiSeatDevices() on Wayland
Task-number: QTBUG-100790
Pick-to: 6.3 6.2
Change-Id: Ieec4791e4322286fedeeabacc43b9cb84ea27962
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-17 00:34:50 +01:00
Allan Sandfeld Jensen
1cc0494f7d Correct haswell function target for clang
Clang uses arch names directly, and not the "arch=xxx" format of GCC.

Appears we do not use this target though.

Pick-to: 6.3 6.2
Change-Id: I1d295f25fe2278c5c6bc0f617496555e28427bea
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-16 22:47:13 +01:00
Alexey Edelev
fedd4f26ad Add missing dependency to the qvkgen tool when generating vulkan code
Pick-to: 6.3 6.2
Fixes: QTBUG-100574
Change-Id: Ib68a3d77e5d3c9a9fc541a69a2748b94ade3ceef
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-16 22:47:13 +01:00
Andreas Buhr
eb628794c7 Repair tst_qtreeview on Android
Scroll tests relied on having a small window. On Android, the
window can not be smaller than the screen.
This patch changes the tests so that the windows have large
enough content so scrolling can happen.

Fixes: QTBUG-87408
Pick-to: 6.2 6.3
Change-Id: I26a444518fd934527089297c594673937f0ecf88
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-02-16 22:32:56 +01:00
Morten Johan Sørvig
2ed3cc8e7a wasm: move canvas configuration to Qt implementation
The required canvas configuration is an implementation
detail; move it out of the .html file (which we expect
that users will replace), and into the QWasmScreen
constructor.

This also enables using a div element as the container
element (instead of a canvas), since Qt then can create
and configure the canvas during QWasmScreen construction.

Change-Id: Ia849517d00fa3e8ec307065a524c0c91296dd490
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2022-02-16 21:20:36 +01:00
Noah Davis
97eeded5fc QPA: add ButtonPressKeys ThemeHint
Platforms should allow more than just Qt::Key_Space and Qt::Key_Select
to press buttons. KDE Plasma developers want to be able to press buttons
with Return/Enter. GTK allows buttons to be pressed with Return/Enter,
so this should be considered the native behavior for GNOME as well.
Adding this ThemeHint allows customizing the keys that can press a
button via a QPlatformTheme subclass.

Change-Id: I73284e9b73590fbdd0b94a0cb4557e94b3722af9
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2022-02-16 15:10:00 -05:00
Andreas Buhr
9beca76786 Repair tst_qabstractitemview in case of no cursor
tst_qabstractitemview requires a movable cursor.
This patch skips the test if there is no movable cursor.

Pick-to: 6.2 6.3
Fixes: QTBUG-87400
Change-Id: I4e917b2ad062ce068f23603410aa9209edb9828d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-02-16 21:09:59 +01:00
Andreas Buhr
e87233fbd8 Repair tst_qfileinfo on Android
Pick-to: 6.2 6.3
Change-Id: I79e0236b90b8a6ca2618d7a9ddac34b26bbd5b5f
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2022-02-16 21:09:59 +01:00
Pasi Petäjäjärvi
8aba951d98 Gui: test also depends for clipboard feature
Pick-to: 6.2 6.3 5.15
Change-Id: Id8684b6800bd5659991bc56f8b374ec3989ee590
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-16 21:02:44 +02:00
Axel Spoerl
43b25286ce Update QToolButton texts and add more stylesheets to test with
Adapt QToolButton texts to descriptive versions.
Add dummy stylesheet that will be used for all test functions, and a
specific style sheet to test rendering of QToolButton with a menu button.

Task-number: QTBUG-100401
Pick-to: 6.3 6.2
Change-Id: I5440407ddb3ea5b45124e77a6f0d1013362b4398
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-16 16:41:43 +00:00
Kai Köhne
3cd8099cfc Doc: Fix cmake example snippets
The argument to file(GENERATE...) is called CONTENT, not CONTENTS.

Pick-to: 6.3
Change-Id: I22fb9eb966223e034b2606cf24315d3cf6a03df1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-02-16 17:41:43 +01:00
Marc Mutz
f310f426d0 qvkgen: optimize generated string tables
Use qOffsetStringArray instead of array-of-const-char* to hold
strings. Saves 174 relocations, as well as over 4KiB in combined TEXT
and DATA size on optimized Linux GCC 11.2 C++20 AMD64 builds.

Pick-to: 6.3
Task-number: QTBUG-100536
Change-Id: I5849168d0340f78664e566920f92ad136f9dc435
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-02-16 16:49:16 +01:00
Jani Heikkinen
58173027b3 Update LICENSE.QT-LICENSE-AGREEMENT
Newest version is 4.4 so update it in the git as well

Task-number: QTBUG-98971
Pick-to: 6.3 6.2 5.15
Change-Id: I4b5bd2852c6c2775bd285c6584eb712fd0b73db3
Reviewed-by: Akseli Salovaara <akseli.salovaara@qt.io>
2022-02-16 17:19:34 +02:00
Kai Köhne
7c801ec93a configure.bat: Fix call without arguments
If there are no arguments, echo will print its status, and config.opt.in
will contain

  ECHO
  is
  off.

Fix this by using "echo." idiom.

This amends 57ad532e75

Pick-to: 6.2 6.3
Change-Id: I1697e59f23cd28256a4a6ce357eae70e36c49d5a
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-02-16 12:05:48 +01:00
Thiago Macieira
1f7089437a CBOR: disable UUID and QRegularExpression support in bootstrapped builds
We don't need them.

Drive-by opportunity to ensure byteData() didn't return null. It could
happen.

Change-Id: I74249c52dc02478ba93cfffd16d1e1fc060cdaef
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-16 01:59:51 -08:00
Thiago Macieira
a1b2c474fd QPluginParsedMetaData: avoid the indirection through QCborMap
value[x] is the same as value.toMap()[x] but avoids the refcounting up
and down just to call the operator[] overload. We're calling the
operator[] overload taking an integer, which means it could match an
array, but we know the data member won't be one because of how
QPluginParsedMetaData::parse() parses.

Change-Id: I2cffe62afda945079b63fffd16bd5c690b2bfee4
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-16 01:59:51 -08:00
Axel Spoerl
ea0e0a8652 Eliminate double arrow in QToolButton
- InstantPopup mode is set and
- application uses a stylesheet that does not apply to QToolButton

Task-number: QTBUG-100401
Pick-to: 6.3 6.2
Change-Id: Iadf752ad9280d59763f4efc1938927a9b83e6ad9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2022-02-16 10:57:20 +01:00
Thiago Macieira
8de0493896 QMetaObjectBuilder: fix addProperty() recording of the property type
Issue introduced by commit 465701bb98.

[ChangeLog][QtCore][QMetaObjectBuilder] Fixed a bug that would cause
addProperty() to use the incorrect type for the property if the
property's name matched a valid type registered with QMetaType.

Pick-to: 6.2 6.3
Change-Id: Ic15405335d804bdea761fffd16d402f2c9611f30
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-16 01:47:09 -08:00
Thiago Macieira
d34282dba0 QFile::copy: add the underlying error messages to ours
Fixes: QTBUG-100867
Pick-to: 6.3
Change-Id: Ic15405335d804bdea761fffd16d401a7c16f32f9
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-16 01:47:09 -08:00
Thiago Macieira
8f1a827d91 QIODevice::read: don't truncate to int(readBytes)
QByteArray in Qt 6 *can* hold more than 2GB-overhead of data.

Untestable.

Fixes: QTBUG-100546
Pick-to: 6.2 6.3
Change-Id: I74249c52dc02478ba93cfffd16d1a0ab398efe9c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-16 09:47:09 +00:00
Zhang Hao
d978c230a4 Do not highlight the HTTP Example anymore in Qt Creator
Pick-to: 6.3
Fixes: QTBUG-100647
Change-Id: I413b37daf784f3a4975caa5a48273f4a83aa1da6
Reviewed-by: Kimmo Leppälä <kimmo.leppala@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2022-02-16 14:40:34 +08:00
Alexandru Croitor
e5b3436255 CMake: Add default launch screen storyboard for iOS apps
Bundle a default LaunchScreen.storyboard file for an iOS app and make
sure it's referenced in the generated Info.plist file.

When launching Qt examples, it ensures the app uses the whole screen
space on the device rather than just a square-ish part of it.

The storyboard file is a copy of the qmake one, which qmake adds
to the Xcode projects it generates.

A custom launch screen can be provided either by setting the
QT_IOS_LAUNCH_SCREEN variable or by setting the
QT_IOS_LAUNCH_SCREEN target property.
The value must be an absolute path to the launch screen file.

The automatic addition of the launch screen entry in the Info.plist
file can be prevented by setting the QT_NO_SET_IOS_LAUNCH_SCREEN
variable to TRUE.

The automatic bundling of the launch screen file in the application
bundle can be prevented by setting the
QT_NO_ADD_IOS_LAUNCH_SCREEN_TO_BUNDLE variable to TRUE.

The current implementation has a limitation that only one launch
screen storyboard and one iOS executable can exist within a project.

If there are multiple executables in the project, all of them will
use the launch screen that is specified last (the last
qt_add_executable call).

Because of this limitation, the API is marked as Technical Preview,
to be improved upon in the future. For now it simply serves as an
improvement to the out-of-the-box experience of iOS apps built
with CMake.

Amends 4d838dae5a

Pick-to: 6.2 6.3
Fixes: QTBUG-95837
Change-Id: I6b067d703d635122959a1ef17fcca713da694a86
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2022-02-16 05:14:24 +01:00
Mårten Nordheim
a1fb3971f2 QHash: fix off-by-one in assertions
Coverity-Id: 378365
Coverity-Id: 378366
Coverity-Id: 378399
Coverity-Id: 378427
Coverity-Id: 378468
Coverity-Id: 378472
Pick-to: 6.3 6.2
Change-Id: Ib1efeacb59030b9d004320e56f560367f564d207
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-16 04:24:21 +01:00
Marc Mutz
a24ef92468 QColor: eradicate QT_STRINGVIEW_LEVEL
It's not used and not useful.

Task-number: QTBUG-100861
Pick-to: 6.3 6.2
Change-Id: I30f7f41311182f056f2f6d5a9b49385fb09d194e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2022-02-16 04:20:51 +01:00
Sona Kurazyan
221df41572 Move QBindingStorage methods marked for removal to removed_api
From the API review.

Pick-to: 6.3
Change-Id: I676ff811a3b3d43ebcbee78ed0210d669d642947
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2022-02-16 02:28:53 +01:00
Thiago Macieira
d1f077a435 QJsonValueRef: don't export the entire class in Qt 7
Change-Id: I54f205f6b7314351b078fffd16d061ca8870b453
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 17:00:05 -08:00
Thiago Macieira
705ea62f9e QJsonValueConstRef: prepare for Qt 7
Instead of storing a pointer to the QJsonArray or QJsonObject (like the
Qt 4 & pre-5.15 versions did), do like QCborValueConstRef and store the
pointer to the QCborContainerPrivate.

Unlike QCborValueRef, we must keep the is_object bit because of API
behavior that assigning an Undefined to an object reference deletes it
from the container. I've chosen to use size_t instead of qsizetype for
this because then we don't lose any bits of the index. Therefore, the
index in the case of objects is stored as pair count (like before),
different from QCborValueRef which stores the actual index in the
QCborContainerPrivate.

It's the LSB (on little-endian architectures) so the calculation of
2 * index + 1 is the actual value stored in memory or in the
register. Unfortunately, right now, both Clang and GCC don't realize
this and generate unnecessary instructions. Clang:

0000000000000000 <QJsonValueConstRef::concreteType(QJsonValueConstRef)>:
   0:   mov    %rsi,%rax
   3:   shr    %rax
   6:   mov    %rsi,%rcx
   9:   or     $0x1,%rcx
   d:   test   $0x1,%sil
  11:   cmove  %rax,%rcx

[GCC code is identical, except it uses an AND instead of TEST]

That OR at offset 9 is a no-op because it sets a bit that is already set
in those conditions. At least they don't do unnecessary shifts.

Change-Id: I89446ea06b5742efb194fffd16bb7aadb6a9b341
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 17:00:05 -08:00
Thiago Macieira
a747ab0b72 QJson{Array,Object}: rewrite & simplify some iterator functions
Instead of manipulating indices in multiple functions, make some call
the others. This reduces the number of places porting must happen at, if
we wanted to.

Change-Id: I89446ea06b5742efb194fffd16bb78d24e0528b2
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 17:00:05 -08:00
Thiago Macieira
01fe59a3b7 QJsonObject::removeAt: stop dividing and multiplying by 2
Change-Id: I89446ea06b5742efb194fffd16bb7d17182c6a2a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:05 -08:00
Thiago Macieira
d263147921 QJsonValueRef: optimize the assignment
Inline some content to avoid unnecessary round-trips through
qcborvalue.cpp, qjsonarray.cpp and qjsonobject.cpp.

Unlike the CBOR counterparts, JSON support has this extra functionality
that assigning Undefined causes the item to be removed from the object
(arrays don't have that behavior, they just become null).

And unlike QCborValueRef, we detach on assignment, not on the obtention
of the QJsonValueRef. This is more dangerous, so we may want to revise.

Change-Id: I89446ea06b5742efb194fffd16bb775e9566ca1a
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2022-02-15 17:00:05 -08:00
Thiago Macieira
c1780165ee QJsonValueConstRef: optimize to{Int,Integer,Bool,Double,String}()
The CBOR-based implementation from Qt 5.15 simply created a QJsonValue and
then called the equivalent function on that result. For integrals and
double where the QJsonValue matched the asked type, the cost was minimal
anyway. For the other types and when the type didn't match, this
resulted in up/down the reference counter in QCborContainerPrivate and
an out-of-line call to the destructor.

This improves the performance for code like:

  for (QJsonValue v : array) {
      if (v.toString() == x) {
          doSomething();
      }
  }

This change propagates the inadviseable behavior of allowing a
dereference of the end() reference in concrete() to concreteType() (and
unit-tests it) but does not do the same for the toXxx() functions. Doing
that causes a dereference of QList's end() iterator, which is UB
(asserts false in debug mode).

Change-Id: I89446ea06b5742efb194fffd16bb3beccd1098e4
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:04 -08:00
Thiago Macieira
dccd1e87f5 QJsonValueConcreteRef: optimize concrete()
Inline the content to avoid a round-trip through qjsonarray.cpp and
qjsonobject.cpp.

This change revealed an inadviseable unit test check that dereferences
the end() iterator to get its type. I haven't changed it, but have
marked with ###. I also fixed a likely copy&paste mistake in that test.

Change-Id: I89446ea06b5742efb194fffd16bb774f3bfbe5f5
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2022-02-15 17:00:04 -08:00