Threadweaver::JobRunHelper::runTheJob failed/done Signals
Alejandro Wainzinger
aikawarazuni at gmail.com
Thu Sep 11 11:09:50 BST 2008
Ok. That all makes sense to me, but the success() method is called
for me anyway in threadweaver/Weaver/Job.cpp in the function I showed
before, and it's strange to me that it emits a failed() signal if
success is false, and not a succceeded() signal if success is true.
At any rate, I guess that's a design decision, I'm just curious as to
the rationale behind it.
So I guess the solution would be as you said, to connect the done slot
to a function that checks if success is true, and to execute a
function if it is. Thanks.
On Wed, Sep 10, 2008 at 12:00 AM, Andreas Pakulat <apaku at gmx.de> wrote:
> On 08.09.08 19:34:24, Alejandro Wainzinger wrote:
>> 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.
>
> Because its correct. Wether a job has failed or not doesn't have any
> influence of the job being done. That is, the job has reached the end of
> its execution, with some kind of result. Its a design decision the
> ThreadWeaver author made.
>
>> 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.
>
> No, definetly not. You simply need to make sure that whatever your
> "done-slot" does is only executed when job->success() == true.
>
> Andreas
>
> --
> You will overcome the attacks of jealous associates.
>
More information about the kde-core-devel
mailing list