Ver Fonte

fix Mac editor plugin path (#16849)

* fix Mac editor plugin path

Signed-off-by: Alex Peterson <[email protected]>

* use GetPathToApplicationBundle helper

Signed-off-by: Alex Peterson <[email protected]>

* Remove redundant logic

Signed-off-by: Alex Peterson <[email protected]>

* added missing 'EditorPlugins' subdirectory to path

Signed-off-by: Alex Peterson <[email protected]>

* simplify plugin path logic

turns out the plugin path mask isn't actually used

Signed-off-by: Alex Peterson <[email protected]>

---------

Signed-off-by: Alex Peterson <[email protected]>
Alex Peterson há 1 ano atrás
pai
commit
8c3d7199dd
3 ficheiros alterados com 25 adições e 20 exclusões
  1. 22 16
      Code/Editor/IEditorImpl.cpp
  2. 2 3
      Code/Editor/PluginManager.cpp
  3. 1 1
      Code/Editor/PluginManager.h

+ 22 - 16
Code/Editor/IEditorImpl.cpp

@@ -23,6 +23,10 @@
 #include <AzCore/Settings/SettingsRegistryMergeUtils.h>
 #include <AzCore/Utils/Utils.h>
 
+#if defined(AZ_PLATFORM_MAC)
+#include <AzCore/Utils/SystemUtilsApple_Platform.h>
+#endif
+
 // AzFramework
 #include <AzFramework/Terrain/TerrainDataRequestBus.h>
 
@@ -229,30 +233,32 @@ void CEditorImpl::LoadPlugins()
 {
     AZStd::scoped_lock lock(m_pluginMutex);
 
-    static const QString editor_plugins_folder("EditorPlugins");
-
-    // Build, verify, and set the engine root's editor plugin folder
-    QString editorPluginPathStr;
+    constexpr const char* editorPluginFolder = "EditorPlugins";
 
-    AZStd::string_view exeFolder;
-    AZ::ComponentApplicationBus::BroadcastResult(exeFolder, &AZ::ComponentApplicationRequests::GetExecutableFolder);
+    AZ::IO::FixedMaxPath pluginsPath;
 
-    QDir testDir;
-    testDir.setPath(AZStd::string(exeFolder).c_str());
-    if (testDir.exists() && testDir.cd(editor_plugins_folder))
+#if defined(AZ_PLATFORM_MAC)
+    char maxPathBuffer[AZ::IO::MaxPathLength];
+    if (auto appBundlePathOutcome = AZ::SystemUtilsApple::GetPathToApplicationBundle(maxPathBuffer);
+       appBundlePathOutcome)
     {
-        editorPluginPathStr = testDir.absolutePath();
+        AZ::IO::FixedMaxPath bundleRootDirectory = appBundlePathOutcome.GetValue();
+
+        // the bundle directory includes Editor.app so we want the parent directory
+        bundleRootDirectory = (bundleRootDirectory / "..").LexicallyNormal();
+        pluginsPath = bundleRootDirectory / editorPluginFolder;
     }
+#endif
 
-    // If no editor plugin path was found based on the root engine path, then fallback to the current editor.exe path
-    if (editorPluginPathStr.isEmpty())
+    if (pluginsPath.empty())
     {
-        editorPluginPathStr = QString("%1/%2").arg(qApp->applicationDirPath(), editor_plugins_folder);
+        // Use the executable directory as the starting point for the EditorPlugins path
+        AZ::IO::FixedMaxPath executableDirectory = AZ::Utils::GetExecutableDirectory();
+        pluginsPath = executableDirectory / editorPluginFolder;
     }
 
-    QString pluginSearchPath = QDir::toNativeSeparators(QString("%1/*" AZ_DYNAMIC_LIBRARY_EXTENSION).arg(editorPluginPathStr));
-
-    GetPluginManager()->LoadPlugins(pluginSearchPath.toUtf8().data());
+    // error handling for invalid paths is handled in LoadPlugins
+    GetPluginManager()->LoadPlugins(pluginsPath.c_str());
 }
 
 CEditorImpl::~CEditorImpl()

+ 2 - 3
Code/Editor/PluginManager.cpp

@@ -123,10 +123,9 @@ namespace
     }
 }
 
-bool CPluginManager::LoadPlugins(const char* pPathWithMask)
+bool CPluginManager::LoadPlugins(const char* pluginsPath)
 {
-    QString strPath = PathUtil::GetPath(pPathWithMask).c_str();
-    QString strMask = PathUtil::GetFile(pPathWithMask);
+    QString strPath{ pluginsPath }; 
 
     CLogFile::WriteLine("[Plugin Manager] Loading plugins...");
 

+ 1 - 1
Code/Editor/PluginManager.h

@@ -42,7 +42,7 @@ public:
     CPluginManager();
     virtual ~CPluginManager();
 
-    bool LoadPlugins(const char* pPathWithMask);
+    bool LoadPlugins(const char* pluginsPath);
 
     // release all plugins (ie, call Release() on them) - but don't drop their DLL
     void ReleaseAllPlugins();