summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsitem
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2010-05-12 05:12:34 (GMT)
committerAlexis Menard <alexis.menard@nokia.com>2010-05-12 05:19:20 (GMT)
commit798bdb4543f84d427659b950a3a1643ae4987b8b (patch)
tree3a68d27f9a5c4b5d2324e5ae1955df9cf4d65c3e /tests/auto/qgraphicsitem
parent29450fd82c2c8efdc296a051f6a8fac2bd3fa76a (diff)
downloadQt-798bdb4543f84d427659b950a3a1643ae4987b8b.zip
Qt-798bdb4543f84d427659b950a3a1643ae4987b8b.tar.gz
Qt-798bdb4543f84d427659b950a3a1643ae4987b8b.tar.bz2
Reset the dragDropItem to 0 when the item dies while dragging on top it.
If you drag something on top of an item and the former is deleted then we need to reset the dragDropItem pointer to 0. Task-number:KDE BUG 232182 Reviewed-by:leo
Diffstat (limited to 'tests/auto/qgraphicsitem')
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 81097be..5a5a821 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -45,6 +45,7 @@
#include <private/qtextcontrol_p.h>
#include <private/qgraphicsitem_p.h>
#include <private/qgraphicsview_p.h>
+#include <private/qgraphicsscene_p.h>
#include <QStyleOptionGraphicsItem>
#include <QAbstractTextDocumentLayout>
#include <QBitmap>
@@ -447,6 +448,7 @@ private slots:
void QT_2649_focusScope();
void sortItemsWhileAdding();
void doNotMarkFullUpdateIfNotInScene();
+ void itemDiesDuringDraggingOperation();
private:
QList<QGraphicsItem *> paintedItems;
@@ -10484,5 +10486,27 @@ void tst_QGraphicsItem::doNotMarkFullUpdateIfNotInScene()
QTRY_COMPARE(item3->painted, 3);
}
+void tst_QGraphicsItem::itemDiesDuringDraggingOperation()
+{
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ QGraphicsRectItem *item = new QGraphicsRectItem(QRectF(0, 0, 100, 100));
+ item->setFlag(QGraphicsItem::ItemIsMovable);
+ item->setAcceptDrops(true);
+ scene.addItem(item);
+ view.show();
+ QApplication::setActiveWindow(&view);
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(QApplication::activeWindow(), (QWidget *)&view);
+ QGraphicsSceneDragDropEvent dragEnter(QEvent::GraphicsSceneDragEnter);
+ dragEnter.setScenePos(item->boundingRect().center());
+ QApplication::sendEvent(&scene, &dragEnter);
+ QGraphicsSceneDragDropEvent event(QEvent::GraphicsSceneDragMove);
+ event.setScenePos(item->boundingRect().center());
+ QApplication::sendEvent(&scene, &event);
+ QVERIFY(QGraphicsScenePrivate::get(&scene)->dragDropItem == item);
+ delete item;
+ QVERIFY(QGraphicsScenePrivate::get(&scene)->dragDropItem == 0);
+}
QTEST_MAIN(tst_QGraphicsItem)
#include "tst_qgraphicsitem.moc"