Fixed memory leak; do not retain delegate; cache scrollerWidth; use nil

instead of empty view


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@7422 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
nico 2000-09-06 15:28:46 +00:00
parent 455fab6e28
commit 4e451907a3

View file

@ -47,6 +47,9 @@
#include <AppKit/NSTextFieldCell.h> #include <AppKit/NSTextFieldCell.h>
#include <AppKit/PSOperators.h> #include <AppKit/PSOperators.h>
/* Cache */
static float scrollerWidth; // == [NSScroller scrollerWidth]
#ifndef HAVE_RINTF #ifndef HAVE_RINTF
#define rintf rint #define rintf rint
#endif #endif
@ -68,7 +71,6 @@
BOOL _isLoaded; BOOL _isLoaded;
id _columnScrollView; id _columnScrollView;
id _columnMatrix; id _columnMatrix;
id _emptyView;
int _numberOfRows; int _numberOfRows;
NSString *_columnTitle; NSString *_columnTitle;
} }
@ -83,7 +85,6 @@
- (int)numberOfRows; - (int)numberOfRows;
- (void)setColumnTitle: (NSString *)aString; - (void)setColumnTitle: (NSString *)aString;
- (NSString *)columnTitle; - (NSString *)columnTitle;
- emptyView;
@end @end
@ -94,7 +95,6 @@
[super init]; [super init];
_isLoaded = NO; _isLoaded = NO;
_emptyView = [[NSView alloc] init];
return self; return self;
} }
@ -105,8 +105,6 @@
[_columnScrollView release]; [_columnScrollView release];
if (_columnMatrix) if (_columnMatrix)
[_columnMatrix release]; [_columnMatrix release];
if (_emptyView)
[_emptyView release];
if (_columnTitle) if (_columnTitle)
[_columnTitle release]; [_columnTitle release];
[super dealloc]; [super dealloc];
@ -167,11 +165,6 @@
return _columnTitle; return _columnTitle;
} }
- emptyView
{
return _emptyView;
}
@end @end
@interface GSBrowserTitleCell: NSTextFieldCell @interface GSBrowserTitleCell: NSTextFieldCell
@ -667,7 +660,7 @@
* immutable strings. * immutable strings.
*/ */
return s; return AUTORELEASE (s);
} }
// ------------------- // -------------------
@ -1157,7 +1150,7 @@
fprintf(stderr, "NSBrowser - (void)setMinColumnWidth: %d\n", columnWidth); fprintf(stderr, "NSBrowser - (void)setMinColumnWidth: %d\n", columnWidth);
#endif #endif
sw = [NSScroller scrollerWidth]; sw = scrollerWidth;
// Take the border into account // Take the border into account
if (_separatesColumns) if (_separatesColumns)
sw += 2 * (_sizeForBorderType (NSBezelBorder)).width; sw += 2 * (_sizeForBorderType (NSBezelBorder)).width;
@ -1336,7 +1329,7 @@
#endif #endif
// Same as horizontal scroller with borders // Same as horizontal scroller with borders
return ([NSScroller scrollerWidth] + (2 * bs.height)); return (scrollerWidth + (2 * bs.height));
} }
// ------------------- // -------------------
@ -1703,7 +1696,7 @@
// Adjust for horizontal scroller // Adjust for horizontal scroller
if (_hasHorizontalScroller) if (_hasHorizontalScroller)
r.origin.y = [NSScroller scrollerWidth] + (2 * bs.height) + NSBR_VOFFSET; r.origin.y = scrollerWidth + (2 * bs.height) + NSBR_VOFFSET;
// Padding : _columnSize.width is rounded in "tile" method // Padding : _columnSize.width is rounded in "tile" method
if (column == _lastVisibleColumn) if (column == _lastVisibleColumn)
@ -1777,10 +1770,9 @@
_scrollerRect.origin.x = bs.width; _scrollerRect.origin.x = bs.width;
_scrollerRect.origin.y = bs.height; _scrollerRect.origin.y = bs.height;
_scrollerRect.size.width = _frame.size.width - (2 * bs.width); _scrollerRect.size.width = _frame.size.width - (2 * bs.width);
_scrollerRect.size.height = [NSScroller scrollerWidth]; _scrollerRect.size.height = scrollerWidth;
_columnSize.height -= [NSScroller scrollerWidth] + (2 * bs.height) _columnSize.height -= scrollerWidth + (2 * bs.height) + NSBR_VOFFSET;
+ NSBR_VOFFSET;
} }
else else
_scrollerRect = NSZeroRect; _scrollerRect = NSZeroRect;
@ -1880,7 +1872,7 @@
"browser: numberOfRowsInColumn: ", "browser: numberOfRowsInColumn: ",
"browser: createRowsForColumn: inMatrix: "]; "browser: createRowsForColumn: inMatrix: "];
ASSIGN(_browserDelegate, anObject); _browserDelegate = anObject;
} }
@ -2079,6 +2071,7 @@
{ {
// Initial version // Initial version
[self setVersion: 1]; [self setVersion: 1];
scrollerWidth = [NSScroller scrollerWidth];
} }
} }
@ -2128,13 +2121,13 @@
_passiveDelegate = YES; _passiveDelegate = YES;
_doubleAction = NULL; _doubleAction = NULL;
bs = _sizeForBorderType (NSBezelBorder); bs = _sizeForBorderType (NSBezelBorder);
_minColumnWidth = [NSScroller scrollerWidth] + (2 * bs.width); _minColumnWidth = scrollerWidth + (2 * bs.width);
// Horizontal scroller // Horizontal scroller
_scrollerRect.origin.x = bs.width; _scrollerRect.origin.x = bs.width;
_scrollerRect.origin.y = bs.height; _scrollerRect.origin.y = bs.height;
_scrollerRect.size.width = _frame.size.width - (2 * bs.width); _scrollerRect.size.width = _frame.size.width - (2 * bs.width);
_scrollerRect.size.height = [NSScroller scrollerWidth]; _scrollerRect.size.height = scrollerWidth;
_horizontalScroller = [[NSScroller alloc] initWithFrame: _scrollerRect]; _horizontalScroller = [[NSScroller alloc] initWithFrame: _scrollerRect];
[_horizontalScroller setTarget: self]; [_horizontalScroller setTarget: self];
[_horizontalScroller setAction: @selector(scrollViaScroller:)]; [_horizontalScroller setAction: @selector(scrollViaScroller:)];
@ -2632,7 +2625,7 @@
if (!(sc = [bc columnScrollView])) if (!(sc = [bc columnScrollView]))
continue; continue;
// Make the column appear empty by removing the matrix // Make the column appear empty by removing the matrix
[sc setDocumentView: [bc emptyView]]; [sc setDocumentView: nil];
[sc setNeedsDisplay: YES]; [sc setNeedsDisplay: YES];
[bc setIsLoaded: NO]; [bc setIsLoaded: NO];
} }
@ -2722,3 +2715,5 @@
} }
@end @end