[Interest] QGraphicsScene crash after removeItem() and delete item
Pierre Fillard
pierre.fillard at gmail.com
Thu Nov 29 23:04:36 CET 2012
It's a sign that you probably forgot to call:
QGraphicsItem::prepareGeometryChange()
when changing the bounding rect of your item. Calling this function tells
the scene to update its indexing, and allows a proper cleanup of the item
when calling scene->removeItem() (AFAIK).
Check in your code if you do update your item's bounding rect, and make
sure to call this function before.
HTH,
Pierre.
On Thu, Nov 29, 2012 at 12:33 PM, Volker Poplawski <volker at openbios.org>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
>
--
Pierre Fillard, Ph.D.,
Research Scientist
INRIA Saclay Ile-de-France
Bâtiment Alan Turing
1 rue Honoré d'Estienne d'Orves
Campus de l'École Polytechnique
91120 Palaiseau
tel: +33 1 72 92 59 62
INRIA Parietal - Neurospin
Bât 145, Point Courrier 156
91191 Gif/Yvette, France
tel: +33 1 69 08 79 92
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20121129/eeb60ecd/attachment.html>
More information about the Interest
mailing list