Prevent crash in OpenGL engine when scaling images / pixmaps.
Make sure the resulting image / pixmap is valid if the source was valid. Task-number: QTBUG-19157 Reviewed-by: Kim Reviewed-by: Benjamin Poulain (cherry picked from commit 1c5da7207a21cc44a4a08d291c290ffcd9b958fd)
This commit is contained in:
parent
d49c561b73
commit
e40443f7df
@ -4449,6 +4449,8 @@ QImage QImage::scaled(const QSize& s, Qt::AspectRatioMode aspectMode, Qt::Transf
|
|||||||
|
|
||||||
QSize newSize = size();
|
QSize newSize = size();
|
||||||
newSize.scale(s, aspectMode);
|
newSize.scale(s, aspectMode);
|
||||||
|
newSize.rwidth() = qMax(newSize.width(), 1);
|
||||||
|
newSize.rheight() = qMax(newSize.height(), 1);
|
||||||
if (newSize == size())
|
if (newSize == size())
|
||||||
return *this;
|
return *this;
|
||||||
|
|
||||||
|
@ -1514,6 +1514,8 @@ QPixmap QPixmap::scaled(const QSize& s, Qt::AspectRatioMode aspectMode, Qt::Tran
|
|||||||
|
|
||||||
QSize newSize = size();
|
QSize newSize = size();
|
||||||
newSize.scale(s, aspectMode);
|
newSize.scale(s, aspectMode);
|
||||||
|
newSize.rwidth() = qMax(newSize.width(), 1);
|
||||||
|
newSize.rheight() = qMax(newSize.height(), 1);
|
||||||
if (newSize == size())
|
if (newSize == size())
|
||||||
return *this;
|
return *this;
|
||||||
|
|
||||||
|
@ -151,6 +151,7 @@ private slots:
|
|||||||
void rgbSwapped();
|
void rgbSwapped();
|
||||||
|
|
||||||
void deepCopyWhenPaintingActive();
|
void deepCopyWhenPaintingActive();
|
||||||
|
void scaled_QTBUG19157();
|
||||||
};
|
};
|
||||||
|
|
||||||
tst_QImage::tst_QImage()
|
tst_QImage::tst_QImage()
|
||||||
@ -2029,5 +2030,12 @@ void tst_QImage::deepCopyWhenPaintingActive()
|
|||||||
QVERIFY(copy != image);
|
QVERIFY(copy != image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QImage::scaled_QTBUG19157()
|
||||||
|
{
|
||||||
|
QImage foo(5000, 1, QImage::Format_RGB32);
|
||||||
|
foo = foo.scaled(1024, 1024, Qt::KeepAspectRatio);
|
||||||
|
QVERIFY(!foo.isNull());
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_QImage)
|
QTEST_MAIN(tst_QImage)
|
||||||
#include "tst_qimage.moc"
|
#include "tst_qimage.moc"
|
||||||
|
@ -196,6 +196,7 @@ private slots:
|
|||||||
#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_OPENVG)
|
#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_OPENVG)
|
||||||
void vgImageReadBack();
|
void vgImageReadBack();
|
||||||
#endif
|
#endif
|
||||||
|
void scaled_QTBUG19157();
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool lenientCompare(const QPixmap &actual, const QPixmap &expected)
|
static bool lenientCompare(const QPixmap &actual, const QPixmap &expected)
|
||||||
@ -1897,5 +1898,12 @@ void tst_QPixmap::vgImageReadBack()
|
|||||||
}
|
}
|
||||||
#endif // Symbian & OpenVG
|
#endif // Symbian & OpenVG
|
||||||
|
|
||||||
|
void tst_QPixmap::scaled_QTBUG19157()
|
||||||
|
{
|
||||||
|
QPixmap foo(5000, 1);
|
||||||
|
foo = foo.scaled(1024, 1024, Qt::KeepAspectRatio);
|
||||||
|
QVERIFY(!foo.isNull());
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_QPixmap)
|
QTEST_MAIN(tst_QPixmap)
|
||||||
#include "tst_qpixmap.moc"
|
#include "tst_qpixmap.moc"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user