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: Fred Kiefer
Subject: Re: Graphos: works on Cocoa not on GNUstep
Date: Sun, 23 Sep 2012 19:08:48 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120825 Thunderbird/15.0

On 12.09.2012 22:09, Wolfgang Lux wrote:
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 is correct here. In GNUstep we don't retain the owner of the
tracking record, but do so for the cursor, when addCursorRect:... is
used. Maybe you should just switch to that method? See:

http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/EventOverview/MouseTrackingEvents/MouseTrackingEvents.html



reply via email to

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