Commit Graph

16184 Commits (14a9a593a2a60ccedad92ef7fbeb6fb0501ac835)

Author SHA1 Message Date
Ivan Solovev 4c93115504 Add QUtf8StringView vs QLatin1StringView relational operators
... by using the new comparison helper macros.

This allows to remove dummy comparison operators from
tst_qstringapisymmetry.

This is also a pre-requisite for a follow-up commit that introduces
relational operators between QLatin1StringView and QByteArrayView.

Task-number: QTBUG-117661
Task-number: QTBUG-108805
Change-Id: I5837b457a777fddff1071bc252982e68d004fa94
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-02-16 18:39:22 +01:00
Ivan Solovev e26914fa0f Refactor tst_qcomparehelpers
Previously the test consisted of just one cpp file. An attempt to add
more test cases to the file resulted in the minGW compiler complaining
about a too large object file:

 Fatal error: tst_qcomparehelpers.cpp.obj: file too big

This patch splits the implementation into a header and a cpp file.
This itself does not fix the issues, but now we can add the new test
cases in a separate cpp file. This patch also adds some comments
that advocate doing so.

Pick-to: 6.7
Change-Id: I451987370fa4e18b7ad81dfc064ea016f1d0da47
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-02-16 18:39:06 +01:00
Giuseppe D'Angelo 73bf1c1a9b QList: add uninitialized resizes
Creating a QList of a given size, or resizing it to a given size, will
always value-initialize its elements. This commit adds support for
uninitialized construction and resizes. The intended use case is using a
QList as storage-to-be-overwritten:

  QList<int> list(size, Qt::Uninitialized);

  fillWithData(list.data(), list.size);

How do we define "uninitialized":

1) if T is constructible using Qt::Uninitialized, use that;
2) otherwise, default-construct T.

In detail:

1) covers (Qt-ish) datatypes that have a default constructor that
   initializes them, but also a dedicated constructor that doesn't
   initialize (e.g. QPoint, QQuaternion, ...).
2) covers everything else. Default initialization of scalars and
   trivially constructible datatypes will leave them uninitialized.

A type which isn't trivially constructible will still get its default
constructor called (and possibly actually gets initialized); we can't
really do better than that, as we still have to construct objects and
start their lifetimes.

[ChangeLog][QtCore][QList] Added support for uninitialized construction
and resizing.

Change-Id: I32c285c7dddbf7e01475943f24e14e824bb13090
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-02-16 14:20:50 +01:00
Ahmad Samir 026e1e3fdb QTimer: use QTest::ingoreMessage() for negative internvals tests
Pick-to: 6.7 6.6 6.5
Change-Id: I87d095b748a7488a71b22710ab7ed72d9451c769
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-02-15 22:35:00 +02:00
Marc Mutz af051f9be2 QVarLengthArray: re-publish Prealloc as a nested PreallocatedSize
This gives users of the class easy access to the Prealloc template
argument, without having to write a pattern-matcher like

   template <typename T>
   constexpr qsizetype preallocated_size_v;
   template <typename T, qsizetype N>
   constexpr qsizetype preallocated_size_v<QVarLengthArray<T,N>> = N;

first.

[ChangeLog][QtCore][QVarLengthArray] Added PreallocatedSize nested
constant, equal to the Prealloc template argument.

Change-Id: I928eaa5e62967445cdd7b0c2759567483fdb8997
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-02-15 17:44:36 +00:00
Eirik Aavitsland 4449dbe737 Baseline tests: avoid rendering items that are blacklisted on the server
Blacklisting items on the baseline server would avoid any mismatch
failures for such items. However, they would still be rendered. That
is undesirable if the rendering itself has unwanted side effects for
such items, e.g. crashing the test executable.

Fix by adding new functionality in the baseline testing framework to
allow checking blacklisting status ahead of time, and add a new macro
QBASELINE_SKIP_IF_BLACKLISTED to do just that.

Add usage of that macro to the QPainter baseline test.

Pick-to: 6.7 6.5 6.2
Change-Id: I35f6df8cff2c6cb985c25ab5470cd42b53d44940
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2024-02-15 18:44:35 +01:00
Mårten Nordheim 775a57f266 tst_QNetworkReply: Try to stabilize qtbug68821proxyError
The test is a bit silly, it was originally written to make sure that
we produce meaningful errors when trying to connect to a proxy server
where the connection is refused or the server doesn't respond at all.

To test that, it creates a local QTcpServer and starts listening to any
free port (by specifying port 0) and then it closed the server and
uses the address-port of localhost:serverPort as the proxy to use, since
we know it _was_ unused, since we were able to bind to it.

However, just calling close() doesn't immediately tear down the internal
socket descriptor, so the OS may still have the port reserved for
some time.

By moving the QTcpServer to a narrower scope we will quickly destroy it
and the internal socket engine, which is parented to the server, and
this in turn releases the socket descriptor.

Pick-to: 6.7 6.6 6.5
Change-Id: If12128fc21d1f545df152f08f0d52c1b14ac6037
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-02-15 16:27:19 +01:00
Rym Bouabid 760043ea8c QDir: Use QT_TEST_EQUALITY_OPS macro in unit-tests
Replace QTestPrivate::testEqualityOperators() helper function with
QT_TEST_EQUALITY_OPS macro to get a reasonable debug output in case of
failure.

Task-number: QTBUG-120303
Change-Id: I1ca23cabfe62ab78e012cf95fd2add631fc88a64
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-02-15 14:51:37 +01:00
Volker Hilsheimer 477381993a Iconbrowser: render theme icons as list with large icons
In icon mode, the name of the icon gets truncated.

Pick-to: 6.7
Change-Id: I8e2081a68006907ae916c8e8fa1aeb6006acbc6d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2024-02-15 05:07:18 +01:00
Shawn Rutledge bf8167c5fc tst_QTextMarkdownWriter: test both ways of setting font characteristics
We have explicit QFont properties, and QTextFormat::setProperty().
Setting FontFixedPitch doesn't necessarily affect the view (QTextEdit or
Qt Quick Text/TextEdit); and setting the font to the one we get from
QFontDatabase::systemFont(QFontDatabase::FixedFont) is also unreliable,
because the "monospace" fallback might actually be proportional.
QTextMarkdownWriter checks for both to decide whether to use backticks;
so markdown writing works if an editor UI makes the format monospace
both ways to be safe. But in the opposite case that the main font is
actually a monospace font, it's always been broken.

The rest of the QTextCharFormat properties are generally working, to
the extent that they are applicable to Markdown. But we lacked explicit
test coverage: so far we were just reading Markdown or HTML and writing
Markdown to test the writer.

Also amend an old comment about writing underlines: writing was always
possible, and since f5c7799f59 reading is
supported too. So the underline support is symmetric (except that we
don't heed the QTextDocument::MarkdownFeatures argument to the writer
ctor: we probably should do that some day).

Pick-to: 6.7
Task-number: QTBUG-54623
Task-number: QTBUG-75648
Task-number: QTBUG-75649
Task-number: QTBUG-79900
Task-number: QTBUG-99676
Task-number: QTBUG-103484
Change-Id: Iacb4ed0ea59030570702d4eadfdadfad872065c6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-02-14 18:36:42 -07:00
Rym Bouabid fec4984dc9 QFileInfo: Use new comparison helper macros
QFileInfo had operator==() and operator!=() defined as public member
functions, so use QT_CORE_REMOVED_SINCE and removed_api.cpp to get
rid of these methods and replace them with a hidden friend.

Use QT_TEST_ALL_EQUALITY_OPS macro in unit-tests.

Task-number: QTBUG-120303
Change-Id: Ie290df230b0f608a0965dccba9184382291cad8e
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-02-14 21:47:29 +01:00
Tor Arne Vestbø 6fbbbef260 QRhiWidget: Tear down resources before window has changed
We were handling QEvent::WindowChangeInternal, but based on what the
code is doing, what the comments say, and what QQuickWidget does,
the right event should be WindowAboutToChangeInternal.

This fixes a crash when reparenting a QRhiWidget into another widget,
where we could call removeCleanupCallback() on an RHI that was already
gone.

The fact that we have a stale RHI pointer at WindowChangeInternal time
is still problematic, and caused by our call to addCleanupCallback not
happening as it should for the first call to ensureRhi(), but this will
be fixed in a follow up.

Pick-to: 6.7
Change-Id: I054120e97a24a1f74af44b2d251470792f03f7f3
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2024-02-14 18:51:29 +01:00
Even Oscar Andersen 1ca7368d59 wasm: Add corelib/io/qdataurl autotest
Change-Id: I69ac2f0c5b364e3d006d3605383a7dd8cdecb887
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2024-02-14 18:24:39 +01:00
Ahmad Samir 2956b84332 QFilesystemWatcher: speed up the unittests
The only backend that requires longer wait times is
QPollingFileSystemWatcherEngine; lower the interval of the polling
engine for the unittests (using the same objectName() trick that is used
to force using a specific watcher engine).

Remove the comment about FAT32 filesystems, there is no where on the CI
where this test fails so far.

Before:
Totals: 23 passed, 0 failed, 0 skipped, 0 blacklisted, 127027ms

After:
Totals: 23 passed, 0 failed, 0 skipped, 0 blacklisted, 666ms

Change-Id: I96378f810463fa5c4ebdc13946ea23810e80f144
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-02-14 17:57:03 +02:00
Lucie Gérard ee8822168c Change license in test file
According to QUIP-18 [1], all test files should be
LicenseRef-Qt-Commercial OR GPL-3.0-only

[1]: https://contribute.qt-project.org/quips/18

Pick-to: 6.7
Task-number: QTBUG-121787
Change-Id: I701e707447ca68977bdd80662200eb0c36545dbe
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2024-02-14 15:23:05 +01:00
Shawn Rutledge 65c40290b4 QTextMarkdownWriter: Don't word-wrap headings
If it wraps, the text on the next line is no longer part of the heading.

Fixes: QTBUG-106526
Change-Id: I8015c948d875c6944422ef3439e3128af5b2a2e2
Pick-to: 6.5 6.6 6.7
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-02-13 21:38:00 -07:00
Shawn Rutledge 908fc2e72b QTextMarkdownWriter: Avoid omitting or misplacing ending indicators
If we need to word-wrap a paragraph after a long formatted span,
write any ending markers before the newline (amends
280d679c55 ).

Break before a fragment if the whole thing is past the column limit;
in that case, write out any ending format markers before the newline.

And now we have test coverage: prepend characters one-at-a-time to a
line that already has a two-word formatted span at the end, and watch
it successively break after the span, in the middle, and then before,
while never putting a newline before the ending markers or failing to
write them.

Fixes: QTBUG-116927
Change-Id: I140e10d19a491cb599bf7ecf8514af866b5383f3
Pick-to: 6.5 6.6 6.7
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-02-13 21:37:43 -07:00
Shawn Rutledge f3e528b97f QTextMarkdownWriter: Handle lists in blockquotes correctly
But we do not yet handle a blockquote in a list item. Presumably
that's less common anyway.

We now also continue block-quote prefixes onto blank lines
within a block quote, which looks more normal.

Pick-to: 6.7
Task-number: QTBUG-104997
Change-Id: I2b5642cf3a0c81a94444a33f026a02ad53e7e6bb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-02-13 21:14:23 -07:00
Allan Sandfeld Jensen dcb2186c2a Fix build with gcc-14
Work-around SiC change made to qfloat16 when using native floats.

Pick-to: 6.7 6.6 6.5
Change-Id: I981505e6eff7277ad14512b56fad334be6e79016
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-02-14 00:25:55 +00:00
Rym Bouabid 39505c86cc QDir: Use new comparison helper macros
QDir had operator==() and operator!=() defined as public member
functions, so use QT_CORE_REMOVED_SINCE and removed_api.cpp to get
rid of these methods and replace them with a hidden friend.

Use QTestPrivate::testEqualityOperators() helper function in unit-tests.

Task-number: QTBUG-120303
Change-Id: I86c2ba18b8b114efd9f62fc2fd628bc9065b04b2
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-02-13 15:58:42 +01:00
Tor Arne Vestbø cd29145ddc macOS: Implement support for backing store static contents
We already had the machinery to copy one buffer to another, so this
machinery has been generalized a bit, so we can use it to preserve
the static content during buffer resize.

As explained in the comments, we need to do the buffer copies during
buffer creation, instead of relying on our back buffer finalization,
as we are not guaranteed that we can always copy the static content
from the front buffer.

Pick-to: 6.7
Change-Id: Ia9b3ac6ec982949990d172b0b14f35b13bbae92a
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-02-13 13:55:01 +01:00
Tor Arne Vestbø cce303b6a7 Add QPlatformIntegration::BackingStoreStaticContents capability
This was a feature in Qt 4, but the only platform that carried it over
to Qt 5 was Windows, in ab76593f18, and
that's still the situation.

As a first step in possibly implementing this on more platforms, lets
replace the hard-coded check in QWidgetRepaintManager::hasStaticContents
with a proper QPlatformIntegration capability check in the only call site.

Pick-to: 6.7
Change-Id: I2067109f45116cd8c62facf7224cd748f19e845b
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-02-13 13:55:01 +01:00
Tor Arne Vestbø ea0cf4a9a2 tst_QWidgetRepaintManager::staticContents: Trigger resize via QWindow
QWidgetPrivate::setGeometry_sys wrongly triggers full update, which is
why the test was QEXPECT_FAIL, even on Windows, which does implement
static contents.

We can test the behavior without involving the broken QWidget behavior
by resizing the QWindow instead, which triggers a resize of the platform
window and will be fed back through QWSI, similar to when the user
resizes the window via the window frame.

The QEXPECT_FAIL message for the QWidget resize has been updated to
reflect why it's expected to fail.

tst_QWidget::optimizedResize_topLevel() has similar issues to this
test, and solves it by using Window specific platform code. For now
this test has been left alone, as there are a lot more going on in
that test in terms of workarounds and blacklistings, so it needs
further investigations.

Pick-to: 6.7
Change-Id: I28a55c0723b3e7f16b362d1ebc369e038d5a7ac4
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-02-13 13:55:01 +01:00
Tor Arne Vestbø 515822de24 QBackingStore: Take DPR into account when resizing with static contents
The plumbing from QBackingStore::resize to the platform backing store
was missing a high-DPI conversion for the backing store's static
contents, which is also expressed in the QtGui coordinate system.

Pick-to: 6.7 6.6 6.5 6.2
Change-Id: Ifaac916cbf184b9386aa5feca1577a53bf2906ed
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-02-13 13:55:01 +01:00
Thiago Macieira 0d15c000ad qHash: backport the q(u)int128-to-quint64 reduction trick to 32-bit
I didn't do it in a template because the 32-bit code requires a
compatibility hack for Qt 6 and it's using an XOR of the high and low
parts.

Fixes: QTBUG-116080
Change-Id: I5dd50a1a7ca5424d9e7afffd17ae0ba5b9ff52f6
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-02-12 17:01:33 -08:00
Marc Mutz 1d7950c946 Add missing qHash(qu/int128) overloads
If we add the typedefs, we also need to add the qHash() overloads. See
code comments for the explanation of how it works. I chose to use an
addition to merge the upper and lower parts because of the comment in
QHashCombineCommutative's operator(), introduced by commit
91b44afdcb.

Found in 6.6 API-review, but didn't make the cut and then was
forgotten.

Drive-by fix long line nearby.

[ChangeLog][QtCore] Added qHash() overloads for quint128 and qint128.

Fixes: QTBUG-116054
Task-number: QTBUG-116080
Change-Id: If484aed08ba476e0eace800b719f435203100f3e
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2024-02-12 17:01:33 -08:00
Thiago Macieira 1845d43327 tst_QHashFunctions: make the consistency check table-driven
So we can test more values. Because we are testing more values, we can't
use QEXPECT_FAIL, because we can't guarantee a mismatch.

Pick-to: 6.7
Task-number: QTBUG-116077
Task-number: QTBUG-116080
Change-Id: I664b9f014ffc48cbb49bfffd17b021719e6d612f
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-02-12 17:01:33 -08:00
Ivan Solovev 612b67cf13 QTimer: do not set active state when setting a negative interval
QObject::startTimer() returns 0 in case of failure, for example when
someone tries to register a timer with a negative interval.

However, QTimer internally uses -1 as an invalid timer id.
This could lead to a situation when the timer was not really started,
but QTimer::isActive() returned true.

This patch fixes it in two ways:
- check the return value of QObject::startTimer() and treat 0 as an
  error.
- do not treat 0 as a valid timer id when calculating the active state.

As a drive-by: move the `using namespace std::chrono_literals;`
declaration to the top of tst_qtimer.cpp, so that we do not need to
repeat it in each test case.

Fixes: QTBUG-122087
Pick-to: 6.7 6.6 6.5
Change-Id: I0e21152b2173ebb5fb0dada1b99a903a321ca9c4
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-02-12 23:49:54 +01:00
Tor Arne Vestbø c6fc6cef33 tst_QWidgetRepaintManager::scrollWithOverlap(): Disable scroll bars
The scroll bars may show up in one of the grabs and not the other,
(as seen on macOS), which is interesting, and possibly a bug, but
is not what the test is checking for, so let's disable the scrollbars
to stabilize the test.

Pick-to: 6.7
Change-Id: Iad97ca5b22783bb1bee51b560957c5461b7d9923
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2024-02-12 21:09:18 +01:00
Tor Arne Vestbø 1308f7e0b1 QWidgetWindow: Don't meddle with WA_WState_{Hidden/ExplicitShowHide}
In ccd3bf0871 we introduced code that would
ensure that our call to QWidgetPrivate::setVisible() from QWidgetWindow
would not result in WA_WState_Hidden being set. This code was later
modified in 51300566ff to apply to
widgets that were explicitly shown/hidden.

Unfortunately, the reset of the Hidden and ExplicitShowHide attributes
would in some cases result in the widget having only ExplicitShowHide
after being hidden, which is an invalid state.

It also resulted in the widget having both Visible, Hidden, and
ExplicitShowHide, if first being hidden via QWidget, and then
shown via QWindow, which in turn prevented the widget from being
hidden via QWidget::hide().

As we no longer rely on the adjustments to Hidden/ExplicitShowHide
to fix QTBUG-73021, we can remove the entire logic. Any setVisible
call to QWidgetWindow will either come from outside, in which case
we should respect that and set Visible/Hidden via QWidgetPrivate,
or the setVisible call is a result of QWidget itself (or its parent)
showing the QWidgetWindow, in which case the QWidget visible state
is already up to date and we skip the QWidgetPrivate::setVisible
call.

Task-number: QTBUG-121398
Task-number: QTBUG-73021
Fixes: QTBUG-120316
Pick-to: 6.7
Change-Id: I3174ad66b7e10c55aa99b7cb433267632169ca8f
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-02-12 21:09:18 +01:00
Tor Arne Vestbø 371d7ea19a Ensure QWidget::destroy() events and attributes match hiding the widget
When destroying a widget via QWidget::destroy(), we clear WA_WState_Created,
and then delete the QWidgetWindow, which in turn hides the widget. But
QWidgetPrivate::setVisible(false) skips hide_helper() if the widget has
not been created, which leaves out important events such as the hide
event, and even more important, fails to clear WA_WState_Visible. As
a result, the widget is left visible (and mapped), even if it has been
destroyed.

This is normally not a big issue for the main use of destroy(), namely
destructing the widget, but for cases where destroy() and create() is
used to recreate the widget this is important.

We now unconditionally call hide_helper() if the widget is not already
hidden. As a result, the widget will correctly be visible=false after a
destroy(). This in turn means we need to re-apply the visible state after
recreating the widget when we detect a mismatch in RHI configuration.

Due to our meddling of the Hidden and ExplicitShowHide attributes in
QWidgetWindow private, a QWidet::show() will not have any effect after
being destroy(). This is okey for now, as destroy() is internal to
a widget, and we make sure to either update WA_WState_Visible and
WA_WState_Hidden (in QWidgetPrivate::setParent_sys), or use the
QWidgetPrivate::setVisible() code path directly, which doesn't
have that issue. The root problem will be fixed in a follow up.

Pick-to: 6.7
Change-Id: I77cb88d75e57f0d9a31741161fb14d618a653291
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2024-02-12 21:09:18 +01:00
Mårten Nordheim b099988f6d QStringConverter: add a test for missing drain
Task-number: QTBUG-118834
Change-Id: I3085e6f83aa5a21f477a101a45186d0ce2133d10
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-02-12 19:12:25 +01:00
Mårten Nordheim 496340f33a QLocal8Bit::convertFromUnicode[win]: support more than 2Gi input
As we did for convertToUnicode. To support more than 2Gi input, we
need to handle the input in chunks because of the `int` parameter in the
Windows API. Testing also revealed some corner cases we also need to
handle, which is mostly happening when there is an incomplete surrogate
pair at the end of the current input window.

The test takes between 3 (plain MinGW) and 8 (MSVC with ASAN) seconds
to run on my machine.

Pick-to: 6.7 6.6 6.5
Fixes: QTBUG-105105
Change-Id: I4fb0420b88ca41dfa8b561a35c6d96659bd81468
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-02-12 19:12:25 +01:00
Mårten Nordheim a7171c6256 QLocal8Bit::convertToUnicode[win]: support more than 2Gi input
To properly support more than 2Gi input we have to support being asked
to resize more than once. Previously we would only have to resize the
one time because we went from our 4K stack buffer to the final size
heap buffer. But now, since our input size can only be specified in
int, we have to deal with looping over the input and resizing the buffer
as needed.

We also have to deal with trailing data at the end of our sliding window
potentially causing issues for the encoding. So we try to shrink our
window when it causes issues, or store the trailing data for the next
call.

The >2Gi test takes about 6-8 seconds on my machine.

Pick-to: 6.7 6.6 6.5
Task-number: QTBUG-105105
Change-Id: I9a44b8f379bf2c2c58183f961544ed2f4c8c7215
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-02-12 19:12:25 +01:00
Tor Arne Vestbø 4e9017c1fc Un-blacklist tst_QWidget::optimizedResizeMove on macOS
It has been passing consistently in dev, 6.7, 6.6, and 6.5 for the past
6 months: http://testresults.qt.io/grafana/goto/S35hM52IR

As a drive-by, fix comment that claims the test is only run on macOS.

Pick-to: 6.7 6.6 6.5
Change-Id: I6502c40e0c39afb68a461bd530df1bacb5211dec
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2024-02-12 17:52:58 +01:00
Marc Mutz e1f45ad818 QMap: add missing qHash() overload
Found in API review, but not deemed important enough to still get into
6.7.

Not implementing it for QMultiMap, because there we need to mod out
order of equivalent elements.

The GHS compiler acted up and tried to compile the noexcept
specification, hitting non-existing qHash(QVariant) for QVariantMap
and producing a hard error instead of SFINAE'ing out. As a
work-around, establish an artificial SFINAE-friendly context, but only
for that compiler.

[ChangeLog][QtCore][QMap/QHash] Added qHash() overload for QMap.

Change-Id: Ia7dbf488e8e5490962118e40581b7c4cc8ed95e5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-02-09 20:33:05 +00:00
Ahmad Samir c2f38c69fc QFileSystemMetaData: use QTRY_COMPARE*(10s)
After d4bb448cdd (thanks to Marc), now we
can use chrono literals with QTRY_* macros.

Amends 72f5b35b3d .

(Cannot be backported to older branches because the QTRY* commit is only
in the dev branch).

Change-Id: Ic31d1ee717af604dd762afa44741cf9ea9b33a8e
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2024-02-09 22:33:04 +02:00
Shawn Rutledge 3f515fa7af QtIcoHandler::canRead(): avoid checking more than once
QtIcoHandler::canRead() calls ICOReader::canRead(), which assumes that
QIODevice::pos() is at the position where the .ico data starts (i.e.
pos() == 0 if this is a separate .ico file). But if an AnimatedImage in
Qt Quick opens an .ico file, canRead() gets called multiple times:
the first is when QQuickAnimatedImage::frameCount() eventually results
in QImageReaderPrivate::initHandler(); then ICOReader::readHeader()
is called, which moves the file position. The second time is when
QQuickAnimatedImage calls QMovie::isValid(). At that time,
QIODevice::pos() == 6: we need to avoid calling ICOReader::canRead()
because it's no longer at the start of the data.

Without this change, AnimatedImage reports "Error Reading Animated Image
File" and doesn't show anything.

The fix is to store the known-good state, the same way that
QTiffHandler::canRead() returns true if its d->tiff already exists
(TIFFClientOpen() succeeded).

The test checks that it's ok to call QMovie::frameCount() first and then
QMovie::isValid(). Calling frameCount() has the effect of moving
QIODevice::pos().

Pick-to: 6.5 6.6 6.7
Task-number: QTBUG-117429
Change-Id: Ie3a5225f2cea9a0d76d685e83ce4d4a10cbe9188
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-02-09 12:17:21 -07:00
Jonas Karlsson 28ecb523ce Improve KTX file reading memory safety
* Use qAddOverflow/qSubOverflow methods for catching additions and
  subtractions with overflow and handle these scenarios when reading the
  file.
* Add 'safeView' method that checks that the byte array view constructed
  is not out of bounds.
* Return error if number of levels is higher than what is reasonable.
* Return error if number of faces is incorrect.
* Add unit test with invalid KTX file previously causing a segmentation
  fault.

This fixes CVE-2024-25580.

Fixes: QTBUG-121918
Pick-to: 6.7 6.6 6.5 6.2 5.15
Change-Id: Ie0824c32a5921de30cf07c1fc1b49a084e6d07b2
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-02-09 13:08:44 +01:00
Christian Ehrlicher 1d799e9108 QAbstractItemView: close all child editors when parent is removed
QAIV::rowsAboutToBeRemoved() closed all child editors when the child was
a direct ancestor of the removed index but forgot to check if the index
is an indirect ancestor. Some of those editors were removed later in
updateEditorGeometries() but not all as the testcase in the bug report
showed.

Pick-to: 6.7 6.6 6.5
Fixes: QTBUG-103476
Change-Id: I90b3d3bff3857aa79f96eecf23d980928693b7bc
Reviewed-by: David Faure <david.faure@kdab.com>
2024-02-08 18:31:26 +01:00
Marc Mutz f4cfc21dec QList: give the LWG 3346 #ifdef'ery a symbolic name
We'll need this in more places, so centralize its definition in
qcompilerdetection.h.

Amends 595b4e1a9b.

Pick-to: 6.7 6.6 6.5
Change-Id: I87f84cb9ff3ad339c000604423295180176f5799
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2024-02-08 17:43:59 +01:00
Ievgenii Meshcheriakov 0e67553aac tst_qttextboundaryfinder: ignore unsupported tests
Qt currently has custom implementation for Indic grapheme breaks.

QTBUG-121907 was created to evaluate whether it is better to use
Unicode implementation instead.

Remove BLACKLIST. The remaining tests pass.

Fixes: QTBUG-121529
Task-number: QTBUG-121907
Change-Id: Ifd8fd76aeeba51d08c9f23b867abbf39750fc7d9
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-02-08 17:43:58 +01:00
Ievgenii Meshcheriakov b2764f7802 QUrl IDNA: Update to Unicode 15.1
Unicode 15.1 (more spcifically UTS #46, revision 31) changes how
host names are processed. The initial Unicode host name mapping
is done without validity checking. That check was used in the past
to mark QUrl's invalid. This patch inserts simplified validity
check later. This check is similar to one performed before
conversion to unicode, but does not include BiDi check to keep
names starting with xn-- valid.

Additional complication is that U+1E9E LATIN CAPITAL LETTER SHARP S
must be mapped to "ss" with transitional processing.

It is not possible anymore to predict whether Qt implementation
considers a URL valid by using only error codes in the tests
vectors file. The test was adjusted to expect an empty string
(indicating invalid QUrl) or string matching the entry in vectors
file if there are any processing errors specified for that entry.

Unblacklist tst_QUrlUts46::idnaTestV2.

Task-number: QTBUG-121529
Change-Id: Iad5dadd1a6695fa54b432e35000b350cd6e06341
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-02-08 17:43:58 +01:00
Ievgenii Meshcheriakov bfd09ec38c unicode: Import version 15.1 (UCD version 32)
Add enumerator for the new Unicode version to QChar::UnicodeVersion.

Remap new line breaking classes to their Unicode 15.0 values:
* AK, AP and AS to AL,
* VI and VF to CM.
These are classes for new line breaking support for Indic scripts
that require more work.

Blacklist failing tests for now:
* tst_QUrlUts46::idnaTestV2
* tst_QTextBoundaryFinder::lineBoundariesDefault
* tst_QTextBoundaryFinder::graphemeBoundariesDefault

Regenerate the source files.

Task-number: QTBUG-121529
Change-Id: I869cc9fbaa53765d8ae6265c22cdbef9f19d05bf
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-02-08 16:43:58 +00:00
Alexandru Croitor a61ac2ca58 CMake: Add test for configuring a standalone test
A standalone test is one that uses
 find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
in its project code.

To ensure we don't accidentally regress this feature, test it as a
cmake test.
Also run test, this somewhat covers testing qt_internal_add_test.

Pick-to: 6.5 6.6 6.7
Change-Id: Ia9f27eef2bd7bd5bb57b96e553304924db252365
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-02-08 15:40:04 +01:00
Nicolas Fella 00d9a9a9b5 QIcuTimeZonePrivate constructor: save iteration over all zone IDs
ICU returns a "valid" representation of GMT when given an unrecognised
ID, so QTZ's constructor has been checking the ID is available before
passing it to the backend constructor. That availability check was
done by generating the list of available IDs to see if the given ID
was in it; this is very inefficient. Furthermore, the QTZ constructor
was also checking availability, to work round the same issue in only
this one backend, making the check redundant.

So overide isTimeZoneIdAvailable() in the ICU backend, calling
ucal_getCanonicalTimeZoneID(), which answers the question directly;
and drop the duplicate check in the QTZ constructor. Expand a test to
verify an invalid name is rejected.

Fixes: QTBUG-121807
Pick-to: 6.7 6.6 6.5
Change-Id: I34f996b607b958d12607a94eb273bb1b406cca1a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-02-08 15:40:03 +01:00
Eirik Aavitsland 930535fe30 Modify the baseline testing framework to show new test items
If a commit adds new baseline test items, they would not be reported
to the server when doing a LanceBot test on that commit, and so not be
visible in the report either. This commit fixes the client side of
that issue; the server is already updated.

Change-Id: I60c2958def5e7b54ddc2789cf5727edcbb1a90e1
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Jonas Karlsson <jonas.karlsson@qt.io>
2024-02-08 12:29:17 +01:00
Mårten Nordheim 3b3b2024f9 Add QNetworkRequestFactory::(set)?Priority
To enable setting a default priority for all requests to a given site.

Fixes: QTBUG-121669
Change-Id: Icd8a9c59e4afb0432c65f84cc8115ae0c7f85506
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-02-08 11:38:10 +01:00
Ivan Solovev cbc6ee0eb9 Deprecate QDataStream::readBytes(char *&, uint &) instead of removing it
We cannot remove the overload using QT_REMOVED_SINCE, because a qint64
lvalue in the new overload will not bind to an uint& parameter, so the
old code would not compile.

Deprecate the old overload, and add a unit-test that makes sure that
it still behaves correctly.

This commit also introduces the new deprecation macros that are
required to do the deprecation in Qt 6.11.

Amends fd48ce0b73

Found in 6.7 API review

Pick-to: 6.7
Change-Id: I02893bfbe040df736f8e746384e0261a0f0041d3
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-02-07 15:02:19 +01:00
Ivan Solovev 0aaf7092cd Fix QDataStream::operator<<(const char *) to handle 64-bit length
The operator was not converted to using a new streaming version, so it
supported only 32-bit length.

Fix it and add a manual test for serialization/deserialization of
large c-style strings.

Amends fd48ce0b73

Pick-to: 6.7
Change-Id: I83704edec021d400b992de810feba5da52d5ffe1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-02-07 15:02:19 +01:00