PDA

View Full Version : Random-memory image in QwtPlotSpectrogram when using invalid Z-interval



alex_sh
24th January 2011, 17:21
Hello,

Our application sometimes triggers a condition when the Z-interval set for QwtMatrixRasterData is invalid (contains NaNs, for example) because the data itself is invalid. The result is that QwtPlotSpectrogram draws unfilled image from uninitialized memory.

This seems to happen in QwtPlotSpectrogram::renderImage(), near


if ( !intensityRange.isValid() )
return image;


If I modify it to the following, a proper transparent image is returned and the random-colored blocks go away.


if ( !intensityRange.isValid() ) {
image.fill(qRgba(0, 0, 0, 0));
return image;
}


To reproduce, just change
setInterval( Qt::ZAxis, QwtInterval(1.0, 6.0) );
to
setInterval( Qt::ZAxis, QwtInterval(1.0, -1.0) );
in the rasterview example.

Thanks!

Uwe
24th January 2011, 19:30
Hm - isn't a null image ( QImage() ) a more adequate return value for this situation ?

Uwe

alex_sh
24th January 2011, 19:40
I'm not sure - for me it's the random-colored blocks on the plot (because of uninitialized memory) that are the problem. As long as the plot behaves normally (that is, not randomly, like now), I'm ok.
Note that there are other items on the plot (besides the spectrogram) which should still work, that's why I picked a transparent image. Also, since NaN behaves like a transparent pixel, and if all my data is composed of NaNs (so the intervals are NaNs as well), I guess that's what I expected. If null image provides all that, I have nothing against it.
Thanks