Index: NSOutlineView.m
===================================================================
--- NSOutlineView.m	(revision 26100)
+++ NSOutlineView.m	(working copy)
@@ -105,6 +105,7 @@
 
 // These methods are private...
 @interface NSOutlineView (TableViewInternalPrivate)
+- (void) _initOutlineDefaults;
 - (void) _autosaveExpandedItems;
 - (void) _autoloadExpandedItems;
 - (void) _collectItemsStartingWith: (id)startitem
@@ -140,22 +141,15 @@
  */
 - (id)initWithFrame: (NSRect)frame
 {
-  [super initWithFrame: frame];
+  self = [super initWithFrame: frame];
 
-  // Initial values
-  _indentationMarkerFollowsCell = YES;
-  _autoResizesOutlineColumn = NO;
-  _autosaveExpandedItems = NO;
-  _indentationPerLevel = 0.0;
-  _outlineTableColumn = nil;
-  _itemDict = NSCreateMapTable(NSObjectMapKeyCallBacks,
-			       NSObjectMapValueCallBacks,
-			       64);
-  _items = [[NSMutableArray alloc] init];
-  _expandedItems = [[NSMutableArray alloc] init];
-  _levelOfItems = NSCreateMapTable(NSObjectMapKeyCallBacks,
-				   NSObjectMapValueCallBacks,
-				   64);
+  if (self != nil)
+    {
+      // Initial values
+      [self _initOutlineDefaults];
+      _outlineTableColumn = nil;
+    }
+
   return self;
 }
 
@@ -391,10 +385,15 @@
 }
 
 /**
- * Returns the item at a given row.
+ * Returns the item at a given row. If no item exists for the given row, returns 
+ * nil.
  */
 - (id)itemAtRow: (int)row
 {
+  if (row >= [_items count])
+    {
+      return nil;
+    }
   return [_items objectAtIndex: row];
 }
 
@@ -706,20 +705,8 @@
   self = [super initWithCoder: aDecoder];
   if ([aDecoder allowsKeyedCoding])
     {     
-      _itemDict = NSCreateMapTable(NSObjectMapKeyCallBacks,
-				   NSObjectMapValueCallBacks,
-				   64);
-      _items = [[NSMutableArray alloc] init];
-      _expandedItems = [[NSMutableArray alloc] init];
-      _levelOfItems = NSCreateMapTable(NSObjectMapKeyCallBacks,
-				       NSObjectMapValueCallBacks,
-				       64);
-
       // these can't be chosen on IB.
-      _indentationPerLevel = 10.0;
-      _indentationMarkerFollowsCell = YES;
-      _autoResizesOutlineColumn = NO;
-      _autosaveExpandedItems = NO;
+      [self _initOutlineDefaults];
 
       // init the table column... (this can't be chosen on IB either)...
       if ([_tableColumns count] > 0)
@@ -729,6 +716,8 @@
     }
   else
     {
+      [self _initOutlineDefaults];
+      // overrides outline defaults with archived values
       [aDecoder decodeValueOfObjCType: @encode(BOOL)
 				   at: &_autoResizesOutlineColumn];
       [aDecoder decodeValueOfObjCType: @encode(BOOL)
@@ -738,15 +727,6 @@
       [aDecoder decodeValueOfObjCType: @encode(float)
 				   at: &_indentationPerLevel];
       _outlineTableColumn = [aDecoder decodeObject];
-      
-      _itemDict = NSCreateMapTable(NSObjectMapKeyCallBacks,
-				   NSObjectMapValueCallBacks,
-				   64);
-      _items = [[NSMutableArray alloc] init];
-      _expandedItems = [[NSMutableArray alloc] init];
-      _levelOfItems = NSCreateMapTable(NSObjectMapKeyCallBacks,
-				       NSObjectMapValueCallBacks,
-				       64); 
     }
   return self;
 }
@@ -1645,6 +1625,23 @@
 
 @implementation NSOutlineView (TableViewInternalPrivate)
 
+- (void) _initOutlineDefaults
+{
+  _itemDict = NSCreateMapTable(NSObjectMapKeyCallBacks,
+			       NSObjectMapValueCallBacks,
+			       64);
+  _items = [[NSMutableArray alloc] init];
+  _expandedItems = [[NSMutableArray alloc] init];
+  _levelOfItems = NSCreateMapTable(NSObjectMapKeyCallBacks,
+				   NSObjectMapValueCallBacks,
+				   64);
+
+  _indentationMarkerFollowsCell = YES;
+  _autoResizesOutlineColumn = NO;
+  _autosaveExpandedItems = NO;
+  _indentationPerLevel = 10.0;
+}
+
 - (void) _autosaveExpandedItems
 {
   if (_autosaveExpandedItems && _autosaveName != nil) 
