summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qcolorspace_p.h
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-10-04 21:19:32 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-10-18 14:02:32 +0200
commitf1408d9966854cf55f15d59547f99d3aa2585fd4 (patch)
tree5d845cd07d63695ca0d633ed738f2f2bac84a440 /src/gui/painting/qcolorspace_p.h
parent9ceedd586321a2eeac4b63ee90d4e9726e143b78 (diff)
QColorSpace: port to QESDP
Replace the hand-rolled refcount management with QESDP. Since the class has a default-constructed / moved-from state where the d-pointer can be nullptr, add a in-class detach() that ensures a private object. Change-Id: Id81431fa60132dbc0eed45bb60b38d4f7d73833f Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/gui/painting/qcolorspace_p.h')
-rw-r--r--src/gui/painting/qcolorspace_p.h18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/gui/painting/qcolorspace_p.h b/src/gui/painting/qcolorspace_p.h
index e7add19ed3..a6c0616e4d 100644
--- a/src/gui/painting/qcolorspace_p.h
+++ b/src/gui/painting/qcolorspace_p.h
@@ -95,24 +95,14 @@ public:
QColorSpacePrivate(const QColorSpacePrimaries &primaries, QColorSpace::TransferFunction fun, float gamma);
QColorSpacePrivate(const QColorSpacePrivate &other) = default;
- // named different from get to avoid accidental detachs
- static QColorSpacePrivate *getWritable(QColorSpace &colorSpace)
+ static const QColorSpacePrivate *get(const QColorSpace &colorSpace)
{
- if (!colorSpace.d_ptr) {
- colorSpace.d_ptr = new QColorSpacePrivate;
- colorSpace.d_ptr->ref.ref();
- } else if (colorSpace.d_ptr->ref.loadRelaxed() != 1) {
- colorSpace.d_ptr->ref.deref();
- colorSpace.d_ptr = new QColorSpacePrivate(*colorSpace.d_ptr);
- colorSpace.d_ptr->ref.ref();
- }
- Q_ASSERT(colorSpace.d_ptr->ref.loadRelaxed() == 1);
- return colorSpace.d_ptr;
+ return colorSpace.d_ptr.get();
}
- static const QColorSpacePrivate *get(const QColorSpace &colorSpace)
+ static QColorSpacePrivate *get(QColorSpace &colorSpace)
{
- return colorSpace.d_ptr;
+ return colorSpace.d_ptr.get();
}
void initialize();