mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
Prevent initWithCoder: from calling initWithFrame: in NSView. According to the documentation, initWithFrame: should not be called when the view is unarchiving itself. Similar changes were needed in other classes since they depended on this call to initialize themselves, so some init code was added to initWithCoder:.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@23143 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b0af40b1cb
commit
53ca2a14c2
6 changed files with 184 additions and 40 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2006-07-06 21:35 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* Source/NSBrowser.m:
|
||||
* Source/NSClipView.m:
|
||||
* Source/NSScrollView.m:
|
||||
* Source/NSTableView.m: Copy some initialization code from
|
||||
initWithFrame: to initWithCoder.
|
||||
* Source/NSView.m: Remove from initWithCoder: a call to initWithFrame:
|
||||
according to the documentation normal objects in a nib should not have
|
||||
thier initWithFrame: method called at the time they are unarchived.
|
||||
Also, copy some initialization code here.
|
||||
|
||||
2006-07-04 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSSpellServer.m:
|
||||
|
|
|
@ -2545,8 +2545,68 @@ static NSTextFieldCell *titleCell;
|
|||
NSString *title = [aDecoder decodeObjectForKey: @"NSFirstColumnTitle"];
|
||||
NSString *sep = [aDecoder decodeObjectForKey: @"NSPathSeparator"];
|
||||
int flags;
|
||||
|
||||
// start //
|
||||
NSSize bs;
|
||||
//NSScroller *hs;
|
||||
|
||||
/* Created the shared titleCell if it hasn't been created already. */
|
||||
if (!titleCell)
|
||||
{
|
||||
titleCell = [GSBrowserTitleCell new];
|
||||
}
|
||||
|
||||
// Class setting
|
||||
_browserCellPrototype = [[[NSBrowser cellClass] alloc] init];
|
||||
_browserMatrixClass = [NSMatrix class];
|
||||
|
||||
// Default values
|
||||
_pathSeparator = @"/";
|
||||
_allowsBranchSelection = YES;
|
||||
_allowsEmptySelection = YES;
|
||||
_allowsMultipleSelection = YES;
|
||||
_reusesColumns = NO;
|
||||
_separatesColumns = YES;
|
||||
_isTitled = YES;
|
||||
_takesTitleFromPreviousColumn = YES;
|
||||
_hasHorizontalScroller = YES;
|
||||
_isLoaded = NO;
|
||||
_acceptsArrowKeys = YES;
|
||||
_acceptsAlphaNumericalKeys = YES;
|
||||
_lastKeyPressed = 0.;
|
||||
_charBuffer = nil;
|
||||
_sendsActionOnArrowKeys = YES;
|
||||
_sendsActionOnAlphaNumericalKeys = YES;
|
||||
_browserDelegate = nil;
|
||||
_passiveDelegate = YES;
|
||||
_doubleAction = NULL;
|
||||
bs = _sizeForBorderType (NSBezelBorder);
|
||||
_minColumnWidth = scrollerWidth + (2 * bs.width);
|
||||
if (_minColumnWidth < 100.0)
|
||||
_minColumnWidth = 100.0;
|
||||
|
||||
// Horizontal scroller
|
||||
_scrollerRect.origin.x = bs.width;
|
||||
_scrollerRect.origin.y = bs.height;
|
||||
_scrollerRect.size.width = _frame.size.width - (2 * bs.width);
|
||||
_scrollerRect.size.height = scrollerWidth;
|
||||
_horizontalScroller = [[NSScroller alloc] initWithFrame: _scrollerRect];
|
||||
[_horizontalScroller setTarget: self];
|
||||
[_horizontalScroller setAction: @selector(scrollViaScroller:)];
|
||||
[self addSubview: _horizontalScroller];
|
||||
_skipUpdateScroller = NO;
|
||||
|
||||
// Columns
|
||||
_browserColumns = [[NSMutableArray alloc] init];
|
||||
|
||||
// Create a single column
|
||||
_lastColumnLoaded = -1;
|
||||
_firstVisibleColumn = 0;
|
||||
_lastVisibleColumn = 0;
|
||||
_maxVisibleColumns = 3;
|
||||
[self _createColumn];
|
||||
// end //
|
||||
|
||||
self = [super initWithCoder: aDecoder];
|
||||
[self setCellPrototype: proto];
|
||||
[self setPathSeparator: sep];
|
||||
[self setTitle: title ofColumn: 0];
|
||||
|
|
|
@ -799,6 +799,9 @@ static inline NSRect integralRect (NSRect rect, NSView *view)
|
|||
if ([[self subviews] count] > 0)
|
||||
{
|
||||
id document = [aDecoder decodeObjectForKey: @"NSDocView"];
|
||||
NSRect rect = [document frame];
|
||||
rect.origin = NSZeroPoint;
|
||||
[document setFrame: rect];
|
||||
[self removeSubview: document];
|
||||
[self setDocumentView: document];
|
||||
}
|
||||
|
|
|
@ -1268,6 +1268,12 @@ static float scrollerWidth;
|
|||
NSScroller *vScroller = [aDecoder decodeObjectForKey: @"NSVScroller"];
|
||||
NSClipView *content = [aDecoder decodeObjectForKey: @"NSContentView"];
|
||||
|
||||
_hLineScroll = 10;
|
||||
_hPageScroll = 10;
|
||||
_vLineScroll = 10;
|
||||
_vPageScroll = 10;
|
||||
_scrollsDynamically = YES;
|
||||
|
||||
if ([aDecoder containsValueForKey: @"NSsFlags"])
|
||||
{
|
||||
unsigned long flags = [aDecoder decodeIntForKey: @"NSsFlags"];
|
||||
|
|
|
@ -5215,6 +5215,32 @@ static inline float computePeriod(NSPoint mouseLocationWin,
|
|||
NSEnumerator *e;
|
||||
NSTableColumn *col;
|
||||
|
||||
// assign defaults, so that there's color in case none is specified
|
||||
ASSIGN (_gridColor, [NSColor gridColor]);
|
||||
ASSIGN (_backgroundColor, [NSColor controlBackgroundColor]);
|
||||
ASSIGN (_tableColumns, [NSMutableArray array]);
|
||||
ASSIGN (_selectedColumns, [NSMutableIndexSet indexSet]);
|
||||
ASSIGN (_selectedRows, [NSMutableIndexSet indexSet]);
|
||||
|
||||
_autoresizesAllColumnsToFit = NO;
|
||||
_clickedRow = -1;
|
||||
_clickedColumn = -1;
|
||||
_drawsGrid = YES;
|
||||
_editedColumn = -1;
|
||||
_editedRow = -1;
|
||||
_highlightedTableColumn = nil;
|
||||
_intercellSpacing = NSMakeSize (5.0, 2.0);
|
||||
_rowHeight = 16.0;
|
||||
_selectedColumn = -1;
|
||||
_selectedRow = -1;
|
||||
_selectingColumns = NO;
|
||||
|
||||
/*
|
||||
_headerView = [NSTableHeaderView new];
|
||||
[_headerView setFrameSize: NSMakeSize (_frame.size.width, 22.0)];
|
||||
[_headerView setTableView: self];
|
||||
*/
|
||||
|
||||
[(NSKeyedUnarchiver *)aDecoder setClass: [GSTableCornerView class] forClassName: @"_NSCornerView"];
|
||||
if ([aDecoder containsValueForKey: @"NSDataSource"])
|
||||
{
|
||||
|
@ -5254,16 +5280,7 @@ static inline float computePeriod(NSPoint mouseLocationWin,
|
|||
{
|
||||
[self setRowHeight: [aDecoder decodeFloatForKey: @"NSRowHeight"]];
|
||||
}
|
||||
if ([aDecoder containsValueForKey: @"NSHeaderView"])
|
||||
{
|
||||
|
||||
NSRect viewFrame = [self frame];
|
||||
float rowHeight = [self rowHeight];
|
||||
|
||||
_headerView = [NSTableHeaderView new];
|
||||
[_headerView setFrameSize: NSMakeSize(viewFrame.size.width, rowHeight)];
|
||||
[_headerView setTableView: self];
|
||||
}
|
||||
if ([aDecoder containsValueForKey: @"NSCornerView"])
|
||||
{
|
||||
NSRect viewFrame;
|
||||
|
@ -5275,6 +5292,17 @@ static inline float computePeriod(NSPoint mouseLocationWin,
|
|||
[[self cornerView] setFrame: viewFrame];
|
||||
}
|
||||
|
||||
if ([aDecoder containsValueForKey: @"NSHeaderView"])
|
||||
{
|
||||
|
||||
NSRect viewFrame = [self frame];
|
||||
float rowHeight = [self rowHeight];
|
||||
|
||||
_headerView = [NSTableHeaderView new];
|
||||
[_headerView setFrameSize: NSMakeSize(viewFrame.size.width, rowHeight)];
|
||||
[_headerView setTableView: self];
|
||||
}
|
||||
|
||||
// get the table columns...
|
||||
columns = [aDecoder decodeObjectForKey: @"NSTableColumns"];
|
||||
e = [columns objectEnumerator];
|
||||
|
@ -5305,14 +5333,6 @@ static inline float computePeriod(NSPoint mouseLocationWin,
|
|||
_columnOrigins = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof(float) * _numberOfColumns);
|
||||
|
||||
_clickedRow = -1;
|
||||
_clickedColumn = -1;
|
||||
_selectingColumns = NO;
|
||||
_selectedColumn = -1;
|
||||
_selectedRow = -1;
|
||||
_editedColumn = -1;
|
||||
_editedRow = -1;
|
||||
|
||||
[self tile];
|
||||
}
|
||||
else
|
||||
|
|
|
@ -3980,15 +3980,58 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
|||
{
|
||||
NSView *prevKeyView = nil;
|
||||
NSView *nextKeyView = nil;
|
||||
|
||||
|
||||
if ([aDecoder containsValueForKey: @"NSFrame"])
|
||||
{
|
||||
_frame = [aDecoder decodeRectForKey: @"NSFrame"];
|
||||
[_frameMatrix setFrameOrigin: _frame.origin];
|
||||
}
|
||||
self = [self initWithFrame: _frame];
|
||||
else
|
||||
{
|
||||
_frame = NSZeroRect;
|
||||
}
|
||||
|
||||
_bounds.origin = NSZeroPoint; // Set bounds rectangle
|
||||
_bounds.size = _frame.size;
|
||||
|
||||
[_frameMatrix setFrameOrigin: _frame.origin];
|
||||
|
||||
_sub_views = [NSMutableArray new];
|
||||
_tracking_rects = [NSMutableArray new];
|
||||
_cursor_rects = [NSMutableArray new];
|
||||
|
||||
_is_rotated_from_base = NO;
|
||||
_is_rotated_or_scaled_from_base = NO;
|
||||
_rFlags.needs_display = YES;
|
||||
_post_frame_changes = NO;
|
||||
_autoresizes_subviews = YES;
|
||||
_autoresizingMask = NSViewNotSizable;
|
||||
_coordinates_valid = NO;
|
||||
_nextKeyView = 0;
|
||||
_previousKeyView = 0;
|
||||
|
||||
_rFlags.flipped_view = [self isFlipped];
|
||||
|
||||
subs = [aDecoder decodeObjectForKey: @"NSSubviews"];
|
||||
|
||||
// iterate over subviews and put them into the view...
|
||||
e = [subs objectEnumerator];
|
||||
while ((sub = [e nextObject]) != nil)
|
||||
{
|
||||
NSAssert([sub window] == nil, NSInternalInconsistencyException);
|
||||
NSAssert([sub superview] == nil, NSInternalInconsistencyException);
|
||||
[sub viewWillMoveToWindow: _window];
|
||||
[sub viewWillMoveToSuperview: self];
|
||||
[sub setNextResponder: self];
|
||||
[_sub_views addObject: sub];
|
||||
_rFlags.has_subviews = 1;
|
||||
[sub resetCursorRects];
|
||||
[sub setNeedsDisplay: YES];
|
||||
[sub _viewDidMoveToWindow];
|
||||
[sub viewDidMoveToSuperview];
|
||||
[self didAddSubview: sub];
|
||||
}
|
||||
RELEASE(subs);
|
||||
|
||||
prevKeyView = [aDecoder decodeObjectForKey: @"NSPreviousKeyView"];
|
||||
nextKeyView = [aDecoder decodeObjectForKey: @"NSNextKeyView"];
|
||||
if (nextKeyView != nil)
|
||||
|
@ -4048,27 +4091,27 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
|||
|
||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &subs];
|
||||
NSDebugLLog(@"NSView", @"NSView: finish decoding\n");
|
||||
|
||||
// iterate over subviews and put them into the view...
|
||||
e = [subs objectEnumerator];
|
||||
while ((sub = [e nextObject]) != nil)
|
||||
{
|
||||
NSAssert([sub window] == nil, NSInternalInconsistencyException);
|
||||
NSAssert([sub superview] == nil, NSInternalInconsistencyException);
|
||||
[sub viewWillMoveToWindow: _window];
|
||||
[sub viewWillMoveToSuperview: self];
|
||||
[sub setNextResponder: self];
|
||||
[_sub_views addObject: sub];
|
||||
_rFlags.has_subviews = 1;
|
||||
[sub resetCursorRects];
|
||||
[sub setNeedsDisplay: YES];
|
||||
[sub _viewDidMoveToWindow];
|
||||
[sub viewDidMoveToSuperview];
|
||||
[self didAddSubview: sub];
|
||||
}
|
||||
RELEASE(subs);
|
||||
}
|
||||
|
||||
// iterate over subviews and put them into the view...
|
||||
e = [subs objectEnumerator];
|
||||
while ((sub = [e nextObject]) != nil)
|
||||
{
|
||||
NSAssert([sub window] == nil, NSInternalInconsistencyException);
|
||||
NSAssert([sub superview] == nil, NSInternalInconsistencyException);
|
||||
[sub viewWillMoveToWindow: _window];
|
||||
[sub viewWillMoveToSuperview: self];
|
||||
[sub setNextResponder: self];
|
||||
[_sub_views addObject: sub];
|
||||
_rFlags.has_subviews = 1;
|
||||
[sub resetCursorRects];
|
||||
[sub setNeedsDisplay: YES];
|
||||
[sub _viewDidMoveToWindow];
|
||||
[sub viewDidMoveToSuperview];
|
||||
[self didAddSubview: sub];
|
||||
}
|
||||
RELEASE(subs);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue