Review Request: Prevent crash in KJob::emitResult() if job is deleted

Aurélien Gâteau agateau at
Mon Dec 6 09:43:31 GMT 2010

This is an automatically generated e-mail. To reply, visit:

(Updated 2010-12-06 09:43:30.877370)

Review request for kdelibs and Kevin Ottens.


Added a Q_ASSERT as requested by Kevin. The assert will trigger if the job is in autodelete mode and has been deleted by a slot.
Adapted the test case to only check in non-autodelete mode.

Summary (updated)

If someone calls "delete job" on a slot connected to the KJob::result() signal, KJob crashes because the job does not exist anymore when execution comes back to KJob::emitResult(). I added a guard to prevent that. An alternative would be to call deleteLater() before emitting the signals but I was afraid it would cause trouble if slots connected to the emitted signals used event loops.

This addresses bug 241562.

Diffs (updated)

  trunk/KDE/kdelibs/kdecore/jobs/kjob.cpp 1203507 
  trunk/KDE/kdelibs/kdecore/tests/kjobtest.h 1203507 
  trunk/KDE/kdelibs/kdecore/tests/kjobtest.cpp 1203507 



Wrote a unit-test to demonstrate the problem. This also helps with bug #241562 although I have another request prepared to hopefully definitely nail it down.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the kde-core-devel mailing list