From 244c2eb2118c5e9840b660b421ba8a1ef4f54301 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 24 Nov 2015 10:02:09 +0100 Subject: [PATCH] Fixed: Open web pages in background under OS X and don't close client --HG-- branch : develop --- code/nel/src/misc/common.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/code/nel/src/misc/common.cpp b/code/nel/src/misc/common.cpp index c16b4b51e..03bd6c3d0 100644 --- a/code/nel/src/misc/common.cpp +++ b/code/nel/src/misc/common.cpp @@ -23,6 +23,8 @@ # include # include # include +#elif defined NL_OS_MAC +# include #elif defined NL_OS_UNIX # include # include @@ -1091,7 +1093,26 @@ static bool openDocWithExtension (const char *document, const char *ext) return true; } #elif defined(NL_OS_MAC) - return launchProgram("open", document); + CFURLRef url = CFURLCreateWithBytes(NULL, (const UInt8 *)document, strlen(document), kCFStringEncodingUTF8, NULL); + + if (url) + { + OSStatus res = LSOpenCFURLRef(url, 0); + CFRelease(url); + + if (res != 0) + { + nlwarning("LSOpenCFURLRef %s returned %d", document, (sint)res); + return false; + } + + return true; + } + else + { + nlwarning("Unable to create URL from %s", document); + return false; + } #else std::string command = "/usr/bin/xdg-open";