Hi,
I`ve got a situation that I`ve been trying to fix for a few days:
I have a scene that contains a single object derived from QGraphicsItem.
If I remove the object from the scene (calling QGraphicsScene::removeItem()) and then delete the pointer to the object, my program crashes later when the QGraphicsScene repaints.
Basically, it turns out the item I removed from the scene is still in the Qt's internal BSP tree representation of the scene. This happens even though a call to QGraphicsScene::items().count() (after deleting the item) returns 0.
- QGraphicsScene derefences the pointer to the object that has been removed and deleted.
If I don't delete the object (i.e. free the memory allocated to it) then QT still renders the object even though the scene is empty (QGraphicsScene::items().count() returns 0) !!!
Does anyone have any ideas what could cause this? Is QT performing reference counting or something.
Is it necessary to call another function to invalidate QT's BSP tree?
Sorry - there is too much code in the project to paste.
Bookmarks