1 | /* -*- C++ -*- |
2 | A decorator to make jobs into QObjects in ThreadWeaver. |
3 | |
4 | SPDX-FileCopyrightText: 2005-2013 Mirko Boehm <mirko@kde.org> |
5 | |
6 | SPDX-License-Identifier: LGPL-2.0-or-later |
7 | */ |
8 | |
9 | #include "qobjectdecorator.h" |
10 | #include "collection.h" |
11 | #include "managedjobpointer.h" |
12 | #include "sequence.h" |
13 | |
14 | namespace ThreadWeaver |
15 | { |
16 | QObjectDecorator::QObjectDecorator(JobInterface *decoratee, QObject *parent) |
17 | : QObject(parent) |
18 | , IdDecorator(decoratee) |
19 | { |
20 | } |
21 | |
22 | QObjectDecorator::QObjectDecorator(JobInterface *decoratee, bool autoDelete, QObject *parent) |
23 | : QObject(parent) |
24 | , IdDecorator(decoratee, autoDelete) |
25 | { |
26 | } |
27 | |
28 | void QObjectDecorator::defaultBegin(const JobPointer &self, Thread *thread) |
29 | { |
30 | Q_ASSERT(job()); |
31 | Q_EMIT started(self); |
32 | job()->defaultBegin(job: self, thread); |
33 | } |
34 | |
35 | void QObjectDecorator::defaultEnd(const JobPointer &self, Thread *thread) |
36 | { |
37 | Q_ASSERT(job()); |
38 | job()->defaultEnd(job: self, thread); |
39 | if (!self->success()) { |
40 | Q_EMIT failed(self); |
41 | } |
42 | Q_EMIT done(self); |
43 | } |
44 | |
45 | } |
46 | |
47 | #include "moc_qobjectdecorator.cpp" |
48 | |