diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h index 4bfdbd91e0..c4703b3712 100644 --- a/src/gui/painting/qpaintengine_raster_p.h +++ b/src/gui/painting/qpaintengine_raster_p.h @@ -250,7 +250,7 @@ private: QRect toNormalizedFillRect(const QRectF &rect); inline void ensureBrush(const QBrush &brush) { - if (!qbrush_fast_equals(state()->lastBrush, brush) || (brush.style() != Qt::NoBrush && state()->fillFlags)) + if (!qbrush_fast_equals(state()->lastBrush, brush) || state()->fillFlags) updateBrush(brush); } inline void ensureBrush() { ensureBrush(state()->brush); } diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index e4340451ce..4604f840da 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -282,6 +282,8 @@ private slots: void QTBUG17053_zeroDashPattern(); + void QTBUG38781_NoBrushAndQBitmap(); + void drawTextOutsideGuiThread(); void drawTextWithComplexBrush(); @@ -4473,6 +4475,26 @@ void tst_QPainter::QTBUG17053_zeroDashPattern() QCOMPARE(image, original); } +void tst_QPainter::QTBUG38781_NoBrushAndQBitmap() +{ + QBitmap bitmap(10, 10); + bitmap.fill(Qt::color0); + QPainter p(&bitmap); + p.setPen(Qt::color1); + p.drawLine(0, 1, 9, 1); // at horizontal line at y=1 + p.setBrush(Qt::NoBrush); + p.drawRect(0, 0, 9, 9); // a rect all around + + QRgb white = qRgb(0xff, 0xff, 0xff); + QRgb black = qRgb(0, 0, 0); + QImage image = bitmap.toImage(); + QCOMPARE(image.pixel(0, 0), black); + QCOMPARE(image.pixel(5, 5), white); + + // Check that the rect didn't overwrite the line + QCOMPARE(image.pixel(5, 1), black); +} + class TextDrawerThread : public QThread { public: