Merge pull request #3438 from aws-lumberyard-dev/carlitosan/development
Bug fixes for SC editor asset scan in version explorer widget
This commit is contained in:
@@ -28,7 +28,7 @@ namespace AZ
|
||||
private:
|
||||
using ElementInformation = ExpressionEvaluation::ElementInformation;
|
||||
|
||||
static const char* EmptyAnyIdentifier;
|
||||
static constexpr AZStd::string_view EmptyAnyIdentifier = "Empty AZStd::any";
|
||||
|
||||
static bool IsEmptyAny(const rapidjson::Value& typeId)
|
||||
{
|
||||
@@ -43,7 +43,7 @@ namespace AZ
|
||||
|
||||
JsonSerializationResult::Result Load
|
||||
( void* outputValue
|
||||
, const Uuid& outputValueTypeId
|
||||
, [[maybe_unused]] const Uuid& outputValueTypeId
|
||||
, const rapidjson::Value& inputValue
|
||||
, JsonDeserializerContext& context) override
|
||||
{
|
||||
@@ -161,8 +161,7 @@ namespace AZ
|
||||
else
|
||||
{
|
||||
rapidjson::Value emptyAny;
|
||||
AZStd::string emptyAnyName(EmptyAnyIdentifier);
|
||||
emptyAny.SetString(emptyAnyName.c_str(), aznumeric_caster(emptyAnyName.size()), context.GetJsonAllocator());
|
||||
emptyAny.SetString(EmptyAnyIdentifier.data(), aznumeric_caster(EmptyAnyIdentifier.size()), context.GetJsonAllocator());
|
||||
outputValue.AddMember
|
||||
( rapidjson::StringRef(JsonSerialization::TypeIdFieldIdentifier)
|
||||
, AZStd::move(emptyAny)
|
||||
@@ -176,6 +175,4 @@ namespace AZ
|
||||
};
|
||||
|
||||
AZ_CLASS_ALLOCATOR_IMPL(ElementInformationSerializer, SystemAllocator, 0);
|
||||
|
||||
const char* ElementInformationSerializer::EmptyAnyIdentifier = "Empty AZStd::any";
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace AZ
|
||||
|
||||
JsonSerializationResult::Result Load
|
||||
( void* outputValue
|
||||
, const Uuid& outputValueTypeId
|
||||
, [[maybe_unused]] const Uuid& outputValueTypeId
|
||||
, const rapidjson::Value& inputValue
|
||||
, JsonDeserializerContext& context) override
|
||||
{
|
||||
|
||||
@@ -88,13 +88,13 @@ namespace ScriptCanvasEditor
|
||||
|
||||
void Enter() override
|
||||
{
|
||||
//Log("ENTER >> %s", GetName());
|
||||
Log("ENTER >> %s", GetName());
|
||||
OnEnter();
|
||||
}
|
||||
|
||||
ExitStatus Exit() override
|
||||
{
|
||||
//Log("EXIT << %s", GetName());
|
||||
Log("EXIT << %s", GetName());
|
||||
return OnExit();
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,21 @@ namespace ScriptCanvasEditor
|
||||
|
||||
}
|
||||
|
||||
void VersionExplorer::Log(const char* format, ...)
|
||||
{
|
||||
if (m_ui->verbose->isChecked())
|
||||
{
|
||||
char sBuffer[1024];
|
||||
va_list ArgList;
|
||||
va_start(ArgList, format);
|
||||
azvsnprintf(sBuffer, sizeof(sBuffer), format, ArgList);
|
||||
sBuffer[sizeof(sBuffer) - 1] = '\0';
|
||||
va_end(ArgList);
|
||||
|
||||
AZ_TracePrintf("Script Canvas", "%s\n", sBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
void VersionExplorer::OnClose()
|
||||
{
|
||||
reject();
|
||||
@@ -96,17 +111,27 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
m_inProgress = true;
|
||||
AZ::Data::AssetInfo& assetToUpgrade = *m_inspectingAsset;
|
||||
|
||||
m_currentAsset = AZ::Data::AssetManager::Instance().GetAsset(assetToUpgrade.m_assetId, assetToUpgrade.m_assetType, AZ::Data::AssetLoadBehavior::PreLoad);
|
||||
Log("SystemTick::ProcessState::Scan: %s pre-blocking load hint", m_currentAsset.GetHint().c_str());
|
||||
m_currentAsset.BlockUntilLoadComplete();
|
||||
if (m_currentAsset.IsReady())
|
||||
{
|
||||
// The asset is ready, grab its info
|
||||
m_inProgress = true;
|
||||
InspectAsset(m_currentAsset);
|
||||
InspectAsset(m_currentAsset, assetToUpgrade);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->tableWidget->insertRow(static_cast<int>(m_inspectedAssets));
|
||||
QTableWidgetItem* rowName = new QTableWidgetItem
|
||||
( tr(AZStd::string::format("Error: %s", assetToUpgrade.m_relativePath.c_str()).c_str()));
|
||||
|
||||
m_ui->spinner->SetText(QObject::tr("%1").arg(m_currentAsset.GetHint().c_str()));
|
||||
m_ui->tableWidget->setItem(static_cast<int>(m_inspectedAssets), static_cast<int>(ColumnAsset), rowName);
|
||||
Log("SystemTick::ProcessState::Scan: %s post-blocking load, problem loading asset", assetToUpgrade.m_relativePath.c_str());
|
||||
++m_currentAssetIndex;
|
||||
++m_failedAssets;
|
||||
ScanComplete(m_currentAsset);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -148,7 +173,6 @@ namespace ScriptCanvasEditor
|
||||
|
||||
AZ::Data::AssetManager::Instance().DispatchEvents();
|
||||
AZ::SystemTickBus::ExecuteQueuedEvents();
|
||||
|
||||
}
|
||||
|
||||
// Backup
|
||||
@@ -297,10 +321,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
if (graphComponent)
|
||||
{
|
||||
if (!graphComponent->UpgradeGraph(asset))
|
||||
{
|
||||
// The upgrade was skipped due to nothing to update (though if we're here, we identified that something was out of date)
|
||||
}
|
||||
graphComponent->UpgradeGraph(asset);
|
||||
}
|
||||
|
||||
return scriptCanvasEntity;
|
||||
@@ -581,13 +602,10 @@ namespace ScriptCanvasEditor
|
||||
{
|
||||
m_assetsToUpgrade.clear();
|
||||
m_assetsToInspect.clear();
|
||||
|
||||
m_ui->tableWidget->setRowCount(0);
|
||||
m_inspectedAssets = 0;
|
||||
|
||||
IUpgradeRequests* upgradeRequests = AZ::Interface<IUpgradeRequests>::Get();
|
||||
m_assetsToInspect = upgradeRequests->GetAssetsToUpgrade();
|
||||
|
||||
DoScan();
|
||||
}
|
||||
|
||||
@@ -596,9 +614,14 @@ namespace ScriptCanvasEditor
|
||||
AZ::SystemTickBus::Handler::BusConnect();
|
||||
|
||||
m_state = ProcessState::Scan;
|
||||
AZ::Debug::TraceMessageBus::Handler::BusConnect();
|
||||
|
||||
if (!m_assetsToInspect.empty())
|
||||
{
|
||||
m_discoveredAssets = m_assetsToInspect.size();
|
||||
m_failedAssets = 0;
|
||||
m_inspectedAssets = 0;
|
||||
|
||||
m_ui->progressFrame->setVisible(true);
|
||||
m_ui->progressBar->setRange(0, aznumeric_cast<int>(m_assetsToInspect.size()));
|
||||
m_ui->progressBar->setValue(0);
|
||||
@@ -622,14 +645,17 @@ namespace ScriptCanvasEditor
|
||||
DoScan();
|
||||
}
|
||||
|
||||
void VersionExplorer::InspectAsset(AZ::Data::Asset<AZ::Data::AssetData>& asset)
|
||||
void VersionExplorer::InspectAsset(AZ::Data::Asset<AZ::Data::AssetData>& asset, AZ::Data::AssetInfo& assetInfo)
|
||||
{
|
||||
Log("InspectAsset: %s", asset.GetHint().c_str());
|
||||
|
||||
AZ::Entity* scriptCanvasEntity = nullptr;
|
||||
if (asset.GetType() == azrtti_typeid<ScriptCanvasAsset>())
|
||||
{
|
||||
ScriptCanvasAsset* scriptCanvasAsset = asset.GetAs<ScriptCanvasAsset>();
|
||||
if (!scriptCanvasAsset)
|
||||
{
|
||||
Log("InspectAsset: %s, AsestData failed to return ScriptCanvasAsset", asset.GetHint().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -640,14 +666,14 @@ namespace ScriptCanvasEditor
|
||||
auto graphComponent = scriptCanvasEntity->FindComponent<ScriptCanvasEditor::Graph>();
|
||||
AZ_Assert(graphComponent, "The Script Canvas entity must have a Graph component");
|
||||
|
||||
|
||||
bool onlyShowOutdatedGraphs = m_ui->onlyShowOutdated->isChecked();
|
||||
bool forceUpgrade = m_ui->forceUpgrade->isChecked();
|
||||
|
||||
if (onlyShowOutdatedGraphs && graphComponent->GetVersion().IsLatest())
|
||||
if (!forceUpgrade && onlyShowOutdatedGraphs && graphComponent->GetVersion().IsLatest())
|
||||
{
|
||||
++m_currentAssetIndex;
|
||||
ScanComplete(asset);
|
||||
|
||||
Log("InspectAsset: %s, is at latest", asset.GetHint().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -655,7 +681,7 @@ namespace ScriptCanvasEditor
|
||||
QTableWidgetItem* rowName = new QTableWidgetItem(tr(asset.GetHint().c_str()));
|
||||
m_ui->tableWidget->setItem(static_cast<int>(m_inspectedAssets), static_cast<int>(ColumnAsset), rowName);
|
||||
|
||||
if (!graphComponent->GetVersion().IsLatest())
|
||||
if (forceUpgrade || !graphComponent->GetVersion().IsLatest())
|
||||
{
|
||||
m_assetsToUpgrade.push_back(asset);
|
||||
|
||||
@@ -665,18 +691,19 @@ namespace ScriptCanvasEditor
|
||||
QPushButton* rowGoToButton = new QPushButton(this);
|
||||
rowGoToButton->setText("Upgrade");
|
||||
rowGoToButton->setEnabled(false);
|
||||
connect(rowGoToButton, &QPushButton::clicked, [this, spinner, rowGoToButton, asset] {
|
||||
|
||||
AZ::SystemTickBus::QueueFunction([this, rowGoToButton, spinner, asset]() {
|
||||
connect(rowGoToButton, &QPushButton::clicked, [this, spinner, rowGoToButton, assetInfo] {
|
||||
|
||||
AZ::SystemTickBus::QueueFunction([this, rowGoToButton, spinner, assetInfo]() {
|
||||
// Queue the process state change because we can't connect to the SystemTick bus in a Qt lambda
|
||||
UpgradeSingle(rowGoToButton, spinner, asset);
|
||||
UpgradeSingle(rowGoToButton, spinner, assetInfo);
|
||||
});
|
||||
|
||||
AZ::SystemTickBus::ExecuteQueuedEvents();
|
||||
|
||||
});
|
||||
m_ui->tableWidget->setCellWidget(static_cast<int>(m_inspectedAssets), static_cast<int>(ColumnAction), rowGoToButton);
|
||||
|
||||
m_ui->tableWidget->setCellWidget(static_cast<int>(m_inspectedAssets), static_cast<int>(ColumnAction), rowGoToButton);
|
||||
m_ui->tableWidget->setCellWidget(static_cast<int>(m_inspectedAssets), static_cast<int>(ColumnStatus), spinner);
|
||||
}
|
||||
|
||||
@@ -713,37 +740,47 @@ namespace ScriptCanvasEditor
|
||||
ScanComplete(asset);
|
||||
}
|
||||
|
||||
void VersionExplorer::UpgradeSingle(QPushButton* rowGoToButton, AzQtComponents::StyledBusyLabel* spinner, const AZ::Data::Asset<AZ::Data::AssetData>& asset)
|
||||
void VersionExplorer::UpgradeSingle
|
||||
( QPushButton* rowGoToButton
|
||||
, AzQtComponents::StyledBusyLabel* spinner
|
||||
, AZ::Data::AssetInfo assetInfo)
|
||||
{
|
||||
AZ::Interface<IUpgradeRequests>::Get()->SetIsUpgrading(true);
|
||||
AZ::Data::Asset<AZ::Data::AssetData> asset = AZ::Data::AssetManager::Instance().GetAsset
|
||||
( assetInfo.m_assetId, assetInfo.m_assetType, AZ::Data::AssetLoadBehavior::PreLoad);
|
||||
|
||||
m_isUpgradingSingleGraph = true;
|
||||
if (asset)
|
||||
{
|
||||
asset.BlockUntilLoadComplete();
|
||||
|
||||
m_logs.clear();
|
||||
m_ui->textEdit->clear();
|
||||
|
||||
spinner->SetIsBusy(true);
|
||||
rowGoToButton->setEnabled(false);
|
||||
|
||||
m_inProgressAsset = AZStd::find_if(m_assetsToUpgrade.begin(), m_assetsToUpgrade.end(), [this, asset](const UpgradeAssets::value_type& assetToUpgrade)
|
||||
if (!asset.IsReady())
|
||||
{
|
||||
return assetToUpgrade.GetId() == asset.GetId();
|
||||
});
|
||||
AZ::Interface<IUpgradeRequests>::Get()->SetIsUpgrading(true);
|
||||
m_isUpgradingSingleGraph = true;
|
||||
m_logs.clear();
|
||||
m_ui->textEdit->clear();
|
||||
spinner->SetIsBusy(true);
|
||||
rowGoToButton->setEnabled(false);
|
||||
|
||||
m_state = ProcessState::Upgrade;
|
||||
|
||||
AZ::SystemTickBus::Handler::BusConnect();
|
||||
m_inProgressAsset = AZStd::find_if(m_assetsToUpgrade.begin(), m_assetsToUpgrade.end()
|
||||
, [this, asset](const UpgradeAssets::value_type& assetToUpgrade)
|
||||
{
|
||||
return assetToUpgrade.GetId() == asset.GetId();
|
||||
});
|
||||
|
||||
m_state = ProcessState::Upgrade;
|
||||
AZ::SystemTickBus::Handler::BusConnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VersionExplorer::ScanComplete(const AZ::Data::Asset<AZ::Data::AssetData>& asset)
|
||||
{
|
||||
Log("ScanComplete: %s", asset.GetHint().c_str());
|
||||
m_inProgress = false;
|
||||
m_ui->progressBar->setValue(aznumeric_cast<int>(m_currentAssetIndex));
|
||||
m_ui->scanButton->setEnabled(true);
|
||||
|
||||
|
||||
m_inspectingAsset = m_assetsToInspect.erase(m_inspectingAsset);
|
||||
|
||||
FlushLogs();
|
||||
|
||||
if (m_inspectingAsset == m_assetsToInspect.end())
|
||||
@@ -755,12 +792,12 @@ namespace ScriptCanvasEditor
|
||||
m_ui->upgradeAllButton->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
asset->Release();
|
||||
}
|
||||
|
||||
void VersionExplorer::FinalizeScan()
|
||||
{
|
||||
Log("FinalizeScan()");
|
||||
|
||||
m_ui->spinner->SetIsBusy(false);
|
||||
m_ui->onlyShowOutdated->setEnabled(true);
|
||||
|
||||
@@ -774,12 +811,18 @@ namespace ScriptCanvasEditor
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString spinnerText = QStringLiteral("Scan Complete");
|
||||
if (m_assetsToUpgrade.empty())
|
||||
{
|
||||
spinnerText.append(" - No graphs require upgrade!");
|
||||
}
|
||||
else
|
||||
{
|
||||
spinnerText.append(QString::asprintf(" - Discovered: %zu, Inspected: %zu, Failed: %zu"
|
||||
, m_discoveredAssets, m_inspectedAssets, m_failedAssets));
|
||||
}
|
||||
|
||||
|
||||
m_ui->spinner->SetText(spinnerText);
|
||||
m_ui->progressBar->setVisible(false);
|
||||
|
||||
@@ -793,11 +836,9 @@ namespace ScriptCanvasEditor
|
||||
UpgradeNotifications::Bus::Handler::BusDisconnect();
|
||||
|
||||
m_keepEditorAlive.reset();
|
||||
|
||||
m_state = ProcessState::Inactive;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
void VersionExplorer::FlushLogs()
|
||||
{
|
||||
if (m_logs.empty())
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace ScriptCanvasEditor
|
||||
void DoScan();
|
||||
void ScanComplete(const AZ::Data::Asset<AZ::Data::AssetData>&);
|
||||
|
||||
void InspectAsset(AZ::Data::Asset<AZ::Data::AssetData>& asset);
|
||||
void InspectAsset(AZ::Data::Asset<AZ::Data::AssetData>& asset, AZ::Data::AssetInfo& assetInfo);
|
||||
|
||||
void OnUpgradeAll();
|
||||
|
||||
@@ -116,10 +116,11 @@ namespace ScriptCanvasEditor
|
||||
bool m_inProgress = false;
|
||||
size_t m_currentAssetIndex = 0;
|
||||
size_t m_inspectedAssets = 0;
|
||||
size_t m_failedAssets = 0;
|
||||
size_t m_discoveredAssets = 0;
|
||||
|
||||
IUpgradeRequests::AssetList m_assetsToInspect;
|
||||
IUpgradeRequests::AssetList::iterator m_inspectingAsset;
|
||||
|
||||
using UpgradeAssets = AZStd::vector<AZ::Data::Asset<AZ::Data::AssetData>>;
|
||||
UpgradeAssets m_assetsToUpgrade;
|
||||
UpgradeAssets::iterator m_inProgressAsset;
|
||||
@@ -138,7 +139,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
bool m_isUpgradingSingleGraph = false;
|
||||
|
||||
void UpgradeSingle(QPushButton* item, AzQtComponents::StyledBusyLabel* spinner, const AZ::Data::Asset<AZ::Data::AssetData>& asset);
|
||||
void UpgradeSingle(QPushButton* item, AzQtComponents::StyledBusyLabel* spinner, AZ::Data::AssetInfo assetInfo);
|
||||
|
||||
void FlushLogs();
|
||||
|
||||
@@ -157,5 +158,7 @@ namespace ScriptCanvasEditor
|
||||
|
||||
bool m_overwriteAll = false;
|
||||
void PerformMove(AZ::Data::Asset<AZ::Data::AssetData>& asset, const AZStd::string& source, const AZStd::string& target);
|
||||
|
||||
void Log(const char* format, ...);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -321,6 +321,26 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="6">
|
||||
<widget class="QCheckBox" name="forceUpgrade">
|
||||
<property name="text">
|
||||
<string>Force Upgrade</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="7">
|
||||
<widget class="QCheckBox" name="verbose">
|
||||
<property name="text">
|
||||
<string>Verbose</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="4">
|
||||
<widget class="QPushButton" name="closeButton">
|
||||
<property name="sizePolicy">
|
||||
|
||||
@@ -128,6 +128,7 @@
|
||||
<addaction name="action_GraphValidation"/>
|
||||
<addaction name="action_Debugging"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="action_UpgradeTool"/>
|
||||
<addaction name="action_ViewUnitTestManager"/>
|
||||
<addaction name="action_NodeStatistics"/>
|
||||
<addaction name="action_PresetsEditor"/>
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace ScriptCanvas
|
||||
|
||||
void BehaviorContextObject::Deserialize(BehaviorContextObject& target, const AZ::BehaviorClass& behaviorClass, AZStd::any& source)
|
||||
{
|
||||
target.m_object = AZStd::move(AZStd::any(AZStd::any_cast<void>(&source), GetAnyTypeInfoObject(behaviorClass)));
|
||||
target.m_object = AZStd::any(AZStd::any_cast<void>(&source), GetAnyTypeInfoObject(behaviorClass));
|
||||
target.m_flags = Owned;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user