mirror of https://github.com/GNOME/gimp.git
Bug 787326 - MacOS's CFSTR() does not work with const variables.
This is untested, written from gathering information on the web. MacOS people, please try and compile GIMP!
This commit is contained in:
parent
1773cd91a2
commit
54b4d1e0a2
|
@ -63,45 +63,52 @@ file_raw_get_executable_path (const gchar *main_executable,
|
||||||
#if defined (GDK_WINDOWING_QUARTZ)
|
#if defined (GDK_WINDOWING_QUARTZ)
|
||||||
if (mac_bundle_id)
|
if (mac_bundle_id)
|
||||||
{
|
{
|
||||||
OSStatus status;
|
CFStringRef bundle_id;
|
||||||
CFURLRef bundle_url = NULL;
|
|
||||||
|
|
||||||
/* For macOS, attempt searching for a darktable app bundle first. */
|
/* For macOS, attempt searching for an app bundle first. */
|
||||||
status = LSFindApplicationForInfo (kLSUnknownCreator,
|
bundle_id = CFStringCreateWithCString (NULL, mac_bundle_id,
|
||||||
CFSTR (mac_bundle_id),
|
kCFStringEncodingUTF8);
|
||||||
NULL, NULL, &bundle_url);
|
if (bundle_id)
|
||||||
|
|
||||||
if (status >= 0)
|
|
||||||
{
|
{
|
||||||
CFBundleRef bundle;
|
OSStatus status;
|
||||||
CFURLRef exec_url, absolute_url;
|
CFURLRef bundle_url = NULL;
|
||||||
CFStringRef path;
|
|
||||||
gchar *ret;
|
|
||||||
CFIndex len;
|
|
||||||
|
|
||||||
bundle = CFBundleCreate (kCFAllocatorDefault, bundle_url);
|
status = LSFindApplicationForInfo (kLSUnknownCreator,
|
||||||
CFRelease (bundle_url);
|
bundle_id, NULL, NULL,
|
||||||
|
&bundle_url);
|
||||||
|
if (status >= 0)
|
||||||
|
{
|
||||||
|
CFBundleRef bundle;
|
||||||
|
CFURLRef exec_url, absolute_url;
|
||||||
|
CFStringRef path;
|
||||||
|
gchar *ret;
|
||||||
|
CFIndex len;
|
||||||
|
|
||||||
exec_url = CFBundleCopyExecutableURL (bundle);
|
bundle = CFBundleCreate (kCFAllocatorDefault, bundle_url);
|
||||||
absolute_url = CFURLCopyAbsoluteURL (exec_url);
|
CFRelease (bundle_url);
|
||||||
path = CFURLCopyFileSystemPath (absolute_url, kCFURLPOSIXPathStyle);
|
|
||||||
|
|
||||||
/* This gets us the length in UTF16 characters, we multiply by 2
|
exec_url = CFBundleCopyExecutableURL (bundle);
|
||||||
* to make sure we have a buffer big enough to fit the UTF8 string.
|
absolute_url = CFURLCopyAbsoluteURL (exec_url);
|
||||||
*/
|
path = CFURLCopyFileSystemPath (absolute_url, kCFURLPOSIXPathStyle);
|
||||||
len = CFStringGetLength (path);
|
|
||||||
ret = g_malloc0 (len * 2 * sizeof (gchar));
|
|
||||||
if (!CFStringGetCString (path, ret, 2 * len * sizeof (gchar),
|
|
||||||
kCFStringEncodingUTF8))
|
|
||||||
ret = NULL;
|
|
||||||
|
|
||||||
CFRelease (path);
|
/* This gets us the length in UTF16 characters, we multiply by 2
|
||||||
CFRelease (absolute_url);
|
* to make sure we have a buffer big enough to fit the UTF8 string.
|
||||||
CFRelease (exec_url);
|
*/
|
||||||
CFRelease (bundle);
|
len = CFStringGetLength (path);
|
||||||
|
ret = g_malloc0 (len * 2 * sizeof (gchar));
|
||||||
|
if (!CFStringGetCString (path, ret, 2 * len * sizeof (gchar),
|
||||||
|
kCFStringEncodingUTF8))
|
||||||
|
ret = NULL;
|
||||||
|
|
||||||
if (ret)
|
CFRelease (path);
|
||||||
return ret;
|
CFRelease (absolute_url);
|
||||||
|
CFRelease (exec_url);
|
||||||
|
CFRelease (bundle);
|
||||||
|
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
CFRelease (bundle_id);
|
||||||
}
|
}
|
||||||
/* else, app bundle was not found, try path search as last resort. */
|
/* else, app bundle was not found, try path search as last resort. */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue