--0016364c720b67f4850465058281 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On Fri, Mar 13, 2009 at 5:51 PM, Hans Meine wrote: > On Friday 13 March 2009 15:14:33 Aleix Pol wrote: > > > #3) The other response is likely right. I bet the following accesses > > > deleted memory with the Raster engine: > > > > > > const int w = 16, h = 16; > > > QRgb* data = new QRgb[w*h*4]; > > > std::memset(data, 0, w*h*4); > > > QImage* i = new QImage(data, w, h, > QImage::Format_ARGB32_Premultiplied); > > > QPixmap p = QPixmap::fromImage(*i); > > > delete i; > > > //Do stuff with p here > > > > > > There seems to be no deep copy going on here (and coincidentally, > > > QImage::convertToFormat docs lie --- it doesn't always return a copy) > > > > Yes it is possible, but I don't know where this copy happens at all. > > Exactly, Maskim (and I) pointed out that there *is* no copy. > AFAICS, it would be enough to detach the QImage, alas detach() is internal. > How about > > QImage* i = new QImage((const QRgb *)data, w, h, > QImage::Format_ARGB32_Premultiplied); > (void)i.bits(); // detach from data > > if the above is the actual code? > > BTW: It probably works with OpenGL for you, because OpenGL is another > client/server system, i.e. the data is copied into an OpenGL-managed > area (possibly even the graphics card's memory). > > HTH, > Hans > > Is there a way to make sure what graphicssystem is being used? I haven't asked for raster at any moment... I only want it to work :S Plus we should warn the user the usage of raster. Thanks, Aleix --0016364c720b67f4850465058281 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On Fri, Mar 13, 2009 at 5:51 PM, Hans Meine <hans_meine@gmx.net<= /a>> wrote:
On Friday 13 March 2009 15:14:33 Aleix Pol wrote:
> > #3) The other response is likely right. I bet the following acces= ses
> > deleted memory with the Raster engine:
> >
> > const int w =3D 16, h =3D 16;
> > QRgb* data =3D new QRgb[w*h*4];
> > std::memset(data, 0, w*h*4);
> > QImage* i =3D new QImage(data, w, h, QImage::Format_ARGB32_Premul= tiplied);
> > QPixmap p =3D QPixmap::fromImage(*i);
> > delete i;
> > //Do stuff with p here
> >
> > There seems to be no deep copy going on here (and coincidentally,=
> > QImage::convertToFormat docs lie --- it doesn't always return= a copy)
>
> Yes it is possible, but I don't know where this copy happens at al= l.

Exactly, Maskim (and I) pointed out that there *is* no copy.
AFAICS, it would be enough to detach the QImage, alas detach() is internal.=
How about

QImage* i =3D new QImage((const QRgb *)data, w, h, QImage::Format_ARGB32_Pr= emultiplied);
(void)i.bits(); // detach from data

if the above is the actual code?

BTW: It probably works with OpenGL for you, because OpenGL is another
client/server system, i.e. the data is copied into an OpenGL-managed
area (possibly even the graphics card's memory).

HTH,
=C2=A0Hans


Is there a way to make sure what graphicssyst= em is being used?
I haven't asked for raster at any moment...
I only want it to work :S

Plus we should warn the user the usage of= raster.

Thanks,
Aleix
--0016364c720b67f4850465058281--