From 2b8f5dd7593708e5fcc8106bd3d0f0f57fa87c2f Mon Sep 17 00:00:00 2001 From: Mike Walters Date: Sun, 6 Mar 2016 16:51:15 +0000 Subject: [PATCH] spectrogram: Workaround crash on final partial tile --- spectrogramplot.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spectrogramplot.cpp b/spectrogramplot.cpp index f2fc330..077daac 100644 --- a/spectrogramplot.cpp +++ b/spectrogramplot.cpp @@ -75,6 +75,7 @@ void SpectrogramPlot::paintMid(QPainter &painter, QRect &rect, range_t sa for (int x = rect.left(); x < rect.right(); x += linesPerTile()) { QPixmap *tile = getPixmapTile(tileID); // TODO: don't draw past rect.right() + // TODO: handle partial final tile painter.drawPixmap(QRect(x, rect.y(), linesPerTile() - xoffset, fftSize), *tile, QRect(xoffset, 0, linesPerTile() - xoffset, fftSize)); xoffset = 0; tileID += getStride() * linesPerTile(); @@ -127,6 +128,8 @@ void SpectrogramPlot::getLine(float *dest, off_t sample) { if (inputSource && fft) { auto buffer = inputSource->getSamples(sample, fftSize); + if (buffer == nullptr) + return; for (int i = 0; i < fftSize; i++) { buffer[i].real(buffer[i].real() * window[i]);