From 7937ece77323c30def9d01bcb3748dc3d14e6795 Mon Sep 17 00:00:00 2001 From: AMZN-ScottR <24445312+AMZN-ScottR@users.noreply.github.com> Date: Tue, 13 Jul 2021 15:07:16 -0700 Subject: [PATCH] [mobile-settings-crash-fix] update mobile settings editor tool to support new project path structure Signed-off-by: AMZN-ScottR <24445312+AMZN-ScottR@users.noreply.github.com> --- .../ProjectSettingsToolWindow.cpp | 36 +++++++++++-------- .../ProjectSettingsToolWindow.h | 4 +-- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/Code/Editor/Plugins/ProjectSettingsTool/ProjectSettingsToolWindow.cpp b/Code/Editor/Plugins/ProjectSettingsTool/ProjectSettingsToolWindow.cpp index f4e4fed973..8222c52193 100644 --- a/Code/Editor/Plugins/ProjectSettingsTool/ProjectSettingsToolWindow.cpp +++ b/Code/Editor/Plugins/ProjectSettingsTool/ProjectSettingsToolWindow.cpp @@ -20,8 +20,9 @@ #include "ValidationHandler.h" #include +#include -#include "AzToolsFramework/UI/PropertyEditor/InstanceDataHierarchy.h" +#include #include #include #include @@ -52,7 +53,7 @@ namespace ProjectSettingsTool PlatformEnabled(PlatformId::Ios) ? ProjectSettingsContainer::PlistInitVector({ ProjectSettingsContainer::PlatformAndPath - { PlatformId::Ios, m_projectRoot + PlatformResourcesFolder(PlatformId::Ios) } + { PlatformId::Ios, GetPlatformResource(PlatformId::Ios) } }) : ProjectSettingsContainer::PlistInitVector()) @@ -647,33 +648,38 @@ namespace ProjectSettingsTool // iOS can be disabled if the plist file is missing if (platformId == PlatformId::Ios) { - const AZStd::string filename = m_projectRoot + PlatformResourcesFolder(platformId); - return CFileUtil::FileExists(filename.c_str()); + AZStd::string plistPath = GetPlatformResource(platformId); + return !plistPath.empty(); } return true; } - const char* ProjectSettingsToolWindow::PlatformResourcesFolder(PlatformId platformId) + AZStd::string ProjectSettingsToolWindow::GetPlatformResource(PlatformId platformId) { if (platformId == PlatformId::Ios) { - const AZStd::string firstfilename = m_projectRoot + "/Gem/Resources/Platform/iOS/Info.plist"; - if (CFileUtil::FileExists(firstfilename.c_str())) + const char* searchPaths[] = { + "Resources/Platform/iOS/Info.plist", + + // legacy paths + "Gem/Resources/Platform/iOS/Info.plist", + "Gem/Resources/IOSLauncher/Info.plist", + }; + + for (auto relPath : searchPaths) { - return "/Gem/Resources/Platform/iOS/Info.plist"; - } - else - { - const AZStd::string filename = m_projectRoot + "/Gem/Resources/IOSLauncher/Info.plist"; - if (CFileUtil::FileExists(filename.c_str())) + AZ::IO::FixedMaxPath projectPlist{ m_projectRoot }; + projectPlist /= relPath; + + if (CFileUtil::FileExists(projectPlist.c_str())) { - return "/Gem/Resources/IOSLauncher/Info.plist"; + return projectPlist.LexicallyNormal().c_str(); } } } - return nullptr; + return AZStd::string(); } #include diff --git a/Code/Editor/Plugins/ProjectSettingsTool/ProjectSettingsToolWindow.h b/Code/Editor/Plugins/ProjectSettingsTool/ProjectSettingsToolWindow.h index 8979672f99..64a6646e7f 100644 --- a/Code/Editor/Plugins/ProjectSettingsTool/ProjectSettingsToolWindow.h +++ b/Code/Editor/Plugins/ProjectSettingsTool/ProjectSettingsToolWindow.h @@ -137,8 +137,8 @@ namespace ProjectSettingsTool // returns true if the platform is enabled bool PlatformEnabled(PlatformId platformId); - // returns the resource folder - const char* PlatformResourcesFolder(PlatformId platformId); + // returns the main platform specific resource file e.g. for iOS it would be the Info.plist + AZStd::string GetPlatformResource(PlatformId platformId); // The ui for the window QScopedPointer m_ui;