Add missing null checks after detach
A few places we didn't check if detach() succeeded including in reinterpretAsFormat(), where it can be undone. Task-number: QTBUG-70785 Change-Id: Ibcc8e26e2961f6288eb7a045ae1cb28e59213a49 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
This commit is contained in:
parent
9436e3c315
commit
f864a62ccd
@ -1454,7 +1454,8 @@ void QImage::setDevicePixelRatio(qreal scaleFactor)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
detach();
|
detach();
|
||||||
d->devicePixelRatio = scaleFactor;
|
if (d)
|
||||||
|
d->devicePixelRatio = scaleFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -2240,8 +2241,15 @@ bool QImage::reinterpretAsFormat(Format format)
|
|||||||
return true;
|
return true;
|
||||||
if (qt_depthForFormat(format) != qt_depthForFormat(d->format))
|
if (qt_depthForFormat(format) != qt_depthForFormat(d->format))
|
||||||
return false;
|
return false;
|
||||||
if (!isDetached()) // Detach only if shared, not for read-only data.
|
if (!isDetached()) { // Detach only if shared, not for read-only data.
|
||||||
|
QImageData *oldD = d;
|
||||||
detach();
|
detach();
|
||||||
|
// In case detach() ran out of memory
|
||||||
|
if (!d) {
|
||||||
|
d = oldD;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
d->format = format;
|
d->format = format;
|
||||||
return true;
|
return true;
|
||||||
@ -3288,6 +3296,8 @@ void QImage::mirrored_inplace(bool horizontal, bool vertical)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
detach();
|
detach();
|
||||||
|
if (!d)
|
||||||
|
return;
|
||||||
if (!d->own_data)
|
if (!d->own_data)
|
||||||
*this = copy();
|
*this = copy();
|
||||||
|
|
||||||
@ -3440,6 +3450,8 @@ void QImage::rgbSwapped_inplace()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
detach();
|
detach();
|
||||||
|
if (!d)
|
||||||
|
return;
|
||||||
if (!d->own_data)
|
if (!d->own_data)
|
||||||
*this = copy();
|
*this = copy();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user