changeset 178:05015e717a0d

* Somewhat better handling of running out of memory or disc space
author Chris Cannam
date Mon, 13 Nov 2006 14:48:57 +0000
parents dbd34ff746c7
children 6a0d54f3f21a
files layer/SpectrogramLayer.cpp
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/layer/SpectrogramLayer.cpp	Fri Nov 10 13:27:57 2006 +0000
+++ b/layer/SpectrogramLayer.cpp	Mon Nov 13 14:48:57 2006 +0000
@@ -29,6 +29,7 @@
 #include <QRect>
 #include <QTimer>
 #include <QApplication>
+#include <QMessageBox>
 
 #include <iostream>
 
@@ -1576,6 +1577,7 @@
     size_t fftSize = getFFTSize(v);
 
     if (m_fftModels.find(v) != m_fftModels.end()) {
+        if (m_fftModels[v].first == 0) return 0;
         if (m_fftModels[v].first->getHeight() != fftSize / 2) {
             delete m_fftModels[v].first;
             m_fftModels.erase(v);
@@ -1593,6 +1595,16 @@
                                        true,
                                        m_candidateFillStartFrame);
 
+        if (!model->isOK()) {
+            QMessageBox::critical
+                (0, tr("FFT cache failed"),
+                 tr("Failed to create the FFT model for this spectrogram.\n"
+                    "There may be insufficient memory or disc space to continue."));
+            delete model;
+            m_fftModels[v] = FFTFillPair(0, 0);
+            return 0;
+        }
+
         m_fftModels[v] = FFTFillPair(model, 0);
 
         model->resume();