Mercurial > hg > piper-cpp
changeset 77:ac1e4634479b
Ensure finish() can be called even if not configured (otherwise there's no way to dispose of the plugin)
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Tue, 11 Oct 2016 14:36:43 +0100 |
parents | 5909d5d25733 |
children | f4b5c0e70771 |
files | vamp-server/server.cpp |
diffstat | 1 files changed, 13 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/vamp-server/server.cpp Tue Oct 11 14:36:18 2016 +0100 +++ b/vamp-server/server.cpp Tue Oct 11 14:36:43 2016 +0100 @@ -230,14 +230,21 @@ case RRType::Finish: { - response.finishResponse.plugin = request.finishRequest.plugin; - response.finishResponse.features = - request.finishRequest.plugin->getRemainingFeatures(); + auto &freq = request.finishRequest; + response.finishResponse.plugin = freq.plugin; + + auto h = mapper.pluginToHandle(freq.plugin); + // Finish can be called (to unload the plugin) even if the + // plugin has never been configured or used. But we want to + // make sure we call getRemainingFeatures only if we have + // actually configured the plugin. + if (mapper.isConfigured(h)) { + response.finishResponse.features = freq.plugin->getRemainingFeatures(); + } // We do not delete the plugin here -- we need it in the - // mapper when converting the features. It gets deleted by the - // caller. - + // mapper when converting the features. It gets deleted in the + // calling function. response.success = true; break; }