From 964cbb95d3e0865348c3eb8e3f349f6c5314f372 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 25 Jun 2021 11:06:41 +0200 Subject: [PATCH] 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 --- common/gestfich.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/common/gestfich.cpp b/common/gestfich.cpp index b05b84d268..c5d5050746 100644 --- a/common/gestfich.cpp +++ b/common/gestfich.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2008 Wayne Stambaugh - * 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 ) )