# HG changeset patch # User Chris Cannam # Date 1568715693 -3600 # Node ID 4eac4bf35b45d4e6403b87f08ea5c6b798e5df6a # Parent cf3eb6252f427efa33ca6e7db16cfba005080733 More graceful handling of failure to construct FFT models in the case where the source model has already been deleted before this occurs diff -r cf3eb6252f42 -r 4eac4bf35b45 data/model/FFTModel.cpp --- a/data/model/FFTModel.cpp Tue Sep 17 10:42:55 2019 +0100 +++ b/data/model/FFTModel.cpp Tue Sep 17 11:21:33 2019 +0100 @@ -71,6 +71,8 @@ this, SIGNAL(modelChanged(ModelId))); connect(model.get(), SIGNAL(modelChangedWithin(ModelId, sv_frame_t, sv_frame_t)), this, SIGNAL(modelChangedWithin(ModelId, sv_frame_t, sv_frame_t))); + } else { + m_error = QString("Model #%1 is not available").arg(m_model.untyped); } } @@ -82,7 +84,15 @@ FFTModel::isOK() const { auto model = ModelById::getAs(m_model); - return (model && model->isOK()); + if (!model) { + m_error = QString("Model #%1 is not available").arg(m_model.untyped); + return false; + } + if (!model->isOK()) { + m_error = QString("Model #%1 is not OK").arg(m_model.untyped); + return false; + } + return true; } int diff -r cf3eb6252f42 -r 4eac4bf35b45 data/model/FFTModel.h --- a/data/model/FFTModel.h Tue Sep 17 10:42:55 2019 +0100 +++ b/data/model/FFTModel.h Tue Sep 17 11:21:33 2019 +0100 @@ -78,7 +78,7 @@ QString getBinName(int n) const override; bool shouldUseLogValueScale() const override { return true; } int getCompletion() const override; - virtual QString getError() const { return ""; } //!!!??? + virtual QString getError() const { return m_error; } virtual sv_frame_t getFillExtent() const { return getEndFrame(); } QString toDelimitedDataString(QString, DataExportOptions, sv_frame_t, sv_frame_t) const override { @@ -152,6 +152,7 @@ Window m_windower; mutable breakfastquay::FFT m_fft; double m_maximumFrequency; + mutable QString m_error; int getPeakPickWindowSize(PeakPickType type, sv_samplerate_t sampleRate, int bin, double &dist) const; diff -r cf3eb6252f42 -r 4eac4bf35b45 transform/FeatureExtractionModelTransformer.cpp --- a/transform/FeatureExtractionModelTransformer.cpp Tue Sep 17 10:42:55 2019 +0100 +++ b/transform/FeatureExtractionModelTransformer.cpp Tue Sep 17 11:21:33 2019 +0100 @@ -643,7 +643,7 @@ while (!ready && !m_abandoned) { { // scope so as to release input shared_ptr before sleeping auto input = ModelById::getAs(inputId); - if (!input) { + if (!input || !input->isOK()) { abandon(); return; } @@ -717,9 +717,13 @@ for (int j = 0; in_range_for(m_outputNos, j); ++j) { setCompletion(j, 100); } - //!!! need a better way to handle this -- previously we were using a QMessageBox but that isn't an appropriate thing to do here either SVDEBUG << "FeatureExtractionModelTransformer::run: Failed to create FFT model for input model " << inputId << ": " << err << endl; - throw AllocationFailed("Failed to create the FFT model for this feature extraction model transformer: error is: " + err); + m_message = "Failed to create the FFT model for this feature extraction model transformer: error is: " + err; + for (int cch = 0; cch < ch; ++cch) { + delete fftModels[cch]; + } + abandon(); + return; } fftModels.push_back(model); }