From 04a36194286049abcceaaf6db97dbe3c4fe22cdf Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Wed, 18 Nov 2020 11:54:12 -0500 Subject: [PATCH] Fix opening symbol documentation field paths with spaces on GTK. Fixes https://gitlab.com/kicad/code/kicad/-/issues/6422 --- common/gestfich.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/common/gestfich.cpp b/common/gestfich.cpp index d349d7f3c4..929b8d447a 100644 --- a/common/gestfich.cpp +++ b/common/gestfich.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com - * Copyright (C) 2008-2017 Wayne Stambaugh + * Copyright (C) 2008 Wayne Stambaugh * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or @@ -195,7 +195,7 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& para bool OpenPDF( const wxString& file ) { wxString command; - const wxString& filename = file; + wxString filename = file; Pgm().ReadPdfBrowserInfos(); @@ -210,11 +210,20 @@ bool OpenPDF( const wxString& file ) } else { + // wxLaunchDefaultApplication on Unix systems is run as an external process passing + // the filename to the appropriate application as a command argument. Spaces in the + // path and/or file name will cause argument parsing issues so always quote the file + // name and path. This is applicable to all Unix platforms. + // See https://github.com/wxWidgets/wxWidgets/blob/master/src/unix/utilsx11.cpp#L2654 +#ifdef __WXGTK__ + filename = wxT( "\"" ) + filename + wxT( "\"" ); +#endif + if( wxLaunchDefaultApplication( filename ) ) return true; #ifdef __WXMAC__ - command = wxT( "/usr/bin/open -a '" ) + filename + wxT( "'" ); + command = wxT( "/usr/bin/open -a '" ) + file + wxT( "'" ); #endif // If launching the system default PDF viewer fails, fall through with empty command // string so the error message is displayed. @@ -330,7 +339,7 @@ bool doPrintFile( const wxString& file, bool aDryRun ) if( !aDryRun ) { - DisplayError( nullptr, wxString::Format( _( "Cannot print '%s'.\n\nUnknown filetype." ), + DisplayError( nullptr, wxString::Format( _( "Cannot print '%s'.\n\nUnknown file type." ), file ) ); }