more aggressively release graph memory in version explorer
Signed-off-by: chcurran <82187351+carlitosan@users.noreply.github.com>
This commit is contained in:
@@ -32,13 +32,6 @@ namespace ScriptCanvasEditor
|
||||
AZ::SystemTickBus::Handler::BusConnect();
|
||||
}
|
||||
|
||||
const SourceHandle& Modifier::GetCurrentAsset() const
|
||||
{
|
||||
return m_state == State::GatheringDependencies
|
||||
? m_assets[m_assetIndex]
|
||||
: m_assets[m_dependencyOrderedAssetIndicies[m_assetIndex]];
|
||||
}
|
||||
|
||||
AZStd::unordered_set<size_t>& Modifier::GetOrCreateDependencyIndexSet()
|
||||
{
|
||||
auto iter = m_dependencies.find(m_assetIndex);
|
||||
@@ -101,36 +94,40 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
anyFailures = true;
|
||||
VE_LOG("Modifier: ERROR - Failed to gather dependencies from graph data: %s"
|
||||
, GetCurrentAsset().Path().c_str())
|
||||
, ModCurrentAsset().Path().c_str())
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
anyFailures = true;
|
||||
VE_LOG("Modifier: ERROR - Failed to load asset %s for modification, even though it scanned properly"
|
||||
, GetCurrentAsset().Path().c_str());
|
||||
, ModCurrentAsset().Path().c_str());
|
||||
}
|
||||
|
||||
ModelNotificationsBus::Broadcast
|
||||
( &ModelNotificationsTraits::OnUpgradeDependenciesGathered
|
||||
, GetCurrentAsset()
|
||||
, ModCurrentAsset()
|
||||
, anyFailures ? Result::Failure : Result::Success);
|
||||
|
||||
ReleaseCurrentAsset();
|
||||
|
||||
// Flush asset database events to ensure no asset references are held by closures queued on Ebuses.
|
||||
AZ::Data::AssetManager::Instance().DispatchEvents();
|
||||
}
|
||||
|
||||
SourceHandle Modifier::LoadAsset()
|
||||
{
|
||||
auto outcome = LoadFromFile(GetCurrentAsset().Path().c_str());
|
||||
if (outcome.IsSuccess())
|
||||
auto& handle = ModCurrentAsset();
|
||||
if (!handle.IsValid())
|
||||
{
|
||||
return outcome.TakeValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
return {};
|
||||
auto outcome = LoadFromFile(handle.Path().c_str());
|
||||
if (outcome.IsSuccess())
|
||||
{
|
||||
handle = outcome.TakeValue();
|
||||
}
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
void Modifier::ModificationComplete(const ModificationResult& result)
|
||||
@@ -147,12 +144,19 @@ namespace ScriptCanvasEditor
|
||||
}
|
||||
}
|
||||
|
||||
SourceHandle& Modifier::ModCurrentAsset()
|
||||
{
|
||||
return m_state == State::GatheringDependencies
|
||||
? m_assets[m_assetIndex]
|
||||
: m_assets[m_dependencyOrderedAssetIndicies[m_assetIndex]];
|
||||
}
|
||||
|
||||
void Modifier::ModifyCurrentAsset()
|
||||
{
|
||||
m_result = {};
|
||||
m_result.asset = GetCurrentAsset();
|
||||
m_result.asset = ModCurrentAsset();
|
||||
|
||||
ModelNotificationsBus::Broadcast(&ModelNotificationsTraits::OnUpgradeModificationBegin, m_config, GetCurrentAsset());
|
||||
ModelNotificationsBus::Broadcast(&ModelNotificationsTraits::OnUpgradeModificationBegin, m_config, ModCurrentAsset());
|
||||
|
||||
if (auto asset = LoadAsset(); asset.IsValid())
|
||||
{
|
||||
@@ -169,13 +173,19 @@ namespace ScriptCanvasEditor
|
||||
void Modifier::ModifyNextAsset()
|
||||
{
|
||||
ModelNotificationsBus::Broadcast
|
||||
( &ModelNotificationsTraits::OnUpgradeModificationEnd, m_config, GetCurrentAsset(), m_result);
|
||||
( &ModelNotificationsTraits::OnUpgradeModificationEnd, m_config, ModCurrentAsset(), m_result);
|
||||
ModificationNotificationsBus::Handler::BusDisconnect();
|
||||
m_modifyState = ModifyState::Idle;
|
||||
ReleaseCurrentAsset();
|
||||
++m_assetIndex;
|
||||
m_result = {};
|
||||
}
|
||||
|
||||
void Modifier::ReleaseCurrentAsset()
|
||||
{
|
||||
ModCurrentAsset() = ModCurrentAsset().Describe();
|
||||
}
|
||||
|
||||
void Modifier::ReportModificationError(AZStd::string_view report)
|
||||
{
|
||||
m_result.asset = {};
|
||||
@@ -286,7 +296,7 @@ namespace ScriptCanvasEditor
|
||||
m_dependencyOrderedAssetIndicies.push_back(index);
|
||||
}
|
||||
|
||||
// go straight into ModifyinGraphs
|
||||
// go straight into ModifyingGraphs
|
||||
m_assetIndex = m_assets.size();
|
||||
}
|
||||
}
|
||||
@@ -309,6 +319,7 @@ namespace ScriptCanvasEditor
|
||||
else
|
||||
{
|
||||
GatherDependencies();
|
||||
ReleaseCurrentAsset();
|
||||
++m_assetIndex;
|
||||
}
|
||||
}
|
||||
@@ -370,7 +381,7 @@ namespace ScriptCanvasEditor
|
||||
(ScriptCanvas::k_VersionExplorerWindow.data()
|
||||
, false
|
||||
, "Modifier: Dependency sort has failed during, circular dependency detected for Asset: %s"
|
||||
, modifier->GetCurrentAsset().Path().c_str());
|
||||
, modifier->ModCurrentAsset().Path().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,12 +83,13 @@ namespace ScriptCanvasEditor
|
||||
FileSaveResult m_fileSaveResult;
|
||||
|
||||
void GatherDependencies();
|
||||
const SourceHandle& GetCurrentAsset() const;
|
||||
AZStd::unordered_set<size_t>& GetOrCreateDependencyIndexSet();
|
||||
SourceHandle LoadAsset();
|
||||
SourceHandle& ModCurrentAsset();
|
||||
void ModifyCurrentAsset();
|
||||
void ModifyNextAsset();
|
||||
void ModificationComplete(const ModificationResult& result) override;
|
||||
void ReleaseCurrentAsset();
|
||||
void ReportModificationError(AZStd::string_view report);
|
||||
void ReportModificationSuccess();
|
||||
void ReportSaveResult();
|
||||
|
||||
@@ -32,8 +32,12 @@ namespace ScannerCpp
|
||||
&& entry->GetFullPath().ends_with(".scriptcanvas"))
|
||||
{
|
||||
auto sourceEntry = azrtti_cast<const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry*>(entry);
|
||||
|
||||
AZStd::string fullPath = sourceEntry->GetFullPath();
|
||||
AzFramework::StringFunc::Path::Normalize(fullPath);
|
||||
|
||||
result.m_catalogAssets.push_back(
|
||||
ScriptCanvasEditor::SourceHandle(nullptr, sourceEntry->GetSourceUuid(), sourceEntry->GetFullPath()));
|
||||
ScriptCanvasEditor::SourceHandle(nullptr, sourceEntry->GetSourceUuid(), fullPath));
|
||||
}
|
||||
|
||||
const int rowCount = model.rowCount(index);
|
||||
@@ -79,23 +83,18 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
if (m_config.filter && m_config.filter(asset) == ScanConfiguration::Filter::Exclude)
|
||||
{
|
||||
VE_LOG("Scanner: Excluded: %s ", GetCurrentAsset().Path().c_str());
|
||||
m_result.m_filteredAssets.push_back(GetCurrentAsset().Describe());
|
||||
ModelNotificationsBus::Broadcast(&ModelNotificationsTraits::OnScanFilteredGraph, GetCurrentAsset());
|
||||
VE_LOG("Scanner: Excluded: %s ", ModCurrentAsset().Path().c_str());
|
||||
m_result.m_filteredAssets.push_back(ModCurrentAsset().Describe());
|
||||
ModelNotificationsBus::Broadcast(&ModelNotificationsTraits::OnScanFilteredGraph, ModCurrentAsset());
|
||||
}
|
||||
else
|
||||
{
|
||||
VE_LOG("Scanner: Included: %s ", GetCurrentAsset().Path().c_str());
|
||||
m_result.m_unfiltered.push_back(GetCurrentAsset().Describe());
|
||||
ModelNotificationsBus::Broadcast(&ModelNotificationsTraits::OnScanUnFilteredGraph, GetCurrentAsset());
|
||||
VE_LOG("Scanner: Included: %s ", ModCurrentAsset().Path().c_str());
|
||||
m_result.m_unfiltered.push_back(ModCurrentAsset().Describe());
|
||||
ModelNotificationsBus::Broadcast(&ModelNotificationsTraits::OnScanUnFilteredGraph, ModCurrentAsset());
|
||||
}
|
||||
}
|
||||
|
||||
const SourceHandle& Scanner::GetCurrentAsset() const
|
||||
{
|
||||
return m_result.m_catalogAssets[m_catalogAssetIndex];
|
||||
}
|
||||
|
||||
const ScanResult& Scanner::GetResult() const
|
||||
{
|
||||
return m_result;
|
||||
@@ -103,7 +102,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
SourceHandle Scanner::LoadAsset()
|
||||
{
|
||||
auto fileOutcome = LoadFromFile(GetCurrentAsset().Path().c_str());
|
||||
auto fileOutcome = LoadFromFile(ModCurrentAsset().Path().c_str());
|
||||
if (fileOutcome.IsSuccess())
|
||||
{
|
||||
return fileOutcome.GetValue();
|
||||
@@ -114,6 +113,11 @@ namespace ScriptCanvasEditor
|
||||
}
|
||||
}
|
||||
|
||||
SourceHandle& Scanner::ModCurrentAsset()
|
||||
{
|
||||
return m_result.m_catalogAssets[m_catalogAssetIndex];
|
||||
}
|
||||
|
||||
void Scanner::OnSystemTick()
|
||||
{
|
||||
if (m_catalogAssetIndex == m_result.m_catalogAssets.size())
|
||||
@@ -130,17 +134,17 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
if (auto asset = LoadAsset(); asset.IsValid())
|
||||
{
|
||||
VE_LOG("Scanner: Loaded: %s ", GetCurrentAsset().Path().c_str());
|
||||
VE_LOG("Scanner: Loaded: %s ", ModCurrentAsset().Path().c_str());
|
||||
FilterAsset(asset);
|
||||
}
|
||||
else
|
||||
{
|
||||
VE_LOG("Scanner: Failed to load: %s ", GetCurrentAsset().Path().c_str());
|
||||
m_result.m_loadErrors.push_back(GetCurrentAsset());
|
||||
ModelNotificationsBus::Broadcast(&ModelNotificationsTraits::OnScanLoadFailure, GetCurrentAsset());
|
||||
VE_LOG("Scanner: Failed to load: %s ", ModCurrentAsset().Path().c_str());
|
||||
m_result.m_loadErrors.push_back(ModCurrentAsset().Describe());
|
||||
ModelNotificationsBus::Broadcast(&ModelNotificationsTraits::OnScanLoadFailure, ModCurrentAsset());
|
||||
}
|
||||
|
||||
VE_LOG("Scanner: scan of %s complete", GetCurrentAsset().Path().c_str());
|
||||
VE_LOG("Scanner: scan of %s complete", ModCurrentAsset().Path().c_str());
|
||||
++m_catalogAssetIndex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ namespace ScriptCanvasEditor
|
||||
ScanResult m_result;
|
||||
|
||||
void FilterAsset(SourceHandle);
|
||||
const SourceHandle& GetCurrentAsset() const;
|
||||
SourceHandle LoadAsset();
|
||||
SourceHandle& ModCurrentAsset();
|
||||
void OnSystemTick() override;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user