Commit 924eca87 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Fix crash in KisOnionSkinCompositor

Don't try to update static sturctures while in multithreading mode
parent 706f382a
...@@ -211,10 +211,10 @@ KisKeyframeSP KisKeyframeChannel::copyKeyframe(const KisKeyframeSP keyframe, int ...@@ -211,10 +211,10 @@ KisKeyframeSP KisKeyframeChannel::copyKeyframe(const KisKeyframeSP keyframe, int
return insertKeyframe(newTime, keyframe, parentCommand); return insertKeyframe(newTime, keyframe, parentCommand);
} }
KisKeyframeSP KisKeyframeChannel::keyframeAt(int time) KisKeyframeSP KisKeyframeChannel::keyframeAt(int time) const
{ {
KeyframesMap::iterator i = m_d->keys.find(time); KeyframesMap::const_iterator i = m_d->keys.constFind(time);
if (i != m_d->keys.end()) { if (i != m_d->keys.constEnd()) {
return i.value(); return i.value();
} }
...@@ -226,6 +226,11 @@ KisKeyframeSP KisKeyframeChannel::activeKeyframeAt(int time) const ...@@ -226,6 +226,11 @@ KisKeyframeSP KisKeyframeChannel::activeKeyframeAt(int time) const
return activeKeyIterator(time).value(); return activeKeyIterator(time).value();
} }
KisKeyframeSP KisKeyframeChannel::firstKeyframe() const
{
return keyframeAt(0);
}
KisKeyframeSP KisKeyframeChannel::nextKeyframe(KisKeyframeSP keyframe) const KisKeyframeSP KisKeyframeChannel::nextKeyframe(KisKeyframeSP keyframe) const
{ {
KeyframesMap::iterator i = m_d->keys.find(keyframe->time()); KeyframesMap::iterator i = m_d->keys.find(keyframe->time());
......
...@@ -53,9 +53,10 @@ public: ...@@ -53,9 +53,10 @@ public:
bool moveKeyframe(KisKeyframeSP keyframe, int newTime, KUndo2Command *parentCommand = 0); bool moveKeyframe(KisKeyframeSP keyframe, int newTime, KUndo2Command *parentCommand = 0);
KisKeyframeSP copyKeyframe(const KisKeyframeSP keyframe, int newTime, KUndo2Command *parentCommand = 0); KisKeyframeSP copyKeyframe(const KisKeyframeSP keyframe, int newTime, KUndo2Command *parentCommand = 0);
KisKeyframeSP keyframeAt(int time); KisKeyframeSP keyframeAt(int time) const;
KisKeyframeSP activeKeyframeAt(int time) const; KisKeyframeSP activeKeyframeAt(int time) const;
KisKeyframeSP firstKeyframe() const;
KisKeyframeSP nextKeyframe(KisKeyframeSP keyframe) const; KisKeyframeSP nextKeyframe(KisKeyframeSP keyframe) const;
KisKeyframeSP previousKeyframe(KisKeyframeSP keyframe) const; KisKeyframeSP previousKeyframe(KisKeyframeSP keyframe) const;
KisKeyframeSP lastKeyframe() const; KisKeyframeSP lastKeyframe() const;
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "KoColor.h" #include "KoColor.h"
#include "KoColorSpace.h" #include "KoColorSpace.h"
#include "KoCompositeOpRegistry.h" #include "KoCompositeOpRegistry.h"
#include "KoColorSpaceConstants.h"
#include "kis_image_config.h" #include "kis_image_config.h"
#include "kis_config_notifier.h" #include "kis_config_notifier.h"
...@@ -42,21 +43,10 @@ struct KisOnionSkinCompositor::Private ...@@ -42,21 +43,10 @@ struct KisOnionSkinCompositor::Private
int skinOpacity(int offset) int skinOpacity(int offset)
{ {
KisImageConfig cfg; const QVector<int> &bo = backwardOpacities;
const QVector<int> &fo = forwardOpacities;
if (offset < 0) { return offset > 0 ? fo[qAbs(offset) - 1] : bo[qAbs(offset) - 1];
while (backwardOpacities.count() < -offset) {
backwardOpacities.append(cfg.onionSkinOpacity(-(backwardOpacities.count() + 1)));
}
return backwardOpacities.at(-offset - 1);
} else {
while (forwardOpacities.count() < offset) {
forwardOpacities.append(cfg.onionSkinOpacity(forwardOpacities.count() + 1));
}
return forwardOpacities.at(offset - 1);
}
} }
KisPaintDeviceSP setUpTintDevice(const QColor &tintColor, const KoColorSpace *colorSpace) KisPaintDeviceSP setUpTintDevice(const QColor &tintColor, const KoColorSpace *colorSpace)
...@@ -69,7 +59,7 @@ struct KisOnionSkinCompositor::Private ...@@ -69,7 +59,7 @@ struct KisOnionSkinCompositor::Private
void compositeFrame(KisRasterKeyframeChannel *keyframes, KisKeyframeSP keyframe, KisPainter &gcFrame, KisPainter &gcDest, KisPaintDeviceSP tintSource, int opacity, const QRect &rect) void compositeFrame(KisRasterKeyframeChannel *keyframes, KisKeyframeSP keyframe, KisPainter &gcFrame, KisPainter &gcDest, KisPaintDeviceSP tintSource, int opacity, const QRect &rect)
{ {
if (keyframe.isNull()) return; if (keyframe.isNull() || opacity == OPACITY_TRANSPARENT_U8) return;
keyframes->fetchFrame(keyframe, gcFrame.device()); keyframes->fetchFrame(keyframe, gcFrame.device());
...@@ -88,8 +78,13 @@ struct KisOnionSkinCompositor::Private ...@@ -88,8 +78,13 @@ struct KisOnionSkinCompositor::Private
backwardTintColor = config.onionSkinTintColorBackward(); backwardTintColor = config.onionSkinTintColorBackward();
forwardTintColor = config.onionSkinTintColorForward(); forwardTintColor = config.onionSkinTintColorForward();
backwardOpacities.clear(); backwardOpacities.resize(numberOfSkins);
forwardOpacities.clear(); forwardOpacities.resize(numberOfSkins);
for (int i = 0; i < numberOfSkins; i++) {
backwardOpacities[i] = config.onionSkinOpacity(-(i + 1));
forwardOpacities[i] = config.onionSkinOpacity(i + 1);
}
} }
}; };
...@@ -143,6 +138,21 @@ void KisOnionSkinCompositor::composite(const KisPaintDeviceSP sourceDevice, KisP ...@@ -143,6 +138,21 @@ void KisOnionSkinCompositor::composite(const KisPaintDeviceSP sourceDevice, KisP
} }
QRect KisOnionSkinCompositor::calculateFullExtent(const KisPaintDeviceSP device)
{
QRect rect;
KisRasterKeyframeChannel *channel = device->keyframeChannel();
KisKeyframeSP keyframe = channel->firstKeyframe();
while (keyframe) {
rect |= channel->frameExtents(keyframe);
keyframe = channel->nextKeyframe(keyframe);
}
return rect;
}
QRect KisOnionSkinCompositor::calculateExtent(const KisPaintDeviceSP device) QRect KisOnionSkinCompositor::calculateExtent(const KisPaintDeviceSP device)
{ {
QRect rect; QRect rect;
......
...@@ -32,6 +32,7 @@ public: ...@@ -32,6 +32,7 @@ public:
void composite(const KisPaintDeviceSP sourceDevice, KisPaintDeviceSP targetDevice, const QRect &rect); void composite(const KisPaintDeviceSP sourceDevice, KisPaintDeviceSP targetDevice, const QRect &rect);
QRect calculateFullExtent(const KisPaintDeviceSP device);
QRect calculateExtent(const KisPaintDeviceSP device); QRect calculateExtent(const KisPaintDeviceSP device);
public Q_SLOTS: public Q_SLOTS:
......
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