[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: Object crashes app after being deleted
From: Michael Pyne <michael.pyne () kdemail ! net>
Date: 2006-09-26 19:36:27
Message-ID: 200609261536.32411.michael.pyne () kdemail ! net
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
On Monday 25 September 2006 17:22, Robert Hogan wrote:
> Hi there,
>
> An event from the tork object causes the deletion of the client object.
> There's stuff still going on in the client object (called from the tork
> object) , which I would expect to cease once it's destroyed.
>
> However, it appears to continue and since the stuff it needs is no longer
> available (because the client object is being deleted) it crashes.
>
> What do I need to do here? I'm pretty sure I'm missing something blindingly
> obvious.
Is the thing that you are deleting a QObject? If so you might want to call
deleteLater() on it instead of deleting it right then.
C++ tidbit:
If you delete an object while that object has code that that is running, the
code will still try to go to completion in the function.
e.g.
void MyClass::foo()
{
printStuff();
print(this->m_a);
// If you delete object when it is running here...
::doMoreStuff(); // It keeps running!
// But it doesn't crash til here as long as doMoreStuff
// doesn't reference this object.
this->keelOver(); // this points to freed memory
}
If it's not a QObject you need to restructure your code such that the object
is not deleted until it is finished being used. Shared pointers may help you
out with that.
Regards,
- Michael Pyne
[Attachment #5 (application/pgp-signature)]
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic