bug-gnustep
[Top][All Lists]
Advanced

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

Re: NSTextView -initWithCoder, recent changes not working


From: Fred Kiefer
Subject: Re: NSTextView -initWithCoder, recent changes not working
Date: Mon, 29 Jun 2009 16:00:42 +0200
User-agent: Thunderbird 2.0.0.19 (X11/20081227)

I don't think that scattering a fee RETAINs in the code will resolve the
underlying problem.
The process of building up the text network is rather complicated and
the new code in initWithCoder: definitely breaks the previous code
structure. There are a few places in that class, where comments try to
explain the overall assumptions of the text network. One of these is in
setTextContainer: where it says that this has to be the only place where
the text container gets changed. The new code doesn't play along with
that.Either you know for sure what you are doing, then please document
it and adjust all affected places. Or you don't, then just play along
with the rest. perhaps it would be enough if the code in NSTextView
initWithCoder: just decoded the NSTextContainer and left the setting of
the ivar to the initWithCoder: method on NSTextContainer.
Setting the NSTextStorage would also not be needed that way, as this
would come in via the NSLayoutManager.

I would suggest something like:

      if ([aDecoder containsValueForKey: @"NSTextContainer"])
        {
          RETAIN([aDecoder decodeObjectForKey: @"NSTextContainer"]);
          // See initWithFrame: for comments on this RELEASE
          RELEASE(self);
        }
      else
        {
          NSSize size = NSMakeSize(0,_maxSize.height);
          NSTextContainer *aTextContainer = [self buildUpTextNetwork:
NSZeroSize];
          [aTextContainer setTextView: (NSTextView *)self];
          // See initWithFrame: for comments on this RELEASE
          RELEASE(self);

          [aTextContainer setContainerSize: size];
          [aTextContainer setWidthTracksTextView: YES];
          [aTextContainer setHeightTracksTextView: NO];
        }


What I am not sure about are the RETAIN and RELEASE calls in the case
where we have an NSTextContainer, but they seem to be in line with the
rest of the code.

Cheers
Fred

Gregory John Casamento wrote:
> I am currently working on this.   The issue is that it is possible, in a
> nib, to encode content in the textview.   Currently GNUstep doesn't
> handle this.
> 
> I'll add the retain you suggested and I should have this fixed soon.
> 
> GC
> Gregory Casamento -- Principal Consultant - OLC, Inc
> # GNUstep Chief Maintainer
> 
> 
> ------------------------------------------------------------------------
> *From:* Georg Fleischmann <G.Fleischmann@vhf.de>
> *To:* greg.casamento@gmail.com; bug-gnustep@gnu.org
> *Sent:* Sunday, June 28, 2009 3:12:17 AM
> *Subject:* NSTextView -initWithCoder, recent changes not working
> 
> Hello Gregory,
> 
> your recent changes in NSTextView to load the NSTextContainer from a Nib
> are not working properly.
> 
> The _textStorage needs a retain or will show a deadface soon.
> With a retain, my Panel containing the TextView appears on screen.
> 
> But when clicking with the mouse into the empty TextView I still get a
> crash with the following stack:
> 
> #0  0xb788325a in -[GSArray count] (self=0x0, _cmd=0xb7fa61e0) at
> GSArray.m:233
> #1  0xb7e697ed in _attributesAtIndexEffectiveRange (index=0, aRange=0x0,
>     tmpLength=0, _infoArray=0x0, foundIndex=0xbf8f1c28) at
> GSTextStorage.m:333
> #2  0xb7e697b2 in -[GSTextStorage attributesAtIndex:effectiveRange:] (
>     self=0x97473d0, _cmd=0xb7b77d18, index=0, aRange=0x0)
>     at GSTextStorage.m:540
> #3  0xb78dbddf in -[NSAttributedString attribute:atIndex:effectiveRange:] (
>     self=0x97473d0, _cmd=0xb7fbb0d8, attributeName=0xb7fa9a30, index=0,
>     aRange=0x0) at NSAttributedString.m:403
> #4  0xb7ea0671 in -[NSTextView(leftovers) mouseDown:] (self=0x9746c08,
>     _cmd=0xb7f9bef0, theEvent=0x97d5948) at NSTextView.m:4821
> #5  0xb7e490d8 in -[NSWindow sendEvent:] (self=0x9c563c0, _cmd=0xb7effba0,
>     theEvent=0x97d5948) at NSWindow.m:3588
> #6  0xb7cb0933 in -[NSApplication sendEvent:] (self=0x84a5eb0,
> _cmd=0x825c898,
>     theEvent=0x97d5948) at NSApplication.m:1963
> ...
> 
> All of this worked before the change.
> 
> Best wishes,
> Georg Fleischmann
> 
> 
> 2009-05-23 11:48-EDT Gregory John Casamento <greg.casamento@gmail.com
> <mailto:greg.casamento@gmail.com>>
> 
>         * Source/GSStandardWindowDecorationView.m: Live window resize
> changes
>         for when using GNUstep decorations in
> resizeWindowStartingWithEvent:.
>         * Source/NSLayoutManager.m: Unarchive the text containers into an
>         array in initWithCoder:.
>         * Source/NSTextContainer.m: Get the layout manager in
> initWithCoder:.
>         * Source/NSTextView.m: Changes to include text container from nib
>         file into the nib loading process in initWithCoder:.





reply via email to

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