Hi
It has been fixed. Horray. A nice chap at Qt support saw the problem and luckily my example had made the problem worst. Anyway here it is:
// Note: if you reimplement the boundingRect() function
//of your QCanvasRectangle subclass and change the values this function
//returns while the item is visible, sure to call QCanvasPolygonalItem::invalidate().
// If you do not the QCanvas will use one bounding rectangle when adding the
// item to the chunks and a different one
//when removing, causing the internal list of items to still contain your
//item after it has been hidden. When the item is deleted, QCanvas still
//believes that the item is visible and uses the pointer and thus your
//program crashes. You will need to call
//invalidate() on the item if you do change it.
I did not realise from the Qt documentation overriding the boundRect() and changing the size would have this effect.
Cya Illya
I have seen the same problems about removing properly the QCanvasItem from the QCanvas. But I did not see the satisfying answer.
I have faced with the same problem. After two days, we found and solved the result as in the following.
When we try to delete the any items from the QCanvas by using the delete statement, we are facing the problem with resize or some thing like that which causes to call the update function of the QCanvas. In detail, it call the drawUnique() function. Anyway, althoug we delete the QCanvasItem from QCanvas, it stores another list which is a memeber of QCanvasChunk. That is, QCanvas uses another list in order to improve the its performance. It uses chunks which displays the changed items in the QCanvas. Therfore, we have to clear this list as well.
In order to do that, First, we can put setVisible(false) or hide() or invalidate() functions at the begining of the overloaded areaPoints() function. Then, we can add setVisible(true) or show() or update() functions at the end of the areaPoints() function.
setVisible() (or the others listed above) call to removeFromChunks() or addChunks() function. So any action which causes to call update function can not reason any conflists between the removed QCanvasItems and the internal list ( the list member of QCanvasChunk ) .
I think it should be a function of QCanvas which clear the chunks as well and it should be used in the destructor like hide as documented.
Best regards
Serhat
Bookmarks