summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2009-06-18 15:29:42 (GMT)
committerAlexis Menard <alexis.menard@nokia.com>2009-06-18 15:29:42 (GMT)
commita18e5288324aa13da014ee52daffbfc589c87be3 (patch)
treea36263a19092fd38ee783fb8c4df5349ed1e33ec /src/gui/graphicsview
parent378b5b603bd269b631bbe108268a683adde11828 (diff)
downloadQt-a18e5288324aa13da014ee52daffbfc589c87be3.zip
Qt-a18e5288324aa13da014ee52daffbfc589c87be3.tar.gz
Qt-a18e5288324aa13da014ee52daffbfc589c87be3.tar.bz2
Fix crash with untransformable items.
Be sure that item goes in the correct list if it set its flags to untransformable. Reviewed-by: andreas
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r--src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp43
1 files changed, 30 insertions, 13 deletions
diff --git a/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp b/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp
index 27b5514..72636b8 100644
--- a/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp
+++ b/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp
@@ -548,14 +548,9 @@ void QGraphicsSceneBspTreeIndexPrivate::removeFromBspTree(QGraphicsItem *item)
// ### remove from child index only if applicable
return;
}
- int index = item->d_func()->index;
- if (index != -1) {
- bsp.removeItem(item, item->sceneBoundingRect());
- freeItemIndexes << index;
- indexedItems[index] = 0;
- item->d_func()->index = -1;
- unindexedItems << item;
+ if (item->d_func()->index != -1) {
+ bsp.removeItem(item, item->sceneBoundingRect());
//prepareGeometryChange will call prepareBoundingRectChange
foreach (QGraphicsItem *child, item->children())
child->prepareGeometryChange();
@@ -570,10 +565,20 @@ void QGraphicsSceneBspTreeIndexPrivate::removeFromBspTree(QGraphicsItem *item)
void QGraphicsSceneBspTreeIndex::prepareBoundingRectChange(const QGraphicsItem *item)
{
Q_D(QGraphicsSceneBspTreeIndex);
- // Note: This will access item's sceneBoundingRect(), which (as this is
- // C++) is why we cannot call removeItem() from QGraphicsItem's
- // destructor.
- d->removeFromBspTree(const_cast<QGraphicsItem *>(item));
+ if (!item->d_ptr->itemIsUntransformable()) {
+ // Note: This will access item's sceneBoundingRect(), which (as this is
+ // C++) is why we cannot call removeItem() from QGraphicsItem's
+ // destructor.
+ QGraphicsItem *thatItem = const_cast<QGraphicsItem *>(item);
+ d->removeFromBspTree(thatItem);
+ int index = item->d_func()->index;
+ if (index != -1) {
+ d->freeItemIndexes << index;
+ d->indexedItems[index] = 0;
+ thatItem->d_func()->index = -1;
+ d->unindexedItems << thatItem;
+ }
+ }
}
/*!
@@ -725,7 +730,13 @@ void QGraphicsSceneBspTreeIndex::itemChange(const QGraphicsItem *item, QGraphics
if (ignoredTransform != willIgnoreTransform) {
QGraphicsItem *thatItem = const_cast<QGraphicsItem *>(item);
removeItem(thatItem);
- addItem(thatItem);
+ thatItem->d_ptr->index = -1;
+ if (willIgnoreTransform) {
+ d->untransformableItems << thatItem;
+ } else {
+ d->unindexedItems << thatItem;
+ d->startIndexTimer(0);
+ }
}
break;
}
@@ -741,7 +752,13 @@ void QGraphicsSceneBspTreeIndex::itemChange(const QGraphicsItem *item, QGraphics
if (ignoredTransform != willIgnoreTransform) {
QGraphicsItem *thatItem = const_cast<QGraphicsItem *>(item);
removeItem(thatItem);
- addItem(thatItem);
+ thatItem->d_ptr->index = -1;
+ if (willIgnoreTransform) {
+ d->untransformableItems << thatItem;
+ } else {
+ d->unindexedItems << thatItem;
+ d->startIndexTimer(0);
+ }
}
break;
}