273 void initialFocus(); |
273 void initialFocus(); |
274 void polishItems(); |
274 void polishItems(); |
275 void polishItems2(); |
275 void polishItems2(); |
276 void isActive(); |
276 void isActive(); |
277 void siblingIndexAlwaysValid(); |
277 void siblingIndexAlwaysValid(); |
|
278 void removeFullyTransparentItem(); |
278 |
279 |
279 // task specific tests below me |
280 // task specific tests below me |
280 void task139710_bspTreeCrash(); |
281 void task139710_bspTreeCrash(); |
281 void task139782_containsItemBoundingRect(); |
282 void task139782_containsItemBoundingRect(); |
282 void task176178_itemIndexMethodBreaksSceneRect(); |
283 void task176178_itemIndexMethodBreaksSceneRect(); |
4331 |
4332 |
4332 //We should not crash |
4333 //We should not crash |
4333 |
4334 |
4334 } |
4335 } |
4335 |
4336 |
|
4337 void tst_QGraphicsScene::removeFullyTransparentItem() |
|
4338 { |
|
4339 QGraphicsScene scene; |
|
4340 |
|
4341 QGraphicsItem *parent = scene.addRect(0, 0, 100, 100); |
|
4342 parent->setFlag(QGraphicsItem::ItemHasNoContents); |
|
4343 |
|
4344 QGraphicsItem *child = scene.addRect(0, 0, 100, 100); |
|
4345 child->setParentItem(parent); |
|
4346 |
|
4347 CustomView view; |
|
4348 view.setScene(&scene); |
|
4349 view.show(); |
|
4350 QTest::qWaitForWindowShown(&view); |
|
4351 |
|
4352 // NB! The parent has the ItemHasNoContents flag set, which means |
|
4353 // the parent itself doesn't generate any update requests, only the |
|
4354 // child can possibly trigger an update. Also note that the child |
|
4355 // is removed before processing events. |
|
4356 view.repaints = 0; |
|
4357 parent->setOpacity(0); |
|
4358 QVERIFY(qFuzzyIsNull(child->effectiveOpacity())); |
|
4359 scene.removeItem(child); |
|
4360 QVERIFY(!scene.items().contains(child)); |
|
4361 QTRY_VERIFY(view.repaints > 0); |
|
4362 |
|
4363 // Re-add child. There's nothing new to display (child is still |
|
4364 // effectively hidden), so it shouldn't trigger an update. |
|
4365 view.repaints = 0; |
|
4366 child->setParentItem(parent); |
|
4367 QVERIFY(scene.items().contains(child)); |
|
4368 QVERIFY(qFuzzyIsNull(child->effectiveOpacity())); |
|
4369 QApplication::processEvents(); |
|
4370 QCOMPARE(view.repaints, 0); |
|
4371 |
|
4372 // Nothing is visible on the screen, removing child item shouldn't trigger an update. |
|
4373 scene.removeItem(child); |
|
4374 QApplication::processEvents(); |
|
4375 QCOMPARE(view.repaints, 0); |
|
4376 delete child; |
|
4377 } |
|
4378 |
4336 void tst_QGraphicsScene::taskQTBUG_5904_crashWithDeviceCoordinateCache() |
4379 void tst_QGraphicsScene::taskQTBUG_5904_crashWithDeviceCoordinateCache() |
4337 { |
4380 { |
4338 QGraphicsScene scene; |
4381 QGraphicsScene scene; |
4339 QGraphicsRectItem *rectItem = scene.addRect(QRectF(0, 0, 100, 200), QPen(Qt::black), QBrush(Qt::green)); |
4382 QGraphicsRectItem *rectItem = scene.addRect(QRectF(0, 0, 100, 200), QPen(Qt::black), QBrush(Qt::green)); |
4340 |
4383 |