summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/painting/qbrush.cpp36
-rw-r--r--tests/auto/qbrush/tst_qbrush.cpp9
2 files changed, 27 insertions, 18 deletions
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp
index 1a83b1d..a82d0f9 100644
--- a/src/gui/painting/qbrush.cpp
+++ b/src/gui/painting/qbrush.cpp
@@ -912,7 +912,7 @@ void QBrush::setTransform(const QTransform &matrix)
otherwise returns false.
Two brushes are different if they have different styles, colors or
- pixmaps.
+ transforms or different pixmaps or gradients depending on the style.
\sa operator==()
*/
@@ -924,7 +924,7 @@ void QBrush::setTransform(const QTransform &matrix)
otherwise returns false.
Two brushes are equal if they have equal styles, colors and
- pixmaps.
+ transforms and equal pixmaps or gradients depending on the style.
\sa operator!=()
*/
@@ -933,26 +933,26 @@ bool QBrush::operator==(const QBrush &b) const
{
if (b.d == d)
return true;
- if (b.d->style == d->style && b.d->color == d->color) {
- switch (d->style) {
- case Qt::TexturePattern: {
- QPixmap &us = (static_cast<QTexturedBrushData *>(d.data()))->pixmap();
- QPixmap &them = (static_cast<QTexturedBrushData *>(b.d.data()))->pixmap();
+ if (b.d->style != d->style || b.d->color != d->color || b.d->transform != d->transform)
+ return false;
+ switch (d->style) {
+ case Qt::TexturePattern:
+ {
+ const QPixmap &us = (static_cast<QTexturedBrushData *>(d.data()))->pixmap();
+ const QPixmap &them = (static_cast<QTexturedBrushData *>(b.d.data()))->pixmap();
return ((us.isNull() && them.isNull()) || us.cacheKey() == them.cacheKey());
}
- case Qt::LinearGradientPattern:
- case Qt::RadialGradientPattern:
- case Qt::ConicalGradientPattern:
- {
- QGradientBrushData *d1 = static_cast<QGradientBrushData *>(d.data());
- QGradientBrushData *d2 = static_cast<QGradientBrushData *>(b.d.data());
- return d1->gradient == d2->gradient;
- }
- default:
- return true;
+ case Qt::LinearGradientPattern:
+ case Qt::RadialGradientPattern:
+ case Qt::ConicalGradientPattern:
+ {
+ const QGradientBrushData *d1 = static_cast<QGradientBrushData *>(d.data());
+ const QGradientBrushData *d2 = static_cast<QGradientBrushData *>(b.d.data());
+ return d1->gradient == d2->gradient;
}
+ default:
+ return true;
}
- return false;
}
/*!
diff --git a/tests/auto/qbrush/tst_qbrush.cpp b/tests/auto/qbrush/tst_qbrush.cpp
index bc2bc60..628e859 100644
--- a/tests/auto/qbrush/tst_qbrush.cpp
+++ b/tests/auto/qbrush/tst_qbrush.cpp
@@ -108,6 +108,15 @@ void tst_QBrush::operator_eq_eq_data()
<< false;
QTest::newRow("rad vs con") << QBrush(QRadialGradient(0, 0, 0, 0, 0)) << QBrush(QConicalGradient(0, 0, 0)) << false;
+
+ QBrush b1(lg);
+ QBrush b2(lg);
+ b1.setTransform(QTransform().scale(2, 2));
+ QTest::newRow("lg with transform vs same lg") << b1 << b2 << false;
+
+ b2.setTransform(QTransform().scale(2, 2));
+ QTest::newRow("lg w/transform vs same lg w/same transform") << b1 << b2 << true;
+
}
void tst_QBrush::operator_eq_eq()