From 9dcec8f016c1fdd9d0e99e0ee717523a8823bca7 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 12 Jul 2019 07:19:50 +0200 Subject: Fix static build Use the GL attribute name helper functions only from QtQuick to avoid a clash of symbols when linking statically. Change-Id: Ic95b984092f5db222db6dc1f4ac5fb443b5ab714 Fixes: QTBUG-77012 Reviewed-by: Andy Shaw --- src/imports/wavefrontmesh/qwavefrontmesh.cpp | 13 ------------- src/quick/items/qquickshadereffectmesh_p.h | 4 ++-- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/src/imports/wavefrontmesh/qwavefrontmesh.cpp b/src/imports/wavefrontmesh/qwavefrontmesh.cpp index 101e6ab4b0..e973ef0103 100644 --- a/src/imports/wavefrontmesh/qwavefrontmesh.cpp +++ b/src/imports/wavefrontmesh/qwavefrontmesh.cpp @@ -53,19 +53,6 @@ QT_BEGIN_NAMESPACE -static const char qt_position_attribute_name[] = "qt_Vertex"; -static const char qt_texcoord_attribute_name[] = "qt_MultiTexCoord0"; - -const char *qtPositionAttributeName() -{ - return qt_position_attribute_name; -} - -const char *qtTexCoordAttributeName() -{ - return qt_texcoord_attribute_name; -} - class QWavefrontMeshPrivate : public QObjectPrivate { public: diff --git a/src/quick/items/qquickshadereffectmesh_p.h b/src/quick/items/qquickshadereffectmesh_p.h index 62a9798e40..79e05a5f9f 100644 --- a/src/quick/items/qquickshadereffectmesh_p.h +++ b/src/quick/items/qquickshadereffectmesh_p.h @@ -66,8 +66,8 @@ QT_REQUIRE_CONFIG(quick_shadereffect); QT_BEGIN_NAMESPACE -const char *qtPositionAttributeName(); -const char *qtTexCoordAttributeName(); +Q_QUICK_PRIVATE_EXPORT const char *qtPositionAttributeName(); +Q_QUICK_PRIVATE_EXPORT const char *qtTexCoordAttributeName(); class QSGGeometry; class QRectF; -- cgit v1.2.3 From 141ffbe37e9263829a156fc1f4d7b93a2bf311be Mon Sep 17 00:00:00 2001 From: Pavel Tumakaev Date: Wed, 22 May 2019 17:32:25 +0300 Subject: Fix crashes in QQmlXMLHttpRequest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ExecutionEngine::callingQmlContext() in some cases returns a null pointer. According to ISO/IEC 14882 ยง9.3.1/1 "If a nonstatic member function of a class X is called for an object that is not of type X, or of a type derived from X, the behavior is undefined". Thus, invoking a QQmlContextData::resolvedUrl() member function on a null instance results in undefined behavior, and leads to a crash in some cases. ExecutionEngine::qmlEngine() in some cases returns a null pointer. The QQmlEnginePrivate::get() method must return a pointer to a QQmlEngine private internal class. Call QQmlEnginePrivate::get() with passed null pointer leads to application crash. If the QQmlEngine pointer is null, the QQmlEnginePrivate pointer should also be null. Thus, if the pointer to QQmlEngine is null pointer, the null pointer to the private class should be passed to the QQmlEnginePrivate::warning(). Task-number: QTBUG-75983 Change-Id: Iad240bb6db0be58e9087b7a86f8d400b07623865 Reviewed-by: Ulf Hermann --- src/qml/qml/qqmlxmlhttprequest.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index 9f629f974d..9877cc027f 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -1574,7 +1574,8 @@ void QQmlXMLHttpRequest::dispatchCallbackNow(Object *thisObj, bool done, bool er if (scope.engine->hasException) { QQmlError error = scope.engine->catchExceptionAsQmlError(); - QQmlEnginePrivate::warning(QQmlEnginePrivate::get(scope.engine->qmlEngine()), error); + QQmlEnginePrivate *qmlEnginePrivate = scope.engine->qmlEngine() ? QQmlEnginePrivate::get(scope.engine->qmlEngine()) : nullptr; + QQmlEnginePrivate::warning(qmlEnginePrivate, error); } }; @@ -1765,8 +1766,13 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_open(const FunctionObject *b, const // Argument 1 - URL QUrl url = QUrl(argv[1].toQStringNoThrow()); - if (url.isRelative()) - url = scope.engine->callingQmlContext()->resolvedUrl(url); + if (url.isRelative()) { + QQmlContextData *qmlContextData = scope.engine->callingQmlContext(); + if (qmlContextData) + url = qmlContextData->resolvedUrl(url); + else + url = scope.engine->resolvedUrl(url.url()); + } bool async = true; // Argument 2 - async (optional) -- cgit v1.2.3 From f806d64249c6e961ab12270d3a045e9980e19cf4 Mon Sep 17 00:00:00 2001 From: Wang Chuan Date: Thu, 11 Jul 2019 10:24:38 +0800 Subject: QQuickItemView: refill itself before populate transition The view uses a visible items list, which is maintained by the refill() method, to determine which items should be triggered to do the populate transition. The refill() was only invoked when component completed before doing the populate transition; but if the size of the view depends on the size of window (for example, using anchors.fill), more delegates could become visible after component completed. In such a case, part of visible items were not be triggered to do the transition. [ChangeLog][QtQuick][Item Views] Item views such as ListView now properly populate delegates with a populate transition when the view is resized after componentComplete. Fixes: QTBUG-76487 Change-Id: Id90c3f73d9911c8a1d6d8b1ea0c51f6c27d0ed5b Reviewed-by: Shawn Rutledge --- src/quick/items/qquickitemview.cpp | 3 + .../data/resizeAfterComponentComplete.qml | 77 ++++++++++++++++++++++ .../quick/qquicklistview/tst_qquicklistview.cpp | 16 +++++ 3 files changed, 96 insertions(+) create mode 100644 tests/auto/quick/qquicklistview/data/resizeAfterComponentComplete.qml diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp index d0715cdb7f..21d644dad5 100644 --- a/src/quick/items/qquickitemview.cpp +++ b/src/quick/items/qquickitemview.cpp @@ -1845,6 +1845,9 @@ void QQuickItemViewPrivate::layout() forceLayout = false; if (transitioner && transitioner->canTransition(QQuickItemViewTransitioner::PopulateTransition, true)) { + // Give the view one more chance to refill itself, + // in case its size is changed such that more delegates become visible after component completed + refill(); for (FxViewItem *item : qAsConst(visibleItems)) { if (!item->transitionScheduledOrRunning()) item->transitionNextReposition(transitioner, QQuickItemViewTransitioner::PopulateTransition, true); diff --git a/tests/auto/quick/qquicklistview/data/resizeAfterComponentComplete.qml b/tests/auto/quick/qquicklistview/data/resizeAfterComponentComplete.qml new file mode 100644 index 0000000000..851d8f9a0c --- /dev/null +++ b/tests/auto/quick/qquicklistview/data/resizeAfterComponentComplete.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2019 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 + +ListView { + id: listView + property var lastItem + anchors.fill: parent + model: 10 + delegate: Rectangle { + width: parent.width + height: 40 + border.color: "lightsteelblue" + Text { + text: "Item" + (index + 1) + } + Component.onCompleted: { + if (index == 9) + listView.lastItem = this + } + } + + populate: Transition { + NumberAnimation { + properties: "x,y" + duration: 1000 + } + } +} diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp index cfd740f33d..d956d89292 100644 --- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp +++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp @@ -276,6 +276,7 @@ private slots: void addOnCompleted(); void setPositionOnLayout(); void touchCancel(); + void resizeAfterComponentComplete(); private: template void items(const QUrl &source); @@ -8994,6 +8995,21 @@ void tst_QQuickListView::touchCancel() // QTBUG-74679 QTRY_COMPARE(listview->contentY(), 500.0); } +void tst_QQuickListView::resizeAfterComponentComplete() // QTBUG-76487 +{ + QScopedPointer window(createView()); + window->setSource(testFileUrl("resizeAfterComponentComplete.qml")); + window->resize(640, 480); + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window.data())); + + QObject *listView = window->rootObject(); + QVERIFY(listView); + + QObject *lastItem = qvariant_cast(listView->property("lastItem")); + QTRY_COMPARE(lastItem->property("y").toInt(), 9 * lastItem->property("height").toInt()); +} + QTEST_MAIN(tst_QQuickListView) #include "tst_qquicklistview.moc" -- cgit v1.2.3