From acfd2a4bb0b63a02f6c17eb72d59dd2ec02cfa59 Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Wed, 8 Nov 2023 14:37:58 +0000 Subject: Make all QPainter operations warn if there's no engine Otherwise, for example fillRect() will fail silently. Most operations already had the warning, but some were missing it. Pick-to: 6.6 Change-Id: I1ef6bf880d5b0722baadcf0ced68a968f0b1a070 Reviewed-by: Eirik Aavitsland Reviewed-by: Volker Hilsheimer Reviewed-by: Giuseppe D'Angelo Reviewed-by: David Faure --- src/gui/painting/qpainter.cpp | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) (limited to 'src/gui/painting') diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index e69f369dbe..5e3842cbcc 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -3901,8 +3901,10 @@ void QPainter::drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, #endif Q_D(QPainter); - if (!d->engine) + if (!d->engine) { + qWarning("QPainter::drawRoundedRect: Painter not active"); return; + } if (xRadius <= 0 || yRadius <= 0) { // draw normal rectangle drawRect(rect); @@ -3963,8 +3965,10 @@ void QPainter::drawEllipse(const QRectF &r) #endif Q_D(QPainter); - if (!d->engine) + if (!d->engine) { + qWarning("QPainter::drawEllipse: Painter not active"); return; + } QRectF rect(r.normalized()); @@ -4004,8 +4008,10 @@ void QPainter::drawEllipse(const QRect &r) #endif Q_D(QPainter); - if (!d->engine) + if (!d->engine) { + qWarning("QPainter::drawEllipse: Painter not active"); return; + } QRect rect(r.normalized()); @@ -4091,8 +4097,10 @@ void QPainter::drawArc(const QRectF &r, int a, int alen) #endif Q_D(QPainter); - if (!d->engine) + if (!d->engine) { + qWarning("QPainter::drawArc: Painter not active"); return; + } QRectF rect = r.normalized(); @@ -4153,8 +4161,10 @@ void QPainter::drawPie(const QRectF &r, int a, int alen) #endif Q_D(QPainter); - if (!d->engine) + if (!d->engine) { + qWarning("QPainter::drawPie: Painter not active"); return; + } if (a > (360*16)) { a = a % (360*16); @@ -4222,8 +4232,10 @@ void QPainter::drawChord(const QRectF &r, int a, int alen) #endif Q_D(QPainter); - if (!d->engine) + if (!d->engine) { + qWarning("QPainter::drawChord: Painter not active"); return; + } QRectF rect = r.normalized(); @@ -6509,8 +6521,10 @@ void QPainter::drawPicture(const QPointF &p, const QPicture &picture) { Q_D(QPainter); - if (!d->engine) + if (!d->engine) { + qWarning("QPainter::drawPicture: Painter not active"); return; + } if (!d->extended) d->updateState(d->state); @@ -6621,8 +6635,10 @@ void QPainter::fillRect(const QRectF &r, const QBrush &brush) { Q_D(QPainter); - if (!d->engine) + if (!d->engine) { + qWarning("QPainter::fillRect: Painter not active"); return; + } if (d->extended && !needsEmulation(brush)) { d->extended->fillRect(r, brush); @@ -6656,8 +6672,10 @@ void QPainter::fillRect(const QRect &r, const QBrush &brush) { Q_D(QPainter); - if (!d->engine) + if (!d->engine) { + qWarning("QPainter::fillRect: Painter not active"); return; + } if (d->extended && !needsEmulation(brush)) { d->extended->fillRect(r, brush); @@ -6694,8 +6712,10 @@ void QPainter::fillRect(const QRect &r, const QColor &color) { Q_D(QPainter); - if (!d->engine) + if (!d->engine) { + qWarning("QPainter::fillRect: Painter not active"); return; + } if (d->extended) { d->extended->fillRect(r, color); -- cgit v1.2.3