From 9fe0d58732e1c56f597763c55d20b49588300526 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Mon, 7 Oct 2019 18:51:22 +0200 Subject: [PATCH] Fixes for wxCocoaLaunch see https://github.com/wxWidgets/wxWidgets/pull/1561 --- src/osx/cocoa/utils_base.mm | 20 ++++---------------- src/unix/utilsunx.cpp | 3 +-- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/osx/cocoa/utils_base.mm b/src/osx/cocoa/utils_base.mm index 06723c5578..53e52d55d5 100644 --- a/src/osx/cocoa/utils_base.mm +++ b/src/osx/cocoa/utils_base.mm @@ -194,17 +194,9 @@ bool wxDateTime::GetFirstWeekDay(wxDateTime::WeekDay *firstDay) bool wxCocoaLaunch(const char* const* argv, pid_t &pid) { - // Obtains the number of arguments for determining the size of - // the CFArray used to hold them - NSUInteger cfiCount = 0; - for (const char* const* argvcopy = argv; *argvcopy != NULL; ++argvcopy) - { - ++cfiCount; - } - // If there is not a single argument then there is no application // to launch - if(cfiCount == 0) + if(!argv) { wxLogDebug(wxT("wxCocoaLaunch No file to launch!")); return false ; @@ -228,12 +220,6 @@ bool wxCocoaLaunch(const char* const* argv, pid_t &pid) NSMutableArray *params = [[NSMutableArray alloc] init]; for( ; *argv != NULL; ++argv ) { - // Check for '<' as this will ring true for - // CFURLCreateWithString but is generally not considered - // typical on mac but is usually passed here from wxExecute - if (wxStrcmp(*argv, wxT("<")) == 0) - continue; - NSURL *cfurlCurrentFile; wxFileName argfn(*argv); // Filename for path wxString dir( *argv ); @@ -273,12 +259,14 @@ bool wxCocoaLaunch(const char* const* argv, pid_t &pid) NSRunningApplication *app = [ws launchApplicationAtURL:url options:NSWorkspaceLaunchAsync configuration:[NSDictionary dictionaryWithObject:params forKey:NSWorkspaceLaunchConfigurationArguments] error:&error]; + [params release]; + if( app != nil ) pid = [app processIdentifier]; else { wxString errorDesc = wxCFStringRef::AsString([error localizedDescription]); - wxLogDebug( wxString::Format( "wxCocoaLaunch failure: error is %s", errorDesc ) ); + wxLogDebug( "wxCocoaLaunch failure: error is %s", errorDesc ); return false; } return true; diff --git a/src/unix/utilsunx.cpp b/src/unix/utilsunx.cpp index 4c286d2d1d..50803d6a12 100644 --- a/src/unix/utilsunx.cpp +++ b/src/unix/utilsunx.cpp @@ -588,12 +588,11 @@ long wxExecute(const char* const* argv, int flags, wxProcess* process, pid_t pid; #if defined(__DARWIN__) && !defined(__WXOSX_IPHONE__) pid = -1; - // wxMacLaunch() only executes app bundles and only does it asynchronously. + // wxCocoaLaunch() only executes app bundles and only does it asynchronously. // It returns false if the target is not an app bundle, thus falling // through to the regular code for non app bundles. if ( !(flags & wxEXEC_SYNC) && wxCocoaLaunch(argv, pid) ) { - // we don't have any PID to return so just make up something non null return pid; } #endif // __DARWIN__