Mercurial > hg > svgui
comparison layer/SpectrogramLayer.cpp @ 1408:c8a6fd3f9dff fix-static-analysis
Use nullptr throughout
author | Chris Cannam |
---|---|
date | Mon, 26 Nov 2018 14:33:54 +0000 |
parents | 4c359c2b220c |
children | 8e40faa56ffd |
comparison
equal
deleted
inserted
replaced
1407:05d614f6e46d | 1408:c8a6fd3f9dff |
---|---|
54 //#define DEBUG_SPECTROGRAM_REPAINT 1 | 54 //#define DEBUG_SPECTROGRAM_REPAINT 1 |
55 | 55 |
56 using namespace std; | 56 using namespace std; |
57 | 57 |
58 SpectrogramLayer::SpectrogramLayer(Configuration config) : | 58 SpectrogramLayer::SpectrogramLayer(Configuration config) : |
59 m_model(0), | 59 m_model(nullptr), |
60 m_channel(0), | 60 m_channel(0), |
61 m_windowSize(1024), | 61 m_windowSize(1024), |
62 m_windowType(HanningWindow), | 62 m_windowType(HanningWindow), |
63 m_windowHopLevel(2), | 63 m_windowHopLevel(2), |
64 m_oversampling(1), | 64 m_oversampling(1), |
81 m_normalizeVisibleArea(false), | 81 m_normalizeVisibleArea(false), |
82 m_lastEmittedZoomStep(-1), | 82 m_lastEmittedZoomStep(-1), |
83 m_synchronous(false), | 83 m_synchronous(false), |
84 m_haveDetailedScale(false), | 84 m_haveDetailedScale(false), |
85 m_exiting(false), | 85 m_exiting(false), |
86 m_fftModel(0), | 86 m_fftModel(nullptr), |
87 m_wholeCache(0), | 87 m_wholeCache(nullptr), |
88 m_peakCache(0), | 88 m_peakCache(nullptr), |
89 m_peakCacheDivisor(8) | 89 m_peakCacheDivisor(8) |
90 { | 90 { |
91 QString colourConfigName = "spectrogram-colour"; | 91 QString colourConfigName = "spectrogram-colour"; |
92 int colourConfigDefault = int(ColourMapper::Green); | 92 int colourConfigDefault = int(ColourMapper::Green); |
93 | 93 |
146 | 146 |
147 delete m_fftModel; | 147 delete m_fftModel; |
148 delete m_peakCache; | 148 delete m_peakCache; |
149 delete m_wholeCache; | 149 delete m_wholeCache; |
150 | 150 |
151 m_fftModel = 0; | 151 m_fftModel = nullptr; |
152 m_peakCache = 0; | 152 m_peakCache = nullptr; |
153 m_wholeCache = 0; | 153 m_wholeCache = nullptr; |
154 } | 154 } |
155 | 155 |
156 pair<ColourScaleType, double> | 156 pair<ColourScaleType, double> |
157 SpectrogramLayer::convertToColourScale(int value) | 157 SpectrogramLayer::convertToColourScale(int value) |
158 { | 158 { |
580 } | 580 } |
581 if (name == "Threshold") { | 581 if (name == "Threshold") { |
582 return new LinearRangeMapper(-81, -1, -81, -1, tr("dB"), false, | 582 return new LinearRangeMapper(-81, -1, -81, -1, tr("dB"), false, |
583 { { -81, Strings::minus_infinity } }); | 583 { { -81, Strings::minus_infinity } }); |
584 } | 584 } |
585 return 0; | 585 return nullptr; |
586 } | 586 } |
587 | 587 |
588 void | 588 void |
589 SpectrogramLayer::setProperty(const PropertyName &name, int value) | 589 SpectrogramLayer::setProperty(const PropertyName &name, int value) |
590 { | 590 { |
1370 SpectrogramLayer::recreateFFTModel() | 1370 SpectrogramLayer::recreateFFTModel() |
1371 { | 1371 { |
1372 SVDEBUG << "SpectrogramLayer::recreateFFTModel called" << endl; | 1372 SVDEBUG << "SpectrogramLayer::recreateFFTModel called" << endl; |
1373 | 1373 |
1374 if (!m_model || !m_model->isOK()) { | 1374 if (!m_model || !m_model->isOK()) { |
1375 emit sliceableModelReplaced(m_fftModel, 0); | 1375 emit sliceableModelReplaced(m_fftModel, nullptr); |
1376 deleteDerivedModels(); | 1376 deleteDerivedModels(); |
1377 return; | 1377 return; |
1378 } | 1378 } |
1379 | 1379 |
1380 if (m_fftModel) m_fftModel->aboutToDelete(); | 1380 if (m_fftModel) m_fftModel->aboutToDelete(); |
1381 | 1381 |
1382 if (m_peakCache) m_peakCache->aboutToDelete(); | 1382 if (m_peakCache) m_peakCache->aboutToDelete(); |
1383 delete m_peakCache; | 1383 delete m_peakCache; |
1384 m_peakCache = 0; | 1384 m_peakCache = nullptr; |
1385 | 1385 |
1386 if (m_wholeCache) m_wholeCache->aboutToDelete(); | 1386 if (m_wholeCache) m_wholeCache->aboutToDelete(); |
1387 delete m_wholeCache; | 1387 delete m_wholeCache; |
1388 m_wholeCache = 0; | 1388 m_wholeCache = nullptr; |
1389 | 1389 |
1390 FFTModel *newModel = new FFTModel(m_model, | 1390 FFTModel *newModel = new FFTModel(m_model, |
1391 m_channel, | 1391 m_channel, |
1392 m_windowType, | 1392 m_windowType, |
1393 m_windowSize, | 1393 m_windowSize, |
1394 getWindowIncrement(), | 1394 getWindowIncrement(), |
1395 getFFTSize()); | 1395 getFFTSize()); |
1396 | 1396 |
1397 if (!newModel->isOK()) { | 1397 if (!newModel->isOK()) { |
1398 QMessageBox::critical | 1398 QMessageBox::critical |
1399 (0, tr("FFT cache failed"), | 1399 (nullptr, tr("FFT cache failed"), |
1400 tr("Failed to create the FFT model for this spectrogram.\n" | 1400 tr("Failed to create the FFT model for this spectrogram.\n" |
1401 "There may be insufficient memory or disc space to continue.")); | 1401 "There may be insufficient memory or disc space to continue.")); |
1402 delete newModel; | 1402 delete newModel; |
1403 delete m_fftModel; | 1403 delete m_fftModel; |
1404 m_fftModel = 0; | 1404 m_fftModel = nullptr; |
1405 return; | 1405 return; |
1406 } | 1406 } |
1407 | 1407 |
1408 FFTModel *oldModel = m_fftModel; | 1408 FFTModel *oldModel = m_fftModel; |
1409 m_fftModel = newModel; | 1409 m_fftModel = newModel; |
2471 } | 2471 } |
2472 | 2472 |
2473 RangeMapper * | 2473 RangeMapper * |
2474 SpectrogramLayer::getNewVerticalZoomRangeMapper() const | 2474 SpectrogramLayer::getNewVerticalZoomRangeMapper() const |
2475 { | 2475 { |
2476 if (!m_model) return 0; | 2476 if (!m_model) return nullptr; |
2477 return new SpectrogramRangeMapper(m_model->getSampleRate(), getFFTSize()); | 2477 return new SpectrogramRangeMapper(m_model->getSampleRate(), getFFTSize()); |
2478 } | 2478 } |
2479 | 2479 |
2480 void | 2480 void |
2481 SpectrogramLayer::updateMeasureRectYCoords(LayerGeometryProvider *v, const MeasureRect &r) const | 2481 SpectrogramLayer::updateMeasureRectYCoords(LayerGeometryProvider *v, const MeasureRect &r) const |