Re: NSApplicationLoad() can't connect to window server in user logged out.
Re: NSApplicationLoad() can't connect to window server in user logged out.
- Subject: Re: NSApplicationLoad() can't connect to window server in user logged out.
- From: "Mr. Gecko" <email@hidden>
- Date: Fri, 18 Dec 2009 20:13:34 -0600
Can I do exactly what I'm doing there in that? I also need to place some text in there which I have in the full code, just made my code shorter as an example.
On Dec 18, 2009, at 8:07 PM, Julien Jalon wrote:
> NSImage needs a connection to the Window Server in Leopard.
>
> If you want to do some offscreen headless rendering, use CoreGraphics + ImageIO
>
> On Sat, Dec 19, 2009 at 2:21 AM, Mr. Gecko <email@hidden> wrote:
> Ok, so I've done some more research and found this http://developer.apple.com/mac/library/technotes/tn2005/tn2083.html#SECPRELOGINANDTRUST, it basically says to run it in the loginwindow, but I can't do that with apache which is what I'm running my code with. Because this is a personal application I wouldn't mind doing things the hacking way and some how make the windowserver trust apache.
>
> On Dec 18, 2009, at 6:06 PM, Mr. Gecko wrote:
>
> > Hello I'm running 10.5 and I'm trying to do some image drawing with NSImage in Terminal via SSH and it seems like every time I try, I get this error
> > _RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
> > 2009-12-18 17:54:04.963 weather.mgm[655:10b] *** -[NSRecursiveLock unlock]: lock (<NSRecursiveLock: 0x121b30> '(null)') unlocked when not locked
> > 2009-12-18 17:54:04.973 weather.mgm[655:10b] *** Break on _NSLockError() to debug.
> > 2009-12-18 17:54:04.978 weather.mgm[655:10b] An uncaught exception was raised
> > 2009-12-18 17:54:05.009 weather.mgm[655:10b] Error (1002) creating CGSWindow
> > 2009-12-18 17:54:05.014 weather.mgm[655:10b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error (1002) creating CGSWindow'
> > 2009-12-18 17:54:05.040 weather.mgm[655:10b] Stack: (
> > 2513718512,
> > 2536973548,
> > 2513718272,
> > 2513718328,
> > 2470748316,
> > 2470747564,
> > 2470746864,
> > 2470746400,
> > 2470743808,
> > 2470755712,
> > 2470754620,
> > 2470754184,
> > 2470743272,
> > 8540
> > )
> > I know this code I'm using works as it runs perfectly fine on Snow Leopard via SSH but for some reason it doesn't work on Leopard, what could be wrong here? How can I get this working on Leopard?
> >
> > Basic code to this is
> > int main (int argc, const char * argv[]) {
> > NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
> > NSApplicationLoad();
> >
> > NSImage *image = [[NSImage alloc] initWithContentsOfFile:@"/background.png"];
> > NSSize imageSize = [image size];
> > [image lockFocus];
> > NSImage *type = [[NSImage alloc] initWithContentsOfFile:@"/icons/93x93/1.png"];
> > [type drawInRect:NSMakeRect((imageSize.width-[type size].width)/2, imageSize.height-[type size].height, [type size].width, [type size].height) fromRect:NSMakeRect(0, 0, [type size].width, [type size].height) operation:NSCompositeSourceOver fraction:1.0];
> > [image unlockFocus];
> >
> > NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:[image TIFFRepresentation]];
> > NSData *iconData = [imageRep representationUsingType:NSPNGFileType properties:nil];
> > [iconData writeToFile:@"/drawn.png" automatcially:YES];
> > [image release];
> >
> > [server release];
> > [pool drain];
> > return 0;
> > }
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> 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:
>
> This email sent to email@hidden
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden