diff --git a/src/lib/plugins/plugins.cpp b/src/lib/plugins/plugins.cpp index 9eb3e1759..2c390d738 100644 --- a/src/lib/plugins/plugins.cpp +++ b/src/lib/plugins/plugins.cpp @@ -220,11 +220,12 @@ void Plugins::loadAvailablePlugins() // PythonPlugin if (m_pythonPlugin) { - auto f = (QVector(*)()) m_pythonPlugin->resolve("pyfalkon_load_available_plugins"); + auto f = (void(*)(QVector*)) m_pythonPlugin->resolve("pyfalkon_load_available_plugins"); if (!f) { qWarning() << "Failed to resolve" << "pyfalkon_load_available_plugins"; } else { - const auto plugins = f(); + QVector plugins; + f(&plugins); for (const auto &plugin : plugins) { registerAvailablePlugin(plugin); } @@ -382,13 +383,15 @@ Plugins::Plugin Plugins::loadPythonPlugin(const QString &name) return Plugin(); } - auto f = (Plugin(*)(const QString &)) m_pythonPlugin->resolve("pyfalkon_load_plugin"); + auto f = (bool(*)(const QString &,Plugin*)) m_pythonPlugin->resolve("pyfalkon_load_plugin"); if (!f) { qWarning() << "Failed to resolve" << "pyfalkon_load_plugin"; return Plugin(); } - return f(name); + Plugin plugin; + f(name, &plugin); + return plugin; } bool Plugins::initPlugin(PluginInterface::InitState state, Plugin *plugin) diff --git a/src/plugins/PyFalkon/pythonplugin.cpp b/src/plugins/PyFalkon/pythonplugin.cpp index 357c625d4..4e69d4b35 100644 --- a/src/plugins/PyFalkon/pythonplugin.cpp +++ b/src/plugins/PyFalkon/pythonplugin.cpp @@ -91,7 +91,7 @@ void pyfalkon_register_plugin(PluginInterface *plugin) pluginInterface = plugin; } -Plugins::Plugin pyfalkon_load_plugin(const QString &name) +bool pyfalkon_load_plugin(const QString &name, Plugins::Plugin *out) { QString fullPath; if (QFileInfo(name).isAbsolute()) { @@ -100,15 +100,14 @@ Plugins::Plugin pyfalkon_load_plugin(const QString &name) fullPath = DataPaths::locate(DataPaths::Plugins, QSL("python/") + name); if (fullPath.isEmpty()) { qWarning() << "Plugin" << name << "not found"; - return Plugins::Plugin(); + return false; } } - Plugins::Plugin plugin; - plugin.type = Plugins::Plugin::PythonPlugin; - plugin.pluginId = QSL("python:%1").arg(QFileInfo(name).fileName()); - plugin.pluginSpec = Plugins::createSpec(DesktopFile(fullPath + QSL("/metadata.desktop"))); - return plugin; + out->type = Plugins::Plugin::PythonPlugin; + out->pluginId = QSL("python:%1").arg(QFileInfo(name).fileName()); + out->pluginSpec = Plugins::createSpec(DesktopFile(fullPath + QSL("/metadata.desktop"))); + return true; } void pyfalkon_init_plugin(Plugins::Plugin *plugin) @@ -143,24 +142,21 @@ void pyfalkon_init_plugin(Plugins::Plugin *plugin) plugin->data = QVariant::fromValue(static_cast(module)); } -QVector pyfalkon_load_available_plugins() +void pyfalkon_load_available_plugins(QVector *out) { - QVector plugins; - const QStringList dirs = script_paths(); for (const QString &dir : dirs) { const auto modules = QDir(dir).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); for (const QFileInfo &info : modules) { - Plugins::Plugin plugin = pyfalkon_load_plugin(info.absoluteFilePath()); + Plugins::Plugin plugin; + pyfalkon_load_plugin(info.absoluteFilePath(), &plugin); if (plugin.pluginSpec.name.isEmpty()) { qWarning() << "Invalid plugin spec of" << info.absoluteFilePath() << "plugin"; continue; } - plugins.append(plugin); + out->append(plugin); } } - - return plugins; } bool pyfalkon_run_script(const QByteArray &script) diff --git a/src/plugins/PyFalkon/pythonplugin.h b/src/plugins/PyFalkon/pythonplugin.h index b52560aa7..a00ac15d7 100644 --- a/src/plugins/PyFalkon/pythonplugin.h +++ b/src/plugins/PyFalkon/pythonplugin.h @@ -21,8 +21,8 @@ void pyfalkon_register_plugin(PluginInterface *plugin); -extern "C" Q_DECL_EXPORT Plugins::Plugin pyfalkon_load_plugin(const QString &name); +extern "C" Q_DECL_EXPORT bool pyfalkon_load_plugin(const QString &name, Plugins::Plugin *out); extern "C" Q_DECL_EXPORT void pyfalkon_init_plugin(Plugins::Plugin *plugin); -extern "C" Q_DECL_EXPORT QVector pyfalkon_load_available_plugins(); +extern "C" Q_DECL_EXPORT void pyfalkon_load_available_plugins(QVector *out); extern "C" Q_DECL_EXPORT bool pyfalkon_run_script(const QByteArray &script);