Well, after following the link Volker gave me (http://code.woboq.org/kde/qt4/src/) and looking at the code related to removing/deleting QGraphicsItem-s I admit my guess was too random. :)
On 11/29/2012 06:53 PM, Constantin Makshin wrote: > QGraphicsScene::removeItem() documentation says "Removes the item item > and all its children from the scene." > > So here is my random guess: > You remove an item which has at least one child. Some time later you > call QGraphicsScene::removeItem() on one of its children and, since it's > not part of the scene anymore, get a crash. > > I can't check this guess because Gitorious doesn't want to show the > contents of qgraphicsscene.cpp and I'm too lazy to download the whole Qt > tarball. :) > > On 11/29/2012 03:33 PM, 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@qt-project.org >> http://lists.qt-project.org/mailman/listinfo/interest
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest