[gimp] Bug 787326 - MacOS's CFSTR() does not work with const variables.
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 787326 - MacOS's CFSTR() does not work with const variables.
- Date: Sat, 9 Sep 2017 12:40:44 +0000 (UTC)
commit 54b4d1e0a22d2bfac9afcab0c1b791702b5171ed
Author: Jehan <jehan girinstud io>
Date: Sat Sep 9 14:37:32 2017 +0200
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!
plug-ins/file-raw/file-raw-utils.c | 81 +++++++++++++++++++----------------
1 files changed, 44 insertions(+), 37 deletions(-)
---
diff --git a/plug-ins/file-raw/file-raw-utils.c b/plug-ins/file-raw/file-raw-utils.c
index 23ab620..906f173 100644
--- a/plug-ins/file-raw/file-raw-utils.c
+++ b/plug-ins/file-raw/file-raw-utils.c
@@ -63,45 +63,52 @@ file_raw_get_executable_path (const gchar *main_executable,
#if defined (GDK_WINDOWING_QUARTZ)
if (mac_bundle_id)
{
- OSStatus status;
- CFURLRef bundle_url = NULL;
+ CFStringRef bundle_id;
- /* For macOS, attempt searching for a darktable app bundle first. */
- status = LSFindApplicationForInfo (kLSUnknownCreator,
- CFSTR (mac_bundle_id),
- NULL, NULL, &bundle_url);
-
- if (status >= 0)
+ /* For macOS, attempt searching for an app bundle first. */
+ bundle_id = CFStringCreateWithCString (NULL, mac_bundle_id,
+ kCFStringEncodingUTF8);
+ if (bundle_id)
{
- CFBundleRef bundle;
- CFURLRef exec_url, absolute_url;
- CFStringRef path;
- gchar *ret;
- CFIndex len;
-
- bundle = CFBundleCreate (kCFAllocatorDefault, bundle_url);
- CFRelease (bundle_url);
-
- exec_url = CFBundleCopyExecutableURL (bundle);
- absolute_url = CFURLCopyAbsoluteURL (exec_url);
- path = CFURLCopyFileSystemPath (absolute_url, kCFURLPOSIXPathStyle);
-
- /* This gets us the length in UTF16 characters, we multiply by 2
- * to make sure we have a buffer big enough to fit the UTF8 string.
- */
- len = CFStringGetLength (path);
- ret = g_malloc0 (len * 2 * sizeof (gchar));
- if (!CFStringGetCString (path, ret, 2 * len * sizeof (gchar),
- kCFStringEncodingUTF8))
- ret = NULL;
-
- CFRelease (path);
- CFRelease (absolute_url);
- CFRelease (exec_url);
- CFRelease (bundle);
-
- if (ret)
- return ret;
+ OSStatus status;
+ CFURLRef bundle_url = NULL;
+
+ status = LSFindApplicationForInfo (kLSUnknownCreator,
+ bundle_id, NULL, NULL,
+ &bundle_url);
+ if (status >= 0)
+ {
+ CFBundleRef bundle;
+ CFURLRef exec_url, absolute_url;
+ CFStringRef path;
+ gchar *ret;
+ CFIndex len;
+
+ bundle = CFBundleCreate (kCFAllocatorDefault, bundle_url);
+ CFRelease (bundle_url);
+
+ exec_url = CFBundleCopyExecutableURL (bundle);
+ absolute_url = CFURLCopyAbsoluteURL (exec_url);
+ path = CFURLCopyFileSystemPath (absolute_url, kCFURLPOSIXPathStyle);
+
+ /* This gets us the length in UTF16 characters, we multiply by 2
+ * to make sure we have a buffer big enough to fit the UTF8 string.
+ */
+ len = CFStringGetLength (path);
+ ret = g_malloc0 (len * 2 * sizeof (gchar));
+ if (!CFStringGetCString (path, ret, 2 * len * sizeof (gchar),
+ kCFStringEncodingUTF8))
+ ret = NULL;
+
+ CFRelease (path);
+ 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. */
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]