* Source/NSCollectionView.m (-newItemForRepresentedObject:):

Don't autorelease the returned object as this method starts with
        "new".
        * Source/NSCollectionViewItem.m (-copyWithZone:): Add call to
        new method to copy over the bindings from the old view hierarchy to
        the new.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@38405 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2015-03-12 22:13:42 +00:00
parent 0bdd4d0ae6
commit 830a6ef782
3 changed files with 51 additions and 1 deletions

View file

@ -1,3 +1,11 @@
2015-03-12 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSCollectionView.m (-newItemForRepresentedObject:): Don't
autorelease the returned object as this method starts with "new".
* Source/NSCollectionViewItem.m (-copyWithZone:): Add call to new
method to copy over the bindings from the old view hierarchy to
the new.
2015-03-11 Germán Arias <germanandre@gmx.es>
* Headers/AppKit/NSCursor.h:

View file

@ -474,6 +474,7 @@ static NSString *placeholderItem = nil;
[item setSelected: YES];
}
[self addSubview: [item view]];
RELEASE(item);
}
return item;
}
@ -486,7 +487,7 @@ static NSString *placeholderItem = nil;
collectionItem = [itemPrototype copy];
[collectionItem setRepresentedObject: object];
}
return AUTORELEASE (collectionItem);
return collectionItem;
}
- (void) _removeItemsViews

View file

@ -26,11 +26,13 @@
*/
#import <Foundation/NSArray.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSKeyedArchiver.h>
#import "AppKit/NSCollectionView.h"
#import "AppKit/NSCollectionViewItem.h"
#import "AppKit/NSImageView.h"
#import "AppKit/NSKeyValueBinding.h"
#import "AppKit/NSTextField.h"
@implementation NSCollectionViewItem
@ -149,11 +151,50 @@
}
}
- (void) copyBindingsTo: (NSCollectionViewItem*)newItem
from: (NSView*)view
onto: (NSView*)newView
{
NSArray *exposedBindings = [view exposedBindings];
NSEnumerator *e = [exposedBindings objectEnumerator];
NSString *binding = nil;
while ((binding = [e nextObject]) != nil)
{
NSDictionary *info = [view infoForBinding: binding];
if (info != nil)
{
NSObject *target = [info objectForKey: NSObservedObjectKey];
if (target == self)
{
[newView bind: binding
toObject: newItem
withKeyPath: [info objectForKey: NSObservedKeyPathKey]
options: [info objectForKey: NSOptionsKey]];
}
}
}
NSView *sub1 = nil;
NSEnumerator *e1 = [[view subviews] objectEnumerator];
NSView *sub2 = nil;
NSEnumerator *e2 = [[newView subviews] objectEnumerator];
while ((sub1 = [e1 nextObject]) != nil)
{
sub2 = [e2 nextObject];
[self copyBindingsTo: newItem from: sub1 onto: sub2];
}
}
- (id) copyWithZone: (NSZone *)zone
{
// FIXME: Cache this data, as we need a lot of copies
NSData *itemAsData = [NSKeyedArchiver archivedDataWithRootObject: self];
NSCollectionViewItem *newItem =
[NSKeyedUnarchiver unarchiveObjectWithData: itemAsData];
// Try to copy bindings too
[self copyBindingsTo: newItem from: [self view] onto: [newItem view]];
return RETAIN(newItem);
}