From 9f814c0f6af2a566b178c498890fda2709240661 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 25 Sep 2023 18:02:54 +0100 Subject: [PATCH] Repair standalone application 3D plugin path resolution. Fixes https://gitlab.com/kicad/code/kicad/-/issues/15322 (cherry picked from commit 04214983cf43941510526366cc2084a050e41bc7) --- common/paths.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/common/paths.cpp b/common/paths.cpp index d0fcb926f4..f6fac6af0a 100644 --- a/common/paths.cpp +++ b/common/paths.cpp @@ -288,6 +288,24 @@ wxString PATHS::GetStockPlugins3DPath() fn.AppendDir( wxT( "plugins" ) ); #elif defined( __WXMAC__ ) fn.Assign( wxStandardPaths::Get().GetPluginsDir(), wxEmptyString ); + + // This must be mapped to main bundle for everything but kicad.app + const wxArrayString dirs = fn.GetDirs(); + + // Check if we are the main kicad binary. in this case, the path will be + // /path/to/bundlename.app/Contents/PlugIns + // If we are an aux binary, the path will be something like + // /path/to/bundlename.app/Contents/Applications/.app/Contents/PlugIns + if( dirs.GetCount() >= 6 && + dirs[dirs.GetCount() - 4] == wxT( "Applications" ) && + dirs[dirs.GetCount() - 6].Lower().EndsWith( wxT( "app" ) ) ) + { + fn.RemoveLastDir(); + fn.RemoveLastDir(); + fn.RemoveLastDir(); + fn.RemoveLastDir(); + fn.AppendDir( wxT( "PlugIns" ) ); + } #else if( wxGetEnv( wxT( "KICAD_RUN_FROM_BUILD_DIR" ), nullptr ) ) {