Hello,

I'm using Matt Gemmell's NSImage category to create an NSImage from a QuickLook 
thumbnail, which uses QLThumbnailImageCreate() to generate the thumbnail image.

My app also makes use of the new 10.6 QuickLook functionality to bring up a 
QuickLook panel for certain file previews.

However, there seems to be a strange (though apparently minor) conflict here. 
QLThumbnailImageCreate() works absolutely fine _until_ a QuickLook panel is 
created. After that, even if the QuickLook panel is ordered out, calling 
QLThumbnailImageCreate() (on the main thread) generates the following error 
message on the console:

[QL] Asking to compute a thumbnail in main thread is potentially blocking the 
user interface

I've created a small demo app, showing the problem, here:

http://www.literatureandlatte.com/misc/QLWarningTest.zip

But you could equally see the problem by placing the following code somewhere, 
such as as in -awakeFromNib:

NSURL *fileURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] 
pathForResource:@"SomeFile" ofType:@"type"]];
NSDictionary *dict = [NSDictionary dictionaryWithObject:[NSNumber 
numberWithBool:YES] forKey:(NSString *)kQLThumbnailOptionIconModeKey];
        
// Call thumbnail image create once - there will be no warning.
NSLog (@"1");
CGImageRef ref = QLThumbnailImageCreate(kCFAllocatorDefault, (CFURLRef)fileURL, 
CGSizeMake(48, 48), (CFDictionaryRef)dict);
        
// Call it again - and again no warning.
NSLog (@"2");
ref = QLThumbnailImageCreate(kCFAllocatorDefault, (CFURLRef)fileURL, 
CGSizeMake(48, 48), (CFDictionaryRef)dict);
        
// Order the QL panel front.
[[QLPreviewPanel sharedPreviewPanel] makeKeyAndOrderFront:nil];

// Now when we try to create a thumbnail, there will be a warning.
NSLog (@"3");
ref = QLThumbnailImageCreate(kCFAllocatorDefault, (CFURLRef)fileURL, 
CGSizeMake(48, 48), (CFDictionaryRef)dict);

The console output will be:
1
2
3
[QL] Asking to compute a thumbnail in main thread is potentially blocking the 
user interface

So, my question is, does anyone know why this warning gets generated by 
QLThumbnailImageCreate after a QuickLook panel has been created in an 
application? The docs say that QLThumbnailImageCreate should "generally" be 
called from a background thread, but do not say that it must be. Is this 
function not supposed to be placed in the main thread after all? I'm not sure 
how I would really improve on Matt Gemmell's NSImage category (included in the 
demo app above, and which I seem to remember reading on his site has already 
had someone at Apple tweak it), as I'm not really sure why the thumbnail 
creation for an image about to be placed in the main interface should have to 
go in a different thread.

Many thanks in advance and all the best,
Keith


      
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to