[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-15 13:16:18
Message-ID: 757d9a550903150616h860dd39t9d7041c684faa2f2 () mail ! gmail ! com
[Download RAW message or body]

On Fri, Mar 13, 2009 at 8:57 PM, Aleix Pol <aleixpol@kde.org> wrote:

> 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
>

Ok, so i recompiled Qt and now it works, i suppose I had my installation
kind of messed (and this made Qt run with raster, which i don't get why).

But of course, KIO::PreviewJob is still broken with raster which, even if it
doesn't really bother me, makes me wonder what will be the bug behaviour on
other platforms...

bye
Aleix

[Attachment #3 (text/html)]

On Fri, Mar 13, 2009 at 8:57 PM, Aleix Pol <span dir="ltr">&lt;<a \
href="mailto:aleixpol@kde.org">aleixpol@kde.org</a>&gt;</span> wrote:<br><div \
class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid \
rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> \
<div><div></div><div class="h5"><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" \
target="_blank">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>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></div></div>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><font color="#888888">Aleix<br>
</font></blockquote></div><br>Ok, so i recompiled Qt and now it works, i suppose I \
had my installation kind of messed (and this made Qt run with raster, which i
don&#39;t get why).<br>
<br>
But of course, KIO::PreviewJob is still broken with raster which, even
if it doesn&#39;t really bother me, makes me wonder what will be the bug
behaviour on other platforms...<br><br>
bye<br>
Aleix<br><br>



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

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