summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qlabel_p.h
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2022-02-23 17:06:49 +0100
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2022-03-01 01:55:08 +0100
commit9c947c131d05d075f29fcfef6b0f36e38b30567b (patch)
tree8220154ff516a8fe0f79fda90d54279dad85c147 /src/widgets/widgets/qlabel_p.h
parentbec3c2a33576bb57306cfeef0343b436cb50bd2c (diff)
QLabel: remove some dynamic allocations
QLabelPrivate uses pointers and dynamically allocated objects as a form of optional. To add insult to injury, the objects are implictly shared, compounding the effects in terms of required allocations. Just use std::optional instead. Change-Id: Ica582dc0d2a9ab56f45ce305290541383b7ddeef Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/widgets/qlabel_p.h')
-rw-r--r--src/widgets/widgets/qlabel_p.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/widgets/widgets/qlabel_p.h b/src/widgets/widgets/qlabel_p.h
index d26bbf6a7f..b7e347b1d5 100644
--- a/src/widgets/widgets/qlabel_p.h
+++ b/src/widgets/widgets/qlabel_p.h
@@ -69,6 +69,8 @@
#include "qmenu.h"
#endif
+#include <optional>
+
QT_BEGIN_NAMESPACE
class Q_AUTOTEST_EXPORT QLabelPrivate : public QFramePrivate
@@ -117,11 +119,11 @@ public:
mutable QSize sh;
mutable QSize msh;
QString text;
- QPixmap *pixmap;
- QPixmap *scaledpixmap;
- QImage *cachedimage;
+ std::optional<QPixmap> pixmap;
+ std::optional<QPixmap> scaledpixmap;
+ std::optional<QImage> cachedimage;
#ifndef QT_NO_PICTURE
- QPicture *picture;
+ std::optional<QPicture> picture;
#endif
#if QT_CONFIG(movie)
QPointer<QMovie> movie;