From c6bcb85562bcbaa098f937fa8bb405df260d0474 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 25 Sep 2021 20:08:32 +0100 Subject: [PATCH] Excise system() calls. Fixes https://gitlab.com/kicad/code/kicad/issues/9236 --- common/gestfich.cpp | 2 +- common/launch_ext.cpp | 11 ++--------- kicad/project_tree_pane.cpp | 20 ++------------------ kicad/tools/kicad_manager_control.cpp | 4 +++- 4 files changed, 8 insertions(+), 29 deletions(-) diff --git a/common/gestfich.cpp b/common/gestfich.cpp index 40169f4c25..640c219aa5 100644 --- a/common/gestfich.cpp +++ b/common/gestfich.cpp @@ -292,7 +292,7 @@ bool doPrintFile( const wxString& file, bool aDryRun ) file ); if( !aDryRun ) - system( printCommand.c_str() ); + ProcessExecute( printCommand ); return true; } diff --git a/common/launch_ext.cpp b/common/launch_ext.cpp index 3b1981023a..1307f5573a 100644 --- a/common/launch_ext.cpp +++ b/common/launch_ext.cpp @@ -25,10 +25,7 @@ void LaunchExternal( const wxString& aPath ) { #ifdef __WXMAC__ - // Quote in case there are spaces in the path. - wxString msg = "open \"" + aPath + "\""; - - system( msg.c_str() ); + wxExecute( wxString::Format( "open \"%s\"", aPath ) ); #else wxString path( aPath ); @@ -48,11 +45,7 @@ void LaunchExternal( const wxString& aPath ) void LaunchURL( const wxString& aUrl ) { #ifdef __WXMAC__ - wxString msg; - - msg.Printf( "open %s", aUrl ); - - system( msg.c_str() ); + wxExecute( wxString::Format( "open %s", aUrl ) ); #else wxLaunchDefaultApplication( aUrl ); #endif diff --git a/kicad/project_tree_pane.cpp b/kicad/project_tree_pane.cpp index 4c86a956df..664a572d85 100644 --- a/kicad/project_tree_pane.cpp +++ b/kicad/project_tree_pane.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include "project_tree_item.h" #include "project_tree.h" @@ -217,24 +218,7 @@ void PROJECT_TREE_PANE::onOpenDirectory( wxCommandEvent& event ) curr_dir += wxFileName::GetPathSeparator(); } -#ifdef __WXMAC__ - wxString msg; - - // Quote in case there are spaces in the path. - msg.Printf( "open \"%s\"", curr_dir ); - - system( msg.c_str() ); -#else - #if !wxCHECK_VERSION( 3, 1, 0 ) - // Quote in case there are spaces in the path. - // Not needed on 3.1.4, but needed in 3.0 versions - // Moreover, on Linux, on 3.1.4 wx version, adding quotes breaks - // wxLaunchDefaultApplication - QuoteString( curr_dir ); - #endif - - wxLaunchDefaultApplication( curr_dir ); -#endif + LaunchExternal( curr_dir ); } } diff --git a/kicad/tools/kicad_manager_control.cpp b/kicad/tools/kicad_manager_control.cpp index 246cc7eed6..1cf036590d 100644 --- a/kicad/tools/kicad_manager_control.cpp +++ b/kicad/tools/kicad_manager_control.cpp @@ -34,6 +34,8 @@ #include #include #include +#include + #ifdef PCM #include "dialog_pcm.h" #endif @@ -790,7 +792,7 @@ int KICAD_MANAGER_CONTROL::Execute( const TOOL_EVENT& aEvent ) #ifdef __WXMAC__ msg.Printf( "osascript -e 'activate application \"%s\"' ", execFile ); - system( msg.c_str() ); + ProcessExecute( msg ); #endif } else