c++ - Crash after QGraphicsScene::removeItem() with custom item class -


i populating qgraphicsscene instances of custom item class (inherting qgraphicspathitem). @ point during runtime, try remove item (plus children) scene calling:

delete pitem; 

this automatically calls qgraphicsscene::removeitem(), leads crash in class qgraphicsscenefinditembsptreevisitor during next repaint.

tl;dr: solution ensure qgraphicsitem::preparegeometrychange() gets called before item's removal scene.


the problem during item removal scene, scene internal index not updated, resulting in crash upon next attempt of drawing scene.

since in case, use custom subclass qgraphicspathitem, put call qgraphicsitem::preparegeometrychange() destructor since not manually removing item scene (via qgraphicsscene::removeitem()), instead call delete pitem; in return triggers item's destructor removeitem() later on.


Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -