From 3f948369223e30f86d3abacf8f89f2c5aeb61214 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 12 Mar 2017 15:48:44 +0100 Subject: Fix T50788: blender startup crash on macOS with some types of volumes available. --- source/blender/editors/space_file/fsmenu.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'source/blender/editors/space_file') diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 631ff06a77a..d7aa1040e0f 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -537,28 +537,22 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) /* Finally get user favorite places */ if (read_bookmarks) { UInt32 seed; - OSErr err = noErr; - CFArrayRef pathesArray; - LSSharedFileListRef list; - LSSharedFileListItemRef itemRef; - CFIndex i, pathesCount; - CFURLRef cfURL = NULL; - CFStringRef pathString = NULL; - list = LSSharedFileListCreate(NULL, kLSSharedFileListFavoriteItems, NULL); - pathesArray = LSSharedFileListCopySnapshot(list, &seed); - pathesCount = CFArrayGetCount(pathesArray); + LSSharedFileListRef list = LSSharedFileListCreate(NULL, kLSSharedFileListFavoriteItems, NULL); + CFArrayRef pathesArray = LSSharedFileListCopySnapshot(list, &seed); + CFIndex pathesCount = CFArrayGetCount(pathesArray); - for (i = 0; i < pathesCount; i++) { - itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(pathesArray, i); + for (CFIndex i = 0; i < pathesCount; i++) { + LSSharedFileListItemRef itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(pathesArray, i); - err = LSSharedFileListItemResolve(itemRef, - kLSSharedFileListNoUserInteraction | - kLSSharedFileListDoNotMountVolumes, - &cfURL, NULL); - if (err != noErr) + CFURLRef cfURL = NULL; + OSErr err = LSSharedFileListItemResolve(itemRef, + kLSSharedFileListNoUserInteraction | + kLSSharedFileListDoNotMountVolumes, + &cfURL, NULL); + if (err != noErr || !cfURL) continue; - pathString = CFURLCopyFileSystemPath(cfURL, kCFURLPOSIXPathStyle); + CFStringRef pathString = CFURLCopyFileSystemPath(cfURL, kCFURLPOSIXPathStyle); if (pathString == NULL || !CFStringGetCString(pathString, line, sizeof(line), kCFStringEncodingUTF8)) continue; -- cgit v1.2.3