summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpainter_p.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2020-06-01 11:54:45 +0200
committerMarc Mutz <marc.mutz@kdab.com>2021-07-14 17:56:01 +0200
commit85e82de916e8799ee1198c63566b7a1f5e47f514 (patch)
treed662e279ff93cf38cb5010eb2f582cf6d47aa0bc /src/gui/painting/qpainter_p.h
parent5a7f4c1f4964a4bf6595002478fbcd474cedd8a6 (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.h10
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