discuss-gnustep
[Top][All Lists]
Advanced

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

Re: NSView drawing in tool


From: Andreas Höschler
Subject: Re: NSView drawing in tool
Date: Tue, 23 Jun 2009 11:15:13 +0200

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





reply via email to

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