clean up open pipeline to render graph
Signed-off-by: chcurran <82187351+carlitosan@users.noreply.github.com>
This commit is contained in:
@@ -58,111 +58,111 @@ namespace ScriptCanvasEditor
|
||||
SaveAs(assetId, {}, onSaveCallback);
|
||||
}
|
||||
|
||||
void AssetTracker::SaveAs(AZ::Data::AssetId assetId, const AZStd::string& path, Callbacks::OnSave onSaveCallback)
|
||||
void AssetTracker::SaveAs(AZ::Data::AssetId /*assetId*/, const AZStd::string& /*path*/, Callbacks::OnSave /*onSaveCallback*/)
|
||||
{
|
||||
auto assetIter = m_assetsInUse.find(assetId);
|
||||
|
||||
if (assetIter != m_assetsInUse.end())
|
||||
{
|
||||
auto onSave = [this, assetId, onSaveCallback](bool saveSuccess, AZ::Data::AssetPtr asset, AZ::Data::AssetId previousFileAssetId)
|
||||
{
|
||||
AZ::Data::AssetId signalId = assetId;
|
||||
AZ::Data::AssetId fileAssetId = asset->GetId();
|
||||
|
||||
// If there is a previous file Id is valid, it means this is a save-as operation and we need to remap the tracking.
|
||||
if (previousFileAssetId.IsValid())
|
||||
{
|
||||
if (saveSuccess)
|
||||
{
|
||||
fileAssetId = m_assetsInUse[assetId]->GetFileAssetId();
|
||||
m_remappedAsset[asset->GetId()] = fileAssetId;
|
||||
|
||||
// Erase the asset first so the smart pointer can deal with it's things.
|
||||
m_assetsInUse.erase(fileAssetId);
|
||||
|
||||
// Then perform the insert once we know nothing will attempt to delete this while we are operating on it.
|
||||
m_assetsInUse[fileAssetId] = m_assetsInUse[assetId];
|
||||
m_assetsInUse.erase(assetId);
|
||||
}
|
||||
|
||||
m_savingAssets.erase(assetId);
|
||||
m_savingAssets.insert(fileAssetId);
|
||||
|
||||
signalId = fileAssetId;
|
||||
|
||||
if (m_queuedCloses.erase(assetId))
|
||||
{
|
||||
m_queuedCloses.insert(fileAssetId);
|
||||
}
|
||||
|
||||
auto assetIter = m_assetsInUse.find(fileAssetId);
|
||||
|
||||
if (assetIter != m_assetsInUse.end())
|
||||
{
|
||||
AZStd::invoke(onSaveCallback, saveSuccess, m_assetsInUse[fileAssetId]->GetAsset().Get(), previousFileAssetId);
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Error("ScriptCanvas", !saveSuccess, "Unable to find Memory Asset for Asset(%s)", fileAssetId.ToString<AZStd::string>().c_str());
|
||||
AZStd::invoke(onSaveCallback, saveSuccess, asset, previousFileAssetId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (saveSuccess)
|
||||
{
|
||||
// This should be the case when we get a save as from a newly created file.
|
||||
//
|
||||
// If we find the 'memory' asset id in the assets in use. This means this was a new file that was saved.
|
||||
// To maintain all of the look-up stuff, we need to treat this like a remapping stage.
|
||||
auto assetInUseIter = m_assetsInUse.find(assetId);
|
||||
if (assetInUseIter != m_assetsInUse.end())
|
||||
{
|
||||
fileAssetId = assetInUseIter->second->GetFileAssetId();
|
||||
|
||||
if (assetId != fileAssetId)
|
||||
{
|
||||
m_remappedAsset[assetId] = fileAssetId;
|
||||
|
||||
m_assetsInUse.erase(fileAssetId);
|
||||
m_assetsInUse[fileAssetId] = AZStd::move(assetInUseIter->second);
|
||||
m_assetsInUse.erase(assetId);
|
||||
|
||||
m_savingAssets.erase(assetId);
|
||||
m_savingAssets.insert(fileAssetId);
|
||||
|
||||
if (m_queuedCloses.erase(assetId))
|
||||
{
|
||||
m_queuedCloses.insert(fileAssetId);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fileAssetId = CheckAssetId(fileAssetId);
|
||||
}
|
||||
|
||||
signalId = fileAssetId;
|
||||
}
|
||||
|
||||
if (onSaveCallback)
|
||||
{
|
||||
AZStd::invoke(onSaveCallback, saveSuccess, m_assetsInUse[signalId]->GetAsset().Get(), previousFileAssetId);
|
||||
}
|
||||
|
||||
AssetTrackerNotificationBus::Broadcast(&AssetTrackerNotifications::OnAssetSaved, m_assetsInUse[signalId], saveSuccess);
|
||||
}
|
||||
|
||||
SignalSaveComplete(signalId);
|
||||
};
|
||||
|
||||
m_savingAssets.insert(assetId);
|
||||
assetIter->second->SaveAs(path, onSave);
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Assert(false, "Cannot SaveAs into an existing AssetId");
|
||||
}
|
||||
// auto assetIter = m_assetsInUse.find(assetId);
|
||||
//
|
||||
// if (assetIter != m_assetsInUse.end())
|
||||
// {
|
||||
// auto onSave = [this, assetId, onSaveCallback](bool saveSuccess, AZ::Data::AssetPtr asset, AZ::Data::AssetId previousFileAssetId)
|
||||
// {
|
||||
// AZ::Data::AssetId signalId = assetId;
|
||||
// AZ::Data::AssetId fileAssetId = asset->GetId();
|
||||
//
|
||||
// // If there is a previous file Id is valid, it means this is a save-as operation and we need to remap the tracking.
|
||||
// if (previousFileAssetId.IsValid())
|
||||
// {
|
||||
// if (saveSuccess)
|
||||
// {
|
||||
// fileAssetId = m_assetsInUse[assetId]->GetFileAssetId();
|
||||
// m_remappedAsset[asset->GetId()] = fileAssetId;
|
||||
//
|
||||
// // Erase the asset first so the smart pointer can deal with it's things.
|
||||
// m_assetsInUse.erase(fileAssetId);
|
||||
//
|
||||
// // Then perform the insert once we know nothing will attempt to delete this while we are operating on it.
|
||||
// m_assetsInUse[fileAssetId] = m_assetsInUse[assetId];
|
||||
// m_assetsInUse.erase(assetId);
|
||||
// }
|
||||
//
|
||||
// m_savingAssets.erase(assetId);
|
||||
// m_savingAssets.insert(fileAssetId);
|
||||
//
|
||||
// signalId = fileAssetId;
|
||||
//
|
||||
// if (m_queuedCloses.erase(assetId))
|
||||
// {
|
||||
// m_queuedCloses.insert(fileAssetId);
|
||||
// }
|
||||
//
|
||||
// auto assetIter = m_assetsInUse.find(fileAssetId);
|
||||
//
|
||||
// if (assetIter != m_assetsInUse.end())
|
||||
// {
|
||||
// AZStd::invoke(onSaveCallback, saveSuccess, m_assetsInUse[fileAssetId]->GetAsset().Get(), previousFileAssetId);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// AZ_Error("ScriptCanvas", !saveSuccess, "Unable to find Memory Asset for Asset(%s)", fileAssetId.ToString<AZStd::string>().c_str());
|
||||
// AZStd::invoke(onSaveCallback, saveSuccess, asset, previousFileAssetId);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (saveSuccess)
|
||||
// {
|
||||
// // This should be the case when we get a save as from a newly created file.
|
||||
// //
|
||||
// // If we find the 'memory' asset id in the assets in use. This means this was a new file that was saved.
|
||||
// // To maintain all of the look-up stuff, we need to treat this like a remapping stage.
|
||||
// auto assetInUseIter = m_assetsInUse.find(assetId);
|
||||
// if (assetInUseIter != m_assetsInUse.end())
|
||||
// {
|
||||
// fileAssetId = assetInUseIter->second->GetFileAssetId();
|
||||
//
|
||||
// if (assetId != fileAssetId)
|
||||
// {
|
||||
// m_remappedAsset[assetId] = fileAssetId;
|
||||
//
|
||||
// m_assetsInUse.erase(fileAssetId);
|
||||
// m_assetsInUse[fileAssetId] = AZStd::move(assetInUseIter->second);
|
||||
// m_assetsInUse.erase(assetId);
|
||||
//
|
||||
// m_savingAssets.erase(assetId);
|
||||
// m_savingAssets.insert(fileAssetId);
|
||||
//
|
||||
// if (m_queuedCloses.erase(assetId))
|
||||
// {
|
||||
// m_queuedCloses.insert(fileAssetId);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// fileAssetId = CheckAssetId(fileAssetId);
|
||||
// }
|
||||
//
|
||||
// signalId = fileAssetId;
|
||||
// }
|
||||
//
|
||||
// if (onSaveCallback)
|
||||
// {
|
||||
// AZStd::invoke(onSaveCallback, saveSuccess, m_assetsInUse[signalId]->GetAsset().Get(), previousFileAssetId);
|
||||
// }
|
||||
//
|
||||
// AssetTrackerNotificationBus::Broadcast(&AssetTrackerNotifications::OnAssetSaved, m_assetsInUse[signalId], saveSuccess);
|
||||
// }
|
||||
//
|
||||
// SignalSaveComplete(signalId);
|
||||
// };
|
||||
//
|
||||
// m_savingAssets.insert(assetId);
|
||||
// assetIter->second->SaveAs(path, onSave);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// AZ_Assert(false, "Cannot SaveAs into an existing AssetId");
|
||||
// }
|
||||
}
|
||||
|
||||
bool AssetTracker::Load(AZ::Data::AssetId fileAssetId, AZ::Data::AssetType assetType, Callbacks::OnAssetReadyCallback onAssetReadyCallback)
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace ScriptCanvasEditor
|
||||
namespace Callbacks
|
||||
{
|
||||
//! Callback used to know when a save operation failed or succeeded
|
||||
using OnSave = AZStd::function<void(bool saveSuccess, AZ::Data::AssetPtr, AZ::Data::AssetId previousFileAssetId)>;
|
||||
using OnSave = AZStd::function<void(bool saveSuccess, const SourceHandle& attempt, const SourceHandle& previous)>;
|
||||
|
||||
using OnAssetReadyCallback = AZStd::function<void(ScriptCanvasMemoryAsset&)>;
|
||||
using OnAssetCreatedCallback = OnAssetReadyCallback;
|
||||
|
||||
@@ -124,6 +124,12 @@ namespace ScriptCanvasEditor
|
||||
}
|
||||
}
|
||||
|
||||
if (auto entity = scriptCanvasData->GetScriptCanvasEntity())
|
||||
{
|
||||
entity->Init();
|
||||
entity->Activate();
|
||||
}
|
||||
|
||||
return AZ::Success(ScriptCanvasEditor::SourceHandle(scriptCanvasData, {}, path));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,10 +283,11 @@ namespace ScriptCanvasEditor
|
||||
m_undoHelper = AZStd::make_unique<UndoHelper>(*this);
|
||||
}
|
||||
|
||||
ScriptCanvasEditor::Widget::CanvasWidget* ScriptCanvasMemoryAsset::CreateView(QWidget* parent)
|
||||
ScriptCanvasEditor::Widget::CanvasWidget* ScriptCanvasMemoryAsset::CreateView(QWidget* /*parent*/)
|
||||
{
|
||||
m_canvasWidget = new Widget::CanvasWidget(m_fileAssetId, parent);
|
||||
return m_canvasWidget;
|
||||
//m_canvasWidget = new Widget::CanvasWidget(m_fileAssetId, parent);
|
||||
//return m_canvasWidget;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ScriptCanvasMemoryAsset::ClearView()
|
||||
@@ -430,68 +431,68 @@ namespace ScriptCanvasEditor
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptCanvasMemoryAsset::SourceFileFailed(AZStd::string relativePath, AZStd::string scanFolder, AZ::Uuid)
|
||||
void ScriptCanvasMemoryAsset::SourceFileFailed(AZStd::string /*relativePath*/, AZStd::string /*scanFolder*/, AZ::Uuid)
|
||||
{
|
||||
AZStd::string fullPath;
|
||||
AzFramework::StringFunc::Path::Join(scanFolder.data(), relativePath.data(), fullPath);
|
||||
AzFramework::ApplicationRequests::Bus::Broadcast(&AzFramework::ApplicationRequests::NormalizePath, fullPath);
|
||||
|
||||
auto assetPathIdIt = AZStd::find(m_pendingSave.begin(), m_pendingSave.end(), fullPath);
|
||||
|
||||
if (assetPathIdIt != m_pendingSave.end())
|
||||
{
|
||||
if (m_onSaveCallback)
|
||||
{
|
||||
m_onSaveCallback(false, m_inMemoryAsset.Get(), AZ::Data::AssetId());
|
||||
m_onSaveCallback = nullptr;
|
||||
}
|
||||
|
||||
m_pendingSave.erase(assetPathIdIt);
|
||||
}
|
||||
// AZStd::string fullPath;
|
||||
// AzFramework::StringFunc::Path::Join(scanFolder.data(), relativePath.data(), fullPath);
|
||||
// AzFramework::ApplicationRequests::Bus::Broadcast(&AzFramework::ApplicationRequests::NormalizePath, fullPath);
|
||||
//
|
||||
// auto assetPathIdIt = AZStd::find(m_pendingSave.begin(), m_pendingSave.end(), fullPath);
|
||||
//
|
||||
// if (assetPathIdIt != m_pendingSave.end())
|
||||
// {
|
||||
// if (m_onSaveCallback)
|
||||
// {
|
||||
// m_onSaveCallback(false, m_inMemoryAsset.Get(), AZ::Data::AssetId());
|
||||
// m_onSaveCallback = nullptr;
|
||||
// }
|
||||
//
|
||||
// m_pendingSave.erase(assetPathIdIt);
|
||||
// }
|
||||
}
|
||||
|
||||
void ScriptCanvasMemoryAsset::SavingComplete(const AZStd::string& streamName, AZ::Uuid sourceAssetId)
|
||||
void ScriptCanvasMemoryAsset::SavingComplete(const AZStd::string& /*streamName*/, AZ::Uuid /*sourceAssetId*/)
|
||||
{
|
||||
AZStd::string normPath = streamName;
|
||||
AzFramework::ApplicationRequests::Bus::Broadcast(&AzFramework::ApplicationRequests::NormalizePath, normPath);
|
||||
|
||||
auto assetPathIdIt = AZStd::find(m_pendingSave.begin(), m_pendingSave.end(), normPath);
|
||||
if (assetPathIdIt != m_pendingSave.end())
|
||||
{
|
||||
AZ::Data::AssetId previousFileAssetId;
|
||||
|
||||
if (sourceAssetId != m_fileAssetId.m_guid)
|
||||
{
|
||||
previousFileAssetId = m_fileAssetId;
|
||||
|
||||
// The source file has changed, store the AssetId to the canonical asset on file
|
||||
SetFileAssetId(sourceAssetId);
|
||||
|
||||
}
|
||||
else if (!m_fileAssetId.IsValid())
|
||||
{
|
||||
SetFileAssetId(sourceAssetId);
|
||||
}
|
||||
|
||||
m_formerGraphIdPair = AZStd::make_pair(m_scriptCanvasId, m_graphId);
|
||||
|
||||
m_fileState = Tracker::ScriptCanvasFileState::UNMODIFIED;
|
||||
|
||||
m_pendingSave.erase(assetPathIdIt);
|
||||
|
||||
m_absolutePath = m_saveAsPath;
|
||||
m_saveAsPath.clear();
|
||||
|
||||
// Connect to the source asset's bus to monitor for situations we may need to handle
|
||||
AZ::Data::AssetBus::MultiHandler::BusConnect(m_inMemoryAsset.GetId());
|
||||
AZ::Data::AssetBus::MultiHandler::BusConnect(m_fileAssetId);
|
||||
|
||||
if (m_onSaveCallback)
|
||||
{
|
||||
m_onSaveCallback(true, m_inMemoryAsset.Get(), previousFileAssetId);
|
||||
m_onSaveCallback = nullptr;
|
||||
}
|
||||
}
|
||||
// AZStd::string normPath = streamName;
|
||||
// AzFramework::ApplicationRequests::Bus::Broadcast(&AzFramework::ApplicationRequests::NormalizePath, normPath);
|
||||
//
|
||||
// auto assetPathIdIt = AZStd::find(m_pendingSave.begin(), m_pendingSave.end(), normPath);
|
||||
// if (assetPathIdIt != m_pendingSave.end())
|
||||
// {
|
||||
// AZ::Data::AssetId previousFileAssetId;
|
||||
//
|
||||
// if (sourceAssetId != m_fileAssetId.m_guid)
|
||||
// {
|
||||
// previousFileAssetId = m_fileAssetId;
|
||||
//
|
||||
// // The source file has changed, store the AssetId to the canonical asset on file
|
||||
// SetFileAssetId(sourceAssetId);
|
||||
//
|
||||
// }
|
||||
// else if (!m_fileAssetId.IsValid())
|
||||
// {
|
||||
// SetFileAssetId(sourceAssetId);
|
||||
// }
|
||||
//
|
||||
// m_formerGraphIdPair = AZStd::make_pair(m_scriptCanvasId, m_graphId);
|
||||
//
|
||||
// m_fileState = Tracker::ScriptCanvasFileState::UNMODIFIED;
|
||||
//
|
||||
// m_pendingSave.erase(assetPathIdIt);
|
||||
//
|
||||
// m_absolutePath = m_saveAsPath;
|
||||
// m_saveAsPath.clear();
|
||||
//
|
||||
// // Connect to the source asset's bus to monitor for situations we may need to handle
|
||||
// AZ::Data::AssetBus::MultiHandler::BusConnect(m_inMemoryAsset.GetId());
|
||||
// AZ::Data::AssetBus::MultiHandler::BusConnect(m_fileAssetId);
|
||||
//
|
||||
// if (m_onSaveCallback)
|
||||
// {
|
||||
// m_onSaveCallback(true, m_inMemoryAsset.Get(), previousFileAssetId);
|
||||
// m_onSaveCallback = nullptr;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void ScriptCanvasMemoryAsset::FinalizeAssetSave(bool, const AzToolsFramework::SourceControlFileInfo& fileInfo, const AZ::Data::AssetStreamInfo& saveInfo, Callbacks::OnSave onSaveCallback)
|
||||
@@ -525,14 +526,14 @@ namespace ScriptCanvasEditor
|
||||
UndoNotificationBus::Broadcast(&UndoNotifications::OnCanRedoChanged, m_undoState->m_undoStack->CanRedo());
|
||||
}
|
||||
|
||||
void ScriptCanvasMemoryAsset::SetFileAssetId(const AZ::Data::AssetId& fileAssetId)
|
||||
void ScriptCanvasMemoryAsset::SetFileAssetId(const AZ::Data::AssetId& /*fileAssetId*/)
|
||||
{
|
||||
m_fileAssetId = fileAssetId;
|
||||
|
||||
if (m_canvasWidget)
|
||||
{
|
||||
m_canvasWidget->SetAssetId(fileAssetId);
|
||||
}
|
||||
// m_fileAssetId = fileAssetId;
|
||||
//
|
||||
// if (m_canvasWidget)
|
||||
// {
|
||||
// m_canvasWidget->SetAssetId(fileAssetId);
|
||||
// }
|
||||
}
|
||||
|
||||
void ScriptCanvasMemoryAsset::SignalFileStateChanged()
|
||||
@@ -604,27 +605,27 @@ namespace ScriptCanvasEditor
|
||||
// AssetSaveFinalizer
|
||||
//////////////////////////////////////
|
||||
|
||||
bool AssetSaveFinalizer::ValidateStatus(const AzToolsFramework::SourceControlFileInfo& fileInfo)
|
||||
bool AssetSaveFinalizer::ValidateStatus(const AzToolsFramework::SourceControlFileInfo& /*fileInfo*/)
|
||||
{
|
||||
auto fileIO = AZ::IO::FileIOBase::GetInstance();
|
||||
if (fileInfo.IsLockedByOther())
|
||||
{
|
||||
AZ_Error("Script Canvas", !fileInfo.IsLockedByOther(), "The file is already exclusively opened by another user: %s", fileInfo.m_filePath.data());
|
||||
AZStd::invoke(m_onSave, false, m_inMemoryAsset, m_fileAssetId);
|
||||
return false;
|
||||
}
|
||||
else if (fileInfo.IsReadOnly() && fileIO->Exists(fileInfo.m_filePath.c_str()))
|
||||
{
|
||||
AZ_Error("Script Canvas", !fileInfo.IsReadOnly(), "File %s is read-only. It cannot be saved."
|
||||
" If this file is in Perforce it may not have been checked out by the Source Control API.", fileInfo.m_filePath.data());
|
||||
AZStd::invoke(m_onSave, false, m_inMemoryAsset, m_fileAssetId);
|
||||
return false;
|
||||
}
|
||||
else if (m_saving)
|
||||
{
|
||||
AZ_Warning("Script Canvas", false, "Trying to save the same file twice. Will result in one save callback being ignored.");
|
||||
return false;
|
||||
}
|
||||
// auto fileIO = AZ::IO::FileIOBase::GetInstance();
|
||||
// if (fileInfo.IsLockedByOther())
|
||||
// {
|
||||
// AZ_Error("Script Canvas", !fileInfo.IsLockedByOther(), "The file is already exclusively opened by another user: %s", fileInfo.m_filePath.data());
|
||||
// AZStd::invoke(m_onSave, false, m_inMemoryAsset, m_fileAssetId);
|
||||
// return false;
|
||||
// }
|
||||
// else if (fileInfo.IsReadOnly() && fileIO->Exists(fileInfo.m_filePath.c_str()))
|
||||
// {
|
||||
// AZ_Error("Script Canvas", !fileInfo.IsReadOnly(), "File %s is read-only. It cannot be saved."
|
||||
// " If this file is in Perforce it may not have been checked out by the Source Control API.", fileInfo.m_filePath.data());
|
||||
// AZStd::invoke(m_onSave, false, m_inMemoryAsset, m_fileAssetId);
|
||||
// return false;
|
||||
// }
|
||||
// else if (m_saving)
|
||||
// {
|
||||
// AZ_Warning("Script Canvas", false, "Trying to save the same file twice. Will result in one save callback being ignored.");
|
||||
// return false;
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user