Commit ebc8a43c authored by Boudewijn Rempt's avatar Boudewijn Rempt

BUG:366713 Fix using the temporary target

A line like

QRect rect = temporaryTarget() ? temporaryTarget()->extent() : QRect();

is dangerous, since the paint device might be gone between the check
and the use. It's better to get a local shared pointer to the paint
device and check that.
parent cdd42948
......@@ -254,14 +254,16 @@ const QBitArray& KisPaintLayer::channelLockFlags() const
QRect KisPaintLayer::extent() const
{
QRect rect = temporaryTarget() ? temporaryTarget()->extent() : QRect();
KisPaintDeviceSP t = temporaryTarget();
QRect rect = t ? t->extent() : QRect();
if (onionSkinEnabled()) rect |= KisOnionSkinCompositor::instance()->calculateExtent(m_d->paintDevice);
return rect | KisLayer::extent();
}
QRect KisPaintLayer::exactBounds() const
{
QRect rect = temporaryTarget() ? temporaryTarget()->exactBounds() : QRect();
KisPaintDeviceSP t = temporaryTarget();
QRect rect = t ? t->extent() : QRect();
if (onionSkinEnabled()) rect |= KisOnionSkinCompositor::instance()->calculateExtent(m_d->paintDevice);
return rect | KisLayer::exactBounds();
}
......@@ -276,7 +278,7 @@ void KisPaintLayer::setAlphaLocked(bool lock)
{
if(m_d->paintChannelFlags.isEmpty())
m_d->paintChannelFlags = colorSpace()->channelFlags(true, true);
if(lock)
m_d->paintChannelFlags &= colorSpace()->channelFlags(true, false);
else
......
......@@ -272,13 +272,17 @@ void KisPainterBasedStrokeStrategy::cancelStrokeCallback()
KisIndirectPaintingSupport *indirect =
dynamic_cast<KisIndirectPaintingSupport*>(node.data());
if(indirect && indirect->hasTemporaryTarget()) {
delete m_transaction;
deletePainters();
QRegion region = indirect->temporaryTarget()->region();
indirect->setTemporaryTarget(0);
node->setDirty(region);
if (indirect) {
KisPaintDeviceSP t = indirect->temporaryTarget();
if (t) {
delete m_transaction;
deletePainters();
QRegion region = t->region();
indirect->setTemporaryTarget(0);
node->setDirty(region);
}
} else {
m_transaction->revert();
delete m_transaction;
......
......@@ -132,14 +132,18 @@ void MoveSelectionStrokeStrategy::cancelStrokeCallback()
KisIndirectPaintingSupport *indirect =
static_cast<KisIndirectPaintingSupport*>(m_paintLayer.data());
QRegion dirtyRegion = indirect->temporaryTarget()->region();
if (indirect) {
KisPaintDeviceSP t = indirect->temporaryTarget();
if (t) {
QRegion dirtyRegion = t->region();
indirect->setTemporaryTarget(0);
m_selection->setVisible(true);
indirect->setTemporaryTarget(0);
m_paintLayer->setDirty(dirtyRegion);
m_selection->setVisible(true);
m_paintLayer->setDirty(dirtyRegion);
}
}
KisStrokeStrategyUndoCommandBased::cancelStrokeCallback();
}
......
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