From 3bc9819c14e7ffc7b0492213704bdf768a30fb8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20L=C3=BCke?= Date: Thu, 2 Jan 2025 22:07:00 +0100 Subject: [PATCH] mana: fix plugin loading --- src/internal/mana_lib.hpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/internal/mana_lib.hpp b/src/internal/mana_lib.hpp index 4734aa3..6392d36 100644 --- a/src/internal/mana_lib.hpp +++ b/src/internal/mana_lib.hpp @@ -367,19 +367,26 @@ PluginWrapper load_mana_plugin(const std::string &filename, PluginWrapper result; result.pluginHandle = boost::dll::shared_library(filename, boost::dll::load_mode::rtld_global); - if (auto entryPoint = result.pluginHandle.get("mana_get_sink_plugin")) + try { - std::vector argv; - for (const auto &arg: pluginArgs) - argv.push_back(arg.data()); - result.destSink = std::make_unique(entryPoint(), argv.size(), argv.data()); + if (auto entryPoint = result.pluginHandle.get("mana_get_sink_plugin")) + { + std::vector argv; + for (const auto &arg: pluginArgs) + argv.push_back(arg.data()); + result.destSink = + std::make_unique(entryPoint(), argv.size(), argv.data()); + } } - else if (auto entryPoint = result.pluginHandle.get("mana_get_plugin")) + catch (const std::exception &e) { - result.manaCppPlugin = std::unique_ptr(entryPoint()); - if (!result.manaCppPlugin) - throw std::runtime_error("plugin {}: mana_get_plugin() returned nullptr"); - result.destSink = result.manaCppPlugin->makeSink(); + if (auto entryPoint = result.pluginHandle.get("mana_get_plugin")) + { + result.manaCppPlugin = std::unique_ptr(entryPoint()); + if (!result.manaCppPlugin) + throw std::runtime_error("plugin {}: mana_get_plugin() returned nullptr"); + result.destSink = result.manaCppPlugin->makeSink(); + } } return result;