[Qt-interest] QPainter segmentation fault on Linux
Srdjan Todorovic
todorovic.s at googlemail.com
Fri Feb 20 16:59:14 CET 2009
Hi,
2009/2/20 Davide <davide83 at gmail.com>:
> 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.
Could you please try Samuel's example? That way we can try to keep
this debugging session a bit more scientific.
> 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);
Why multiply by 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
Glad it finally works, but we should find out what went wrong...
> Furthermore it works in windows.
Haha. Made me laugh. ;)
Srdjan
More information about the Qt-interest-old
mailing list