« Return to Thread: NSView drawing in tool

Re: NSView drawing in tool

by Andreas Höschler :: Rate this Message:

Reply to Author | View in Thread

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!

Thanks,

   Andreas



_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@...
http://lists.gnu.org/mailman/listinfo/discuss-gnustep

 « Return to Thread: NSView drawing in tool