mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-02 00:44:43 -05:00
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:
+8
-2
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user