Sorry for incomplete post earlier.

I am not using qt 5, but if I am not mistaken QGraphicsScene code was
migrated from QT4,
so if assumption that no bug was introduced you do nothing wrong unless
deleting leads to the problem in the code you did not post ( using outdated
pointer for example )

I would suggest to create small compilable test case which demonstrate the
problem.

By the way you should be able to delete line below and effect should be the
same.
  scene.removeItem(food);

item will be removed as soon you delete it.

Alex


On Mon, Sep 23, 2013 at 3:46 PM, Alex Malyushytskyy <[email protected]>wrote:

> I am not using qt 5, but if I am not mistaken QGraphicsScene code was
> migrated from QT4
>
>
> On Sun, Sep 22, 2013 at 8:56 AM, 程梁 <[email protected]> wrote:
>
>> Hi, there! I have a problem: when I called QGraphicsScene::removeItem()
>> then delete the removed item, my application crashed. This happens on Qt5
>> 64bits (I tested on openSUSE with 5.1.1 and gcc 4.7.2) but not on Qt4.
>>
>> This is my code:
>>
>> void GameController::snakeAteFood(Snake *snake, Food *food)
>> {
>>     scene.removeItem(food);
>>     delete food;
>>
>>     addNewFood();
>> }
>>
>> If I remove the line "delete food;" everything is OK. But it will crash
>> with this line. The Food::boundingRect() will not change but
>> Snake::boundingRect() does so I did add prepareGeometryChange() function
>> before it changed. I've no idea why this still crashed. Please help me.
>>
>> Thank you!
>>
>> Cheng Liang
>> Nanjing, China
>> http://www.devbean.net
>>
>> _______________________________________________
>> Interest mailing list
>> [email protected]
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
>>
>
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to