From 1a414ac69ca024ddcdfb65e3f2fce13219125311 Mon Sep 17 00:00:00 2001 From: cacaodev Date: Tue, 23 Sep 2014 13:56:52 +0200 Subject: [PATCH] view-based table: always use the proto UID as view identifier -setDataView: was not working because the caching system was picking views cached with the column identifier which is persistent. Test: CPTableViewTest -testLayout --- AppKit/CPTableColumn.j | 1 + AppKit/CPTableView.j | 48 ++++++++++++++++++++++++------------------ 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/AppKit/CPTableColumn.j b/AppKit/CPTableColumn.j index 3765fac89..a9ab441a2 100644 --- a/AppKit/CPTableColumn.j +++ b/AppKit/CPTableColumn.j @@ -565,6 +565,7 @@ CPTableColumnUserResizingMask = 1 << 1; columnIndexes = [CPIndexSet indexSetWithIndex:column]; // Reloads objectValues only, not the views. + // FIXME: reload data for all rows or just exposed rows ? [tableView _reloadDataForRowIndexes:rowIndexes columnIndexes:columnIndexes]; } diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index ee4fe4338..49015bd8e 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -232,18 +232,18 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; CPInteger _dirtyTableColumnRangeIndex; CPInteger _numberOfHiddenColumns; - BOOL _reloadAllRows; - BOOL _invalidateObjectValuesCache; - Object _objectValues; + BOOL _reloadAllRows; + BOOL _invalidateObjectValuesCache; + Object _objectValues; - CGRect _exposedRect; - CPIndexSet _exposedRows; - CPIndexSet _exposedColumns; + CGRect _exposedRect; + CPIndexSet _exposedRows; + CPIndexSet _exposedColumns; - Object _dataViewsForRows; - Object _cachedDataViews; - CPDictionary _archivedDataViews; - Object _unavailable_custom_cibs; + Object _dataViewsForRows; + Object _cachedDataViews; + CPDictionary _archivedDataViews; + Object _unavailable_custom_cibs; //Configuring Behavior BOOL _allowsColumnReordering; @@ -3674,18 +3674,26 @@ Your delegate can implement this method to avoid subclassing the tableview to ad if (!view) { - var columnIdentifier = [aTableColumn identifier]; + // For cell-based tables, use the dataView prototype identifier as view identifier + // instead of column identifier because 1/ the column identifier may be nil + // and 2/ the tableColumn dataView may change after the column identifier was set. + var identifier; - // For cell-based tables, use the dataView prototype identifier. - if (!columnIdentifier) - columnIdentifier = [[aTableColumn dataView] UID]; + if (_isViewBased) + { + identifier = [aTableColumn identifier]; + view = [self makeViewWithIdentifier:identifier owner:_delegate]; + } + else + { + identifier = [[aTableColumn dataView] UID]; + view = [self makeViewWithIdentifier:identifier owner:_delegate]; - view = [self makeViewWithIdentifier:columnIdentifier owner:_delegate]; + if (!view) + view = [aTableColumn _newDataView]; + } - if (!view) - view = [aTableColumn _newDataView]; - - [view setIdentifier:columnIdentifier]; + [view setIdentifier:identifier]; } return view; @@ -5954,7 +5962,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad keyPath = [_info objectForKey:CPObservedKeyPathKey]; _content = [destination valueForKey:keyPath]; - + // FIXME: reload data for all rows or just exposed rows ? [_source _reloadDataViews]; }