Looks like your plug-in is being running as a tool without a connection to
the window server.
 
On 01/29/2009 3:54 PM, "Bridger Maxwell" <[email protected]> wrote:

> It turns out the error is completely different from what I thought it was
> (isn't it always?). It turns out Xcode was omitting part of the output from
> IBTool. When I tried to compile my xib from Terminal, I got this error:
> 
> Description: ibtool encountered an error while loading the ibplugin from
> /Users/bridger/Development/Mercury/MercuryStation/build/Debug/SCMercury.framew
> ork/Versions/A/Resources/SCThemes.ibplugin.
> Error: Error Domain=com.apple.InterfaceBuilder Code=-1 UserInfo=0x6e9e90
> "Interface Builder could not load the 'Themes' plug-in because an exception
> was raised.
> 
>  Exception name: NSInternalInconsistencyException
>  Reason: Error (1002) creating CGSWindow"
> 
> I Googled around a bit, and I know it has something to do with drawing. In
> fact, I have narrowed it down to these lines of code:
> 
>     NSImage * canvas = [[NSImage alloc] initWithSize: canvas_size];
> 
>     [canvas lockFocus];
> 
> ...
> 
>     [canvas unlockFocus];
> 
> 
> This is a vital part of my plugin though. I use this in an NSImage category
> which crops an NSImage. Why does lockFocus cause IB compilation errors, and
> can how can I fix it?
> 
> 
> Also, here is the NSImage category in its entirety. I actually took it from
> someone else on this list a while back.
> 
> 
> - (NSImage *) imageFromRect: (NSRect) rect
> 
> {
> 
>     NSAffineTransform * xform = [NSAffineTransform transform];
> 
>      // translate reference frame to map rectangle 'rect' into first
> quadrant
> 
>     [xform translateXBy: -rect.origin.x
> 
>                     yBy: -rect.origin.y];
> 
> 
> 
>     NSSize canvas_size = [xform transformSize: rect.size];
> 
>      NSImage * canvas = [[NSImage alloc] initWithSize: canvas_size];
> 
>     [canvas lockFocus];
> 
>      [xform concat];
> 
> 
> 
>     // Get NSImageRep of image
> 
>     NSImageRep * rep = [self bestRepresentationForDevice: nil];
> 
> 
>     [rep drawAtPoint: NSZeroPoint];
> 
> 
> 
>     [canvas unlockFocus];
> 
>     return [canvas autorelease];
> 
> return nil;
> 
> }
> 
> 
> Thank You,
> 
> Bridger Maxwell


_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to