Re: [NSWindow _initBackendWindow] segmentation fault ...

Fred Kiefer <[email protected]>
Newsgroups gmane.comp.lib.gnustep.user
Message-ID <[email protected]>
Christophe JALADY wrote:
> I've a segmentation fault on:
> [NSWindow _initBackendWindow] at NSWindow.m:791
> 
> The line in the file is this one:
> ...
> // Set window in new _gstate
> DPSgsave(context);
> ...
> 
> With ddd, I found that "context" is nil (0x0) but it initialised with
> that : "NSGraphicsContext *context = GSCurrentContext();".
> 
> So what are reason's that GSCurrentContext can return nil ?
> 
> To know, my last application call is a [NSImage lockFocus] with an
> NSimage wich is init with "initWithSize" and wich respond "false" to
> isValid (is it normal?). With the call to "lockFocus" I've the
> segmentation fault describe above.
> 
> Thank's in advance for your help.
> 
> Christophe.
> 
> ps:
> I use the "current release" of GNUStep.
> I try both with art and xlib backend but I've the same bug.
> My application is a port of a MAC/COCOA to gnustep. 
> It have 2 threads.
> 

Without seeing your code it is hard to tell the reason for the problem. 
One possibility is that you did not initialize the backend, that is you 
did not call [NSApplication sharedApplication] one way or the other.
Another possibility is that you are making this call from the second 
thread, the one not used to initialize the backend. GSCurrentContext() 
gets the context from the current thread, so it will fail when used with 
a secondardy thread. You may work around this problem by using
[NSObject performSelectorOnMainThread:withObject:waitUntilDone:].

Fred
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.