From kde-commits Mon Dec 06 14:08:20 2010 From: =?utf-8?q?Aur=C3=A9lien=20G=C3=A2teau?= Date: Mon, 06 Dec 2010 14:08:20 +0000 To: kde-commits Subject: KDE/kdelibs/kdecore Message-Id: <20101206140820.4A298AC8A4 () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=129164452915814 SVN commit 1204252 by gateau: Reverted "Do not crash if an job was deleted in a slot connected to result()" David explanation: """ In addition, you added a guard in kjob.cpp itself, but what about the moc- generated code in between? When deleting the sender, we then go back to the signal emission code inside of a deleted object... """ M +1 -12 jobs/kjob.cpp M +0 -18 tests/kjobtest.cpp M +0 -2 tests/kjobtest.h --- trunk/KDE/kdelibs/kdecore/jobs/kjob.cpp #1204251:1204252 @@ -24,13 +24,11 @@ #include "kjobuidelegate.h" -#include #include #include #include #include #include -#include bool KJobPrivate::_k_kjobUnitEnumRegistered = false; KJobPrivate::KJobPrivate() @@ -304,9 +302,6 @@ Q_D(KJob); d->isFinished = true; - bool autoDelete = isAutoDelete(); - QWeakPointer guard(this); - if ( d->eventLoop ) { d->eventLoop->quit(); } @@ -316,15 +311,9 @@ emit result( this ); - if ( autoDelete ) { - Q_ASSERT( guard.data() ); - if ( guard.data() ) { + if ( isAutoDelete() ) deleteLater(); - } else { - kWarning() << "Job was marked as autoDelete() but has already been deleted!"; } - } -} void KJob::emitPercent( qulonglong processedAmount, qulonglong totalAmount ) { --- trunk/KDE/kdelibs/kdecore/tests/kjobtest.cpp #1204251:1204252 @@ -303,24 +303,6 @@ m_outerJob->exec(); } -void KJobTest::testDeletedInResult() -{ - TestJob *job = new TestJob; - job->setAutoDelete( false ); - - connect( job, SIGNAL( result( KJob* ) ), - this, SLOT( deleteJob( KJob* ) ) ); - - job->start(); - loop.exec(); -} - -void KJobTest::deleteJob(KJob *job) -{ - delete job; - loop.quit(); -} - void KJobTest::slotStartInnerJob() { QTimer::singleShot( 100, this, SLOT( slotFinishOuterJob() ) ); --- trunk/KDE/kdelibs/kdecore/tests/kjobtest.h #1204251:1204252 @@ -79,11 +79,9 @@ void testKill(); void testDelegateUsage(); void testNestedExec(); - void testDeletedInResult(); void slotResult( KJob *job ); void slotFinished(KJob *job); - void deleteJob(KJob *); private: QEventLoop loop;