* Source/NSTextView.m (-initWithCoder:, -setTextContainer:):

Attempt to resolve the memory issues when coding a text container.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@28405 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2009-07-24 07:35:38 +00:00
parent d221178290
commit 2ed61072dd
2 changed files with 28 additions and 9 deletions

View file

@ -1,3 +1,8 @@
2009-07-24 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSTextView.m (-initWithCoder:, -setTextContainer:):
Attempt to resolve the memory issues when coding a text container.
2009-07-21 15:06-EDT Gregory John Casamento <greg.casamento@gmail.com>
* Headers/AppKit/NSFontDescriptor.h: Correct mispelling pointed

View file

@ -844,28 +844,35 @@ that makes decoding and encoding compatible with the old code.
_tf.is_vertically_resizable = YES;
}
// currently not used....
if ([aDecoder containsValueForKey: @"NSTextStorage"])
{
_textStorage = RETAIN([aDecoder decodeObjectForKey: @"NSTextStorage"]);
// FIXME: No idea why somebody added this, later this get overridden
// when the text container gets loaded or generated.
// This code results in a memory leak.
//_textStorage = RETAIN([aDecoder decodeObjectForKey: @"NSTextStorage"]);
}
// currently not used....
if ([aDecoder containsValueForKey: @"NSTextContainer"])
{
/*
// Decode the text container, but don't retain it, as it will be owned by the
// decoded layout manager.
[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];
[aTextContainer setTextView: self];
// See initWithFrame: for comments on this RELEASE
RELEASE(self);
[aTextContainer setContainerSize: size];
[aTextContainer setWidthTracksTextView: YES];
[aTextContainer setHeightTracksTextView: NO];
*/
_textContainer = RETAIN([aDecoder decodeObjectForKey: @"NSTextContainer"]);
}
}
if ([aDecoder containsValueForKey: @"NSTVFlags"])
{
@ -1028,7 +1035,14 @@ to this method from the text container or layout manager.
/* Any of these three might be nil. */
_textContainer = container;
_layoutManager = (NSLayoutManager *)[container layoutManager];
_textStorage = [_layoutManager textStorage];
if (_tf.owns_text_network)
{
ASSIGN(_textStorage, [_layoutManager textStorage]);
}
else
{
_textStorage = [_layoutManager textStorage];
}
/* Search for an existing text view attached to this layout manager. */
tcs = [_layoutManager textContainers];