# HG changeset patch # User Chris Cannam # Date 1534170332 -3600 # Node ID fde8c497373fe8662c5b3733aefe19224827f70b # Parent 6965c83c8fa7e7f42c7106a23c0f96f3eae88fa6 Avoid crashing if an effects plugin can't be instantiated and so the output vector is empty in the transformer's run() method diff -r 6965c83c8fa7 -r fde8c497373f transform/RealTimeEffectModelTransformer.cpp --- a/transform/RealTimeEffectModelTransformer.cpp Mon Aug 13 11:43:38 2018 +0100 +++ b/transform/RealTimeEffectModelTransformer.cpp Mon Aug 13 15:25:32 2018 +0100 @@ -47,14 +47,14 @@ QString pluginId = transform.getPluginIdentifier(); -// SVDEBUG << "RealTimeEffectModelTransformer::RealTimeEffectModelTransformer: plugin " << pluginId << ", output " << output << endl; + SVDEBUG << "RealTimeEffectModelTransformer::RealTimeEffectModelTransformer: plugin " << pluginId << ", output " << transform.getOutput() << endl; RealTimePluginFactory *factory = RealTimePluginFactory::instanceFor(pluginId); if (!factory) { - cerr << "RealTimeEffectModelTransformer: No factory available for plugin id \"" - << pluginId << "\"" << endl; + SVCERR << "RealTimeEffectModelTransformer: No factory available for plugin id \"" + << pluginId << "\"" << endl; return; } @@ -67,8 +67,8 @@ input->getChannelCount()); if (!m_plugin) { - cerr << "RealTimeEffectModelTransformer: Failed to instantiate plugin \"" - << pluginId << "\"" << endl; + SVCERR << "RealTimeEffectModelTransformer: Failed to instantiate plugin \"" + << pluginId << "\"" << endl; return; } @@ -129,13 +129,25 @@ SVDEBUG << "RealTimeEffectModelTransformer::run: Waiting for input model to be ready..." << endl; usleep(500000); } - if (m_abandoned) return; + if (m_abandoned) { + return; + } + if (m_outputs.empty()) { + return; + } + + SparseTimeValueModel *stvm = + dynamic_cast(m_outputs[0]); + WritableWaveFileModel *wwfm = + dynamic_cast(m_outputs[0]); - SparseTimeValueModel *stvm = dynamic_cast(m_outputs[0]); - WritableWaveFileModel *wwfm = dynamic_cast(m_outputs[0]); - if (!stvm && !wwfm) return; + if (!stvm && !wwfm) { + return; + } - if (stvm && (m_outputNo >= int(m_plugin->getControlOutputCount()))) return; + if (stvm && (m_outputNo >= int(m_plugin->getControlOutputCount()))) { + return; + } sv_samplerate_t sampleRate = input->getSampleRate(); int channelCount = input->getChannelCount();