restore file save

Signed-off-by: chcurran <82187351+carlitosan@users.noreply.github.com>
This commit is contained in:
chcurran
2021-12-01 23:04:07 -08:00
committed by Chris Burel
parent 499cdaae5e
commit d8add36212
2 changed files with 9 additions and 15 deletions
@@ -1051,7 +1051,7 @@ namespace ScriptCanvasEditor
auto graph = entity->CreateComponent<ScriptCanvasEditor::Graph>(); auto graph = entity->CreateComponent<ScriptCanvasEditor::Graph>();
entity->CreateComponent<EditorGraphVariableManagerComponent>(graph->GetScriptCanvasId()); entity->CreateComponent<EditorGraphVariableManagerComponent>(graph->GetScriptCanvasId());
if (ScriptCanvas::DataPtr data = AZStd::make_shared<ScriptCanvas::ScriptCanvasData>()) if (ScriptCanvas::DataPtr data = aznew ScriptCanvas::ScriptCanvasData())
{ {
data->m_scriptCanvasEntity.reset(entity); data->m_scriptCanvasEntity.reset(entity);
graph->MarkOwnership(*data); graph->MarkOwnership(*data);
@@ -97,23 +97,15 @@ namespace ScriptCanvasEditor
} }
else else
{ {
// #sc_editor_asset - skip save, narrow down the memory corruption
AZ::SystemTickBus::QueueFunction([this, tmpFileName]()
{
FileSaveResult result;
result.tempFileRemovalError = RemoveTempFile(tmpFileName);
m_onComplete(result);
});
// the actual move attempt // the actual move attempt
/*
auto moveResult = AZ::IO::SmartMove(tmpFileName.c_str(), target.c_str()); auto moveResult = AZ::IO::SmartMove(tmpFileName.c_str(), target.c_str());
if (moveResult.GetResultCode() == AZ::IO::ResultCode::Success) if (moveResult.GetResultCode() == AZ::IO::ResultCode::Success)
{ {
auto streamer = AZ::Interface<AZ::IO::IStreamer>::Get(); auto streamer = AZ::Interface<AZ::IO::IStreamer>::Get();
AZ::IO::FileRequestPtr flushRequest = streamer->FlushCache(target.c_str()); AZ::IO::FileRequestPtr flushRequest = streamer->FlushCache(target.c_str());
// Bump the slice asset up in the asset processor's queue. // Bump the slice asset up in the asset processor's queue.
AzFramework::AssetSystemRequestBus::Broadcast(&AzFramework::AssetSystem::AssetSystemRequests::EscalateAssetBySearchTerm, target.c_str()); AzFramework::AssetSystemRequestBus::Broadcast
(&AzFramework::AssetSystem::AssetSystemRequests::EscalateAssetBySearchTerm, target.c_str());
AZ::SystemTickBus::QueueFunction([this, tmpFileName]() AZ::SystemTickBus::QueueFunction([this, tmpFileName]()
{ {
@@ -124,17 +116,19 @@ namespace ScriptCanvasEditor
} }
else else
{ {
AZ_Warning(ScriptCanvas::k_VersionExplorerWindow.data(), false, "moving converted file to tmpFileName destination failed: %s, trying again", target.c_str()); AZ_Warning(ScriptCanvas::k_VersionExplorerWindow.data(), false
, "moving converted file to tmpFileName destination failed: %s, trying again", target.c_str());
auto streamer = AZ::Interface<AZ::IO::IStreamer>::Get(); auto streamer = AZ::Interface<AZ::IO::IStreamer>::Get();
AZ::IO::FileRequestPtr flushRequest = streamer->FlushCache(target.c_str()); AZ::IO::FileRequestPtr flushRequest = streamer->FlushCache(target.c_str());
streamer->SetRequestCompleteCallback(flushRequest, [this, tmpFileName, target, remainingAttempts]([[maybe_unused]] AZ::IO::FileRequestHandle request) streamer->SetRequestCompleteCallback(flushRequest
, [this, tmpFileName, target, remainingAttempts]([[maybe_unused]] AZ::IO::FileRequestHandle request)
{ {
// Continue saving. // Continue saving.
AZ::SystemTickBus::QueueFunction([this, tmpFileName, target, remainingAttempts]() { PerformMove(tmpFileName, target, remainingAttempts - 1); }); AZ::SystemTickBus::QueueFunction(
[this, tmpFileName, target, remainingAttempts]() { PerformMove(tmpFileName, target, remainingAttempts - 1); });
}); });
streamer->QueueRequest(flushRequest); streamer->QueueRequest(flushRequest);
} }
**/
} }
} }