gnustep-dev
[Top][All Lists]
Advanced

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

Re: Graphos: works on Cocoa not on GNUstep


From: Wolfgang Lux
Subject: Re: Graphos: works on Cocoa not on GNUstep
Date: Wed, 12 Sep 2012 22:09:58 +0200

Hi Riccardo,

>> This code works on OS X either because Cocoa is returning a preallocated 
>> color (you might try whether copying a text object with some non-standard 
>> color works) or because Cocoa uses a cache of color objects.
> On my version, I did not get a crash for both "standard" as randomly choosen 
> colors of the color wheel. For you it crashed though. I just ocmmited the 
> fix, does it work for you on Mac now?

the fix works, but I now get a different crash whenever the mouse moves over 
the document window.

Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
0   libobjc-gnu.3.dylib                 0x0000000100d0cbad objc_msg_lookup + 45
1   libgnustep-gui.0.23.dylib           0x00000001002625c5 -[NSWindow 
_checkTrackingRectangles:forEvent:] + 647 (NSWindow.m:3714)
2   libgnustep-gui.0.23.dylib           0x0000000100262aa2 -[NSWindow 
_checkTrackingRectangles:forEvent:] + 1892 (NSWindow.m:3784)
3   libgnustep-gui.0.23.dylib           0x0000000100262aa2 -[NSWindow 
_checkTrackingRectangles:forEvent:] + 1892 (NSWindow.m:3784)
4   libgnustep-gui.0.23.dylib           0x0000000100262aa2 -[NSWindow 
_checkTrackingRectangles:forEvent:] + 1892 (NSWindow.m:3784)
5   libgnustep-gui.0.23.dylib           0x0000000100262aa2 -[NSWindow 
_checkTrackingRectangles:forEvent:] + 1892 (NSWindow.m:3784)
6   libgnustep-gui.0.23.dylib           0x0000000100264214 -[NSWindow 
sendEvent:] + 4023 (NSWindow.m:4136)
7   libgnustep-gui.0.23.dylib           0x0000000100089d1d -[NSApplication 
sendEvent:] + 755 (NSApplication.m:2239)
8   libgnustep-gui.0.23.dylib           0x0000000100088775 -[NSApplication run] 
+ 632 (NSApplication.m:1617)
9   libgnustep-gui.0.23.dylib           0x0000000100066743 NSApplicationMain + 
638 (Functions.m:93)
10  Graphos                             0x000000010002aaba main + 32 (main.m:14)
11  Graphos                             0x00000001000010a4 start + 52

After a bit of debugging, I tracked this down to the initializer of GRDocView, 
which contains this code:
  NSImage *img;
  NSCursor *cur;

  img = [NSImage imageNamed: @"blackarrow.tiff"];
  cur = [[NSCursor alloc] initWithImage: img hotSpot: NSMakePoint(0, 0)];
  [cur setOnMouseEntered: YES];
  [cur setOnMouseExited: YES];
  [self addTrackingRect: [self frame]
        owner: cur userData: NULL
        assumeInside: YES];
  [cur release];
Here you create a fresh cursor, then add a tracking rectangle to the view with 
the cursor as the owner of the tracing rectangle, and finally release the 
cursor. This leaves a dangling pointer to the cursor behind, which crashes the 
application when the tracking areas of the window containing the new GRDocView 
are examined. I am not sure whether this is supposed to work under Cocoa (the 
documentation remains silent on whether the owner of a tracking rectangle is 
retained), but in any case it would be more safe to retain the cursor in an 
attribute of the GRDoc view and release it when the view is deallocated.

Wolfgang




reply via email to

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