From 1a360094d2117ead40ea11cafbdfcea5192ffd39 Mon Sep 17 00:00:00 2001 From: amzn-sj Date: Mon, 24 May 2021 15:06:04 -0700 Subject: [PATCH] Unregister custom SettingsRegistries in the test Teardown --- Code/Tools/AssetBundler/tests/applicationManagerTests.cpp | 6 ++++++ Code/Tools/AssetBundler/tests/tests_main.cpp | 7 ++++++- .../platformconfiguration/platformconfigurationtests.cpp | 8 +++++++- .../Code/Tests/Builders/MaterialBuilderTests.cpp | 6 ++++++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Code/Tools/AssetBundler/tests/applicationManagerTests.cpp b/Code/Tools/AssetBundler/tests/applicationManagerTests.cpp index 497e28d3ec..f2477782d0 100644 --- a/Code/Tools/AssetBundler/tests/applicationManagerTests.cpp +++ b/Code/Tools/AssetBundler/tests/applicationManagerTests.cpp @@ -101,6 +101,12 @@ namespace AssetBundler delete m_data->m_localFileIO; AZ::IO::FileIOBase::SetInstance(m_data->m_priorFileIO); + auto settingsRegistry = AZ::SettingsRegistry::Get(); + if(settingsRegistry == &m_registry) + { + AZ::SettingsRegistry::Unregister(settingsRegistry); + } + m_data->m_applicationManager->Stop(); m_data->m_applicationManager.reset(); m_data.reset(); diff --git a/Code/Tools/AssetBundler/tests/tests_main.cpp b/Code/Tools/AssetBundler/tests/tests_main.cpp index b38d09dacb..09d8e39a33 100644 --- a/Code/Tools/AssetBundler/tests/tests_main.cpp +++ b/Code/Tools/AssetBundler/tests/tests_main.cpp @@ -118,7 +118,6 @@ namespace AssetBundler { AZ::SettingsRegistry::Register(&m_registry); registry = &m_registry; - } else { @@ -157,6 +156,12 @@ namespace AssetBundler delete m_data->m_localFileIO; AZ::IO::FileIOBase::SetInstance(m_data->m_priorFileIO); + auto settingsRegistry = AZ::SettingsRegistry::Get(); + if(settingsRegistry == &m_registry) + { + AZ::SettingsRegistry::Unregister(settingsRegistry); + } + m_data->m_gemInfoList.set_capacity(0); m_data->m_gemSeedFilePairList.set_capacity(0); m_data->m_application.get()->Stop(); diff --git a/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp b/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp index d11650cbb1..5343a434cf 100644 --- a/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp +++ b/Code/Tools/AssetProcessor/native/tests/platformconfiguration/platformconfigurationtests.cpp @@ -49,7 +49,7 @@ void PlatformConfigurationUnitTests::SetUp() + "/project_path"; registry->Set(projectPathKey, "AutomatedTesting"); AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*registry); - + using namespace AssetProcessor; m_qApp = new QCoreApplication(m_argc, m_argv); AssetProcessorTest::SetUp(); @@ -61,6 +61,12 @@ void PlatformConfigurationUnitTests::TearDown() AssetUtilities::ResetAssetRoot(); delete m_qApp; AssetProcessor::AssetProcessorTest::TearDown(); + + auto settingsRegistry = AZ::SettingsRegistry::Get(); + if(settingsRegistry == &m_registry) + { + AZ::SettingsRegistry::Unregister(settingsRegistry); + } } TEST_F(PlatformConfigurationUnitTests, TestFailReadConfigFile_BadPlatform) diff --git a/Gems/LmbrCentral/Code/Tests/Builders/MaterialBuilderTests.cpp b/Gems/LmbrCentral/Code/Tests/Builders/MaterialBuilderTests.cpp index 9782c94f6c..2f534be88a 100644 --- a/Gems/LmbrCentral/Code/Tests/Builders/MaterialBuilderTests.cpp +++ b/Gems/LmbrCentral/Code/Tests/Builders/MaterialBuilderTests.cpp @@ -71,6 +71,12 @@ protected: void TearDown() override { + auto settingsRegistry = AZ::SettingsRegistry::Get(); + if(settingsRegistry == &m_registry) + { + AZ::SettingsRegistry::Unregister(settingsRegistry); + } + AZ::Debug::TraceMessageBus::Handler::BusDisconnect(); m_app->Stop(); m_app.reset();