gnustep-dev
[Top][All Lists]
Advanced

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

_control_view stuff...


From: Matt Rice
Subject: _control_view stuff...
Date: Tue, 28 Oct 2008 03:43:54 -0700

David Ayers let me know about a segfault affecting DBModeler...

(gdb) bt
#0  0x00000000014bd3cd in objc_msg_lookup (receiver=0x7f50dc245760, op=0xc6f7b0)
    at /usr/src/debug/gcc-4.3.0-20080428/libobjc/sendmsg.c:224
#1  0x00000000007e0430 in -[NSActionCell setStringValue:] (self=0x7f50dbef1290,
    _cmd=0xc90de0, aString=0x625020) at NSActionCell.m:231
#2  0x000000000081f76d in -[NSBrowser drawTitle:inRect:ofColumn:] (
    self=0x7f50dc173a00, _cmd=0xc90dd0, title=0x625020, aRect=
        {origin = {x = 0, y = 219}, size = {width = 190, height =
21}}, column=0)
    at NSBrowser.m:1456
#3  0x000000000081f6de in -[NSBrowser drawTitleOfColumn:inRect:] (
    self=0x7f50dc173a00, _cmd=0xc91060, column=0, aRect=
        {origin = {x = 0, y = 219}, size = {width = 190, height = 21}})
    at NSBrowser.m:1442
#4  0x0000000000822042 in -[NSBrowser drawRect:] (self=0x7f50dc173a00,
    _cmd=0xd5ca30, rect=
        {origin = {x = 0, y = 0}, size = {width = 190, height = 240}})
    at NSBrowser.m:2324
#5  0x000000000095dbcb in -[NSView displayRectIgnoringOpacity:inContext:] (
    self=0x7f50dc173a00, _cmd=0xd5ca10, aRect=
        {origin = {x = 0, y = 0}, size = {width = 190, height = 240}},
    context=0x7f50dc289c80) at NSView.m:2392
#6  0x000000000095de8d in -[NSView displayRectIgnoringOpacity:inContext:] (
    self=0x7f50dc156d70, _cmd=0xd5ca10, aRect=
        {origin = {x = 0, y = 0}, size = {width = 200, height = 300}},
    context=0x7f50dc289c80) at NSView.m:2425
#7  0x000000000095de8d in -[NSView displayRectIgnoringOpacity:inContext:] (
    self=0x7f50dc0d5830, _cmd=0xd5ca10, aRect=
        {origin = {x = 0, y = 0}, size = {width = 206, height = 326}},
    context=0x7f50dc289c80) at NSView.m:2425
#8  0x000000000095d79d in -[NSView displayRectIgnoringOpacity:] (
    self=0x7f50dc0d5830, _cmd=0xd5c9f0, aRect=
        {origin = {x = 0, y = 0}, size = {width = 206, height = 326}})
    at NSView.m:2338
#9  0x000000000095d684 in -[NSView displayRect:] (self=0x7f50dc0d5830,
    _cmd=0xd5c9b0, aRect=
        {origin = {x = 0, y = 0}, size = {width = 206, height = 326}})
    at NSView.m:2325
#10 0x000000000095cfd0 in -[NSView display] (self=0x7f50dc0d5830, _cmd=0xd66860)
    at NSView.m:2223
#11 0x000000000096db5e in -[NSWindow orderWindow:relativeTo:]
(self=0x7f50dc145680,
    _cmd=0xd66810, place=NSWindowAbove, otherWin=-1) at NSWindow.m:1690
#12 0x000000000096d8eb in -[NSWindow orderFrontRegardless]
(self=0x7f50dc145680,
    _cmd=0xc7e7b0) at NSWindow.m:1615
#13 0x00000000007f8ac2 in -[NSApplication beginModalSessionForWindow:] (
    self=0x21602d0, _cmd=0xc7eee0, theWindow=0x7f50dc145680) at
NSApplication.m:1486
#14 0x00000000007f8e5f in -[NSApplication runModalForWindow:] (self=0x21602d0,
    _cmd=0x625c50, theWindow=0x7f50dc145680) at NSApplication.m:1560
#15 0x000000000040626d in -[AdaptorsPanel runAdaptorsPanel]
(self=0x7f50dc17ab40,
    _cmd=0x623de0) at AdaptorsPanel.m:129
#16 0x0000000000404a77 in -[Modeler setAdaptor:] (self=0x7f50dc3261a0,
    _cmd=0x62da50, sender=0x7f50dcb606e0) at Modeler.m:251
#17 0x00000000010b7f7a in __builtin_avcall ()
   from /usr/GNUstep/System/Library/Libraries/libgnustep-base.so.1.15
#18 0x00007f00dcb58f00 in ?? ()
#19 0x00007f50dcb59347 in ?? ()
#20 0x00007f50dc1d3d8c in ?? ()
#21 0x00007f50dcb59348 in ?? ()
#22 0x00007f50dc1d3d90 in ?? ()
#23 0x0000000000000000 in ?? ()

attached are a couple of hacks either of which seem to work around the problem
of note from NSBrowser +initialize:

      /* Create the shared titleCell if it hasn't been created already. */
      if (!titleCell)
        {
          titleCell = [GSBrowserTitleCell new];
        }


so as you can see titleCell is shared by many views, the titleCell is
drawn in one view, then that view is deallocated and the _control_view
still points to it,
when NSBrowser calls -setStringValue: before drawWithFrame:inView: and
ends up segfaulting attempting to call -updateCell: on the old view.

now, i've always been weary of this _control_view ivar and was careful
to never use it outside of code paths called from
drawWithFrame:inView: where it is normally set, and known to be valid,
but there are many places where this isn't the case anymore in
gnustep, and there is no documentation for why I would have that
opinion...

anyhow ignoring that it seems that assuming that the code in
-setStringValue: is correct, we need to do one of a few things

when calling a method which ends up calling -updateCell: we need to
setControlView: or when deallocating a view we need to check if any
cells have us as a _control_view and set it to nil...

note that NSCell.h has this:
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
- (void)setControlView:(NSView*)view;
#endif
so i'm not sure if its alright to add the NSControl part of the patch,
but the NSBrowser part is called on an NSActionCell which has always
had a -setControlView: method

either or both of these titleCell changes fix the segfault, but it
would be good to have an official position/documentation on this
_control_view ivar wrt when it is valid, whose job it is to keep it
valid, or if it should only be used when its known to be safe to use.

e.g. should it be set before you call a NSCell method which uses it,
or should a control unset itself if it is,
or should cells only use it when they know its valid?

i've always thought of cells the other way, views tell them when/where
and what to draw, so the idea of the cell having its setStringValue:
method called, and then telling the view that it should redraw the
cell seems fairly weird to me

anyhow...




reply via email to

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