aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/quick/demos/clocks/clocks.qmlproject8
-rw-r--r--src/quick/items/qquickflickable.cpp27
-rw-r--r--src/quick/items/qquickitemview.cpp4
-rw-r--r--src/quick/items/qquickmousearea.cpp1
-rw-r--r--sync.profile6
-rw-r--r--tests/auto/qmltest/events/tst_drag.qml10
-rw-r--r--tests/auto/quick/qquicklistview/data/emptymodel.qml23
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp16
-rw-r--r--tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp42
9 files changed, 89 insertions, 48 deletions
diff --git a/examples/quick/demos/clocks/clocks.qmlproject b/examples/quick/demos/clocks/clocks.qmlproject
new file mode 100644
index 0000000000..b15654600e
--- /dev/null
+++ b/examples/quick/demos/clocks/clocks.qmlproject
@@ -0,0 +1,8 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "clocks.qml"
+ QmlFiles { directory: "." }
+ JavaScriptFiles { directory: "." }
+ ImageFiles { directory: "." }
+}
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp
index 9346c79847..dd7357822a 100644
--- a/src/quick/items/qquickflickable.cpp
+++ b/src/quick/items/qquickflickable.cpp
@@ -1014,20 +1014,14 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event)
bool prevHMoved = hMoved;
bool prevVMoved = vMoved;
- bool moveY = false;
- bool moveX = false;
-
- qreal newY = 0;
- qreal newX = 0;
-
qint64 elapsedSincePress = computeCurrentTime(event) - lastPressTime;
if (q->yflick()) {
qreal dy = event->localPos().y() - pressPos.y();
bool overThreshold = QQuickWindowPrivate::dragOverThreshold(dy, Qt::YAxis, event);
- if (vData.dragStartOffset == 0)
- vData.dragStartOffset = dy;
if (overThreshold || elapsedSincePress > 200) {
- newY = dy + vData.pressPos - vData.dragStartOffset;
+ if (!vMoved)
+ vData.dragStartOffset = dy;
+ qreal newY = dy + vData.pressPos - vData.dragStartOffset;
// Recalculate bounds in case margins have changed, but use the content
// size estimate taken at the start of the drag in case the drag causes
// the estimate to be altered
@@ -1047,8 +1041,8 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event)
}
if (!rejectY && stealMouse && dy != 0.0) {
clearTimeline();
+ vData.move.setValue(newY);
vMoved = true;
- moveY = true;
}
if (!rejectY && overThreshold)
stealY = true;
@@ -1058,10 +1052,10 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event)
if (q->xflick()) {
qreal dx = event->localPos().x() - pressPos.x();
bool overThreshold = QQuickWindowPrivate::dragOverThreshold(dx, Qt::XAxis, event);
- if (hData.dragStartOffset == 0)
- hData.dragStartOffset = dx;
if (overThreshold || elapsedSincePress > 200) {
- newX = dx + hData.pressPos - hData.dragStartOffset;
+ if (!hMoved)
+ hData.dragStartOffset = dx;
+ qreal newX = dx + hData.pressPos - hData.dragStartOffset;
const qreal minX = hData.dragMinBound + hData.startMargin;
const qreal maxX = hData.dragMaxBound - hData.endMargin;
if (newX > minX)
@@ -1079,8 +1073,8 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event)
if (!rejectX && stealMouse && dx != 0.0) {
clearTimeline();
+ hData.move.setValue(newX);
hMoved = true;
- moveX = true;
}
if (!rejectX && overThreshold)
@@ -1108,11 +1102,6 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event)
q->movementStarting();
}
- if (moveY)
- vData.move.setValue(newY);
- if (moveX)
- hData.move.setValue(newX);
-
qint64 currentTimestamp = computeCurrentTime(event);
qreal elapsed = qreal(currentTimestamp - (lastPos.isNull() ? lastPressTime : lastPosTime)) / 1000.;
if (elapsed <= 0)
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp
index b9d508ec9d..72f892178f 100644
--- a/src/quick/items/qquickitemview.cpp
+++ b/src/quick/items/qquickitemview.cpp
@@ -249,10 +249,8 @@ QQuickItemView::~QQuickItemView()
QQuickItem *QQuickItemView::currentItem() const
{
Q_D(const QQuickItemView);
- if (!d->currentItem)
- return 0;
const_cast<QQuickItemViewPrivate*>(d)->applyPendingChanges();
- return d->currentItem->item;
+ return d->currentItem ? d->currentItem->item : 0;
}
QVariant QQuickItemView::model() const
diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp
index 2fa52d9ed2..ad0a265035 100644
--- a/src/quick/items/qquickmousearea.cpp
+++ b/src/quick/items/qquickmousearea.cpp
@@ -828,6 +828,7 @@ void QQuickMouseArea::mouseMoveEvent(QMouseEvent *event)
|| QQuickWindowPrivate::dragOverThreshold(dragPos.y() - startPos.y(), Qt::YAxis, event))) {
setKeepMouseGrab(true);
d->stealMouse = true;
+ d->startScene = event->windowPos();
}
d->moved = true;
diff --git a/sync.profile b/sync.profile
index 61d25bafa5..bddfd0f7f3 100644
--- a/sync.profile
+++ b/sync.profile
@@ -17,7 +17,7 @@
# - any git symbolic ref resolvable from the module's repository (e.g. "refs/heads/master" to track master branch)
#
%dependencies = (
- "qtbase" => "refs/heads/dev",
- "qtxmlpatterns" => "refs/heads/dev",
- "qtjsbackend" => "refs/heads/dev",
+ "qtbase" => "refs/heads/stable",
+ "qtxmlpatterns" => "refs/heads/stable",
+ "qtjsbackend" => "refs/heads/stable",
);
diff --git a/tests/auto/qmltest/events/tst_drag.qml b/tests/auto/qmltest/events/tst_drag.qml
index 7a17007495..70e0ea2096 100644
--- a/tests/auto/qmltest/events/tst_drag.qml
+++ b/tests/auto/qmltest/events/tst_drag.qml
@@ -47,6 +47,10 @@ Rectangle{
width:200
height:200
+ TestUtil {
+ id: util
+ }
+
Rectangle {
id:container
width:20
@@ -67,8 +71,8 @@ Rectangle{
when:windowShown
function test_mouseDrag() {
mouseDrag(container, 10, 10, 20, 30);
- compare(container.x, 20);
- compare(container.y, 30);
+ compare(container.x, 20 - util.dragThreshold - 1);
+ compare(container.y, 30 - util.dragThreshold - 1);
}
}
-} \ No newline at end of file
+}
diff --git a/tests/auto/quick/qquicklistview/data/emptymodel.qml b/tests/auto/quick/qquicklistview/data/emptymodel.qml
new file mode 100644
index 0000000000..16bcd3f9ae
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/emptymodel.qml
@@ -0,0 +1,23 @@
+import QtQuick 2.0
+Rectangle {
+ ListModel {
+ id: model
+ ListElement { name: "hello"}
+ }
+ ListView {
+ id: list
+ model: model
+ delegate: Item {
+ }
+ }
+ function remove() {
+ model.remove(0)
+ isCurrentItemNull = list.currentItem === null //check no seg fault
+ }
+
+ function add() {
+ model.append({name: "hello"})
+ isCurrentItemNull = list.currentItem === null
+ }
+ property bool isCurrentItemNull
+}
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index 65892ddd9b..f8c7de6635 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -207,6 +207,7 @@ private slots:
void parentBinding();
void defaultHighlightMoveDuration();
+ void accessEmptyCurrentItem_QTBUG_30227();
private:
template <class T> void items(const QUrl &source, bool forceLayout);
@@ -6814,6 +6815,21 @@ void tst_QQuickListView::defaultHighlightMoveDuration()
QCOMPARE(obj->property("highlightMoveDuration").toInt(), -1);
}
+void tst_QQuickListView::accessEmptyCurrentItem_QTBUG_30227()
+{
+ QQuickView *window = createView();
+ window->setSource(testFileUrl("emptymodel.qml"));
+
+ QQuickListView *listview = window->rootObject()->findChild<QQuickListView*>();
+ QTRY_VERIFY(listview != 0);
+
+ QMetaObject::invokeMethod(window->rootObject(), "remove");
+ QVERIFY(window->rootObject()->property("isCurrentItemNull").toBool());
+
+ QMetaObject::invokeMethod(window->rootObject(), "add");
+ QVERIFY(!window->rootObject()->property("isCurrentItemNull").toBool());
+}
+
QTEST_MAIN(tst_QQuickListView)
#include "tst_qquicklistview.moc"
diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
index 3c08b16168..fa33f3f626 100644
--- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
+++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
@@ -276,20 +276,22 @@ void tst_QQuickMouseArea::dragging()
// First move event triggers drag, second is acted upon.
// This is due to possibility of higher stacked area taking precedence.
-
+ // The item is moved relative to the position of the mouse when the drag
+ // was triggered, this prevents a sudden change in position when the drag
+ // threshold is exceeded.
QTest::mouseMove(window, QPoint(111,111), 50);
QTest::mouseMove(window, QPoint(116,116), 50);
QTest::mouseMove(window, QPoint(122,122), 50);
QTRY_VERIFY(drag->active());
- QTRY_COMPARE(blackRect->x(), 72.0);
- QCOMPARE(blackRect->y(), 72.0);
+ QTRY_COMPARE(blackRect->x(), 61.0);
+ QCOMPARE(blackRect->y(), 61.0);
QTest::mouseRelease(window, button, 0, QPoint(122,122));
QTRY_VERIFY(!drag->active());
- QCOMPARE(blackRect->x(), 72.0);
- QCOMPARE(blackRect->y(), 72.0);
+ QCOMPARE(blackRect->x(), 61.0);
+ QCOMPARE(blackRect->y(), 61.0);
delete window;
}
@@ -382,14 +384,14 @@ void tst_QQuickMouseArea::setDragOnPressed()
QTest::qWait(50);
QVERIFY(drag->active());
- QCOMPARE(target->x(), 72.0);
+ QCOMPARE(target->x(), 61.0);
QCOMPARE(target->y(), 50.0);
QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(122,122));
QTest::qWait(50);
QVERIFY(!drag->active());
- QCOMPARE(target->x(), 72.0);
+ QCOMPARE(target->x(), 61.0);
QCOMPARE(target->y(), 50.0);
delete window;
@@ -801,8 +803,8 @@ void tst_QQuickMouseArea::preventStealing()
// Flickable content should have moved.
- QCOMPARE(flickable->contentX(), 22.);
- QCOMPARE(flickable->contentY(), 22.);
+ QCOMPARE(flickable->contentX(), 11.);
+ QCOMPARE(flickable->contentY(), 11.);
QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50, 50));
@@ -1047,8 +1049,8 @@ void tst_QQuickMouseArea::disableAfterPress()
QTRY_COMPARE(mousePositionSpy.count(), 2);
QVERIFY(drag->active());
- QCOMPARE(blackRect->x(), 72.0);
- QCOMPARE(blackRect->y(), 72.0);
+ QCOMPARE(blackRect->x(), 61.0);
+ QCOMPARE(blackRect->y(), 61.0);
mouseArea->setEnabled(false);
@@ -1060,8 +1062,8 @@ void tst_QQuickMouseArea::disableAfterPress()
QTRY_COMPARE(mousePositionSpy.count(), 4);
QVERIFY(drag->active());
- QCOMPARE(blackRect->x(), 94.0);
- QCOMPARE(blackRect->y(), 94.0);
+ QCOMPARE(blackRect->x(), 83.0);
+ QCOMPARE(blackRect->y(), 83.0);
QVERIFY(mouseArea->pressed());
QVERIFY(mouseArea->hovered());
@@ -1071,8 +1073,8 @@ void tst_QQuickMouseArea::disableAfterPress()
QTRY_COMPARE(mouseReleaseSpy.count(), 1);
QVERIFY(!drag->active());
- QCOMPARE(blackRect->x(), 94.0);
- QCOMPARE(blackRect->y(), 94.0);
+ QCOMPARE(blackRect->x(), 83.0);
+ QCOMPARE(blackRect->y(), 83.0);
QVERIFY(!mouseArea->pressed());
QVERIFY(!mouseArea->hovered()); // since hover is not enabled
@@ -1343,25 +1345,25 @@ void tst_QQuickMouseArea::changeAxis()
QTest::mouseMove(view, QPoint(122, 122));
QTRY_VERIFY(drag->active());
- QCOMPARE(blackRect->x(), 72.0);
- QCOMPARE(blackRect->y(), 72.0);
+ QCOMPARE(blackRect->x(), 61.0);
+ QCOMPARE(blackRect->y(), 61.0);
QCOMPARE(drag->axis(), QQuickDrag::XAndYAxis);
/* When blackRect.x becomes bigger than 75, the drag axis is changed to
* Drag.YAxis by the QML code. Verify that this happens, and that the drag
* movement is effectively constrained to the Y axis. */
- QTest::mouseMove(view, QPoint(133, 133));
+ QTest::mouseMove(view, QPoint(144, 144));
QTRY_COMPARE(blackRect->x(), 83.0);
QTRY_COMPARE(blackRect->y(), 83.0);
QTRY_COMPARE(drag->axis(), QQuickDrag::YAxis);
- QTest::mouseMove(view, QPoint(144, 144));
+ QTest::mouseMove(view, QPoint(155, 155));
QTRY_COMPARE(blackRect->y(), 94.0);
QCOMPARE(blackRect->x(), 83.0);
- QTest::mouseRelease(view, Qt::LeftButton, 0, QPoint(144, 144));
+ QTest::mouseRelease(view, Qt::LeftButton, 0, QPoint(155, 155));
QTRY_VERIFY(!drag->active());
QCOMPARE(blackRect->x(), 83.0);