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.

Change-Id: I1ef6bf880d5b0722baadcf0ced68a968f0b1a070
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: David Faure <david.faure@kdab.com>
(cherry picked from commit acfd2a4bb0b63a02f6c17eb72d59dd2ec02cfa59)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Sergio Martins 2023-11-08 14:37:58 +00:00 committed by Qt Cherry-pick Bot
parent 874e5be7ff
commit 74d460959b

View File

@ -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);