[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GWorkspace porting troubles
From: |
Enrico Sersale |
Subject: |
Re: GWorkspace porting troubles |
Date: |
Tue, 30 Oct 2001 12:55:56 +0200 (EET) |
On Tue, 30 Oct 2001, Nicola Pero wrote:
>
> > I need a shared istance of the principal class of gworkspace to be
> > accessible through all the app.
> > So, since, when I started all the stuff, I was not thinking at any kind of
> > port :-) , I've used this method, (probably copied from a library class):
> >
> > ...
> >
>
> <untested, just as it comes from the heart>
>
> static volatile GWorkspace *gworkspace = nil;
> static NSLock *lock = nil;
>
> @implementation GWorkspace
>
> + (void) initialize
> {
> lock = [NSLock new];
> }
>
> + (GWorkspace *)gworkspace
> {
> if (gworkspace == nil)
> {
> [lock lock];
> if (gworkspace == nil)
> {
> /* Make sure alloc/init never calls this
> method otherwise you get a deadlock */
> gworkspace = [[GWorkspace alloc] init];
> }
> [lock unlock];
> }
> return (GWorkspace *)gworkspace;
> }
> ...
This doesn't work because the GWorkspace class is subclass of NSWorkspace
and "you may not allocate a workspace directly".
It works if I change
gworkspace = [[GWorkspace alloc] init];
with:
gworkspace = (GWorkspace*)NSAllocateObject(self, 0, NSDefaultMallocZone());
is this acceptable for the porting?
- Re: GWorkspace porting troubles, (continued)
- Re: GWorkspace porting troubles, Aurelien, 2001/10/27
- Re: GWorkspace porting troubles, Richard Frith-Macdonald, 2001/10/27
- Re: GWorkspace porting troubles, Nicola Pero, 2001/10/27
- Re: GWorkspace porting troubles, LHelldorf, 2001/10/29
- Re: GWorkspace porting troubles, LHelldorf, 2001/10/29
- Re: GWorkspace porting troubles, Enrico Sersale, 2001/10/30
Re: GWorkspace porting troubles, LHelldorf, 2001/10/29