summaryrefslogtreecommitdiffstats
path: root/sigtools/PluginLoader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sigtools/PluginLoader.cpp')
-rw-r--r--sigtools/PluginLoader.cpp26
1 files changed, 9 insertions, 17 deletions
diff --git a/sigtools/PluginLoader.cpp b/sigtools/PluginLoader.cpp
index b28d0a0c..7bdd927b 100644
--- a/sigtools/PluginLoader.cpp
+++ b/sigtools/PluginLoader.cpp
@@ -55,11 +55,6 @@ KService::Ptr PluginLoader::service(const QString& type, const QString& name)
return loader->service(type, name);
}
-Game* PluginLoader::game(const QString& name)
-{
- return loader->game(name);
-}
-
PluginBase* PluginLoader::plugin(const QString& type, const QString& name)
{
return loader->factory(type, name);
@@ -75,6 +70,11 @@ CanvasPlugin* PluginLoader::pluginForCanvas(const QString& canvas)
return qobject_cast<CanvasPlugin*>(loader->factory("Canvas", canvas));
}
+QSharedPointer<Game> PluginLoader::game(const QString& name)
+{
+ return loader->game(name);
+}
+
Arena* PluginLoader::loadArena(const QString& name, GameWrapper* game, Config* parent)
{
ArenaPlugin* plugin = pluginForArena(name);
@@ -111,12 +111,7 @@ void PluginLoader::Private::refresh(const QString& type)
delete service.second;
m_available[type].clear();
if (type == "Sigmod")
- {
- QList<Game*> games = m_games.values();
- foreach (Game* game, games)
- delete game;
m_games.clear();
- }
// TODO: Progress dialog?
KService::List services = KServiceTypeTrader::self()->query(QString("Sigen/%1").arg(type), "[X-Sigen-MinVersion] <= 000101");
foreach (KService::Ptr service, services)
@@ -136,7 +131,7 @@ void PluginLoader::Private::refresh(const QString& type)
if (!fileName.isEmpty())
{
QFile file(fileName);
- Game* game = NULL;
+ QSharedPointer<Game> game;
if (file.open(QIODevice::ReadOnly))
{
QDomDocument xml;
@@ -146,7 +141,7 @@ void PluginLoader::Private::refresh(const QString& type)
if (xml.setContent(&file, &error, &line, &column))
{
if (xml.doctype().name() == "Sigmod")
- game = new Game(xml.documentElement());
+ game = QSharedPointer<Game>(new Game(xml.documentElement()));
else
KMessageBox::error(NULL, "The file is not a Sigmod.", "Invalid Sigmod");
}
@@ -215,13 +210,13 @@ PluginBase* PluginLoader::Private::factory(const QString& type, const QString& n
return NULL;
}
-Game* PluginLoader::Private::game(const QString& name)
+QSharedPointer<Game> PluginLoader::Private::game(const QString& name)
{
if (!m_games.contains(name))
refresh("Sigmod");
if (m_games.contains(name))
return m_games[name];
- return NULL;
+ return QSharedPointer<Game>();
}
void PluginLoader::Private::clean(const QString& type)
@@ -237,8 +232,5 @@ void PluginLoader::Private::clean(const QString& type)
}
}
if (type == "Sigmod")
- {
- qDeleteAll(m_games.values());
m_games.clear();
- }
}