diff --git a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/EntityOutliner_EntityOrdering.py b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/EntityOutliner_EntityOrdering.py index 8b1e4763db..e4575d4d17 100644 --- a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/EntityOutliner_EntityOrdering.py +++ b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/EntityOutliner_EntityOrdering.py @@ -44,12 +44,12 @@ def EntityOutliner_EntityOrdering(): entity_outliner_model = entity_outliner.model() # Get the outliner index for the root prefab container entity - def get_prefab_container_index(): + def get_root_prefab_container_index(): return entity_outliner_model.index(0, 0) - # Get the outlienr index for the top level entity of a given name + # Get the outliner index for the top level entity of a given name def index_for_name(name): - root_index = get_prefab_container_index() + root_index = get_root_prefab_container_index() for row in range(entity_outliner_model.rowCount(root_index)): row_index = entity_outliner_model.index(row, 0, root_index) if row_index.data() == name: @@ -59,7 +59,7 @@ def EntityOutliner_EntityOrdering(): # Validate that the outliner top level entity order matches the expected order def verify_entities_sorted(expected_order): actual_order = [] - root_index = get_prefab_container_index() + root_index = get_root_prefab_container_index() for row in range(entity_outliner_model.rowCount(root_index)): row_index = entity_outliner_model.index(row, 0, root_index) actual_order.append(row_index.data()) @@ -73,8 +73,9 @@ def EntityOutliner_EntityOrdering(): # Creates an entity from the outliner context menu def create_entity(): pyside_utils.trigger_context_menu_entry( - entity_outliner, "Create entity", index=get_prefab_container_index() + entity_outliner, "Create entity", index=get_root_prefab_container_index() ) + # Wait a tick after entity creation to let events process general.idle_wait(0.0) # Moves an entity (wrapped by move_entity_before and move_entity_after) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityHelpers.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityHelpers.cpp index 511f9dd580..3e256430a2 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityHelpers.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/EditorEntityHelpers.cpp @@ -470,6 +470,7 @@ namespace AzToolsFramework EditorEntityInfoRequestBus::EventResult(children, parentId, &EditorEntityInfoRequestBus::Events::GetChildren); // If Prefabs are enabled, don't check the order for an invalid parent, just return its children (i.e. the root container entity) + // There will currently always be one root container entity, so there's no order to retrieve if (!parentId.IsValid()) { bool isPrefabEnabled = false;