KIO::PreviewJob pixmaps + Qt4.5 crashes

Hans Meine hans_meine at gmx.net
Fri Mar 13 12:05:02 GMT 2009


Hi Aleix!

On Friday 13 March 2009 01:40:51 Aleix Pol wrote:
> While developing an application we've (me and afiestas) found that there is
> some problems while trying to paint QPixmaps that come from a
> KIO::PreviewJob. Here I am sending a program that exposes this problem and
> a couple of backtraces that might be of some use.
>
> The problem seems to be related to the new Qt 4.5 and its many
> --graphicssystem backends since, after some research we've noticed that it
> kind of works if we pass as a paremeter "--graphicssystem opengl" (with
> some problems), it works perfectly if we put "--grahicssystem <anything>"
> (yes, if it is not recognized it works just fine, maybe it is the old X11
> environment?) and if we do not put anything or "--graphicssystem raster" it
> crashes when the image is resized.

Funny, yesterday I found the reason for an annoying crash in one of my PyQt 
apps which happened only on Windows.  The reason was that I converted a QImage 
into a QPixmap and threw away the QImage.  With X11, this is perfectly fine, 
since the memory has been transferred into the X server, but with Windows' 
graphics system (and likely also with Qt's newer, optimized systems) where the 
conversion is cheap and does not copy the memory, this may lead to free'd 
memory being referenced.  (And yes, I also had delayed crashes upon the first 
window resize/repaint/...)

In case you wonder: The memory was not directly owned by the QImage, but by a 
numpy array which was referenced by an attribute on the QImage's python 
wrapper, exactly to prevent this crash.  Qt would probably have cared about 
not freeing the memory if it was managed by Qt directly, but now at least the 
python wrapper around the QImage was free'd by PyQt, which was sufficient to 
lead to the crash.

I hope that helps you in finding the problem (likely free'd image data); it 
looks really relevant.

Ciao,
  Hans




More information about the kde-core-devel mailing list