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-16 14:06:57 +0200
commit49df693145bbd94afd0b65a57c5b93d7773ff886 (patch)
treeacf735094aef96752a695c29cc9b2b355e22a9cd /src/gui/painting/qpainter_p.h
parented9effb62dd2f0d0a283ed783ba1e7c90e33e9d3 (diff)
QPainter: replace manual memory management [5/5]: d_ptrs
Replace a manually-managed pointer + size with QVarLengthArray, allowing use of pre-allocated space. Change-Id: Ife3abea0b3b0f2577bb76c348513d52d46f79641 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/gui/painting/qpainter_p.h')
-rw-r--r--src/gui/painting/qpainter_p.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/gui/painting/qpainter_p.h b/src/gui/painting/qpainter_p.h
index 09de84f2b2..7f5fe1a6c5 100644
--- a/src/gui/painting/qpainter_p.h
+++ b/src/gui/painting/qpainter_p.h
@@ -198,7 +198,11 @@ public:
~QPainterPrivate();
QPainter *q_ptr;
- QPainterPrivate **d_ptrs = nullptr;
+ // Allocate space for 4 d-pointers (enough for up to 4 sub-sequent
+ // redirections within the same paintEvent(), which should be enough
+ // in 99% of all cases). E.g: A renders B which renders C which renders D.
+ static constexpr qsizetype NDPtrs = 4;
+ QVarLengthArray<QPainterPrivate*, NDPtrs> d_ptrs;
std::unique_ptr<QPainterState> state;
template <typename T, std::size_t N = 8>
@@ -212,7 +216,6 @@ public:
QTransform invMatrix;
uint txinv:1;
uint inDestructor : 1;
- uint d_ptrs_size = 0;
uint refcount = 1;
enum DrawOperation { StrokeDraw = 0x1,