Commit Graph

12101 Commits

Author SHA1 Message Date
David Skoland
34f0841451 Fix minor errors in tests
Fix indentation in tst_qlockfile and remove QtTest include in
tst_qcheckbox.

Change-Id: Idf630c6337859dbcc8f644010b941bfe55bb0633
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-01-05 12:43:09 +01:00
Edward Welbourne
6974737695 Change QLineF::setLength() to work whenever length() is non-zero
Previously it only worked when isNull() was false, which is true for
very short lines, even though length() may be non-zero.

[ChangeLog][QtCore][QLineF] QLineF::setLength() will now set the
length if the line's length() is non-zero. Previously, it was
documented to only set the length if isNull() was false; this is a
fuzzy check, so isNull() could be true for a line with non-zero
length().

Fixes: QTBUG-89569
Pick-to: 6.0 5.15
Change-Id: I803e622ad09c85815dde25df8dd3ba6dfcba0714
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-01-05 12:43:09 +01:00
Christian Ehrlicher
672d2ea8f4 QAbstractItemView: fix selectionCommand() with no event
QAbstractItemView::selectionCommand() returned the wrong SelectionFlags
when no event is given since c4366ff018.
Therefore re-add the call to QGuiApplication::keyboardModifiers() when
no event is given and add a unittest for them so it's not removed again.

Fixes: QTBUG-89711
Change-Id: I107357df08c4ff1b1a14d49523401c5e7b428f56
Pick-to: 6.0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-01-05 07:49:21 +01:00
Laszlo Agocs
8da171a5ae Adjust surface type usage for onscreen tests in tst_qrhi
Change-Id: I1ae076f8bb44e00bf9ff7706063344e8c5502101
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-04 17:30:37 +01:00
Laszlo Agocs
133af89038 rhi: shadowmap manual test: use Nearest filtering
Just to avoid validation warnings on systems where the sampling
a D32 texture with linear filtering is not supported.

This is likely not a problem elsewhere: Qt Quick 3D for example
samples the depth texture only with Nearest filtering already.

Fixes: QTBUG-89761
Pick-to: 6.0
Change-Id: I80bf5b7ecfcb3365f4010daa17f2ef00bb206b74
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-04 17:30:26 +01:00
Laszlo Agocs
c715974dc2 rhi: Make triquadcube manual test compile after recent changes
Amends a0aafefd00

Change-Id: I616df866e32fe6df87ce2944f09aac8f0c077534
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-01-04 11:42:15 +01:00
Laszlo Agocs
97da4519ba Add a dedicated QWindow surface type for D3D
Even though there is no D3D-specific logic in the windows platform
plugin, meaning a QWindow with either OpenGLSurface or VulkanSurface
(or anything really) is DXGI/D3D-compatible, it now looks like it is
beneficial, and more future proof, if there is a dedicated surface
type.

As the linked report shows, there are OpenGL-specific workarounds
accumulated in the platform plugin, while not being clear if these
are relevant to non-OpenGL content, or if they are relevant at all
still. (and some of these can be difficult/impossible to retest and
verify in practice)

When D3D-based windows use the same surface type, all these are
active for those windows as well, while Vulkan-based windows have
their own type and so some of these old workarounds are not active
for those. To reduce confusion, having a dedicated surface type for
D3D as well allows the logic to skip the old OpenGL workarounds,
giving us (and users) a more clear overall behavior when it comes
to OpenGL vs. Vulkan vs. D3D.

The change is compatible with any existing code in other modules
because any code that uses OpenGLSurface for D3D will continue to
work, using the new type can be introduced incrementally.

Task-number: QTBUG-89715
Change-Id: Ieba86a580bf5a3636730952184dc3a3ab7669b26
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-01-04 10:37:11 +00:00
Alex Trotsenko
e334d6f9a7 QProcess: allow pipelining for detached processes
[ChangeLog][QtCore][QProcess] Added support for
setStandardOutputProcess() with startDetached().

Change-Id: I61278cdb7084127f583c8c017688da392017b44c
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-12-31 12:16:46 +00:00
Alex Trotsenko
04c34eb799 QProcess: allow merged channels forwarding for detached processes
[ChangeLog][QtCore][QProcess] Added support for QProcess::MergedChannels
mode with startDetached().

Change-Id: I953ad2063322015332269522a297f8e2842e438c
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-12-31 12:16:38 +00:00
Andreas Buhr
741862875c Add test creating QDateTime in double-DST gap in 1947 Germany
In 1947, Germany had not only a summer time but also a
"Hochsommerzeit", a high summer time. This patch adds a test
creating a QDateTime in the time gap at the beginning of this
Hochsommerzeit on May 11, 1947.

Pick-to: 6.0
Change-Id: Ib81a23914965f092c3e3195e4c7258e5a4e0b30e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-24 19:41:48 +01:00
Liang Qi
489ce6f91b tests: unblacklist tst_QWindow::modalWithChildWindow() on openSUSE
This reverts 3d53cf976d.

Task-number: QTBUG-66851
Change-Id: Ib2b76c539c57fe70ee60426635e6ba59291a1f90
Reviewed-by: Liang Qi <liang.qi@qt.io>
2020-12-23 19:41:42 +00:00
Liang Qi
ab8b061620 tests: unblacklist tst_qwidget::saveRestoreGeometry on xcb
This reverts b4977a332b.

Task-number: QTBUG-69666
Change-Id: I07b57d248f3a09969e9f0d89404a3366b882e097
Reviewed-by: Liang Qi <liang.qi@qt.io>
2020-12-23 19:41:39 +00:00
Samuli Piippo
d6c3d6355a qfont: blacklist tests for QEMU
Blacklist qfont tests that don't work correctly with qemu.

Task-number: QTQAINFRA-3836
Change-Id: I7f5d4b07428febb0adb82d38203226b5c56a2ad5
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
2020-12-23 10:55:56 +02:00
David Skoland
27d96b4789 Replace QtTest headers with QTest
Complete search and replace of QtTest and QtTest/QtTest with QTest, as
QtTest includes the whole module. Replace all such instances with
correct header includes. See Jira task for more discussion.

Fixes: QTBUG-88831
Change-Id: I981cfae18a1cabcabcabee376016b086d9d01f44
Pick-to: 6.0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-22 15:20:30 +01:00
Friedemann Kleint
f6bf303cee tst_qimagereader.cpp: Fix MSVC int conversions warnings
Change-Id: I1b002ffde60dea9c54a8c41985ed295c05c45858
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-12-21 16:21:28 +01:00
Christian Ehrlicher
950c1925b1 QCheckBox: cleanup autotest
Avoid possible memory leaks by creating the checkbox on the stack, adopt
coding style.

Change-Id: I25f8b9048c8318d2897fd942492254a036c3a706
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-12-21 13:55:47 +01:00
Michal Klocek
b770b7517d Fix crash on reallocateAndGrow
After 6be398 few tests fail/crash with qtcharts.
Fix issue on reallocateAndGraw and avoid accessing
flags on invalid header.

Data::allocate can return invalid header and dataptr,
which takes place if capacity is 0. In code before 6be398
clone method checks if header is not null before resetting
flags. However after b76fbb4 resetting flags is no longer
needed since it is done in allocateGrow.

Task-number: QTBUG-89092
Pick-to: 6.0
Change-Id: I2fde781dad7a0694a5f17ab716f647c2e35f4ff0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2020-12-21 10:35:16 +00:00
Friedemann Kleint
ec7eb1eab1 Blacklist tst_QDeadlineTimer::stdchrono on Windows/clang
It has been failing consistently, recently.

Pick-to: 6.0
Change-Id: I71b2e8857c3d5ce86ad17864c95aac7265ed9a8a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-21 10:23:15 +01:00
hjk
c6dde54e67 Check size of QObjectPrivate::ExtraData in tst_toolsupport.cpp
Change-Id: I96a5ec886fe862e0ee5d25120dda625478ecf420
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-12-18 13:12:28 +01:00
Fabian Kosmale
10bf3ae90c QProperty add markdirty
This adds functionality for marking properties (QProperty and related
classes) manually as dirty. This facilliates the integration of bindable
properties with non-binable properties and makes it possible for
bindable properties to change due to external events.

Fixes: QTBUG-89167
Change-Id: I256cf154d914149dacb6cadaba92b13c88c9d027
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-12-18 13:10:46 +01:00
Samuli Piippo
abd2cbc12a Revert "Fix network tests on qemu/arm"
SIOCGIFNAME is now supported on QEMU.
This reverts commit 42b3ed763f.

Change-Id: I79caa371dc798464ab76851d2ea3189ec9eb0c57
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-18 11:18:44 +02:00
Alex Trotsenko
7a4e686240 QSocketNotifier: hone setSocket() API
Remove a second argument to the setSocket(qintptr, bool) function as
it makes the API harder to understand.

Change-Id: Ib1852a4e9d96adde35bfbf0fe03b386d9ded395a
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-12-17 21:33:17 +02:00
Samuli Piippo
331fdee9dd qRound: do not expect failure on ARM64
Amend aa136d46e1 that changed qRound()
implementation to use __builtin_round() functions on ARM64 which do
not fail "round largest representable float less than 0.5" test,
unlike the simple version of qRound() used elsewhere.

Change-Id: Ic66cb0f826d91cd6a85ad72b646c79ded1c0eeca
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-12-17 18:29:48 +00:00
Sona Kurazyan
d75c5026e9 Clean-up warnings in corelib/thread tests
Fixed the following warnings:

 - empty expression statement has no effect; remove unnecessary ';'
   to silence this warning
 - zero as null pointer constant
 - no previous extern declaration for non-static variable
 - use of old-style cast
 - integer conversion warnings

Change-Id: Ieb31b127ce8e3b543aaf88a8e8fc463dcc8bc4e3
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-12-17 14:33:56 +01:00
Friedemann Kleint
a46a723dba Tests: Fix building with qmake on Windows
Apparently some library definitions went overboard, link them directly.

Pick-to: 6.0
Change-Id: I009737f7e3edff5619241b700a627dc4e25e6018
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-12-17 13:02:15 +01:00
Ivan Solovev
f0668433c4 Bindable property with initialization
Implement Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS and
Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS macros.
They allow to directly initialize the property member.

Task-number: QTBUG-85520
Change-Id: I76541d6785bbbf27976b9f0b865fb45be1e9beee
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-12-17 12:41:13 +01:00
Ivan Solovev
f8de5e5402 Blacklist tst_QMdiArea::updateScrollBars on macos
Pick-to: 6.0
Task-number: QTBUG-41343
Change-Id: I782ded140932ab3af52ee5ca9b743fd2a3cdb473
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-12-17 08:57:53 +00:00
Mårten Nordheim
0ca4635832 QCache: fix updating entries breaking the internal chain
After f08492c6fd was
merged this bug would manifest as an entry appearing twice
in the chain when a updating an existing entry (insert with
an existing key). This could sometimes result in crashes later
as the list filled up and the list was used in trim() to remove
various entries.

Fixes: QTBUG-89176
Pick-to: 6.0
Change-Id: Ide80160fb4317dc0aefe79eec5dce7ec6813e790
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-16 14:54:17 +01:00
Andreas Buhr
3d785249ba Restore previous QDateTime behavior in DST gap
Historic QDateTime behavior when being asked to create a
QDateTime in the DST gap was to interpret the given date
as if it was in the time before that gap, mapping it to a point
in time after the gap. This has changed with
a04411119e .
Since then, the given date is interpreted as if it was in the
time after the gap, thus being mapped to a point in time
before the gap.
This patch restores the historic behavior.
This was not caught by Coin because machines ran in timezone
"Atlantic/Reykjavik" which does not have DST since 1967.
This patch changes tests to always run in "Europe/Oslo".
Driveby: Test function "findSpring" did some operations in
local time, even though being asked to work in a specific
time zone. Fixed that.

Fixes: QTBUG-86960
Fixes: QTBUG-89208
Pick-to: 6.0 5.15
Change-Id: Iecce5898bf9711a10e7dfc0a25e4bbeaed1c8ade
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-15 15:54:46 +01:00
Alex Trotsenko
6dac45b246 QSocketNotifier: extend API to provide more flexible startup
Technically, having a single constructor limits the use-cases for this
class. We should take into account that:

  - an opened socket descriptor must be available at the moment of
    construction;
  - the constructor unconditionally enables the notifier (the possible
    solution

        notifier = new QSocketNotifier(...);
        notifier->setEnabled(false);

    is suboptimal due to heavy operations inside the event dispatcher);
  - for these reasons, QSocketNotifier most often cannot be a member of
    another class (we have an extra allocation and indirect access).

This patch addresses this shortcoming by making it possible to set the
socket descriptor at a later point:

[ChangeLog][QtCore][QSocketNotifier] Added setSocket() and an additional
constructor which requires no socket.

Change-Id: I2eb2edf33ddafe99e528aac7d3774ade40795e7a
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-12-11 18:08:31 +02:00
Robert Loehning
379799b10d Fuzzing: Provide link to oss-fuzz
Change-Id: Iac77faac8bd901504073b1aacd067a42e349eca3
Pick-to: 5.15 6.0
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2020-12-11 13:45:25 +00:00
Sona Kurazyan
335acffe1d Add support of invoking QFuture continuations in a given context
Added overloads of .then()/.onFailed()/.onCanceled() which take a
pointer of a context object, and invoke the continuations in the
object's thread.

Task-number: QTBUG-86794
Change-Id: I0f3cbb0500695673fc4087af5d4b96b416e3e1ce
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2020-12-11 09:36:45 +01:00
Christian Ehrlicher
0e4cc2aca7 QTableView: honor spans when calculating height/width hint
QTableViewPrivate::heightHintForIndex()/widthHintForIndex() did not
honor spans and therefore returned too big values.

Fixes: QTBUG-89116
Change-Id: I52948902b7eaaa27c092ed39da68950c3840e8e4
Pick-to: 5.15
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2020-12-10 19:41:26 +01:00
Thiago Macieira
928b51704a tst_QFile: add a couple more sequential Unix device files
/dev/zero and /dev/null are expected to always be present in any system
(even containers). Unlike /dev/null, you *can* read from /dev/zero so
test that QIODevice doesn't think it is random-access because of that.

/dev/tty is also always present but has an interesting semantic. Could
also try /dev/full, /dev/random and /dev/urandom.

Change-Id: Ia2aa807ffa8a4c798425fffd15d84b60573f2c26
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-12-10 15:20:33 +01:00
Alexandru Croitor
2304acab5f CMake: Regenerate projects using pro2cmake one last time
And fix up some wrong qmake project files

Pick-to: 6.0
Change-Id: I66cb82aeb9c1419a74df1a650fa78a511ade7443
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-12-10 11:52:30 +01:00
Allan Sandfeld Jensen
48346e8d2d Add colorspace transfer functions based on tables of inputs
This is the most basic way to represent custom transfer functions.

Change-Id: I529fb647ece82c03e85ef77b056d9daf13fe5a61
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2020-12-10 11:03:12 +01:00
Liang Qi
4fc8a446fe tests: blacklist tst_NetworkSelfTest::smbServer() on openSUSE
Task-number: QTBUG-89209
Change-Id: I8d7d9bbf30a8f0654bc9aa84f7833c950e838b34
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
2020-12-10 11:02:06 +01:00
Giuseppe D'Angelo
ce0b767310 QStringView: add some QRegularExpression-related overloads
[ChangeLog][QtCore][QStringView] Added the indexOf(), contains(),
lastIndexOf() and count() methods taking a QRegularExpression.

Fixes: QTBUG-89050
Change-Id: Ic726754f67e06b3764302d2fad252e0378a77afc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-10 02:15:18 +01:00
Giuseppe D'Angelo
be83ff65c4 QString::lastIndexOf: fix off-by-one for zero length matches
Otherwise, it would report that lastIndexOf of an empty pattern
in an empty string doesn't exist. Next commit adds extensive autotests;
for now, disable a broken autotest (which already features a comment
about why it's broken).

Change-Id: I9a0e5c0142007f81f5cf93e356c8bd82f00066f7
Pick-to: 5.15 6.0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-10 02:15:18 +01:00
Thiago Macieira
4a1091f489 QUrl: fix parsing of empty IPv6 addresses
There's an assertion. Found by Google fuzz scan of CBOR data.

Pick-to: 6.0 5.15
Change-Id: I55083c2909f64a1f8868fffd164f1ff3af71605b
Reviewed-by: David Faure <david.faure@kdab.com>
2020-12-09 12:40:31 -08:00
Thiago Macieira
c000143ee4 QDeadlineTimer: optimize when std::chrono::steady_clock is the same
Change-Id: Ib57b52598e2f452985e9fffd14583173716343b0
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-09 12:54:59 -07:00
Giuseppe D'Angelo
7c3208c97d QString: fix count(QRegularExpression)
There is an off by one in the implementation of count(): a match
must be attempted even at the very end of the string, because
a 0-length match can happen there. While at it, improve
the documentation on the counter-intuitive behavior of count(),
which doesn't merely count how many times a regexp matches
into a string using ordinary global matching.

[ChangeLog][QtCore][QString] Fixed a corner case when using
QString::count(QRegularExpression), causing an empty in the
last position not to be accounted for in the returned result.

Change-Id: I064497839a96979abfbac2d0a96546ce160bbc46
Pick-to: 5.15 6.0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-12-09 20:41:18 +01:00
Andreas Buhr
92c066b1e5 Modify test_QFINDTESTDATA to not leave files in source tree
test_QFINDTESTDATA is a test which is built and run in the source
tree. It tests usage of relative paths of the Ninja generator, which
only occurs when building in the source tree, so this test cannot
be done outside of the source tree.
Developer's expectation is, however, that an out-of-source build
does not change the source tree. Having "git status" showing
differences after running the tests is irritating. This patch removes
the in-source build files after executing the test.

Change-Id: Ia9fd368c9d54b97a415b63254b45e17bc95ecf45
Reviewed-by: Craig Scott <craig.scott@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-12-09 20:30:05 +01:00
Liang Qi
472c8290af tests: blacklist two functions in tst_QDateTimeEdit on openSUSE
Task-number: QTBUG-89208
Change-Id: I0c0c14e3522a0c504241e178a058687ecfedf55d
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
2020-12-09 20:30:04 +01:00
Fabian Kosmale
ddc585b7c7 QProperty: Handle eager binding calling setBinding
When an eager binding  triggers a setBinding call, we end up with a
special kind of binding loop:
setBinding() -> evaluate -> notifyObserver
      ^                           |
      |                           /
      ----------------------------
We now catch set condition, and set the binding status to BindingLoop
(with a distinct description).

Task-number: QTBUG-87153
Task-number: QTBUG-87733
Pick-to: 6.0
Change-Id: I9f9915797d82eab820fc279baceaf89d7e5a3f4a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-12-09 12:48:36 +01:00
Andreas Buhr
aeb5165cb6 Fix tst_qlineedit for offscreen rendering and tiling window managers
tst_QLineEdit::QTBUG13520_textNotVisible checks that text is visible
if a QLineEdit is set to Qt::AlignRight. To do that, it writes
some text into a line edit and checks afterwards that the first
character is in the left half of the window. This fails if the window
is larger than twice the length of the text used and thus might fail
in multiple situations where Qt is not in full control over the size
of the windows created, as is the case with tiling window managers.
This patch changes the test to not check for the first character in
the left half of the window, but instead check for the first character
be approximately at the expected position.

Pick-to: 6.0
Change-Id: I18f6de356ea20f4744f3a58cd2b1d76f6a9545a4
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-12-08 15:18:41 +01:00
Liang Qi
4a85160e0b tests: blacklist tst_QGlyphRun::drawRightToLeft() on openSUSE
Task-number: QTBUG-89169
Change-Id: I4dfd608e264c9503093cc9fe27e80c489efe7aaf
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
2020-12-08 09:35:21 +01:00
Thiago Macieira
017e41bb86 QCborValue & QCborStreamReader tests: fix warning about %llx on 32-bit
cborlargedatavalidation.cpp:93:60: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘qsizetype’ {aka ‘int’} [-Wformat=]
   93 |         QTest::addRow("bytearray-too-big-for-qbytearray-%llx", v)
      |                                                         ~~~^   ~
      |                                                            |   |
      |                                                            |   qsizetype {aka int}
      |                                                            long long unsigned int
      |                                                         %x

The cast to size_t is required to make the 64-bit not complain due to
the long vs long long difference.

Pick-to: 5.15 6.0
Change-Id: I00b01c01a66748508ea1fffd164a9add2a2650cf
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-12-07 22:54:43 +00:00
Thiago Macieira
3c88728b53 tst_QCborValue: adjust the size of the minimum string that won't fit
I don't know which of the previous commits caused this: as far as I can
tell, this test should never have passed.

Pick-to: 5.15 6.0
Change-Id: I55083c2909f64a1f8868fffd164e7e8c24eec1f8
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-12-07 14:54:41 -08:00
Thiago Macieira
58bea7f3a2 QCborStreamReader::next: don't allocate too much memory in a QBA
Because CBOR strings are encoded in UTF-8, it's possible that the string
that won't fit a QString in UTF-16 would still fit QByteArray in UTF-8
(e.g., anything US-ASCII and most Latin text).

The previous solution was an improvement because we used to read into a
QByteArray then convert the QByteArray to QString, thus using 3x the
amount of memory (1x in QByteArray, 2x in QString). The previous commit
skipped the middle allocation and made the regular readString() function
do the decoding either directly on source memory or by reading in small
chunks (16 kB).

Future improvement for Qt 6.1: add readStringChunk(char16_t *, qsizetype)
so we can do the validation / skipping at O(1) memory.

Pick-to: 5.15 6.0
Change-Id: I7b9b97ae9b32412abdc6fffd1645458c655cc566
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-12-07 22:54:39 +00:00