[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: KIO::PreviewJob pixmaps + Qt4.5 crashes
From:       Aleix Pol <aleixpol () kde ! org>
Date:       2009-03-13 19:57:23
Message-ID: 757d9a550903131257j3fd86a6dr9f1956122a9d6ae9 () mail ! gmail ! com
[Download RAW message or body]

On Fri, Mar 13, 2009 at 5:51 PM, Hans Meine <hans_meine@gmx.net> 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

[Attachment #3 (text/html)]

<div class="gmail_quote">On Fri, Mar 13, 2009 at 5:51 PM, Hans Meine <span \
dir="ltr">&lt;<a href="mailto:hans_meine@gmx.net">hans_meine@gmx.net</a>&gt;</span> \
wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, \
204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> <div class="im">On Friday 13 \
March 2009 15:14:33 Aleix Pol wrote:<br> &gt; &gt; #3) The other response is likely \
right. I bet the following accesses<br> &gt; &gt; deleted memory with the Raster \
engine:<br> &gt; &gt;<br>
&gt; &gt; const int w = 16, h = 16;<br>
&gt; &gt; QRgb* data = new QRgb[w*h*4];<br>
&gt; &gt; std::memset(data, 0, w*h*4);<br>
&gt; &gt; QImage* i = new QImage(data, w, h, \
QImage::Format_ARGB32_Premultiplied);<br> &gt; &gt; QPixmap p = \
QPixmap::fromImage(*i);<br> &gt; &gt; delete i;<br>
&gt; &gt; //Do stuff with p here<br>
&gt; &gt;<br>
&gt; &gt; There seems to be no deep copy going on here (and coincidentally,<br>
&gt; &gt; QImage::convertToFormat docs lie --- it doesn&#39;t always return a \
copy)<br> &gt;<br>
&gt; Yes it is possible, but I don&#39;t know where this copy happens at all.<br>
<br>
</div>Exactly, Maskim (and I) pointed out that there *is* no copy.<br>
AFAICS, it would be enough to detach the QImage, alas detach() is internal.<br>
How about<br>
<br>
QImage* i = new QImage((const QRgb *)data, w, h, \
QImage::Format_ARGB32_Premultiplied);<br> (void)i.bits(); // detach from data<br>
<br>
if the above is the actual code?<br>
<br>
BTW: It probably works with OpenGL for you, because OpenGL is another<br>
client/server system, i.e. the data is copied into an OpenGL-managed<br>
area (possibly even the graphics card&#39;s memory).<br>
<br>
HTH,<br>
<font color="#888888">   Hans<br>
<br>
</font></blockquote></div><br>Is there a way to make sure what graphicssystem is \
being used?<br>I haven&#39;t asked for raster at any moment...<br><br>I only want it \
to work :S<br><br>Plus we should warn the user the usage of raster.<br> \
<br>Thanks,<br>Aleix<br>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic