Fix memory leak

When creating a new QColorSpacePrivate it must be reffed otherwise in
the destructor the deref() will bring the count to -1 which is true
and will not delete the d_ptr.

Change-Id: Id569bae22134b56bf6ad37158d7079b495599fd7
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
Giulio Camuffo 2020-03-20 14:05:34 +01:00
parent 7e4361ffbd
commit 20eabb72de

View File

@ -553,6 +553,7 @@ void QColorSpace::setTransferFunction(QColorSpace::TransferFunction transferFunc
return;
if (!d_ptr) {
d_ptr = new QColorSpacePrivate(Primaries::Custom, transferFunction, gamma);
d_ptr->ref.ref();
return;
}
if (d_ptr->transferFunction == transferFunction && d_ptr->gamma == gamma)
@ -593,6 +594,7 @@ void QColorSpace::setPrimaries(QColorSpace::Primaries primariesId)
return;
if (!d_ptr) {
d_ptr = new QColorSpacePrivate(primariesId, TransferFunction::Custom, 0.0f);
d_ptr->ref.ref();
return;
}
if (d_ptr->primaries == primariesId)
@ -618,6 +620,7 @@ void QColorSpace::setPrimaries(const QPointF &whitePoint, const QPointF &redPoin
return;
if (!d_ptr) {
d_ptr = new QColorSpacePrivate(primaries, TransferFunction::Custom, 0.0f);
d_ptr->ref.ref();
return;
}
QColorMatrix toXyz = primaries.toXyzMatrix();