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