From f986c0c3390ba7d033b6e6276f63dcd4818adb5c Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Thu, 29 Sep 2016 17:35:31 +0200 Subject: Fix crash on cancel QQuickImageResponse We don't need to deleteLater here, we can not be sure that the response won't continue for a bit after this, and it's not even needed since documentation says you need to emit finished in all cases and this will call deleteLater on the response anyway. Task-number: QTBUG-56056 Change-Id: I7cc90620f499beaaaaa61aac77d72d067308838c Reviewed-by: Michael Brasser --- src/quick/util/qquickimageprovider.cpp | 2 ++ src/quick/util/qquickpixmapcache.cpp | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/quick/util/qquickimageprovider.cpp b/src/quick/util/qquickimageprovider.cpp index d11229717a..9ed38f72c6 100644 --- a/src/quick/util/qquickimageprovider.cpp +++ b/src/quick/util/qquickimageprovider.cpp @@ -181,6 +181,8 @@ QString QQuickImageResponse::errorString() const This method is used to communicate that the response is no longer required by the engine. It may be reimplemented to cancel a request in the provider side, however, it is not mandatory. + + A cancelled QQuickImageResponse still needs to emit finished(). */ void QQuickImageResponse::cancel() { diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp index 230c31807c..50b6de25fb 100644 --- a/src/quick/util/qquickpixmapcache.cpp +++ b/src/quick/util/qquickpixmapcache.cpp @@ -584,7 +584,6 @@ void QQuickPixmapReader::processJobs() if (asyncResponse) { asyncResponses.remove(asyncResponse); asyncResponse->cancel(); - asyncResponse->deleteLater(); } } PIXMAP_PROFILE(pixmapStateChanged(job->url)); -- cgit v1.2.3 From f08270439fb34925d0e5510983f9964369eabba3 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 14 Sep 2016 15:41:18 +0200 Subject: Flickable: add a trackpad (touchpad) autotest We've had this feature for a long time, to use pixel deltas and scroll phase effectively, but no autotest until now. It's still not very thorough but it's a start. Task-number: QTBUG-55871 Change-Id: Iaf6e7a842ce90828da3253e8673cac9905abd046 Reviewed-by: J-P Nurmi --- .../quick/qquickflickable/tst_qquickflickable.cpp | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp index 7de0a0fa0e..da3d8c41e2 100644 --- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp +++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp @@ -74,6 +74,7 @@ private slots: void returnToBounds(); void returnToBounds_data(); void wheel(); + void trackpad(); void movingAndFlicking(); void movingAndFlicking_data(); void movingAndDragging(); @@ -768,6 +769,50 @@ void tst_qquickflickable::wheel() QCOMPARE(flick->property("movementsAfterEnd").value(), 0); // QTBUG-55886 } +void tst_qquickflickable::trackpad() +{ + QScopedPointer window(new QQuickView); + window->setSource(testFileUrl("wheel.qml")); + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window.data())); + QVERIFY(window->rootObject() != 0); + + QQuickFlickable *flick = window->rootObject()->findChild("flick"); + QVERIFY(flick != 0); + QSignalSpy moveEndSpy(flick, SIGNAL(movementEnded())); + QPoint pos(200, 200); + + { + QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(0,-100), QPoint(0,-120), -120, Qt::Vertical, Qt::NoButton, Qt::NoModifier, Qt::ScrollBegin); + event.setAccepted(false); + QGuiApplication::sendEvent(window.data(), &event); + } + + QTRY_VERIFY(flick->contentY() > 0); + QCOMPARE(flick->contentX(), qreal(0)); + + flick->setContentY(0); + QCOMPARE(flick->contentY(), qreal(0)); + + { + QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(-100,0), QPoint(-120,0), -120, Qt::Horizontal, Qt::NoButton, Qt::NoModifier, Qt::ScrollUpdate); + event.setAccepted(false); + QGuiApplication::sendEvent(window.data(), &event); + } + + QTRY_VERIFY(flick->contentX() > 0); + QCOMPARE(flick->contentY(), qreal(0)); + + { + QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(0,0), QPoint(0,0), 0, Qt::Horizontal, Qt::NoButton, Qt::NoModifier, Qt::ScrollEnd); + event.setAccepted(false); + QGuiApplication::sendEvent(window.data(), &event); + } + + QTRY_COMPARE(moveEndSpy.count(), 1); // QTBUG-55871 + QCOMPARE(flick->property("movementsAfterEnd").value(), 0); // QTBUG-55886 +} + void tst_qquickflickable::movingAndFlicking_data() { QTest::addColumn("verticalEnabled"); -- cgit v1.2.3 From 643d75e3ff2f8cbe60eeff2084fb6ec3fcb096a0 Mon Sep 17 00:00:00 2001 From: Frederik Schwarzer Date: Wed, 21 Sep 2016 16:13:00 +0200 Subject: QQuickRectangle: fix typo in apidoc Change-Id: Ib026302143df82196fdfd70b9ea9923098adbc7c Reviewed-by: Robin Burchell --- src/quick/items/qquickrectangle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/quick/items/qquickrectangle.cpp b/src/quick/items/qquickrectangle.cpp index eb17187ad5..ab22fceee1 100644 --- a/src/quick/items/qquickrectangle.cpp +++ b/src/quick/items/qquickrectangle.cpp @@ -360,7 +360,7 @@ QQuickPen *QQuickRectangle::border() The gradient to use to fill the rectangle. This property allows for the construction of simple vertical gradients. - Other gradients may by formed by adding rotation to the rectangle. + Other gradients may be formed by adding rotation to the rectangle. \div {class="float-left"} \inlineimage declarative-rect_gradient.png -- cgit v1.2.3 From 55b3d76671090da348d63a89417ea73dab5d315d Mon Sep 17 00:00:00 2001 From: Frederik Schwarzer Date: Fri, 23 Sep 2016 13:47:40 +0200 Subject: QQuickPositioners: fix sentence structure in apidoc Change-Id: I14eb860386dfad57ab8cf492cb782970497756b9 Reviewed-by: Robin Burchell --- src/quick/items/qquickpositioners.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/quick/items/qquickpositioners.cpp b/src/quick/items/qquickpositioners.cpp index de2596b679..8f690c03d4 100644 --- a/src/quick/items/qquickpositioners.cpp +++ b/src/quick/items/qquickpositioners.cpp @@ -866,7 +866,7 @@ void QQuickPositionerAttached::setIsLastItem(bool isLastItem) the item that is being added. See the \l ViewTransition documentation for more details and examples on using these transitions. - \note This transition is not applied to the items that already part of the positioner + \note This transition is not applied to the items that are already part of the positioner at the time of its creation. In this case, the \l populate transition is applied instead. \sa populate, ViewTransition, {Qt Quick Examples - Positioners} @@ -1033,7 +1033,7 @@ void QQuickColumn::reportConflictingAnchors() the item that is being added. See the \l ViewTransition documentation for more details and examples on using these transitions. - \note This transition is not applied to the items that already part of the positioner + \note This transition is not applied to the items that are already part of the positioner at the time of its creation. In this case, the \l populate transition is applied instead. \sa populate, ViewTransition, {Qt Quick Examples - Positioners} @@ -1301,7 +1301,7 @@ void QQuickRow::reportConflictingAnchors() the item that is being added. See the \l ViewTransition documentation for more details and examples on using these transitions. - \note This transition is not applied to the items that already part of the positioner + \note This transition is not applied to the items that are already part of the positioner at the time of its creation. In this case, the \l populate transition is applied instead. \sa populate, ViewTransition, {Qt Quick Examples - Positioners} @@ -1876,7 +1876,7 @@ void QQuickGrid::reportConflictingAnchors() the item that is being added. See the \l ViewTransition documentation for more details and examples on using these transitions. - \note This transition is not applied to the items that already part of the positioner + \note This transition is not applied to the items that are already part of the positioner at the time of its creation. In this case, the \l populate transition is applied instead. \sa populate, ViewTransition, {Qt Quick Examples - Positioners} -- cgit v1.2.3 From 4d375f3f2b95bfcb322402df3525db6cc7a723ce Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Tue, 4 Oct 2016 11:42:10 +0200 Subject: QML: Clear weak references on Object destruction for C++-owned QObjects Otherwise a re-use of the C++-owned QObject will have a back reference to a possibly GCed QV4::QObjectWrapper, which results in exciting behavior. Task-number: QTBUG-46263 Change-Id: Iff0e36f9e67c01abd02cfb5a89605d0f26ddb0de Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4qobjectwrapper.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 246df4c4e9..77de84bf90 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -1042,6 +1042,10 @@ void QObjectWrapper::destroyObject(bool lastCall) delete h->object; else h->object->deleteLater(); + } else { + // If the object is C++-owned, we still have to release the weak reference we have + // to it. + ddata->jsWrapper.clear(); } } } -- cgit v1.2.3 From 9182797dec1897cda4e2e0368a16ddbd5c18b031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 20 Mar 2015 13:46:43 +0100 Subject: Canvas: Implement high-DPI render mode Scale the canvas image and texture buffer by the target devicePixelRatio. Task-number: QTBUG-37095 Change-Id: Ic432b278caa5c85cf3487d3108967cf3fcd2fa48 Reviewed-by: Shawn Rutledge --- src/quick/items/context2d/qquickcontext2dtexture.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/quick/items/context2d/qquickcontext2dtexture.cpp b/src/quick/items/context2d/qquickcontext2dtexture.cpp index 5ac971dc7d..78c526b299 100644 --- a/src/quick/items/context2d/qquickcontext2dtexture.cpp +++ b/src/quick/items/context2d/qquickcontext2dtexture.cpp @@ -538,6 +538,9 @@ QPaintDevice* QQuickContext2DFBOTexture::beginPainting() { QQuickContext2DTexture::beginPainting(); + const qreal devicePixelRatio = (m_item && m_item->window()) ? + m_item->window()->effectiveDevicePixelRatio() : qApp->devicePixelRatio(); + if (m_canvasWindow.size().isEmpty()) { delete m_fbo; delete m_multisampledFbo; @@ -552,7 +555,7 @@ QPaintDevice* QQuickContext2DFBOTexture::beginPainting() delete m_paint_device; m_paint_device = 0; - m_fboSize = npotAdjustedSize(m_canvasWindow.size()); + m_fboSize = npotAdjustedSize(m_canvasWindow.size() * devicePixelRatio); m_canvasWindowChanged = false; if (doMultisampling()) { @@ -590,6 +593,7 @@ QPaintDevice* QQuickContext2DFBOTexture::beginPainting() QOpenGLPaintDevice *gl_device = new QOpenGLPaintDevice(m_fbo->size()); gl_device->setPaintFlipped(true); gl_device->setSize(m_fbo->size()); + gl_device->setDevicePixelRatio(devicePixelRatio); m_paint_device = gl_device; } @@ -694,8 +698,12 @@ QPaintDevice* QQuickContext2DImageTexture::beginPainting() if (m_canvasWindow.size().isEmpty()) return 0; + const qreal devicePixelRatio = (m_item && m_item->window()) ? + m_item->window()->effectiveDevicePixelRatio() : qApp->devicePixelRatio(); + if (m_canvasWindowChanged) { - m_image = QImage(m_canvasWindow.size(), QImage::Format_ARGB32_Premultiplied); + m_image = QImage(m_canvasWindow.size() * devicePixelRatio, QImage::Format_ARGB32_Premultiplied); + m_image.setDevicePixelRatio(devicePixelRatio); m_image.fill(0x00000000); m_canvasWindowChanged = false; } -- cgit v1.2.3 From 59e48836e207aff52b2727cc4f3733209475e8bb Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Tue, 2 Aug 2016 13:25:35 +0200 Subject: Use QElapsedTimer instead of QTime to measure elapsed time Getting the current time from QTime is expensive as it adheres to the locale timezone. To measure elapsed time in a code block, using the monotonic QElapsedTimer is much faster. Change-Id: Ibea390d7bc5270a20cf35111dfc919e37be7001e Reviewed-by: Simon Hausmann --- src/qml/memory/qv4mm.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp index 4592dd5c9b..2588d8db00 100644 --- a/src/qml/memory/qv4mm.cpp +++ b/src/qml/memory/qv4mm.cpp @@ -40,7 +40,7 @@ #include "PageAllocation.h" #include "StdLibExtras.h" -#include +#include #include #include @@ -562,18 +562,17 @@ void MemoryManager::runGC() } else { const size_t totalMem = getAllocatedMem(); - QTime t; + QElapsedTimer t; t.start(); mark(); - int markTime = t.elapsed(); - t.restart(); + qint64 markTime = t.restart(); const size_t usedBefore = getUsedMem(); const size_t largeItemsBefore = getLargeItemsMem(); int chunksBefore = m_d->heapChunks.size(); sweep(); const size_t usedAfter = getUsedMem(); const size_t largeItemsAfter = getLargeItemsMem(); - int sweepTime = t.elapsed(); + qint64 sweepTime = t.elapsed(); qDebug() << "========== GC =========="; qDebug() << "Marked object in" << markTime << "ms."; -- cgit v1.2.3