QGraphicsSceneFindItemBspTreeVisitor::visit crashes due to an obsolete PaintEvent after QGraphicsScene::removeItem
-
Replying here, even though this thread is quite old ... I also ran into the same issue using PySide2. Disabling BSP indexing does indeed work for me, but is a sub-optimal solution because the scene that I'm working with can get arbitrarily large. I also tried to call update
prepareGeometryChange
before removing the item, and while that did seem to work for a while, the error re-appeared just a few weeks later.What worked for me (so far) is manually removing all child items before removing the item itself...
To that end, I am overwriting theQGraphicsScene::removeItem
method in Python:class GraphicsScene(QtWidgets.QGraphicsScene): def removeItem(self, item: QtWidgets.QGraphicsItem) -> None: for child_item in item.childItems(): super().removeItem(child_item) super().removeItem(item)
Note that this will not quite work the same in C++ because
QGraphicsScene::removeItem
is not a virtual method, so you will probably have to add your own methodremoveItemSafely
or whatever.Disclaimer: Other methods have worked for me as well ... until they didn't. I have not seen a crash in
QGraphicsSceneFindItemBspTreeVisitor::visit
since introducing this workaround, but that does not mean that this is actually the solution. Use at your own risk.