Changeset View
Changeset View
Standalone View
Standalone View
lib/abstractimageoperation.cpp
Show All 17 Lines | |||||
18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
19 | 19 | | |||
20 | */ | 20 | */ | ||
21 | // Self | 21 | // Self | ||
22 | #include "abstractimageoperation.h" | 22 | #include "abstractimageoperation.h" | ||
23 | 23 | | |||
24 | // Qt | 24 | // Qt | ||
25 | #include <QUrl> | 25 | #include <QUrl> | ||
26 | #include <QTimer> | ||||
26 | 27 | | |||
27 | // KDE | 28 | // KDE | ||
28 | #include <KJob> | 29 | #include <KJob> | ||
29 | 30 | | |||
30 | // Local | 31 | // Local | ||
31 | #include "document/documentfactory.h" | 32 | #include "document/documentfactory.h" | ||
32 | #include "document/documentjob.h" | 33 | #include "document/documentjob.h" | ||
33 | 34 | | |||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | |||||
85 | } | 86 | } | ||
86 | 87 | | |||
87 | void AbstractImageOperation::finish(bool ok) | 88 | void AbstractImageOperation::finish(bool ok) | ||
88 | { | 89 | { | ||
89 | if (ok) { | 90 | if (ok) { | ||
90 | ImageOperationCommand* command = new ImageOperationCommand(this); | 91 | ImageOperationCommand* command = new ImageOperationCommand(this); | ||
91 | command->setText(d->mText); | 92 | command->setText(d->mText); | ||
92 | document()->undoStack()->push(command); | 93 | document()->undoStack()->push(command); | ||
94 | document()->imageOperationCompleted(); | ||||
93 | } else { | 95 | } else { | ||
94 | deleteLater(); | 96 | deleteLater(); | ||
95 | } | 97 | } | ||
96 | } | 98 | } | ||
97 | 99 | | |||
98 | void AbstractImageOperation::finishFromKJob(KJob* job) | 100 | void AbstractImageOperation::finishFromKJob(KJob* job) | ||
99 | { | 101 | { | ||
100 | finish(job->error() == KJob::NoError); | 102 | finish(job->error() == KJob::NoError); | ||
101 | } | 103 | } | ||
102 | 104 | | |||
105 | void AbstractImageOperation::finishUndoJob() | ||||
106 | { | ||||
107 | // Give QUndoStack time to update in case the undo is executed immediately | ||||
108 | // (e.g. undo crop just sets the previous image) | ||||
rkflx: I don't really understand what you mean with "is not executed asynchronous(ly)". Could you… | |||||
muhlenpfordt: * Replace the QTimer line with the direct call `document()->imageOperationCompleted();`
* Crop… | |||||
Ah, I see. Maybe it would make sense then to reword the comment a bit, e.g.:
rkflx: Ah, I see. Maybe it would make sense then to reword the comment a bit, e.g.:
- not… | |||||
Is this comment more understandable? Better suggestions always welcome. ;) muhlenpfordt: Is this comment more understandable? Better suggestions always welcome. ;) | |||||
rkflx: Works for me, thanks for the update ;) | |||||
109 | QTimer::singleShot(0, document().data(), &Document::imageOperationCompleted); | ||||
110 | } | ||||
111 | | ||||
103 | void AbstractImageOperation::setText(const QString& text) | 112 | void AbstractImageOperation::setText(const QString& text) | ||
104 | { | 113 | { | ||
105 | d->mText = text; | 114 | d->mText = text; | ||
106 | } | 115 | } | ||
107 | 116 | | |||
108 | void AbstractImageOperation::redoAsDocumentJob(DocumentJob* job) | 117 | void AbstractImageOperation::redoAsDocumentJob(DocumentJob* job) | ||
109 | { | 118 | { | ||
110 | connect(job, SIGNAL(result(KJob*)), SLOT(finishFromKJob(KJob*))); | 119 | connect(job, SIGNAL(result(KJob*)), SLOT(finishFromKJob(KJob*))); | ||
111 | document()->enqueueJob(job); | 120 | document()->enqueueJob(job); | ||
112 | } | 121 | } | ||
113 | 122 | | |||
114 | } // namespace | 123 | } // namespace |
I don't really understand what you mean with "is not executed asynchronous(ly)". Could you provide some steps to reproduce some kind of problem if we called the function directly instead of using the timer?