Fix issues caused by SC editor component holding onto a live graph (#6734)

Signed-off-by: carlitosan <82187351+carlitosan@users.noreply.github.com>
This commit is contained in:
carlitosan
2022-01-06 16:35:36 -08:00
committed by GitHub
parent 54e0b8b7b5
commit 7f4fe67f77
4 changed files with 28 additions and 33 deletions
@@ -246,6 +246,16 @@ namespace ScriptCanvasBuilder
}
}
void BuildVariableOverrides::SetHandlesToDescription()
{
m_source = m_source.Describe();
for (auto& dependency : m_dependencies)
{
dependency.SetHandlesToDescription();
}
}
ScriptCanvas::RuntimeDataOverrides ConvertToRuntime(const BuildVariableOverrides& buildOverrides)
{
ScriptCanvas::RuntimeDataOverrides runtimeOverrides;
@@ -38,6 +38,8 @@ namespace ScriptCanvasBuilder
// use this to initialize the new data, and make sure they have a editor graph variable for proper editor display
void PopulateFromParsedResults(ScriptCanvas::Grammar::AbstractCodeModelConstPtr abstractCodeModel, const ScriptCanvas::VariableData& variables);
void SetHandlesToDescription();
// #functions2 provide an identifier for the node/variable in the source that caused the dependency. the root will not have one.
ScriptCanvasEditor::SourceHandle m_source;
@@ -245,13 +245,13 @@ namespace ScriptCanvasEditor
void EditorScriptCanvasComponent::OpenEditor([[maybe_unused]] const AZ::Data::AssetId& assetId, const AZ::Data::AssetType&)
{
AzToolsFramework::OpenViewPane(LyViewPane::ScriptCanvas);
AZ::Outcome<int, AZStd::string> openOutcome = AZ::Failure(AZStd::string());
if (m_sourceHandle.IsDescriptionValid())
{
GeneralRequestBus::BroadcastResult(openOutcome, &GeneralRequests::OpenScriptCanvasAsset, m_sourceHandle, Tracker::ScriptCanvasFileState::UNMODIFIED, -1);
if (!openOutcome)
{
AZ_Warning("Script Canvas", openOutcome, "%s", openOutcome.GetError().data());
@@ -261,7 +261,7 @@ namespace ScriptCanvasEditor
{
AzToolsFramework::EntityIdList selectedEntityIds;
AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult(selectedEntityIds, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntities);
// Going to bypass the multiple selected entities flow for right now.
if (selectedEntityIds.size() == 1)
{
@@ -279,7 +279,7 @@ namespace ScriptCanvasEditor
void EditorScriptCanvasComponent::InitializeSource(const SourceHandle& sourceHandle)
{
m_sourceHandle = sourceHandle;
m_sourceHandle = sourceHandle.Describe();
}
//=========================================================================
@@ -345,6 +345,7 @@ namespace ScriptCanvasEditor
}
m_variableOverrides = parseOutcome.TakeValue();
m_variableOverrides.SetHandlesToDescription();
m_runtimeDataIsValid = true;
}
@@ -373,13 +374,7 @@ namespace ScriptCanvasEditor
void EditorScriptCanvasComponent::SetPrimaryAsset(const AZ::Data::AssetId& assetId)
{
m_sourceHandle = SourceHandle(nullptr, assetId.m_guid, {});
auto completeAsset = CompleteDescription(m_sourceHandle);
if (completeAsset)
{
m_sourceHandle = *completeAsset;
}
CompleteDescriptionInPlace(m_sourceHandle);
OnScriptCanvasAssetChanged(SourceChangeDescription::SelectionChanged);
SetName(m_sourceHandle.Path().Filename().Native());
AzToolsFramework::ToolsApplicationEvents::Bus::Broadcast(&AzToolsFramework::ToolsApplicationEvents::InvalidatePropertyDisplay, AzToolsFramework::Refresh_AttributesAndValues);
@@ -399,7 +394,7 @@ namespace ScriptCanvasEditor
OnScriptCanvasAssetChanged(SourceChangeDescription::SelectionChanged);
return AZ::Edit::PropertyRefreshLevels::EntireTree;
}
void EditorScriptCanvasComponent::OnScriptCanvasAssetChanged(SourceChangeDescription changeDescription)
{
ScriptCanvas::GraphIdentifier newIdentifier = GetGraphIdentifier();
@@ -417,20 +412,11 @@ namespace ScriptCanvasEditor
ClearVariables();
}
m_sourceHandle = m_previousHandle;
if (m_sourceHandle.IsDescriptionValid())
{
if (!m_sourceHandle.Get())
{
if (auto loaded = LoadFromFile(m_sourceHandle.Path().c_str()); loaded.IsSuccess())
{
m_sourceHandle = SourceHandle(loaded.TakeValue(), m_sourceHandle.Id(), m_sourceHandle.Path().c_str());
}
}
if (m_sourceHandle.Get())
{
UpdatePropertyDisplay(m_sourceHandle);
}
UpdatePropertyDisplay();
}
AzToolsFramework::ToolsApplicationNotificationBus::Broadcast(&AzToolsFramework::ToolsApplicationEvents::InvalidatePropertyDisplay, AzToolsFramework::Refresh_EntireTree_NewContent);
@@ -492,14 +478,11 @@ namespace ScriptCanvasEditor
return ScriptCanvas::GraphIdentifier(m_sourceHandle.Id(), 0);
}
void EditorScriptCanvasComponent::UpdatePropertyDisplay(const SourceHandle& sourceHandle)
void EditorScriptCanvasComponent::UpdatePropertyDisplay()
{
if (sourceHandle.IsGraphValid())
{
BuildGameEntityData();
UpdateName();
AzToolsFramework::ToolsApplicationNotificationBus::Broadcast(&AzToolsFramework::ToolsApplicationEvents::InvalidatePropertyDisplay, AzToolsFramework::Refresh_EntireTree_NewContent);
}
BuildGameEntityData();
UpdateName();
AzToolsFramework::ToolsApplicationNotificationBus::Broadcast(&AzToolsFramework::ToolsApplicationEvents::InvalidatePropertyDisplay, AzToolsFramework::Refresh_EntireTree_NewContent);
}
void EditorScriptCanvasComponent::ClearVariables()
@@ -121,7 +121,7 @@ namespace ScriptCanvasEditor
void UpdateName();
//=====================================================================
void UpdatePropertyDisplay(const SourceHandle& sourceHandle);
void UpdatePropertyDisplay();
//=====================================================================
void BuildGameEntityData();