diff options
author | Ben Boeckel <MathStuf@gmail.com> | 2009-03-27 03:44:17 -0400 |
---|---|---|
committer | Ben Boeckel <MathStuf@gmail.com> | 2009-03-27 03:44:17 -0400 |
commit | 6fd11afdde2304a0e8e288c101be0f85a77a52bc (patch) | |
tree | 1eeff2a05d4a27f0dd0136314bbace8db54579a7 /sigtools | |
parent | 5c1308bfa586a6a77f909314ec2e5e7a8c402fad (diff) | |
download | sigen-6fd11afdde2304a0e8e288c101be0f85a77a52bc.tar.gz sigen-6fd11afdde2304a0e8e288c101be0f85a77a52bc.tar.xz sigen-6fd11afdde2304a0e8e288c101be0f85a77a52bc.zip |
Add ctor and dtor to PluginLoader::Private
Diffstat (limited to 'sigtools')
-rw-r--r-- | sigtools/PluginLoader.cpp | 32 | ||||
-rw-r--r-- | sigtools/PluginLoader_p.h | 5 |
2 files changed, 37 insertions, 0 deletions
diff --git a/sigtools/PluginLoader.cpp b/sigtools/PluginLoader.cpp index dc2608ab..b28d0a0c 100644 --- a/sigtools/PluginLoader.cpp +++ b/sigtools/PluginLoader.cpp @@ -91,6 +91,19 @@ Canvas* PluginLoader::loadCanvas(const QString& name, GameWrapper* game, Config* return NULL; } +PluginLoader::Private::Private() +{ + if (!KGlobal::dirs()->resourceDirs("sigmod").size()) + KGlobal::dirs()->addResourceType("sigmod", "data", "sigmod/"); +} + +PluginLoader::Private::~Private() +{ + QStringList types = m_available.keys(); + foreach (const QString& type, types) + clean(type); +} + void PluginLoader::Private::refresh(const QString& type) { QList<Service> curServices = m_available[type].values(); @@ -210,3 +223,22 @@ Game* PluginLoader::Private::game(const QString& name) return m_games[name]; return NULL; } + +void PluginLoader::Private::clean(const QString& type) +{ + // TODO fix this + QStringList curServices = m_available[type].keys(); + foreach (const QString& service, curServices) + { + if (m_available[type][service].second && !m_available[type][service].second->classesUsedCount()) + { + delete m_available[type][service].second; + m_available[type].remove(service); + } + } + if (type == "Sigmod") + { + qDeleteAll(m_games.values()); + m_games.clear(); + } +} diff --git a/sigtools/PluginLoader_p.h b/sigtools/PluginLoader_p.h index 5597a45a..89c37cda 100644 --- a/sigtools/PluginLoader_p.h +++ b/sigtools/PluginLoader_p.h @@ -50,12 +50,17 @@ class SIGTOOLS_NO_EXPORT Private : public QObject Q_OBJECT public: + Private(); + ~Private(); + void refresh(const QString& type); QStringList services(const QString& type); KService::Ptr service(const QString& type, const QString& name); Sigencore::Plugins::PluginBase* factory(const QString& type, const QString& name); Sigmod::Game* game(const QString& name); protected: + void clean(const QString& type); + typedef QPair<KService::Ptr, Sigencore::Plugins::PluginBase*> Service; typedef QMap<QString, Service> PluginList; QMap<QString, PluginList> m_available; |