Workaround wxWidgets inability to find the default PDF viewer.

Fixes: lp:1843061
* https://bugs.launchpad.net/kicad/+bug/1843061
This commit is contained in:
Jeff Young 2019-09-06 17:19:46 +01:00
parent 2553dd2942
commit d55f4d05b4
1 changed files with 6 additions and 7 deletions

View File

@ -211,27 +211,27 @@ bool OpenPDF( const wxString& file )
wxString command; wxString command;
wxString filename = file; wxString filename = file;
// Quote in case there are spaces in the file name.
AddDelimiterString( filename );
Pgm().ReadPdfBrowserInfos(); Pgm().ReadPdfBrowserInfos();
if( !Pgm().UseSystemPdfBrowser() ) // Run the preferred PDF Browser if( !Pgm().UseSystemPdfBrowser() ) // Run the preferred PDF Browser
{ {
command = Pgm().GetPdfBrowserName() + wxT( " " ) + filename; command = Pgm().GetPdfBrowserName() + wxT( " '" ) + filename + wxT( "'" );
} }
else else
{ {
if( wxLaunchDefaultApplication( filename ) ) if( wxLaunchDefaultApplication( filename ) )
return true; return true;
#ifdef __WXMAC__
command = wxT( "/usr/bin/open -a '" ) + filename + wxT( "'" );
#endif
// If launching the system default PDF viewer fails, fall through with empty command // If launching the system default PDF viewer fails, fall through with empty command
// string so the error message is displayed. // string so the error message is displayed.
} }
if( !command.IsEmpty() ) if( !command.IsEmpty() )
{ {
if( ProcessExecute( command ) ) if( ProcessExecute( command ) != -1 )
{ {
return true; return true;
} }
@ -269,8 +269,6 @@ void OpenFile( const wxString& file )
if( !command.IsEmpty() ) if( !command.IsEmpty() )
ProcessExecute( command ); ProcessExecute( command );
DisplayError( NULL, wxString::Format( _( "Cannot print '%s'.\n\nUnknown filetype." ), file ) );
} }
@ -339,6 +337,7 @@ bool doPrintFile( const wxString& file, bool aDryRun )
} }
#endif #endif
DisplayError( NULL, wxString::Format( _( "Cannot print '%s'.\n\nUnknown filetype." ), file ) );
return false; return false;
} }