Fixed bugs in replaceLayoutManager:

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@14672 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Nicola Pero 2002-10-08 17:57:33 +00:00
parent 2cab5b1dd2
commit 82656d0255

View file

@ -122,27 +122,32 @@
return _layoutManager;
}
- (void) replaceLayoutManager: (NSLayoutManager*)newLayoutManager
- (void) replaceLayoutManager: (NSLayoutManager *)newLayoutManager
{
if (newLayoutManager != _layoutManager)
{
id textStorage = [_layoutManager textStorage];
NSArray *textContainers = [_layoutManager textContainers];
unsigned i, count = [textContainers count];
id oldLayoutManager = _layoutManager;
RETAIN (oldLayoutManager);
[textStorage removeLayoutManager: _layoutManager];
[textStorage addLayoutManager: newLayoutManager];
[_layoutManager setTextStorage: nil];
for (i = 0; i < count; i++)
{
NSTextContainer *container;
NSTextContainer *container;
container = RETAIN ([textContainers objectAtIndex: i]);
[_layoutManager removeTextContainerAtIndex: i];
[newLayoutManager addTextContainer: container];
/* The textview is caching the layout manager; refresh the
* cache with this do-nothing call. */
[[container textView] setTextContainer: container];
RELEASE (container);
}
RELEASE (oldLayoutManager);
}
}