Fixed table header/content random disappearance with unarchived table/outline

views.

NSTableView non-keyed unarchiving was not always initializing _columnOrigins.
NSScrollView keyed unarchiving was decoding non-encoded flags (the flags were 
thus initialized with random memory content).
See ChangeLog for detailed explanations.

Also added double action keyed archiving to NSTableView.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29494 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Quentin Mathe 2010-02-06 11:32:34 +00:00
parent b3af151d7b
commit 2da78331b1
3 changed files with 46 additions and 18 deletions

View file

@ -1,3 +1,23 @@
2010-02-06 Quentin Mathe <quentin.mathe@gmail.com>
Fixed table header/content random disappearance with unarchived table
views.
* Source/NSTableView.m (-initWithCoder:): Fixed _columnsOrigin to be
always initialized by calling -tile with non-keyed unarchiving. Until
now, in case no method that invokes -tile was called before the
display, the table header view was not drawing the table header cells
but just an empty black stroked rect, since -columnAtPoint: was
returning invalid values. This was rarely visible since you usually
set a data source with an outlet and -setDataSource: calls -tile.
Also fixed a _columnOrigins memory with keyed unarchiving.
(-initWithCoder:, -encodeWithCoder:): Added double action keyed
archiving.
* Source/NSScrollView.m (-initWithCoder:): Fixed to only decode the
flags we really encode, otherwise we read random memory and the
flags are then incorrect. This can prevent the table header/content to
be drawn in a table view enclosed in a scroll view, and also result
in keyed archiving exceptions complaning about some NaN rect values.
2010-02-05 16:26-EST Gregory John Casamento <greg.casamento@gmail.com>
* Headers/Additions/GNUstepGUI/GSWindowDecorationView.h: Added

View file

@ -1536,6 +1536,8 @@ static float scrollerWidth;
_vLineScroll = 10;
_vPageScroll = 10;
_scrollsDynamically = YES;
/* _autohidesScroller, _rulersVisible, _hasHorizRuler and _hasVertRuler
implicitly set to NO */
if ([aDecoder containsValueForKey: @"NSsFlags"])
{
@ -1550,11 +1552,13 @@ static float scrollerWidth;
_hasVertScroller = scrollViewFlags.hasVScroller;
_hasHorizScroller = scrollViewFlags.hasHScroller;
_autohidesScrollers = scrollViewFlags.autohidesScrollers;
_scrollsDynamically = (!scrollViewFlags.nonDynamic);
_rulersVisible = scrollViewFlags.showRulers;
_hasHorizRuler = scrollViewFlags.hasHRuler;
_hasVertRuler = scrollViewFlags.hasVRuler;
// TODO: Enable once we encode the next values in
// -encodeWithCoder:, but not before otherwise we read random memory.
//_autohidesScrollers = scrollViewFlags.autohidesScrollers;
//_scrollsDynamically = (!scrollViewFlags.nonDynamic);
//_rulersVisible = scrollViewFlags.showRulers;
//_hasHorizRuler = scrollViewFlags.hasHRuler;
//_hasVertRuler = scrollViewFlags.hasVRuler;
// [self setDrawsBackground: (!scrollViewFlags.doesNotDrawBack)];
_borderType = scrollViewFlags.border;
}

View file

@ -5616,6 +5616,10 @@ This method is deprecated, use -columnIndexesInRect:. */
{
[aCoder encodeObject: NSStringFromSelector([self action]) forKey: @"NSAction"];
}
if ([self doubleAction] != NULL)
{
[aCoder encodeObject: NSStringFromSelector([self doubleAction]) forKey: @"NSDoubleAction"];
}
[aCoder encodeObject: [self backgroundColor] forKey: @"NSBackgroundColor"];
[aCoder encodeObject: [self gridColor] forKey: @"NSGridColor"];
@ -5717,6 +5721,12 @@ This method is deprecated, use -columnIndexesInRect:. */
NSString *action = [aDecoder decodeObjectForKey: @"NSAction"];
[self setAction: NSSelectorFromString(action)];
}
if ([aDecoder containsValueForKey: @"NSDoubleAction"])
{
NSString *action = [aDecoder decodeObjectForKey: @"NSDoubleAction"];
[self setDoubleAction: NSSelectorFromString(action)];
}
if ([aDecoder containsValueForKey: @"NSBackgroundColor"])
{
[self setBackgroundColor: [aDecoder decodeObjectForKey: @"NSBackgroundColor"]];
@ -5797,16 +5807,12 @@ This method is deprecated, use -columnIndexesInRect:. */
e = [columns objectEnumerator];
while ((col = [e nextObject]) != nil)
{
/* Will initialize -[NSTableColumn tableView], _numberOfColumns and
allocate _columnsOrigins */
[self addTableColumn: col];
[col setTableView: self];
}
_numberOfColumns = [columns count];
if (_numberOfColumns)
_columnOrigins = NSZoneMalloc(NSDefaultMallocZone (),
sizeof(float) * _numberOfColumns);
[self tile];
[self tile]; /* Initialize _columnOrigins */
}
else
{
@ -5854,14 +5860,12 @@ This method is deprecated, use -columnIndexesInRect:. */
[aDecoder decodeValueOfObjCType: @encode(BOOL) at: &_verticalMotionDrag];
}
if (_numberOfColumns)
_columnOrigins = NSZoneMalloc (NSDefaultMallocZone (),
sizeof(float) * _numberOfColumns);
if (version == 2)
if (_numberOfColumns > 0)
{
[self tile];
_columnOrigins = NSZoneMalloc (NSDefaultMallocZone (),
sizeof(float) * _numberOfColumns);
}
[self tile]; /* Initialize _columnOrigins */
}
return self;