diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2020-06-01 11:54:45 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2021-07-14 17:56:01 +0200 |
commit | 85e82de916e8799ee1198c63566b7a1f5e47f514 (patch) | |
tree | d662e279ff93cf38cb5010eb2f582cf6d47aa0bc /src/gui/painting/qpainter_p.h | |
parent | 5a7f4c1f4964a4bf6595002478fbcd474cedd8a6 (diff) |
QPainter: replace manual memory management [3/5]: engine
Use unique_ptr to indicate ownership, even though it's conditional (on
QPaintEngine::autoDestruct()). That just requires a custom deleter.
Change-Id: Icf8e356c333f9617b2e5172b14f13197e63c9502
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/gui/painting/qpainter_p.h')
-rw-r--r-- | src/gui/painting/qpainter_p.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/gui/painting/qpainter_p.h b/src/gui/painting/qpainter_p.h index 8994bcd3e7..c9caca7901 100644 --- a/src/gui/painting/qpainter_p.h +++ b/src/gui/painting/qpainter_p.h @@ -268,7 +268,15 @@ public: QPaintDevice *device; QPaintDevice *original_device; QPaintDevice *helper_device; - QPaintEngine *engine; + struct QPaintEngineDestructor { + void operator()(QPaintEngine *pe) const noexcept + { + if (pe && pe->autoDestruct()) + delete pe; + } + }; + + std::unique_ptr<QPaintEngine, QPaintEngineDestructor> engine; QEmulationPaintEngine *emulationEngine; QPaintEngineEx *extended; QBrush colorBrush; // for fill with solid color |