Fix URL launching on MacOS

This commit is contained in:
Jon Evans 2020-02-22 09:47:51 -05:00
parent 41b7c62c15
commit 80233aece9
3 changed files with 22 additions and 1 deletions

View File

@ -25,6 +25,7 @@
#include <config.h> #include <config.h>
#include <kicad_curl/kicad_curl_easy.h> #include <kicad_curl/kicad_curl_easy.h>
#include <launch_ext.h>
#include <string> #include <string>
// kicad_curl.h must be included before wx headers, to avoid // kicad_curl.h must be included before wx headers, to avoid
@ -677,5 +678,5 @@ void DIALOG_ABOUT::onReportBug( wxCommandEvent& event )
wxString url_string; wxString url_string;
url_string.Printf( m_bugReportUrl, kcurl.Escape( message.ToStdString() ) ); url_string.Printf( m_bugReportUrl, kcurl.Escape( message.ToStdString() ) );
wxLaunchDefaultApplication( url_string ); LaunchURL( url_string );
} }

View File

@ -40,3 +40,17 @@ void LaunchExternal( const wxString& aPath )
wxLaunchDefaultApplication( path ); wxLaunchDefaultApplication( path );
#endif #endif
} }
void LaunchURL( const wxString& aUrl )
{
#ifdef __WXMAC__
wxString msg;
msg.Printf( "open %s", aUrl );
system( msg.c_str() );
#else
wxLaunchDefaultApplication( aUrl );
#endif
}

View File

@ -29,4 +29,10 @@ class wxString;
*/ */
void LaunchExternal( const wxString& aPath ); void LaunchExternal( const wxString& aPath );
/**
* Attempts to launch a given URL in the user's browser
* @param aUrl is a valid URL (already escaped)
*/
void LaunchURL( const wxString& aUrl );
#endif #endif