gestfich.cpp: fix an issue on wxGTK when calling wxLaunchDefaultApplication()

- On wxGTK version < 3.1, the filename must be quoted if containing spaces,
and can be always quoted.
- On wxGTK version >= 3.1, the filename must *never* be quoted because
a quoted filename breaks wxLaunchDefaultApplication().
Fixes #8670
https://gitlab.com/kicad/code/kicad/issues/8670
This commit is contained in:
jean-pierre charras 2021-06-25 11:06:41 +02:00
parent 4eafd2664a
commit 964cbb95d3
1 changed files with 11 additions and 5 deletions

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -212,12 +212,18 @@ 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.
// the filename to the appropriate application as a command argument.
// depending on wxWidgets version, spaces in the path and/or file name will cause
// argument parsing issues so always quote the filename and path.
// This is applicable to all Unix platforms with wxWidgets version < 3.1.0.
// See https://github.com/wxWidgets/wxWidgets/blob/master/src/unix/utilsx11.cpp#L2654
#ifdef __WXGTK__
filename = wxT( "\"" ) + filename + wxT( "\"" );
#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
AddDelimiterString( filename );
#endif
#endif
if( wxLaunchDefaultApplication( filename ) )