diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2019-06-13 21:21:53 +0200 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2019-06-13 21:23:22 +0200 |
commit | 784c94c7272684439abfa99273f5688d31ab2959 (patch) | |
tree | c1a94efae724e0bbb5bb5f44701c937b8dbac28a /src/gui/painting | |
parent | 779f1ff9fad916ce7beb7dfbf3a96b0207c01319 (diff) |
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 <shawn.rutledge@qt.io>
Diffstat (limited to 'src/gui/painting')
-rw-r--r-- | src/gui/painting/qpainter.cpp | 28 | ||||
-rw-r--r-- | src/gui/painting/qpainter_p.h | 1 |
2 files changed, 18 insertions, 11 deletions
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; |