Merge pull request #410 from aws-lumberyard-dev/ly-sdk/phistere/LYN-2723-Merge

LYN-2723: Fixes issues with bad project or engine paths

Cherry-pick: 6ce7a6d30c57c941459b43c157861df5d9143ae1
This commit is contained in:
Eric Phister
2021-04-29 11:01:32 -05:00
committed by GitHub
22 changed files with 281 additions and 225 deletions
+21 -7
View File
@@ -5045,12 +5045,28 @@ extern "C"
#pragma comment(lib, "Shell32.lib")
#endif
struct CryAllocatorsRAII
{
CryAllocatorsRAII()
{
AZ_Assert(!AZ::AllocatorInstance<AZ::LegacyAllocator>::IsReady(), "Expected allocator to not be initialized, hunt down the static that is initializing it");
AZ_Assert(!AZ::AllocatorInstance<CryStringAllocator>::IsReady(), "Expected allocator to not be initialized, hunt down the static that is initializing it");
AZ::AllocatorInstance<AZ::LegacyAllocator>::Create();
AZ::AllocatorInstance<CryStringAllocator>::Create();
}
~CryAllocatorsRAII()
{
AZ::AllocatorInstance<CryStringAllocator>::Destroy();
AZ::AllocatorInstance<AZ::LegacyAllocator>::Destroy();
}
};
extern "C" int AZ_DLL_EXPORT CryEditMain(int argc, char* argv[])
{
AZ_Assert(!AZ::AllocatorInstance<AZ::LegacyAllocator>::IsReady(), "Expected allocator to not be initialized, hunt down the static that is initializing it");
AZ::AllocatorInstance<AZ::LegacyAllocator>::Create();
AZ_Assert(!AZ::AllocatorInstance<CryStringAllocator>::IsReady(), "Expected allocator to not be initialized, hunt down the static that is initializing it");
AZ::AllocatorInstance<CryStringAllocator>::Create();
CryAllocatorsRAII cryAllocatorsRAII;
// ensure the EditorEventsBus context gets created inside EditorLib
[[maybe_unused]] const auto& editorEventsContext = AzToolsFramework::EditorEvents::Bus::GetOrCreateContext();
@@ -5058,7 +5074,7 @@ extern "C" int AZ_DLL_EXPORT CryEditMain(int argc, char* argv[])
// connect relevant buses to global settings
gSettings.Connect();
CCryEditApp* theApp = new CCryEditApp();
auto theApp = AZStd::make_unique<CCryEditApp>();
// this does some magic to set the current directory...
{
QCoreApplication app(argc, argv);
@@ -5145,8 +5161,6 @@ extern "C" int AZ_DLL_EXPORT CryEditMain(int argc, char* argv[])
}
delete theApp;
gSettings.Disconnect();
return ret;
+4 -7
View File
@@ -30,17 +30,14 @@ int main(int argc, char* argv[])
[[maybe_unused]] const bool loaded = handle->Load(true);
AZ_Assert(loaded, "EditorLib could not be loaded");
int ret = 1;
if (auto fn = handle->GetFunction<CryEditMain>(CryEditMainName); fn != nullptr)
{
const int ret = AZStd::invoke(fn, argc, argv);
AZ::AllocatorInstance<AZ::OSAllocator>::Destroy();
AZ::Environment::Detach();
return ret;
ret = AZStd::invoke(fn, argc, argv);
}
handle = {};
AZ::AllocatorInstance<AZ::OSAllocator>::Destroy();
AZ::Environment::Detach();
return 1;
return ret;
}