Browse Source

Bugfix: Fix crash on shutdown and when deleting objects

BearishSun 6 years ago
parent
commit
25a2a7c205

+ 6 - 4
Source/EditorCore/GUI/BsGUISceneTreeView.cpp

@@ -179,17 +179,19 @@ namespace bs
 				}
 			}
 
-			for(UINT32 i = 0; i < element->mChildren.size(); i++)
+			// Make sure to update children list before deleting them. Deletions cause callbacks which can ultimately call
+			// back into this method
+			element->mChildren.swap(newChildren);
+
+			for(UINT32 i = 0; i < newChildren.size(); i++)
 			{
 				if(!tempToDelete[i])
 					continue;
 
-				deleteTreeElementInternal(element->mChildren[i]);
+				deleteTreeElementInternal(newChildren[i]);
 			}
 
 			bs_stack_free(tempToDelete);
-
-			element->mChildren = newChildren;
 			needsUpdate = true;
 		}
 

+ 3 - 0
Source/EditorScript/BsScriptGizmoManager.cpp

@@ -193,6 +193,9 @@ namespace bs
 	{
 		for(auto& sceneObject : sceneObjects)
 		{
+			if(sceneObject.isDestroyed())
+				continue;
+
 			Vector<HComponent> components = sceneObject->getComponents();
 			for(auto& component : components)
 			{