aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/coreSQLiteStudio/pluginloader.cpp
blob: 007e54c7b85b60067122da6103bfe06d11a465de (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "plugin.h"
#include "pluginloader.h"
#include "unused.h"

AbstractPluginLoader::~AbstractPluginLoader()
{
    foreach (Plugin* plugin, plugins.values())
    {
        plugin->deinit();
    }

    foreach (QPluginLoader* loader, plugins.keys())
    {
        if (!loader->unload())
            qDebug() << "Could not unload plugin" << loader->fileName() << ":" << loader->errorString();

        delete loader;
    }
    plugins.clear();
}

bool AbstractPluginLoader::add(QPluginLoader* loader, Plugin* plugin)
{
    if (!plugin->init())
        return false;

    plugins[loader] = plugin;
    return true;
}


QList<Plugin*> AbstractPluginLoader::getPlugins() const
{
    return plugins.values();
}