[Qt-interest] crash with QPixmap::fromImage(image);
Matthias Pospiech
matthias.pospiech at gmx.de
Mon Jul 19 08:54:45 CEST 2010
Tim Dewhirst schrieb:
> Hello,
>
> Matthias Pospiech wrote:
>> In this code I experience a crash in the line with QPixmap::fromImage
>>
>> void QCameraImage::setImage(const QImage & image)
>> {
>> d->time.start();
>> d->imageChanged = true;
>> d->image = image;
>> d->pixmap = QPixmap::fromImage(d->image);
>> update(); // calls paintEvent
>> }
>>
>> and need help since I can not see at all how to debug this.
>
> Odd; your stack jumps off to QWizard and you don't show what value d
> is in frame 6. If I had to guess, I would say that d is uninitialized
> or was initialized but was subsequently free'd and not NULL'd off.
d is valid. It only gets deleted on destruction.
> Another possibility is that the QImage was constructed from raw data
> and that the raw image data is no longer valid.
That could happen. But then I need to understand more about how QImage
uses the data. This is how the data gets there:
QImage QCameraSMX::image()
{
return QImage((uchar*)d->frameArrayRgb, viewPort().width(),
viewPort().height(), QImage::Format_RGB888);
}
void DialogCameraSMX::OnButtonCapture()
{
if (cameraSMX->isInitialized())
{
cameraSMX->takeSnapshot();
ui->widgetCameraImage->setImage(cameraSMX->image());
}
}
The data thus is raw, but I do not want QImage to rely on its validity,
I want it to copy the data.
So how would I do that? And what effect might the copy of the QImage have?
Matthias
More information about the Qt-interest-old
mailing list