fixing file params in wxCocoaLaunch
unfortunately the API does not work as advertised, so use a newer one if possible, fallback to individually sending an open
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
#include "wx/apptrait.h"
|
#include "wx/apptrait.h"
|
||||||
|
|
||||||
#include "wx/osx/private.h"
|
#include "wx/osx/private.h"
|
||||||
|
#include "wx/osx/private/available.h"
|
||||||
|
|
||||||
#if (defined(__WXOSX_COCOA__) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10) \
|
#if (defined(__WXOSX_COCOA__) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10) \
|
||||||
|| (defined(__WXOSX_IPHONE__) && defined(__IPHONE_8_0))
|
|| (defined(__WXOSX_IPHONE__) && defined(__IPHONE_8_0))
|
||||||
@@ -234,10 +235,13 @@ bool wxCocoaLaunch(const char* const* argv, pid_t &pid)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSMutableArray *params = [[NSMutableArray alloc] init];
|
||||||
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10
|
||||||
|
if ( WX_IS_MACOS_AVAILABLE(10, 10) )
|
||||||
|
{
|
||||||
// Loop through command line arguments to the bundle,
|
// Loop through command line arguments to the bundle,
|
||||||
// turn them into CFURLs and then put them in cfaFiles
|
// turn them into CFURLs and then put them in cfaFiles
|
||||||
// For use to launch services call
|
// For use to launch services call
|
||||||
NSMutableArray *params = [[NSMutableArray alloc] init];
|
|
||||||
for( ; *argv != NULL; ++argv )
|
for( ; *argv != NULL; ++argv )
|
||||||
{
|
{
|
||||||
NSURL *cfurlCurrentFile;
|
NSURL *cfurlCurrentFile;
|
||||||
@@ -275,10 +279,42 @@ bool wxCocoaLaunch(const char* const* argv, pid_t &pid)
|
|||||||
// release it as the CFArray adds a ref count to it
|
// release it as the CFArray adds a ref count to it
|
||||||
[params addObject:cfurlCurrentFile];
|
[params addObject:cfurlCurrentFile];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
|
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
|
||||||
NSRunningApplication *app = [ws launchApplicationAtURL:url options:NSWorkspaceLaunchAsync
|
|
||||||
configuration:[NSDictionary dictionaryWithObject:params forKey:NSWorkspaceLaunchConfigurationArguments]
|
|
||||||
|
NSRunningApplication *app = nil;
|
||||||
|
|
||||||
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10
|
||||||
|
if ( WX_IS_MACOS_AVAILABLE(10, 10) && [params count] > 0 )
|
||||||
|
{
|
||||||
|
app = [ws openURLs:params withApplicationAtURL:url
|
||||||
|
options:NSWorkspaceLaunchAsync
|
||||||
|
configuration:[NSDictionary dictionary]
|
||||||
error:&error];
|
error:&error];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
app = [ws launchApplicationAtURL:url
|
||||||
|
options:NSWorkspaceLaunchAsync
|
||||||
|
configuration:[NSDictionary dictionary]
|
||||||
|
error:&error];
|
||||||
|
|
||||||
|
// this was already processed argv is NULL and nothing bad will happen
|
||||||
|
for( ; *argv != NULL; ++argv )
|
||||||
|
{
|
||||||
|
wxString currfile(*argv);
|
||||||
|
if( [ws openFile:wxCFStringRef(currfile).AsNSString()
|
||||||
|
withApplication:wxCFStringRef(path).AsNSString()] == NO )
|
||||||
|
{
|
||||||
|
wxLogDebug(wxT("wxCocoaLaunch Could not open argument:%s"), *argv);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[params release];
|
[params release];
|
||||||
|
|
||||||
if( app != nil )
|
if( app != nil )
|
||||||
|
Reference in New Issue
Block a user