From 74a5307b58e5dfb0aee988014470fd64aa5f4267 Mon Sep 17 00:00:00 2001 From: Mike Walters Date: Sun, 6 Mar 2016 17:38:51 +0000 Subject: [PATCH] spectrogram: Use unique_ptr for fft --- spectrogramplot.cpp | 8 +------- spectrogramplot.h | 3 +-- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/spectrogramplot.cpp b/spectrogramplot.cpp index fb14fd8..a05255b 100644 --- a/spectrogramplot.cpp +++ b/spectrogramplot.cpp @@ -45,11 +45,6 @@ SpectrogramPlot::SpectrogramPlot(SampleSource> *src) } -SpectrogramPlot::~SpectrogramPlot() -{ - delete fft; -} - void SpectrogramPlot::paintMid(QPainter &painter, QRect &rect, range_t sampleRange) { if (!inputSource || inputSource->count() == 0) @@ -143,8 +138,7 @@ void SpectrogramPlot::setSampleRate(int rate) void SpectrogramPlot::setFFTSize(int size) { fftSize = size; - delete fft; - fft = new FFT(fftSize); + fft.reset(new FFT(fftSize)); window.reset(new float[fftSize]); for (int i = 0; i < fftSize; i++) { diff --git a/spectrogramplot.h b/spectrogramplot.h index 48cb30e..4a067c0 100644 --- a/spectrogramplot.h +++ b/spectrogramplot.h @@ -38,7 +38,6 @@ class SpectrogramPlot : public Plot public: SpectrogramPlot(SampleSource> *src); - ~SpectrogramPlot(); void paintMid(QPainter &painter, QRect &rect, range_t sampleRange); @@ -66,7 +65,7 @@ private: const int linesPerGraduation = 50; const int tileSize = 65536; // This must be a multiple of the maximum FFT size - FFT *fft = nullptr; + std::unique_ptr fft; std::unique_ptr window; fftwf_complex *lineBuffer = nullptr; QCache pixmapCache;