KJob deleting itself too early?

Andreas Pakulat apaku at gmx.de
Mon Nov 19 22:48:11 GMT 2007


On 19.11.07 23:36:09, David Faure wrote:
> On Monday 19 November 2007, Andreas Pakulat wrote:
> > On 19.11.07 23:06:09, David Faure wrote:
> > > On Sunday 18 November 2007, Andreas Pakulat wrote:
> > > > Hi,
> > > > 
> > > > I'd like to know why KJob deletes itself when he's done doing its work?
> > > > Shouldn't this be done by whoever creates the KJob?
> > > No, many jobs are fire-and-forget, and when they're not, people would forget to delete them.
> > > The job is done, it's done, it deletes itself. KDE3's KIO::Job has always worked like that.
> > > 
> > > > I don't think its a good idea to delete the job behind the back of the
> > > > user, in particular when you don't know how a KJob instance (or subclass
> > > > thereof) is used.
> > > Doesn't matter how it's used: after the job emits finished, it's finished :)
> > 
> > Yeah, but the problem is I can't access the data the job carries after a
> > run of the event loop. 
> I'm surprised by this need, but OK.

Well, maybe we abuse the job-idea a bit, though thas mostly for saving
some extra API on our VcsJob class. The reason is simply that the job
carries information about the parameters it was created with, for
example url+revision of an svn log operation. And that information is
then later on used to create a diff between the log entry and its
predecessor. Sure I can work around that in various ways, but it would
just be much easier if I could rely on the job being there until I
delete it.

> > I don't care if KIO jobs are fire-and-forget, but for a general-purpose
> > job class in kdelibs/kdecore this just sounds like an uneeded
> > restriction. In particular this makes it impossible to have KJob provide
> > the job-implementation for KDevelop VCS support. 
> 
> We cannot change the default behavior of KJob at this point.

Agreed :) I was hitting the send button a bit too early. Of course that
should be documented better - /me heads off to improve api dox.

> But a setAutoDelete(false) would be fine with me.
> Kévin is the maintainer though, he has final say.

Ok, I'll write up a patch and post that here (should I cc Kevin to get
his attention?). And unless I'm mistaken this is post-4.0 material,
right? (I mean it can be added in a BC way)

Andreas

-- 
You will receive a legacy which will place you above want.




More information about the kde-core-devel mailing list