Commit ce3a6cf4 authored by Dmitry Kazakov's avatar Dmitry Kazakov

Fix a crash in Cage Transform when working with an empty paint device

parent 7b7f6299
......@@ -67,6 +67,11 @@ struct KisCageTransformWorker::Private
QSize gridSize;
bool isGridEmpty() const {
return allSrcPoints.isEmpty();
}
QVector<QPointF> calculateTransformedPoints();
/**
......@@ -184,6 +189,9 @@ void KisCageTransformWorker::prepareTransform()
QRectF(m_d->srcImageOffset, m_d->srcImage.size()).toAlignedRect();
srcBounds &= srcPolygon.boundingRect().toAlignedRect();
// no need to process empty devices
if (srcBounds.isEmpty()) return;
m_d->gridSize =
GridIterationTools::calcGridSize(srcBounds, m_d->pixelPrecision);
......@@ -472,6 +480,8 @@ iterateThroughGrid(PolygonOp polygonOp,
void KisCageTransformWorker::run()
{
if (m_d->isGridEmpty()) return;
KIS_ASSERT_RECOVER_RETURN(m_d->origCage.size() >= 3);
KIS_ASSERT_RECOVER_RETURN(m_d->origCage.size() == m_d->transfCage.size());
......@@ -504,6 +514,8 @@ void KisCageTransformWorker::run()
QImage KisCageTransformWorker::runOnQImage(QPointF *newOffset)
{
if (m_d->isGridEmpty()) QImage();
KIS_ASSERT_RECOVER(m_d->origCage.size() >= 3 &&
m_d->origCage.size() == m_d->transfCage.size()) {
return QImage();
......
......@@ -183,6 +183,8 @@ struct PaintDevicePolygonOp
void operator() (const QPolygonF &srcPolygon, const QPolygonF &dstPolygon, const QPolygonF &clipDstPolygon) {
QRect boundRect = clipDstPolygon.boundingRect().toAlignedRect();
if (boundRect.isEmpty()) return;
KisSequentialIterator dstIt(m_dstDev, boundRect);
KisRandomSubAccessorSP srcAcc = m_srcDev->createRandomSubAccessor();
......
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