The section item has not been removed or added to the section cache
in all cases when the corresponding delegate item has been moved out
of the visible area, either during flick or scroll. This happens in
a case where the delegate item has been requested to be removed (as
it goes out of the visible area) from the list view, but it's not
released from the delegate model due to its caching mechanism. When
an item is outside the visible area, releaseItem() is triggered,
intended to free the item and its sections. The problem arises when
releaseItem() calls QQmlInstanceModel::release(), which caches the
item in the delegate model, but does not free the section. This
prevents the section item from being released properly.
This patch releases the section item whenever removeItem is
triggered from the list view, which happens when the delegate item
is moved out of the visible area.
Fixes: QTBUG-137172
Pick-to: 6.8 6.5
Change-Id: Ib7e78309e076e76750b03f3238a7501563a3962a
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
(cherry picked from commit 5a664f0836)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit d0287165a7)
QTest::createTouchDevice() passes ownership of the device to the caller,
so make sure it gets deleted.
Change-Id: I1289def6b40bf688a7334b9997f7e4319516d018
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit f09eb295c3)
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Never use module-wide inclusions. They blow up build times. For QtTest
this is usually just a typo (QTest was meant instead). Add missing
includes as needed.
In the diffs I've spotted other huge inclusions (QtQuick, QtQml), but
those need more attention.
Task-number: QTQAINFRA-7110
Pick-to: 6.8
Change-Id: I74bf3fe212f50a7a3a6af2b1c80bbcaabc2516d7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit fb4abf95c1)
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
tst_QQuickListView::enforceRange_withoutHighlight is flaky where a key
press is not received when the window is not active yet and fails.
Verify that the window is active before sending the keypress event.
Unblacklist tst_QQuickListView::enforceRange_withoutHighlight on
Opensuse as it is no longer flaky.
Pick-to: 6.8 6.5
Change-Id: Ib1013a73d9267354f7d045345bac74125366ff03
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 6c4d8f3bea)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Since d7623d79ef Flickable has worked
directly with touch events; and we are expected to have stylus devices
(QTabletEvents) working well too. So we need to be able to expand the
test coverage to more types of devices. This is the first step.
Pick-to: 6.8
Change-Id: I93a3a4b84424eb69e0cd7c9f4ebe58b9f27082d9
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
I'm not sure if any actual CI failures resulted from failure to
terminate the do..while loops, but it seems likely, since a recent patch
seems to provoke that. It's better to fail after a reasonable number of
loops, rather than letting it go and hoping for a timeout. In practice
it seems 2 rounds is enough, so let's try 4 as the limit.
While we're at it, round the grid.contentX/contentY values that are
displayed. Intermediate values have always been shown with way too many
decimal places, which interfered with whatever value it has to display
the numbers.
Pick-to: 6.8
Task-number: QTBUG-33017
Task-number: QTBUG-88644
Change-Id: I2fc4843071276b3af544c2506eb152698542cd06
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
As long as we rely on QGuiApplicationPrivate::processTabletEvent() to
synthesize mouse events from tablet events (we aren't doing it on the
fly as with touch events in 468626e99a),
and as long as most QQuickItems are not handling tablet events,
QQuickDeliveryAgentPrivate::onGrabChanged() almost always sees a
QMouseEvent losing its grab when e.g. ListView takes over from one of
its delegates while the user is trying to scroll with a stylus device.
This event's device is the stylus, though.
Whenever we see an EventPoint being canceled or ungrabbed, we must call
either mouseUngrabEvent() on the item, or touchUngrabEvent() if all the
points are released or cancelled, to avoid items getting "stuck" in
pressed state. It must not be skipped. So call mouseUngrabEvent()
whenever the event is a QSinglePointEvent, and touchUngrabEvent()
otherwise (since only touchscreens send multi-point events).
Make QQuickTest::pointerPress/Move/Release functions more correct for
stylus devices:
- we need the timestamp to monotonically increase, even though
QTest::defaultMouseDelay() is usually 0 (which isn't sensible)
- QTest::mouseEvent() calls qt_handleMouseEvent which converts
logical coordinates to native positions; but for tablet events,
do it here for now, since there are no QTest methods to generate them.
This helps QQuickFlickablePrivate::handleMoveEvent() to calculate
deltas correctly.
Fixes: QTBUG-118903
Pick-to: 6.8 6.7 6.6 6.5
Change-Id: I5ec54c5181f5b9137fe16248884010aea94f671a
Reviewed-by: Doris Verria <doris.verria@qt.io>
The test assumed that an item inserted in the beginning of the ListView
will always end up at position 0 (x or y).
This is wrong assumption, since the ListView can choose to put the new
items above/left of the existing items without having to adjust the
coordinates of all of the existing items, and then accordingly it will
adjust the origin(X,Y), ensuring that the visual rendering will
be the same for both cases.
The documentation of Flickable::originY explicitly mentions this
(https://doc.qt.io/qt-6/qml-qtquick-flickable.html#originY-prop):
"originY : real
[...]
This is usually (0,0), however ListView and GridView may have an
arbitrary origin due to delegate size variation, or item
insertion/removal outside the visible region."
This can also be reproduced without any transitions, so assuming that
the y coordinate of the first item is always 0 should therefore strictly
not be part of a test intended for transitions.
Pick-to: 6.7 6.8
Fixes: QTBUG-123894
Change-Id: Idc63cd385ed62936d9e45e31fcf3f725ee4405c4
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
In case the sections are displayed using ViewSection.CurrentLabelAtStart,
the section size should be taken into account while snapping the items.
This patch extends the fixup() method to perform such checks.
The drawback of this approach is that the position adjustment takes
some time (because of the animation) and happens after the scrolling is
finished.
A better solution would be to fix the scrolling process in such a way,
that no adjustment is needed during fixup.
Fixes: QTBUG-30768
Pick-to: 6.8 6.7 6.5 6.2
Change-Id: I31a1a3af55afe8be4e8d7980cbb163622e3283bc
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
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: I26d72e8de04d4c7c57b3b7838af5d033265de5ba
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
The density of Q_FOREACH uses is high here, too high for this author,
unfamiliar with this code, to tackle in a short amount of time. But
they're concentrated in just a few TUs, so pick a different strategy:
Mark the whole module with QT_NO_FOREACH, to prevent new uses from
creeping in, and whitelist the affected TUs by #undef'ing
QT_NO_FOREACH locally, at the top of each file. For TUs that are part
of a larger executable, this requires these files to be compiled
separately, so add them to NO_PCH_SOURCES (which implies
NO_UNITY_BUILD_SOURCES, too). Created QTBUG-115808 to keep track of
this.
Task-number: QTBUG-115808
Change-Id: I29c377f939e3d747e3ce72c224c4ee722df7a95d
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Don't use QCOMPARE for a true/false test, use QVERIFY. This conveniently
fixes the (bogus, perhaps) compiler warning with MSVC about comparing
a quint32 (the underlying type of the polishScheduled bitfield) with a
bool.
Pick-to: 6.5
Change-Id: Ib273ee30906e09955e849e65af2b7ff8ce3e2512
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
The content position of list view is incorrect, if populate animation
is configured with BottomToTop or RightToLeft layout direction. This is
because, we are not setting internal position for first item in the
list view.
This patch will set correct internal postion to the first item in list
view.
Fixes: QTBUG-111050
Change-Id: I1a233a938e2c088d176d79871a08bcd2a8edd6b3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Renames the pressed() getter of the pressed property in QQuickMouseArea
to isPressed() to avoid overloading the pressed()-signal.
Signals should not be overloaded. Also, it makes code generation in
qmltc more complicated.
Task-number: QTBUG-110029
Change-Id: I2373f4fe97b1e955b815825003bc746f2eaf43be
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
We need to see the values when it fails. It turns out that the movement
can be exactly 100 on macOS, and that's also "more than just a couple
pixels" so it should be ok.
Pick-to: 6.5
Change-Id: I4dcdf647886dd5dcc7267a32b1dd9858fdccf64d
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
If we make flickDeceleration's default value platform-dependent and
often larger, this test begins failing because it expects to flick
all the way to the end of the ListView. If we flick a longer distance
(starting at the lower-right instead of in the middle of the ListView)
in the same time, it's more likely to get to the end.
An alternative would be to set flickDeceleration back to the old value
in this test.
Pick-to: 6.5
Change-Id: If85d9502ceef9fbf6fc087240572cc98326453a5
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
QQuickFlickable maxXExtent() and maxYExtent() return the amount of space
that is not shown when inside a ScrollView. QQuickItemView however just
returned width() if vertical and height() if horizontal. In these cases
just defer to the QQuickFlickable base implementation like minXExtent()
and minYExtent() already do.
Fixes: QTBUG-83890
Pick-to: 6.2 6.4
Change-Id: I7f4060c2f46ae07611bedceca0d322c5f7f6affb
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to
handle typedefs and accesses through pointers, too:
const std::string o = "object";
auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); };
auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) {
auto exprOfDeclaredType = [&](auto decl) {
return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o);
};
return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))));
};
auto renameMethod = [&] (ArrayRef<StringRef> classes,
StringRef from, StringRef to) {
return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)),
callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))),
changeTo(cat(access(o, cat(to)), "()")),
cat("use '", to, "' instead of '", from, "'"));
};
renameMethod(<classes>, "count", "size");
renameMethod(<classes>, "length", "size");
except that on() was replaced with a matcher that doesn't ignoreParens().
a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'.
Change-Id: I58e1b41b91c34d2e860dbb5847b3752edbfc6fc9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.
Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace.
Task-number: QTBUG-99313
Change-Id: I601bf70f020f511019ed28731ba53b14b765dbf0
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8:
auto QtContainerClass = anyOf(
expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o),
expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o));
makeRule(cxxMemberCallExpr(on(QtContainerClass),
callee(cxxMethodDecl(hasAnyName({"count", "length"),
parameterCountIs(0))))),
changeTo(cat(access(o, cat("size"), "()"))),
cat("use 'size()' instead of 'count()/length()'"))
a.k.a qt-port-to-std-compatible-api with config Scope: 'Container',
with the extended set of container classes recognized.
Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
After this patch, if a QQmlDataTest-derived class passes
FailOnWarningsPolicy::FailOnWarnings to the base constructor, any
non-empty warning encountered by that test will result in a test
failure.
This avoids the need to duplicate the catch-all regex in tests that
want to fail on warnings.
The goal is to gradually enable failure-on-warnings over time.
Leave comments and explicitly pass DoNotFailOnWarnings for tests that
should never fail on warnings.
Task-number: QTBUG-98718
Pick-to: 6.2 6.3 6.4
Change-Id: I4b647d93a0f28ac891c4bdb19ef74569f2918e8f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
Files that have to be modified by hand are modified.
License files are organized under LICENSES directory.
Pick-to: 6.4
Task-number: QTBUG-67283
Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
- Ensure that context properties outlive the view.
- Ensure that delegates don't unconditionally reference properties of
the parent (which may be null).
- Add missing TestObject and test model.
Task-number: QTBUG-98718
Pick-to: 6.2 6.3 6.4
Change-Id: Icaf3c6824674819c88fc7be51932e6d7e5fb205a
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This adds a qIsPolishScheduled(QQuickWindow *) overload of
qIsPolishScheduled(QQuickItem *) (added in
40d6072bc8) and deprecates
qWaitForItemPolished() (added in
7a3cad0619) in favor of qWaitForPolish(),
which has QQuickItem* and QQuickWindow* overloads.
The existing functions that take QQuickItem are useful, but testing
Qt Quick applications can be made even easier by allowing users to
check if a window has any items that need to be polished. This
information is already present (in QQuickWindowPrivate::itemsToPolish),
so it's very efficient to check for.
This is especially useful now that Qt Quick Layouts using polishing for
their layouting, for example, as it's no longer necessary to find
individual polishable items in complex hierarchies before proceeding
to interact with child items.
[ChangeLog][QtQuickTest][QQuickTest] Added
QQuickTest::qIsPolishScheduled(QQuickWindow *) and
QQuickTest::qWaitForPolish(QQuickWindow *) functions for verifying that
updatePolish() was called on one or more items managed by a window.
[ChangeLog][QtQuickTest][QQuickTest] Deprecated
QQuickTest::qWaitForItemPolished(QQuickItem *). Use the new
QQuickTest::qWaitForPolish(QQuickItem *) function instead.
Fixes: QTBUG-93757
Change-Id: I95b6e051b3c9fd2fa93604f4d9ccda486bb29f9d
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This reverts commit d9f9d773e9.
It causes a heap-use-after-free in tst_swipeview.qml.
Task-number: QTBUG-97423
Pick-to: 5.15 6.1 6.2
Change-Id: I42e9831ae1399a010df28c39496a7778121f5e35
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Previously each test would include and build sources from the shared
folder. Now we make those sources a library, build it once, then have
each test link to it instead.
We also take the opportunity to move some helpers that qtquickcontrols2
had added into the quicktestutils library where it makes sense, and
for the helpers that don't make sense to be there, move them into
quickcontrolstestutils.
We add the libraries to src/ so that they are internal modules built as
part of Qt, rather than tests. That way we can use them in a standalone
test outside of qtdeclarative.
Task-number: QTBUG-95621
Pick-to: 6.2
Change-Id: I0a2ab3976fdbff2e4414df7bdc0808f16453b80a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
For now this patch just tacks on another list type, but there may be a
better way to account for all types in the future.
This change also adds tst_qquicklistview2 to speed up development.
tst_QQuickListView is 10000 lines long, and compiling it
is slow (36 seconds on a 2016 i7 MacBook Pro). In addition, a similar
approach (creating a second test to avoid the slowness of a massive one)
already exists for QQuickItem tests.
Task-number: QTBUG-72906
Pick-to: 6.1
Change-Id: I05455a2f20978b07eb38591ab63e7d0fb7dac1ab
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This is separate from the fix, since the test is supposed to also be
merged into dev. (Where the fix was not needed)
Task-number: QTBUG-86567
Pick-to: 5.15
Change-Id: I2cf1a4b11eed4fe356588aeff322d3a432f0fe83
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
It only failed due to being in a "bad" sequence with other tests somehow.
Fixing by reordering is lame, but I can't find the actual reason that it
fails, so far.
Task-number: QTBUG-86729
Change-Id: I8450c2e4b3119326c8518a526801cd10e933dca0
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Change from the QVariant enum to the QMetaType enum and prefer typeId
over userType where possible
Change-Id: Ic89c55978d46cc23d23b8e9c82c475c0c220fae3
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Use streaming operators for debug/warnings to avoid qsizehint/int
conflicts.
Don't ignore return values from [[no_discard]] functions.
Don't copy elements from containers that return references.
Remove unused variables.
Change-Id: I7a0bef94a5e828bd8facee0c625ec48c3d1f1bdb
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Earlier we reimplemented the contains() method of ListView to prevent
dragging in an Overlay or Pullback header or footer. But in QQuickWindow
(QQuickWindowPrivate::pointerTargets()), an early check prevents
delivery of pointer events to an item that is clipped and for which
contains() returns false, and also to its children. In that case, the
header or footer no longer responds to a mouse event even if you put a
MouseArea in it.
Reverts 6ad3445f1e159d9beea936b66d267dcaacdc5d6c; reimplemented using
similar logic in a new QQuickListViewPrivate::wantsPointerEvent()
method, overriding QQuickFlickablePrivate::wantsPointerEvent(), which
is now checked in event-handling code in addition to checking the
interactive flag.
Done-with: Wang Chuan <ouchuanm@outlook.com>
Pick-to: 5.15
Task-number: QTBUG-74046
Fixes: QTBUG-85302
Change-Id: I9474f035d26b74ee36c0ac19e45a77de2e694bf1
Reviewed-by: Wang Chuan <ouchuanm@outlook.com>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Some platforms aren't registering their mouse devices yet, and we don't
want false failures in CI because of that, so just register a mouse,
even if it ends up being an extra one a lot of times.
Task-number: QTBUG-86729
Change-Id: Ia3a91e3d1e4fb8df90352555c9a7ec6ea18bf6fe
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
...and generally deal with changes immediately required after adding
QInputDevice and QPointingDevice.
Also fixed a few usages of deprecated accessors that weren't taken
care of in 212c2bffbb.
Task-number: QTBUG-46412
Task-number: QTBUG-69433
Task-number: QTBUG-72167
Change-Id: I93a2643162878afa216556f10808fd92e0b20071
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Amends a20132c326, which fixed a crash,
but also prevented the item from being culled. This is fixed by
narrowing the scope of the condition to affect only the caching related
part.
Fixes: QTBUG-84604
Pick-to: 5.15
Change-Id: I9b8a1a148d6538a18280475d89b87a4049ff3465
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
- Don't use context properties: a singleton is better
- Use required properties to declare dependendencies
- Rename to treeDelegateModelLayoutChange() to describe what it's testing
rather than just a bug number, and because it's somewhat analogous to
tst_QQuickPathView::treeModel()
Task-number: QTBUG-39492
Change-Id: I753bbdf625b8d8c82774b6a2b1754fe3c8895823
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
The evaluation callback does not have to perform the comparison anymore
and the shared pointer of the private is not used in the API anymore.
Also, the versionFunctions() has been moved out of QOpenGLContext
and renamed QOpenGLVersionFunctionsFactory::get().
QHash doesn't keep iterators stable under erase(), so clean up
the code relying on it, and avoid an intermediate QList at the
same time.
Task-number: QTBUG-74409
Change-Id: I90176be1067d88c8f2b1ea07198a06d432f5be9c
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This construction leaks the resulting character array. You need to
actually delete[] it. However, we can be pretty sure that there are no
questionable characters in those strings. Therefore we can just use
qPrintable instead.
Change-Id: Ib863f0ed7db800680a44df534e3b46a4ba807798
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
We should check for the window's root item before accessing it.
Change-Id: I196d9cb4d0e525ffb62b3fd347fd986033cab3dd
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
We can use it as model passed via a context property as shown in the
objectlistmodel example. We should also be able to pass it directly
then.
Change-Id: I55db74df969d8024553d9470f1afe4710e61b1bf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>