diff --git a/src/lib/plugins/plugins.cpp b/src/lib/plugins/plugins.cpp index 03f422647..6124eb16b 100644 --- a/src/lib/plugins/plugins.cpp +++ b/src/lib/plugins/plugins.cpp @@ -415,18 +415,26 @@ Plugins::Plugin Plugins::loadSharedLibraryPlugin(const QString &name) Plugins::Plugin Plugins::loadPythonPlugin(const QString &name) { + Plugin out; + if (!m_pythonPlugin) { qWarning() << "Python support plugin is not loaded"; - return Plugin(); + return out; } - auto f = (Plugin(*)(const QString &)) m_pythonPlugin->resolve("pyfalkon_load_plugin"); + auto f = (Plugin*(*)(const QString &)) m_pythonPlugin->resolve("pyfalkon_load_plugin"); if (!f) { qWarning() << "Failed to resolve" << "pyfalkon_load_plugin"; - return Plugin(); + return out; } - return f(name); + Plugin *p = f(name); + if (p) { + out = *p; + delete p; + } + + return out; } bool Plugins::initPlugin(PluginInterface::InitState state, Plugin *plugin) diff --git a/src/plugins/PyFalkon/pythonplugin.cpp b/src/plugins/PyFalkon/pythonplugin.cpp index 5c4eccc58..fb0af280c 100644 --- a/src/plugins/PyFalkon/pythonplugin.cpp +++ b/src/plugins/PyFalkon/pythonplugin.cpp @@ -82,7 +82,7 @@ void pyfalkon_register_plugin(PluginInterface *plugin) pluginInterface = plugin; } -Plugins::Plugin pyfalkon_load_plugin(const QString &name) +Plugins::Plugin *pyfalkon_load_plugin(const QString &name) { QString fullPath; if (QFileInfo(name).isAbsolute()) { @@ -91,15 +91,15 @@ Plugins::Plugin pyfalkon_load_plugin(const QString &name) fullPath = DataPaths::locate(DataPaths::Plugins, name); if (fullPath.isEmpty()) { qWarning() << "Python plugin" << name << "not found"; - return Plugins::Plugin(); + return nullptr; } } - Plugins::Plugin plugin; - plugin.type = Plugins::Plugin::PythonPlugin; - plugin.pluginId = QSL("python:%1").arg(QFileInfo(name).fileName()); - plugin.pluginPath = fullPath; - plugin.pluginSpec = Plugins::createSpec(DesktopFile(fullPath + QSL("/metadata.desktop"))); + Plugins::Plugin *plugin = new Plugins::Plugin; + plugin->type = Plugins::Plugin::PythonPlugin; + plugin->pluginId = QSL("python:%1").arg(QFileInfo(name).fileName()); + plugin->pluginPath = fullPath; + plugin->pluginSpec = Plugins::createSpec(DesktopFile(fullPath + QSL("/metadata.desktop"))); return plugin; } diff --git a/src/plugins/PyFalkon/pythonplugin.h b/src/plugins/PyFalkon/pythonplugin.h index db3bd8308..21ef8b632 100644 --- a/src/plugins/PyFalkon/pythonplugin.h +++ b/src/plugins/PyFalkon/pythonplugin.h @@ -21,5 +21,5 @@ void pyfalkon_register_plugin(PluginInterface *plugin); -extern "C" Q_DECL_EXPORT Plugins::Plugin pyfalkon_load_plugin(const QString &name); +extern "C" Q_DECL_EXPORT Plugins::Plugin *pyfalkon_load_plugin(const QString &name); extern "C" Q_DECL_EXPORT void pyfalkon_init_plugin(Plugins::Plugin *plugin);