Slight improvement of error handling

- Do not try to reinitialize assets whose initialization failed.
- Fail gracefully when adding a scenegraphnode with a name that already exists
This commit is contained in:
Emil Axelsson
2017-12-23 10:17:08 +01:00
parent 4b65e20570
commit 5139f7df4f
3 changed files with 15 additions and 3 deletions
+8 -2
View File
@@ -141,6 +141,10 @@ void Asset::requiredAssetChangedState(std::shared_ptr<Asset> child,
// called more than once.
return;
}
if (state() == State::InitializationFailed) {
// Do not do anything if the asset failed to initialize.
return;
}
if (childState == State::SyncResolved) {
if (isSyncResolveReady()) {
setState(State::SyncResolved);
@@ -154,10 +158,12 @@ void Asset::requestedAssetChangedState(std::shared_ptr<Asset> child,
Asset::State childState)
{
if (child->hasInitializedParent()) {
if (childState == State::Loaded) {
if (childState == State::Loaded &&
child->state() == State::Loaded) {
child->startSynchronizations();
}
if (childState == State::SyncResolved) {
if (childState == State::SyncResolved &&
child->state() == State::SyncResolved) {
child->initialize();
}
}
+6
View File
@@ -377,6 +377,12 @@ SceneGraphNode* Scene::loadNode(const ghoul::Dictionary& dict) {
const std::string nodeName = dict.value<std::string>(KeyName);
const bool hasParent = dict.hasKey(KeyParentName);
if (_nodesByName.find(nodeName) != _nodesByName.end()) {
LERROR("Cannot add scene graph node " << nodeName <<
". A node with that name already exisis.");
return nullptr;
}
SceneGraphNode* parent = nullptr;
if (hasParent) {
std::string parentName = dict.value<std::string>(KeyParentName);
+1 -1
View File
@@ -359,7 +359,7 @@ int addSceneGraphNode(lua_State* L) {
try {
SceneGraphNode* node = OsEng.renderEngine().scene()->loadNode(d);
if (!node) {
LERRORC("Could not load scene graph node", "scene");
LERRORC("Scene", "Could not load scene graph node");
return luaL_error(L, "Error loading scene graph node");
}