Threadweaver::JobRunHelper::runTheJob failed/done Signals

Alejandro Wainzinger aikawarazuni at gmail.com
Tue Sep 9 03:34:24 BST 2008


In the Threadweaver::JobRunHelper::runTheJob method(
KDE/kdelibs/threadweaver/Weaver/Job.cpp ), there is the following
piece of code:

if ( ! job->success() )
    {
        emit ( failed( job ) );
    }

    emit ( done( job ) );

I've subclassed a Threadweaver::Job, and reimplemented the success()
method, and connected the appropriate signals/slots for done/failed
signals that are emitted as shown above.  With this code though, both
the failed and done signals are emitted, and so both slots are called,
which is not what I want.  I only want the failed slot to be called if
it fails.  I'm wondering why the above piece of code isn't an if-else.

I think I can accomplish what I want by having the slot triggered by
the failed signal, disconnect the connection to the slot triggered by
the done signal.  Is that the right way of doing this?  It seems a bit
ugly, as the only way I can do that is by using the QObject sender()
method.

Please correct me if I'm using the wrong approach here.




More information about the kde-core-devel mailing list