[Development] QImage::transformed returns shallow copy for QTransform::TxNone matrix type.

Benjamin TERRIER b.terrier at gmail.com
Tue Jul 12 10:15:01 CEST 2016


2016-07-11 21:21 GMT+02:00 Sune Vuorela <nospam at vuorela.dk>:
> On 2016-07-11, Allan Sandfeld Jensen <kde at carewolf.com> wrote:
>> On Monday 11 July 2016, Benjamin TERRIER wrote:
>>> QImage::detach() is not public API.
>>> However QPixmap::detach() is, so why QImage::detach() couldn't be made
>>> public too?
>>>
>> It probably should be. It is a lot more sensible to use than copy(rect()).
>
> https://codereview.qt-project.org/#/c/164886/
>
> /Sune
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development

Just something worth stating here, from Mark Mutz on the codereview:
    "QImage::detach() doesn't (if the QImage was constructed from the
mutable-uchar* ctor)."

So it's seem that all detach() functions which are internal will not
detach when using external data which is the case discussed here in
the first place.
However detach() member functions which are part of the public API
(e.g QPixmap::detach()) will always detach.

The consequence is that for Tomasz Olszak's use case calling
QImage::detach() is a bad idea because (1) it is not public API and
(2) it will NOT detach. So the only solution seems to call the non
const version of bits() as suggested earlier.

BR,

Benjamin Terrier



More information about the Development mailing list