From 94891b75f971289ae038fa35d42b8cb778bfa370 Mon Sep 17 00:00:00 2001 From: Adam Wolf Date: Tue, 12 Jun 2018 21:35:42 -0500 Subject: [PATCH] Handle STEP export properly on MacOS when launched from standalone pcbnew. --- pcbnew/dialogs/dialog_export_step.cpp | 11 +++++++++++ pcbnew/pcb_edit_frame.cpp | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pcbnew/dialogs/dialog_export_step.cpp b/pcbnew/dialogs/dialog_export_step.cpp index 492d4c9b16..50d712bd45 100644 --- a/pcbnew/dialogs/dialog_export_step.cpp +++ b/pcbnew/dialogs/dialog_export_step.cpp @@ -249,6 +249,17 @@ void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent ) double yOrg = 0.0; wxFileName appK2S( wxStandardPaths::Get().GetExecutablePath() ); + #ifdef __WXMAC__ + // On macOS, we have standalone applications inside the main bundle, so we handle that here: + if( appK2S.GetPath().find( _("/Contents/Applications/pcbnew.app/Contents/MacOS") ) != wxNOT_FOUND ) + { + appK2S.AppendDir( _("..")); + appK2S.AppendDir( _("..")); + appK2S.AppendDir( _("..")); + appK2S.AppendDir( _("..")); + appK2S.AppendDir( _("MacOS")); + } + #endif appK2S.SetName( "kicad2step" ); wxString cmdK2S = "\""; diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index 5f9e930c55..938ac9a642 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -518,7 +518,12 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : // disable Export STEP item if kicad2step does not exist wxString strK2S = Pgm().GetExecutablePath(); #ifdef __WXMAC__ - strK2S += "Contents/MacOS/"; + if (strK2S.find( _("pcbnew.app") ) != wxNOT_FOUND ) + { + // On macOS, we have standalone applications inside the main bundle, so we handle that here: + strK2S += "../../"; + } + strK2S += "Contents/MacOS/"; #endif wxFileName appK2S( strK2S, "kicad2step" );