kjob::exec and autodeletion

Andreas Pakulat apaku at gmx.de
Sun Apr 12 00:24:53 BST 2009


On 11.04.09 21:47:16, Till Adam wrote:
> Folks,
> 
> KJob::exec() uses a secondary event loop to implement synchronous execution of 
> a job. On OSX (at least), if the job is set to delete itself, that event loop 
> will get and process the deletion even posted by deleteLater(), just after 
> emitting result() (which leads to a quit() of the event loop), such that upon 
> return from exec() the job is already deleted and the subsequent access to the 
> private object crashes. This does not seem to happen on Linux, at least, but I 
> seem to remember seeing it happen on Windows as well, somewhere in Kleo, which 
> does something similar in its job class.

Something like this happened to us in KDevelop, IIRC the fix at that
time was the addition of QEventLoop::ExcludeUserInputEvents and it
worked for us. 
 
> Attached patch works around this issue. I can't make up my mind whether this 
> is to be considered a bug in Qt, after all the chain of events _should_ be, at 
> least according to my expectations:

IMHO its a bug in Qt, if I call quit on on a loop it should definetly
_not_ execute any events that are being schedules after the call to
quit. Did you file a report already?

> In any case, shall I commit the workaround, or does someone have a better one?

+1 from me.

Andreas

-- 
Try the Moo Shu Pork.  It is especially good today.




More information about the kde-core-devel mailing list