[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Object crashes app after being deleted
From:       Robert Hogan <robert () roberthogan ! net>
Date:       2006-09-27 18:32:39
Message-ID: 200609271932.39907.robert () roberthogan ! net
[Download RAW message or body]

On Tuesday 26 September 2006 20:36, Michael Pyne wrote:
> 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.
>

The problem appears to be when another qobject is called by the qobject i'm 
trying to delete. deletelater() still results in a crash. The nested qobject 
is qhttp modified to block (i.e. kapp->processevents()) until it gets a 
response.

Am i right in thinking that blocking with kapp->processevents() this way is 
preventing deletelater() from working 'properly' in this case?

>
> 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.
>

This is what I have done, sort of. But it's an ugly hack even by my low 
standards, so I'd be interested to see how it is done properly. How do 
you 'wait' until code has exited a certain point before attempting to delete?

Thanks for your help so far!

-- 

KlamAV - An Anti-Virus Manager for KDE - http://www.klamav.net
TorK   - A Tor Controller For KDE      - http://tork.sf.net
 
>> 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