[Qt-interest] Not able to delete a QGraphicsItem

Srdjan Todorovic todorovic.s at googlemail.com
Wed Apr 22 15:45:57 CEST 2009


Hi,

2009/4/22 Alexis Ménard <alexis.menard at trolltech.com>:
> On Wednesday 22 April 2009 14:45:32 Sujan Dasmahapatra wrote:
>> Dear Friends
>>
>> I have a QGraphicsItem what I am hiding and showing and after that trying
>> to check whether it selected or not...It's crashing I think its a Qt
>> bug.Please help what have I done wrong else ?
>>
>
> I would say it is not a Qt bug...
>
> gdb and breakpoints or qdebug may help you.
>
> test the value of currentRow(), then geoMetry[currentRow()]
>
> and if one of them is 0 or pointer garbage you know why it crash. Then you
> have to fix your code, probably in deletePart some stuff is already deleted.

That's what I tried to tell Sujan the other day.
I'm not sure this person is going to listen to our advice...

Anyway, as you have stated, if currentRow() is 0 or some low value,
and deletePart() is called, then geoMetry[0] will be deleted, but is
then dereferenced later on. geoMetry[0] does not get set with the new
currentRow() after the row is deleted.

Next time showPart() runs, the code dereferences an invalid pointer
and we have a spectacular Segfault.

The problem is that geoMetry[] does not match the table widget's data.

Regards,
Srdjan




More information about the Qt-interest-old mailing list