Commit 4cbc15c8 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Move Isolate Mode activation and deactivation into a stroke

If we just manually check tryBarrierLock() and skip activation,
then "continued isolated mode" will work incorrectly. Indeed,
GUI requested to switch the root, but image refuses to do that
because it is busy.

Now we just post all the requests to the strokes queue and change
isolated root unconditionally.

BUG:392969
parent 8b2309a3
......@@ -84,6 +84,9 @@ void KisIdleWatcher::setTrackedImages(const QVector<KisImageSP> &images)
m_d->trackedImages << image;
m_d->connectionsStore.addConnection(image, SIGNAL(sigImageModified()),
this, SLOT(slotImageModified()));
m_d->connectionsStore.addConnection(image, SIGNAL(sigIsolatedModeChanged()),
this, SLOT(slotImageModified()));
}
}
}
......
......@@ -64,6 +64,7 @@
#include "kis_image_signal_router.h"
#include "kis_image_animation_interface.h"
#include "kis_stroke_strategy.h"
#include "kis_simple_stroke_strategy.h"
#include "kis_image_barrier_locker.h"
......@@ -1304,40 +1305,75 @@ void KisImage::KisImagePrivate::notifyProjectionUpdatedInPatches(const QRect &rc
bool KisImage::startIsolatedMode(KisNodeSP node)
{
if (!tryBarrierLock()) return false;
struct StartIsolatedModeStroke : public KisSimpleStrokeStrategy {
StartIsolatedModeStroke(KisNodeSP node, KisImageSP image)
: KisSimpleStrokeStrategy("start-isolated-mode", kundo2_noi18n("start-isolated-mode")),
m_node(node),
m_image(image)
{
this->enableJob(JOB_INIT);
setClearsRedoOnStart(false);
}
void initStrokeCallback() {
m_image->m_d->isolatedRootNode = m_node;
emit m_image->sigIsolatedModeChanged();
unlock();
// the GUI uses our thread to do the color space conversion so we
// need to emit this signal in multiple threads
m_image->m_d->notifyProjectionUpdatedInPatches(m_image->bounds());
m_d->isolatedRootNode = node;
emit sigIsolatedModeChanged();
m_image->invalidateAllFrames();
}
private:
KisNodeSP m_node;
KisImageSP m_image;
};
// the GUI uses our thread to do the color space conversion so we
// need to emit this signal in multiple threads
m_d->notifyProjectionUpdatedInPatches(bounds());
KisStrokeId id = startStroke(new StartIsolatedModeStroke(node, this));
endStroke(id);
invalidateAllFrames();
return true;
}
void KisImage::stopIsolatedMode()
{
if (!m_d->isolatedRootNode) return;
struct StopIsolatedModeStroke : public KisSimpleStrokeStrategy {
StopIsolatedModeStroke(KisImageSP image)
: KisSimpleStrokeStrategy("stop-isolated-mode", kundo2_noi18n("stop-isolated-mode")),
m_image(image)
{
this->enableJob(JOB_INIT);
setClearsRedoOnStart(false);
}
void initStrokeCallback() {
if (!m_image->m_d->isolatedRootNode) return;
//KisNodeSP oldRootNode = m_image->m_d->isolatedRootNode;
m_image->m_d->isolatedRootNode = 0;
KisNodeSP oldRootNode = m_d->isolatedRootNode;
m_d->isolatedRootNode = 0;
emit m_image->sigIsolatedModeChanged();
emit sigIsolatedModeChanged();
// the GUI uses our thread to do the color space conversion so we
// need to emit this signal in multiple threads
m_image->m_d->notifyProjectionUpdatedInPatches(m_image->bounds());
m_image->invalidateAllFrames();
// TODO: Substitute notifyProjectionUpdated() with this code
// when update optimization is implemented
//
// QRect updateRect = bounds() | oldRootNode->extent();
// oldRootNode->setDirty(updateRect);
}
// the GUI uses our thread to do the color space conversion so we
// need to emit this signal in multiple threads
m_d->notifyProjectionUpdatedInPatches(bounds());
invalidateAllFrames();
private:
KisImageSP m_image;
};
// TODO: Substitute notifyProjectionUpdated() with this code
// when update optimization is implemented
//
// QRect updateRect = bounds() | oldRootNode->extent();
// oldRootNode->setDirty(updateRect);
KisStrokeId id = startStroke(new StopIsolatedModeStroke(this));
endStroke(id);
}
KisNodeSP KisImage::isolatedModeRoot() const
......
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