Excise system() calls.

Fixes https://gitlab.com/kicad/code/kicad/issues/9236
This commit is contained in:
Jeff Young 2021-09-25 20:08:32 +01:00
parent 6bd4a77d70
commit c6bcb85562
4 changed files with 8 additions and 29 deletions

View File

@ -292,7 +292,7 @@ bool doPrintFile( const wxString& file, bool aDryRun )
file ); file );
if( !aDryRun ) if( !aDryRun )
system( printCommand.c_str() ); ProcessExecute( printCommand );
return true; return true;
} }

View File

@ -25,10 +25,7 @@
void LaunchExternal( const wxString& aPath ) void LaunchExternal( const wxString& aPath )
{ {
#ifdef __WXMAC__ #ifdef __WXMAC__
// Quote in case there are spaces in the path. wxExecute( wxString::Format( "open \"%s\"", aPath ) );
wxString msg = "open \"" + aPath + "\"";
system( msg.c_str() );
#else #else
wxString path( aPath ); wxString path( aPath );
@ -48,11 +45,7 @@ void LaunchExternal( const wxString& aPath )
void LaunchURL( const wxString& aUrl ) void LaunchURL( const wxString& aUrl )
{ {
#ifdef __WXMAC__ #ifdef __WXMAC__
wxString msg; wxExecute( wxString::Format( "open %s", aUrl ) );
msg.Printf( "open %s", aUrl );
system( msg.c_str() );
#else #else
wxLaunchDefaultApplication( aUrl ); wxLaunchDefaultApplication( aUrl );
#endif #endif

View File

@ -41,6 +41,7 @@
#include <kiplatform/environment.h> #include <kiplatform/environment.h>
#include <core/kicad_algo.h> #include <core/kicad_algo.h>
#include <paths.h> #include <paths.h>
#include <launch_ext.h>
#include "project_tree_item.h" #include "project_tree_item.h"
#include "project_tree.h" #include "project_tree.h"
@ -217,24 +218,7 @@ void PROJECT_TREE_PANE::onOpenDirectory( wxCommandEvent& event )
curr_dir += wxFileName::GetPathSeparator(); curr_dir += wxFileName::GetPathSeparator();
} }
#ifdef __WXMAC__ LaunchExternal( curr_dir );
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
} }
} }

View File

@ -34,6 +34,8 @@
#include <wx/checkbox.h> #include <wx/checkbox.h>
#include <wx/dir.h> #include <wx/dir.h>
#include <wx/filedlg.h> #include <wx/filedlg.h>
#include <common.h>
#ifdef PCM #ifdef PCM
#include "dialog_pcm.h" #include "dialog_pcm.h"
#endif #endif
@ -790,7 +792,7 @@ int KICAD_MANAGER_CONTROL::Execute( const TOOL_EVENT& aEvent )
#ifdef __WXMAC__ #ifdef __WXMAC__
msg.Printf( "osascript -e 'activate application \"%s\"' ", execFile ); msg.Printf( "osascript -e 'activate application \"%s\"' ", execFile );
system( msg.c_str() ); ProcessExecute( msg );
#endif #endif
} }
else else