From 3639d5789259561c531a3481d7061a0cb492c644 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Tue, 9 Oct 2018 12:05:28 +0200 Subject: Unlink plugins from lib/ libraries --- src/main.cpp | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 6940856..e0ba7eb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,7 +7,6 @@ */ #include "browser.h" -#include "plugin.h" #include "session.h" #include "util.h" #include "version.h" @@ -17,6 +16,8 @@ #include #include #include +#include +#include #ifdef _WIN32 #include #include @@ -102,19 +103,23 @@ int main(int argc, char **argv) return 0; } - QVector plugins; + QVector plugins; + CommandHash_t pluginCommands; + for(const QString &path : Util::files(config->value("plugins.path").value())) { - plugins.append(loadPluginFromPath(path)); - } - QMap> pluginCommands; - for(const auto &plugin : plugins) { - auto *pluginInterface = qobject_cast(plugin.instance); - Q_CHECK_PTR(pluginInterface); - - QHashIterator> i(pluginInterface->commands()); - while(i.hasNext()) { - i.next(); - pluginCommands.insert(i.key(), i.value()); + QPluginLoader *loader = new QPluginLoader(path); + const bool loaded = loader->load(); +#ifdef QT_DEBUG + qDebug("Loading plugin %s %s", qUtf8Printable(path), loaded ? "[ok]" : "[failed]"); +#endif + + if(loader->load()) { + plugins.append(loader); + auto *plugin = qobject_cast(loader->instance()); + pluginCommands.unite(plugin->commands()); + } else { + qDebug("%s", qUtf8Printable(loader->errorString())); + delete loader; } } @@ -187,11 +192,7 @@ int main(int argc, char **argv) auto profile = config->value("profile.default"); app.setConfiguration(config); - app.setup(); - - for(const Plugin &plugin : plugins) { - app.registerPlugin(plugin); - } + app.setup(plugins); QStringList urls; if(arguments) { -- cgit v1.2.1