summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@nokia.com>2010-04-21 11:24:27 (GMT)
committerSamuli Piippo <samuli.piippo@digia.com>2011-06-09 10:05:43 (GMT)
commit13945c8d65c4a3ad9a4088785851dabcc0a25dcf (patch)
tree6e2c1a863f0cdf5f503aaa6214d59f26c90f8b17
parent998bd0db4e676bb19e958bc31aa4fbce7aa3100f (diff)
downloadQt-13945c8d65c4a3ad9a4088785851dabcc0a25dcf.zip
Qt-13945c8d65c4a3ad9a4088785851dabcc0a25dcf.tar.gz
Qt-13945c8d65c4a3ad9a4088785851dabcc0a25dcf.tar.bz2
Fixes wrong QGraphicsView's viewport cursor reset.
The cursor was reset even when it had not been previously saved. Autotest included. Task-number: QTBUG-7438 Reviewed-by: bnilsen (cherry picked from commit ad0c6b17cde4a3ce0041d1a54b96ccb5a6792520)
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp12
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp28
2 files changed, 35 insertions, 5 deletions
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index 23f2401..5f803b3 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -733,11 +733,13 @@ void QGraphicsViewPrivate::_q_unsetViewportCursor()
}
// Restore the original viewport cursor.
- hasStoredOriginalCursor = false;
- if (dragMode == QGraphicsView::ScrollHandDrag)
- viewport->setCursor(Qt::OpenHandCursor);
- else
- viewport->setCursor(originalCursor);
+ if (hasStoredOriginalCursor) {
+ hasStoredOriginalCursor = false;
+ if (dragMode == QGraphicsView::ScrollHandDrag)
+ viewport->setCursor(Qt::OpenHandCursor);
+ else
+ viewport->setCursor(originalCursor);
+ }
}
#endif
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index a831a44..59ec720 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -239,6 +239,7 @@ private slots:
void QTBUG_4151_clipAndIgnore_data();
void QTBUG_4151_clipAndIgnore();
void QTBUG_5859_exposedRect();
+ void QTBUG_7438_cursor();
};
void tst_QGraphicsView::initTestCase()
@@ -4085,5 +4086,32 @@ void tst_QGraphicsView::QTBUG_5859_exposedRect()
QCOMPARE(item.lastExposedRect, scene.lastBackgroundExposedRect);
}
+void tst_QGraphicsView::QTBUG_7438_cursor()
+{
+#ifndef QT_NO_CURSOR
+#if defined(Q_OS_WINCE)
+ QSKIP("Qt/CE does not have regular cursor support", SkipAll);
+#endif
+ QGraphicsScene scene;
+ QGraphicsItem *item = scene.addRect(QRectF(-10, -10, 20, 20));
+ item->setFlag(QGraphicsItem::ItemIsMovable);
+
+ QGraphicsView view(&scene);
+ view.setFixedSize(400, 400);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ QCOMPARE(view.viewport()->cursor().shape(), QCursor().shape());
+ view.viewport()->setCursor(Qt::PointingHandCursor);
+ QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor);
+ sendMouseMove(view.viewport(), view.mapFromScene(0, 0));
+ QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor);
+ sendMousePress(view.viewport(), view.mapFromScene(0, 0));
+ QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor);
+ sendMouseRelease(view.viewport(), view.mapFromScene(0, 0));
+ QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor);
+#endif
+}
+
QTEST_MAIN(tst_QGraphicsView)
#include "tst_qgraphicsview.moc"