From c96850c89ab6e63fcf11d2e979988b3745a35a68 Mon Sep 17 00:00:00 2001 From: FredKiefer Date: Sun, 5 Nov 2000 16:30:06 +0000 Subject: [PATCH] In [setWidthTracksTextView:] and [setHeightTracksTextView:] make sure that the view post changes and that notifications are only send once. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@8038 72102866-910b-0410-8b05-ffd578937521 --- Source/NSTextContainer.m | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Source/NSTextContainer.m b/Source/NSTextContainer.m index 4938181b2..adc27b5ed 100644 --- a/Source/NSTextContainer.m +++ b/Source/NSTextContainer.m @@ -137,6 +137,8 @@ if (_textView) { [_textView setTextContainer: nil]; + // May we realy switch this off, as somebody else might be listening + // to those notifications? [_textView setPostsFrameChangedNotifications: NO]; [nc removeObserver: self name: NSViewFrameDidChangeNotification object: _textView]; @@ -182,15 +184,22 @@ - (void) setWidthTracksTextView: (BOOL)flag { NSNotificationCenter *nc; - nc = [NSNotificationCenter defaultCenter]; + BOOL old_observing = _observingFrameChanges; _widthTracksTextView = flag; _observingFrameChanges = _widthTracksTextView | _heightTracksTextView; + if (_textView == nil) return; + if (_observingFrameChanges == old_observing) + return; + + nc = [NSNotificationCenter defaultCenter]; + if (_observingFrameChanges) { + [_textView setPostsFrameChangedNotifications: YES]; [nc addObserver: self selector: @selector(_textViewFrameChanged:) name: NSViewFrameDidChangeNotification @@ -211,15 +220,21 @@ - (void) setHeightTracksTextView: (BOOL)flag { NSNotificationCenter *nc; - nc = [NSNotificationCenter defaultCenter]; + BOOL old_observing = _observingFrameChanges; _heightTracksTextView = flag; _observingFrameChanges = _widthTracksTextView | _heightTracksTextView; if (_textView == nil) return; + if (_observingFrameChanges == old_observing) + return; + + nc = [NSNotificationCenter defaultCenter]; + if (_observingFrameChanges) { + [_textView setPostsFrameChangedNotifications: YES]; [nc addObserver: self selector: @selector(_textViewFrameChanged:) name: NSViewFrameDidChangeNotification