Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Avoid division by zero in ref image painting

Dat Leb9a2d3fabcd3
diff --git a/libs/ui/tool/KisAsyncColorSamplerHelper.cpp b/libs/ui/tool/KisAsyncColorSamplerHelper.cpp
index 520d1fd608..693f9af3dd 100644
--- a/libs/ui/tool/KisAsyncColorSamplerHelper.cpp
+++ b/libs/ui/tool/KisAsyncColorSamplerHelper.cpp
@@ -820,6 +820,9 @@ void KisAsyncColorSamplerHelper::paintCircleReferenceImagePreview(QPainter &gc,
qreal xScale = refImage->size().width() / image.width();
qreal yScale = refImage->size().height() / image.height();
+ // This only happens when refImage size is 0, so painting it probably won't make senses
+ if (xScale == 0 || yScale == 0) continue;
+
QRect refPixelRect = QRect(refPixelPoint, QSize(zoomDocRectF.width() / xScale, zoomDocRectF.height() / yScale));
refPixelRect = m_d->standardizeZoomPreviewPixelRect(refPixelRect);