Commit 57686d84 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Fix logic of the stroke lifetime in QMic

We shouldn't try to end the same stroke multiple times. The patch
also makes sure KisProcessingApplicator is owned by a scoped pointer
instead of manual handling.

BUG:407520
parent 292b1db1
......@@ -141,7 +141,7 @@ qint32 KisStroke::numJobs() const
void KisStroke::endStroke()
{
Q_ASSERT(!m_strokeEnded);
KIS_SAFE_ASSERT_RECOVER_RETURN(!m_strokeEnded);
m_strokeEnded = true;
enqueue(m_finishStrategy.data(), m_strokeStrategy->createFinishData());
......
......@@ -385,7 +385,6 @@ void QMic::slotStartApplicator(QStringList gmicImages)
m_gmicApplicator->setProperties(viewManager()->image(), rootNode, images, actionName, layers);
m_gmicApplicator->apply();
m_gmicApplicator->finish();
}
bool QMic::prepareCroppedImages(QByteArray *message, QRectF &rc, int inputMode)
......
......@@ -27,13 +27,12 @@
#include "kis_qmic_synchronize_layers_command.h"
#include "kis_qmic_synchronize_image_size_command.h"
KisQmicApplicator::KisQmicApplicator():m_applicator(0),m_applicatorStrokeEnded(false)
KisQmicApplicator::KisQmicApplicator()
{
}
KisQmicApplicator::~KisQmicApplicator()
{
delete m_applicator;
}
void KisQmicApplicator::setProperties(KisImageWSP image, KisNodeSP node, QVector<gmic_image<float> *> images, const KUndo2MagicString &actionName, KisNodeListSP kritaNodes)
......@@ -56,9 +55,11 @@ void KisQmicApplicator::apply()
KisImageSignalVector emitSignals;
emitSignals << ComplexSizeChangedSignal() << ModifiedSignal;
m_applicator = new KisProcessingApplicator(m_image, m_node,
KisProcessingApplicator::RECURSIVE | KisProcessingApplicator::NO_UI_UPDATES,
emitSignals, m_actionName);
m_applicator.reset(
new KisProcessingApplicator(m_image, m_node,
KisProcessingApplicator::RECURSIVE |
KisProcessingApplicator::NO_UI_UPDATES,
emitSignals, m_actionName));
dbgPlugins << "Created applicator " << m_applicator;
m_gmicData = KisQmicDataSP(new KisQmicData());
......@@ -91,20 +92,11 @@ void KisQmicApplicator::cancel()
dbgPlugins << "KisQmicApplicator::cancel";
if (m_applicator) {
if (!m_applicatorStrokeEnded) {
dbgPlugins << "Cancelling applicator: Yes!";
m_applicator->cancel();
}
else {
dbgPlugins << "Cancelling applicator: No! Reason: Already finished!";
}
dbgPlugins << "Cancelling applicator!";
m_applicator->cancel();
dbgPlugins << "deleting applicator: " << m_applicator;
delete m_applicator;
m_applicator = 0;
m_applicatorStrokeEnded = false;
dbgPlugins << ppVar(m_applicatorStrokeEnded);
m_applicator.reset();
}
else {
dbgPlugins << "Cancelling applicator: No! Reason: Null applicator!";
......@@ -116,9 +108,8 @@ void KisQmicApplicator::finish()
dbgPlugins << "Applicator " << m_applicator << " finished";
if (m_applicator) {
m_applicator->end();
m_applicatorStrokeEnded = true;
m_applicator.reset();
}
dbgPlugins << ppVar(m_applicatorStrokeEnded);
}
float KisQmicApplicator::getProgress() const
......
......@@ -27,6 +27,7 @@
#include "gmic.h"
#include "kis_qmic_data.h"
#include <QScopedPointer>
class KisProcessingApplicator;
......@@ -49,12 +50,11 @@ Q_SIGNALS:
void gmicFinished(bool successfully, int milliseconds = -1, const QString &msg = QString());
private:
KisProcessingApplicator *m_applicator;
QScopedPointer<KisProcessingApplicator> m_applicator;
KisImageWSP m_image;
KisNodeSP m_node;
KUndo2MagicString m_actionName;
KisNodeListSP m_kritaNodes;
bool m_applicatorStrokeEnded;
QVector<gmic_image<float> *> m_images;
KisQmicDataSP m_gmicData;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment