My quick look generator used to work properly but is now broken.
Is it a bug or am I doing something wrong?
Here’s my code:
OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview,
CFURLRef url, CFStringRef contentTypeUTI,
CFDictionaryRef options) {
NSDictionary * myDoc = [NSDictionary dictionaryWithContentsOfURL:(NSURL *)url];
if (myDoc) {
NSData * pngData = [myDoc valueForKey:@"pngPreview"];
if (pngData) {
QLPreviewRequestSetDataRepresentation(preview,(__bridge CFDataRef)pngData,
kUTTypeImage,NULL);
}
}
}
My doc is a normal plist with a png preview stored as data in it.
I checked that pngPreview does contain png data, I created the image and its size was 350×350.
However, I’m constantly getting these errors:
qlmanage[702] : CGImageCreate: invalid image size: 0 x 0.
qlmanage[702:303] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x9e27, name = 'com.apple.tsm.portname'
See /usr/include/servers/bootstrap_defs.h for the error codes.
qlmanage[702:303] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x3f2b, name = 'com.apple.CFPasteboardClient'
See /usr/include/servers/bootstrap_defs.h for the error codes.
qlmanage[702:303] Failed to allocate communication port for com.apple.CFPasteboardClient; this is likely due to sandbox restrictions
My app is not sandboxed so I don’t think the last 3 errors are important.
I used to use kUTTypePNG but have tried kUTTypeImage to no avail (the docs for QLPreviewRequestSetDataRepresentation says currently supported UTIs are kUTTypeImage, kUTTypePDF, kUTTypeHTML, kUTTypeXML, kUTTypePlainText, kUTTypeRTF, kUTTypeMovie, and kUTTypeAudio).
Other points to consider:
The docs state:
"The binary of a Quick Look generator must be universal and must be 32-bit only." This page
But this page states:
"For OS X v10.6 and later, you must build Quick Look generators for both 32- and 64-bit." Which is rather unclear...
How do I set my target?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…