discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSView drawing in tool


From: Fred Kiefer
Subject: Re: NSView drawing in tool
Date: Wed, 24 Jun 2009 10:18:56 +0200
User-agent: Thunderbird 2.0.0.19 (X11/20081227)

Andreas Höschler wrote:
> Hi all,
> 
>> I just realized that the tool works as expected on GNUstep when being
>> logged in on the console of the machine supposed to run the service.
>> However, in production this service is supposed to be started by cron
>> with noone being logged in!? Any idea how to get around the
>>
>> Abort (core dumped)Tools/OSMMapServer: Uncaught exception
>> WindowServerCommunication, reason: Unable to connect to X Server `'
>>
>> problem then?
> 
> I forgot to mention that one needs to generate a window around the view
> to get this to work. My tool code basically looks as follows now:
> 
>       NSWindow *window = [[NSWindow alloc]
> initWithContentRect:NSMakeRect(0,0, _imageSize.width, _imageSize.height)
> styleMask:0 backing:NSBackingStoreNonretained defer:NO];
>       MapView *mapView = [[MapView alloc] initWithFrame:NSMakeRect(0,0,
> _imageSize.width, _imageSize.height)];
>       [window setContentView:mapView];
>       ...
>       // fetch data from the database and do some magic with
> NSBezierPath in drawRect:
>       ...
>       [mapView display];
>       [mapView lockFocus];
>       NSBitmapImageRep *rep = [[NSBitmapImageRep alloc]
> initWithFocusedViewRect:[mapView bounds]];
>       NSData *data = [[[rep TIFFRepresentation] retain] autorelease];
>       [mapView unlockFocus];
>       [rep release];
>       [mapView release];
>       [window release];
>       return data;
> 
> As reported in my last email this code works great on GNUstep as long as
> I am looged in and have started the tool via Terminal.app. However,
> starting the tool from a ssh session or via cron gives me
> 
> Abort (core dumped)Tools/OSMMapServer: Uncaught exception
> WindowServerCommunication, reason: Unable to connect to X Server `'
> 
> ! :-(
> 
> Hints still greatly appreciated!

Is there at all an X server running while the service is executing? In
that case "xhost +" might help. If there isn't any X server then you
will need a different GNUstep backend that is capable of initializing
itself and do the drawing without the help of X. We currently have
nothing in that direction, but theoretically it is possible to write
this sort of backend.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]