Commit 3cfad16e authored by Dmitry Kazakov's avatar Dmitry Kazakov

Fix crash when selecting too tiny scale for a brush texture

BUG:344884
parent f3b345f8
......@@ -160,6 +160,20 @@ QPointF ensureInRect(QPointF pt, const QRectF &bounds)
return ensureInRectImpl(pt, bounds);
}
QRect ensureRectNotSmaller(QRect rc, const QSize &size)
{
if (rc.width() < size.width() ||
rc.height() < size.height()) {
int width = qMax(rc.width(), size.width());
int height = qMax(rc.height(), size.height());
rc = QRect(rc.topLeft(), QSize(width, height));
}
return rc;
}
bool intersectLineRect(QLineF &line, const QRect rect)
{
QPointF pt1 = QPointF(), pt2 = QPointF();
......
......@@ -231,10 +231,10 @@ QPainterPath KRITAIMAGE_EXPORT smallArrow();
*/
QRect KRITAIMAGE_EXPORT blowRect(const QRect &rect, qreal coeff);
QPoint ensureInRect(QPoint pt, const QRect &bounds);
QPointF ensureInRect(QPointF pt, const QRectF &bounds);
QPoint KRITAIMAGE_EXPORT ensureInRect(QPoint pt, const QRect &bounds);
QPointF KRITAIMAGE_EXPORT ensureInRect(QPointF pt, const QRectF &bounds);
QRect KRITAIMAGE_EXPORT ensureRectNotSmaller(QRect rc, const QSize &size);
/**
* Attempt to intersect a line to the area of the a rectangle.
......
......@@ -48,6 +48,8 @@
#include <kis_fixed_paint_device.h>
#include <kis_gradient_slider.h>
#include "kis_embedded_pattern_manager.h"
#include "kis_algebra_2d.h"
#include <time.h>
class KisTextureOptionWidget : public QWidget
......@@ -266,7 +268,7 @@ void KisTextureProperties::recalculateMask()
if (!qFuzzyCompare(scale, 0.0)) {
QTransform tf;
tf.scale(scale, scale);
QRect rc = tf.mapRect(mask.rect());
QRect rc = KisAlgebra2D::ensureRectNotSmaller(tf.mapRect(mask.rect()), QSize(2,2));
mask = mask.scaled(rc.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
}
#if QT_VERSION >= 0x040700
......
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