diff data/fileio/CSVFileReader.cpp @ 1508:b837ccdd4946 import-audio-data

Catch failure to create model, e.g. because 0 channels for wave-file model
author Chris Cannam
date Tue, 04 Sep 2018 14:11:10 +0100
parents f0c2b8b31609
children 3299b42d8bdd
line wrap: on
line diff
--- a/data/fileio/CSVFileReader.cpp	Tue Sep 04 13:19:20 2018 +0100
+++ b/data/fileio/CSVFileReader.cpp	Tue Sep 04 14:11:10 2018 +0100
@@ -311,13 +311,25 @@
                     break;
                 }
 
-                if (model) {
+                if (model && model->isOK()) {
                     if (m_filename != "") {
                         model->setObjectName(m_filename);
                     }
                 }
             }
 
+            if (!model || !model->isOK()) {
+                SVCERR << "Failed to create model to load CSV file into"
+                       << endl;
+                if (model) {
+                    delete model;
+                    model = 0;
+                    model1 = 0; model2 = 0; model2a = 0; model2b = 0;
+                    model3 = 0; modelW = 0;
+                }
+                break;
+            }
+            
             float value = 0.f;
             float pitch = 0.f;
             QString label = "";