Revision 1cee0f5b
Von Christian Ehringfeld vor fast 11 Jahren hinzugefügt
| src/entityinstancefactory.cpp | ||
|---|---|---|
|
|
||
|
Entity *EntityInstanceFactory::createInstance(const char *className) {
|
||
|
QString s = QString(className);
|
||
|
bool contained = false;
|
||
|
if (!s.contains("*")) {
|
||
|
contained = true;
|
||
|
s.append("*");
|
||
|
}
|
||
|
return EntityInstanceFactory::createInstance(QMetaType::type(
|
||
|
s.toUtf8().constData()));
|
||
|
auto ptr = EntityInstanceFactory::createInstance(QMetaType::type(
|
||
|
s.toUtf8().constData()));
|
||
|
if(!ptr) {
|
||
|
if(contained) {
|
||
|
s.remove("*");
|
||
|
}
|
||
|
ptr = EntityInstanceFactory::createObject(s.toUtf8());
|
||
|
}
|
||
|
return ptr;
|
||
|
}
|
||
|
|
||
|
Entity *EntityInstanceFactory::createInstance(const QString &className) {
|
||
| ... | ... | |
|
e = static_cast<Entity *>(newObj);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (!e) {
|
||
|
qDebug() << "Entity instance could not created!";
|
||
|
throw - 2; //testing
|
||
|
}
|
||
|
} else {
|
||
|
qDebug() << metaTypeId << "EntityClass NOT registered! Please register it!";
|
||
|
throw - 1; //testing
|
||
|
}
|
||
|
return e;
|
||
|
}
|
||
Auch abrufbar als: Unified diff
stupid stuff