[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kdecore/jobs
From: Sebastian Sauer <mail () dipe ! org>
Date: 2009-11-25 13:01:10
Message-ID: 1259154070.813983.20082.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1054077 by sebsauer:
Quit Eventloop before emitting finished and result signals.
If KJob::exec is called then it can happen that the result(KJob*) signal is emitted \
before the QEventLoop in KJob::exec is quit. If a slot connected with the \
result(KJob*) signal does then e.g. call the same KJob::exec again then funny things \
may happen. The patch introduces a new internal signal that is called before the \
finished and result signals are emitted and that quits the eventloop. This way we can \
be sure that the finished and result signals are always emitted once the eventloop is \
done.
http://reviewboard.kde.org/r/2140/
M +13 -5 kjob.cpp
M +2 -0 kjob_p.h
--- trunk/KDE/kdelibs/kdecore/jobs/kjob.cpp #1054076:1054077
@@ -35,7 +35,8 @@
: q_ptr(0), uiDelegate(0), error(KJob::NoError),
progressUnit(KJob::Bytes), percentage(0),
suspended(false), capabilities(KJob::NoCapabilities),
- speedTimer(0), isAutoDelete(true), isFinished(false)
+ speedTimer(0), isAutoDelete(true), isFinished(false),
+ eventLoop(0)
{
if (!_k_kjobUnitEnumRegistered) {
_k_kjobUnitEnumRegistered = qRegisterMetaType<KJob::Unit>("KJob::Unit");
@@ -193,13 +194,13 @@
// suspend autodeletion and manually do it afterwards.
const bool wasAutoDelete = isAutoDelete();
setAutoDelete( false );
- QEventLoop loop( this );
- connect( this, SIGNAL( result( KJob* ) ),
- &loop, SLOT( quit() ) );
+ Q_ASSERT( ! d->eventLoop );
+ d->eventLoop = new QEventLoop( this );
+
start();
if( !d->isFinished ) {
- loop.exec(QEventLoop::ExcludeUserInputEvents);
+ d->eventLoop->exec(QEventLoop::ExcludeUserInputEvents);
}
if ( wasAutoDelete ) {
@@ -298,6 +299,13 @@
{
Q_D(KJob);
d->isFinished = true;
+
+ if ( d->eventLoop ) {
+ d->eventLoop->quit();
+ d->eventLoop->deleteLater();
+ d->eventLoop = 0;
+ }
+
// If we are displaying a progress dialog, remove it first.
emit finished( this );
--- trunk/KDE/kdelibs/kdecore/jobs/kjob_p.h #1054076:1054077
@@ -27,6 +27,7 @@
class KJobUiDelegate;
class QTimer;
+class QEventLoop;
// This is a private class, but it's exported for
// KIO::Job's usage. Other Job classes in kdelibs may
@@ -50,6 +51,7 @@
KJob::Capabilities capabilities;
QTimer *speedTimer;
bool isAutoDelete;
+ QEventLoop *eventLoop;
void _k_speedTimeout();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic