From 784c94c7272684439abfa99273f5688d31ab2959 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Thu, 13 Jun 2019 21:21:53 +0200 Subject: Replace QPainter::initFrom() with begin() It's deprecated since e56401818b1aae9856a5334f530c4eda33788429 but still needed for QWidget rendering - therefore move it to QPainterPrivate. Change-Id: I35880ffa22830c2921c6675b1acf7e4ca38601db Reviewed-by: Shawn Rutledge --- src/gui/painting/qpainter.cpp | 28 +++++++++++++++++----------- src/gui/painting/qpainter_p.h | 1 + 2 files changed, 18 insertions(+), 11 deletions(-) (limited to 'src/gui/painting') diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 95e6bda78b..84b34e390b 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -283,7 +283,7 @@ bool QPainterPrivate::attachPainterPrivate(QPainter *q, QPaintDevice *pdev) Q_ASSERT(q->d_ptr->state); // Now initialize the painter with correct widget properties. - q->initFrom(pdev); + q->d_ptr->initFrom(pdev); QPoint offset; pdev->redirected(&offset); offset += q->d_ptr->engine->coordinateOffset(); @@ -1560,22 +1560,28 @@ void QPainter::initFrom(const QPaintDevice *device) { Q_ASSERT_X(device, "QPainter::initFrom(const QPaintDevice *device)", "QPaintDevice cannot be 0"); Q_D(QPainter); - if (!d->engine) { + d->initFrom(device); +} +#endif + +void QPainterPrivate::initFrom(const QPaintDevice *device) +{ + if (!engine) { qWarning("QPainter::initFrom: Painter not active, aborted"); return; } - device->initPainter(this); + Q_Q(QPainter); + device->initPainter(q); - if (d->extended) { - d->extended->penChanged(); - } else if (d->engine) { - d->engine->setDirty(QPaintEngine::DirtyPen); - d->engine->setDirty(QPaintEngine::DirtyBrush); - d->engine->setDirty(QPaintEngine::DirtyFont); + if (extended) { + extended->penChanged(); + } else if (engine) { + engine->setDirty(QPaintEngine::DirtyPen); + engine->setDirty(QPaintEngine::DirtyBrush); + engine->setDirty(QPaintEngine::DirtyFont); } } -#endif /*! Saves the current painter state (pushes the state onto a stack). A @@ -1843,7 +1849,7 @@ bool QPainter::begin(QPaintDevice *pd) // Copy painter properties from original paint device, // required for QPixmap::grabWidget() if (d->original_device->devType() == QInternal::Widget) { - initFrom(d->original_device); + d->initFrom(d->original_device); } else { d->state->layoutDirection = Qt::LayoutDirectionAuto; // make sure we have a font compatible with the paintdevice diff --git a/src/gui/painting/qpainter_p.h b/src/gui/painting/qpainter_p.h index bd2bc4c9b3..29d4880eb9 100644 --- a/src/gui/painting/qpainter_p.h +++ b/src/gui/painting/qpainter_p.h @@ -256,6 +256,7 @@ public: QTransform hidpiScaleTransform() const; static bool attachPainterPrivate(QPainter *q, QPaintDevice *pdev); void detachPainterPrivate(QPainter *q); + void initFrom(const QPaintDevice *device); QPaintDevice *device; QPaintDevice *original_device; -- cgit v1.2.3