I have this program that works just fine here, but it crashes at the customer. He was nice enough to save a crash report.
From I gather reading it, it seems to happen in a thread where I gather all the font names within a given folder, and use a declare to get the font name.
What does the + numbers on the right in Thread 6 mean ? For instance
0x0029b7ca Module1.getPostScriptName%s%s + 798
Is it the number of times the method was called ?
Here is the code :
[code]Function getPostScriptName(URL as String) As String
dim f as folderitem = GetFolderItem(URL, FolderItem.PathTypeShell)
if f <> nil then
// - We have a True Type Font file, first step to make a CFURL.
// CFURLRef CFURLCreateFromFSRef (
// CFAllocatorRef allocator,
// const struct FSRef *fsRef
// );
declare function CFURLCreateFromFSRef lib "Cocoa" ( allocator as Ptr, fsRef as Ptr ) as Ptr
Dim CFURLRef as Ptr = CFUrlCreateFromFSRef( nil, f.MacFSRef )
if CFUrlRef = nil then
'Msgbox "Failed to get the CFURLRef of folder """+ f.nativePath + """"
return f.name
else
'SWIFT
'func CTFontManagerCreateFontDescriptorsFromURL(_ fileURL: CFURL!) -> CFArray!
declare function CTFontManagerCreateFontDescriptorsFromURL lib "Cocoa" ( fontURL as Ptr) as CFTypeRef
Dim aCFArray As CFTyperef = CTFontManagerCreateFontDescriptorsFromURL( CFURLRef )
'func CTFontDescriptorCopyAttribute(_ descriptor: CTFontDescriptor!,
'_ attribute: CFString!) -> AnyObject!
declare function CTFontDescriptorCopyAttribute lib "Cocoa" (CTFontDescriptor as Ptr, Attribut as CFStringRef) as CFStringRef
Dim attribute as CFStringRef = "NSFontVisibleNameAttribute"
declare function CFArrayGetCount lib "CoreFoundation.framework" (theArray as CFTypeRef) as Integer
declare function CFArrayGetValueAtIndex lib "CoreFoundation.framework" (theArray as CFTypeRef, idx as Integer) as Ptr
Dim ub As Int32 = CFArrayGetCount( aCFArray ) - 1
For i As Int32 = 0 To ub
Dim aCTFontDescriptorRef As Ptr = CFArrayGetValueAtIndex( aCFArray, i )
// then use CTFontDescriptorCopyAttribute() to get the name
'System.DebugLog CTFontDescriptorCopyAttribute(aCTFontDescriptorRef, attribute)
Return CTFontDescriptorCopyAttribute(aCTFontDescriptorRef, attribute)
Next
// - As we had a valid CFURLRef from a 'Create' or 'Copy' API, we must release it.
declare sub CFRelease lib "Cocoa" ( ref as ptr )
CFRelease CFUrlRef
end if
end if
End Function
[/code]
<https://xojo.com/issue/42530>
I am not that comfortable with Mac OS X declares. I wonder if I did it right. Maybe it leaks or something.
Will appreciate any insight.