Commit 77c57103 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Fix crash when moving a layer under a transformation mask

When doing KisPaintDevice::prepareClone(), we should first set
new defaultBounds object, and only after that clone the data.
The reason for this: switching defaultBounds can change current
level-of-detail/frameId, and therefore, switch currentData().

BUG:412361
parent 4686d100
...@@ -195,7 +195,7 @@ public: ...@@ -195,7 +195,7 @@ public:
void prepareClone(KisPaintDeviceSP src) void prepareClone(KisPaintDeviceSP src)
{ {
prepareCloneImpl(src, src->m_d->currentData()); prepareCloneImpl(src, src->m_d->currentData());
Q_ASSERT(fastBitBltPossible(src)); KIS_SAFE_ASSERT_RECOVER_NOOP(fastBitBltPossible(src));
} }
bool fastBitBltPossible(KisPaintDeviceSP src) bool fastBitBltPossible(KisPaintDeviceSP src)
...@@ -527,10 +527,17 @@ private: ...@@ -527,10 +527,17 @@ private:
void prepareCloneImpl(KisPaintDeviceSP src, Data *srcData) void prepareCloneImpl(KisPaintDeviceSP src, Data *srcData)
{ {
currentData()->prepareClone(srcData); /**
* The result of currentData() depends on the current
* level of detail and animation frame index. So we
* should first connect the device to the new
* default bounds object, and only after that ask
* currentData() to start cloning.
*/
q->setDefaultPixel(KoColor(srcData->dataManager()->defaultPixel(), colorSpace())); q->setDefaultPixel(KoColor(srcData->dataManager()->defaultPixel(), colorSpace()));
q->setDefaultBounds(src->defaultBounds()); q->setDefaultBounds(src->defaultBounds());
currentData()->prepareClone(srcData);
} }
bool fastBitBltPossibleImpl(Data *srcData) bool fastBitBltPossibleImpl(Data *srcData)
...@@ -1086,7 +1093,6 @@ void KisPaintDevice::setProjectionDevice(bool value) ...@@ -1086,7 +1093,6 @@ void KisPaintDevice::setProjectionDevice(bool value)
void KisPaintDevice::prepareClone(KisPaintDeviceSP src) void KisPaintDevice::prepareClone(KisPaintDeviceSP src)
{ {
m_d->prepareClone(src); m_d->prepareClone(src);
Q_ASSERT(fastBitBltPossible(src));
} }
void KisPaintDevice::makeCloneFrom(KisPaintDeviceSP src, const QRect &rect) void KisPaintDevice::makeCloneFrom(KisPaintDeviceSP src, const QRect &rect)
......
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