From f3b6eeeac4e1606a288c7f12fec271fbb7f120f6 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 20 Feb 2013 19:45:00 -0600 Subject: Got instance loading working. --- libinstance/src/instancelist.cpp | 9 ++++++--- libinstance/src/instanceloader.cpp | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'libinstance/src') diff --git a/libinstance/src/instancelist.cpp b/libinstance/src/instancelist.cpp index 15f79d05..3b0b668f 100644 --- a/libinstance/src/instancelist.cpp +++ b/libinstance/src/instancelist.cpp @@ -43,9 +43,10 @@ InstanceList::InstListError InstanceList::loadList() QString subDir = iter.next(); if (QFileInfo(PathCombine(subDir, "instance.cfg")).exists()) { - QSharedPointer inst; + Instance *instPtr = NULL; + InstanceLoader::InstTypeError error = InstanceLoader::get(). - loadInstance(inst.data(), subDir); + loadInstance(instPtr, subDir); if (error != InstanceLoader::NoError && error != InstanceLoader::NotAnInstance) @@ -66,13 +67,15 @@ InstanceList::InstListError InstanceList::loadList() } qDebug(errorMsg.toUtf8()); } - else if (!inst.data()) + else if (!instPtr) { qDebug(QString("Error loading instance %1. Instance loader returned null."). arg(QFileInfo(subDir).baseName()).toUtf8()); } else { + QSharedPointer inst(instPtr); + qDebug(QString("Loaded instance %1").arg(inst->name()).toUtf8()); inst->setParent(this); append(QSharedPointer(inst)); diff --git a/libinstance/src/instanceloader.cpp b/libinstance/src/instanceloader.cpp index eff9d56e..620562b6 100644 --- a/libinstance/src/instanceloader.cpp +++ b/libinstance/src/instanceloader.cpp @@ -49,7 +49,7 @@ InstanceLoader::InstTypeError InstanceLoader::registerInstanceType(InstanceTypeI return NoError; } -InstanceLoader::InstTypeError InstanceLoader::createInstance(Instance *inst, +InstanceLoader::InstTypeError InstanceLoader::createInstance(Instance *&inst, const InstanceTypeInterface *type, const QString &instDir) { @@ -61,7 +61,7 @@ InstanceLoader::InstTypeError InstanceLoader::createInstance(Instance *inst, return type->createInstance(inst, instDir); } -InstanceLoader::InstTypeError InstanceLoader::loadInstance(Instance *inst, +InstanceLoader::InstTypeError InstanceLoader::loadInstance(Instance *&inst, const InstanceTypeInterface *type, const QString &instDir) { @@ -72,7 +72,7 @@ InstanceLoader::InstTypeError InstanceLoader::loadInstance(Instance *inst, return type->loadInstance(inst, instDir); } -InstanceLoader::InstTypeError InstanceLoader::loadInstance(Instance *inst, +InstanceLoader::InstTypeError InstanceLoader::loadInstance(Instance *&inst, const QString &instDir) { QFileInfo instConfig(PathCombine(instDir, "instance.cfg")); -- cgit