[Interest] QGraphicsScene crash after removeItem() and delete item
Guido Seifert
wargand at gmx.de
Thu Nov 29 17:17:01 CET 2012
QGraphicsItem is a QObject. To delete Objects with 'delete' is a
risky game. Better use deleteLater().
Guido
On Thu, Nov 29, 2012 at 12:33:58PM +0100, Volker Poplawski wrote:
> Hi everybody,
>
> I'm facing segfault in succession of deleting a number of
> QGraphicsItems from a scene.
>
> The following code leads to the stack trace below on the next redraw
> of the scene.
>
> while (not m_items.isEmpty()) { QGraphicsItem *item =
> m_items.takeFirst(); m_scene->removeItem(item); // qtdoc says it's
> faster to remove item first then delete delete item; }
>
>
> The interesting things is that without the removeItem() call, i.e.
> just calling delete on the items, my program does not crash.
>
>
>
>
>
>
> 0
> QGraphicsSceneFindItemBspTreeVisitor::visit(QList<QGraphicsItem*>*)
> 0x1075cff 1
> QGraphicsSceneBspTree::climbTree(QGraphicsSceneBspTreeVisitor*,
> QRectF const&, int) const 0x1074c40 2
> QGraphicsSceneBspTree::climbTree(QGraphicsSceneBspTreeVisitor*,
> QRectF const&, int) const 0x1074ce0 3
> QGraphicsSceneBspTree::climbTree(QGraphicsSceneBspTreeVisitor*,
> QRectF const&, int) const 0x1074c40 4
> QGraphicsSceneBspTree::climbTree(QGraphicsSceneBspTreeVisitor*,
> QRectF const&, int) const 0x1074c40 5
> QGraphicsSceneBspTree::climbTree(QGraphicsSceneBspTreeVisitor*,
> QRectF const&, int) const 0x1074c40 6
> QGraphicsSceneBspTree::climbTree(QGraphicsSceneBspTreeVisitor*,
> QRectF const&, int) const 0x1074c40 7
> QGraphicsSceneBspTree::climbTree(QGraphicsSceneBspTreeVisitor*,
> QRectF const&, int) const 0x1074c40 8
> QGraphicsSceneBspTree::climbTree(QGraphicsSceneBspTreeVisitor*,
> QRectF const&, int) const 0x1074c40 9
> QGraphicsSceneBspTree::climbTree(QGraphicsSceneBspTreeVisitor*,
> QRectF const&, int) const 0x1074ce0 10
> QGraphicsSceneBspTree::items(QRectF const&, bool) const 0x107539e
> 11 QGraphicsSceneBspTreeIndexPrivate::estimateItems(QRectF
> const&, Qt::SortOrder, bool) 0xf24058 12
> QGraphicsSceneBspTreeIndex::estimateTopLevelItems(QRectF
> const&, Qt::SortOrder) const 0xf24233 13
> QGraphicsScenePrivate::drawItems(QPainter*,
> QTransform const*, QRegion*, QWidget*) 0xf194ad 14
> QGraphicsView::paintEvent(QPaintEvent*) 0xf3505c 15
> QWidget::event(QEvent*) 0xa6941a 16 QFrame::event(QEvent*)
> 0xd81236 17 QGraphicsView::viewportEvent(QEvent*) 0xf362bb 18
> QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*,
> QEvent*) 0x11992b7 19 QApplicationPrivate::notify_helper(QObject*,
> QEvent*) 0xa240f1 20 QApplication::notify(QObject*, QEvent*)
> 0xa2c63f ... <More>
>
>
>
>
>
> ....Volker
> ____________________________________________________________________
> Interest mailing list Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
More information about the Interest
mailing list