[Qt-interest] QPainter segmentation fault on Linux

Davide davide83 at gmail.com
Fri Feb 20 16:50:10 CET 2009


Hi,

On Fri, Feb 20, 2009 at 3:58 PM, Samuel Rødal <sroedal at trolltech.com> wrote:
> I tried to reproduce it here with the following code:
>
> But it doesn't crash for me. Does this example crash for you?

I didn't tried your example, but I've got an important update.
The program works in this way:

I declared an array as private in my class:
      uchar localdata[960000];

and I add this code:
      memcpy(localdata, Image.data, Image.width*Image.height*2);
      qImage = new QImage(localdata, Image.width, Image.height,
QImage::Format_RGB32);

and than as always:
     QPainter p;
     p.begin(qImage);
     p.setPen((Qt::GlobalColor)(Qt::cyan));
     p.drawRect(2, 2, 20, 20);
     p.end();

In this way the program run magically without any error. I can see my
image with a rectangle.
The problem is that I shouldn't get an error even without this trick
because Image.data is a valid buffer. Furthermore it works in windows.

I think I hate QPainter class...  :D

Regards

-- 
Davide




More information about the Qt-interest-old mailing list