Skip to content

Commit

Permalink
Fixed BWSplitView memory leaks (using mutableCopy + autorelease)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabien committed Jun 8, 2009
1 parent b860893 commit 3179749
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions BWSplitView.m
Expand Up @@ -328,7 +328,7 @@ - (void)setMinSizeForCollapsibleSubview:(NSNumber *)minSize
{
if ([self hasCollapsibleSubview])
{
NSMutableDictionary *tempMinValues = [[self minValues] mutableCopy];
NSMutableDictionary *tempMinValues = [[[self minValues] mutableCopy] autorelease];
[tempMinValues setObject:minSize forKey:[NSNumber numberWithInt:[[self subviews] indexOfObject:[self collapsibleSubview]]]];
[self setMinValues:tempMinValues];
}
Expand All @@ -338,7 +338,7 @@ - (void)removeMinSizeForCollapsibleSubview
{
if ([self hasCollapsibleSubview])
{
NSMutableDictionary *tempMinValues = [[self minValues] mutableCopy];
NSMutableDictionary *tempMinValues = [[[self minValues] mutableCopy] autorelease];
[tempMinValues removeObjectForKey:[NSNumber numberWithInt:[[self subviews] indexOfObject:[self collapsibleSubview]]]];
[self setMinValues:tempMinValues];
}
Expand Down Expand Up @@ -874,8 +874,8 @@ - (void)correctCollapsiblePreferredProportionOrSize;
if (![self hasCollapsibleSubview])
return;

NSMutableDictionary *preferredProportions = [[self resizableSubviewPreferredProportion] mutableCopy];
NSMutableDictionary *preferredSizes = [[self nonresizableSubviewPreferredSize] mutableCopy];
NSMutableDictionary *preferredProportions = [[[self resizableSubviewPreferredProportion] mutableCopy] autorelease];
NSMutableDictionary *preferredSizes = [[[self nonresizableSubviewPreferredSize] mutableCopy] autorelease];

NSNumber *key = [NSNumber numberWithInt:[self collapsibleSubviewIndex]];
NSView *subview = [self collapsibleSubview];
Expand Down Expand Up @@ -1037,7 +1037,7 @@ - (void)resizeAndAdjustSubviews;
// TODO: Could add a special case for resizableSubviewsTotalAvailableSize <= 0 : just set all resizable subviews to minimum size

// Make array of all the resizable subviews indexes
NSMutableArray *resizableSubviewIndexes = [[resizableSubviewPreferredProportion allKeys] mutableCopy];
NSMutableArray *resizableSubviewIndexes = [[[resizableSubviewPreferredProportion allKeys] mutableCopy] autorelease];
[resizableSubviewIndexes sortUsingDescriptors:[NSArray arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"self" ascending:YES] autorelease]]];

// Loop until none of the resizable subviews' constraints are violated
Expand Down Expand Up @@ -1143,7 +1143,7 @@ - (void)resizeAndAdjustSubviews;
if (RESIZE_DEBUG_LOGS) NSLog(@"newSubviewSizes after nonresizable proportional resizing: %@", newSubviewSizes);

// Make array of all the non-resizable subviews indexes
NSMutableArray *nonresizableSubviewIndexes = [[nonresizableSubviewPreferredSize allKeys] mutableCopy];
NSMutableArray *nonresizableSubviewIndexes = [[[nonresizableSubviewPreferredSize allKeys] mutableCopy] autorelease];
[nonresizableSubviewIndexes sortUsingDescriptors:[NSArray arrayWithObject:[[[NSSortDescriptor alloc] initWithKey:@"self" ascending:YES] autorelease]]];

// Loop until none of the non-resizable subviews' constraints are violated
Expand Down
12 changes: 6 additions & 6 deletions BWSplitViewInspector.m
Expand Up @@ -193,7 +193,7 @@ - (void)setMinUnitPopupSelection:(int)index

NSNumber *minUnit = [NSNumber numberWithInt:index];

NSMutableDictionary *tempMinUnits = [[splitView minUnits] mutableCopy];
NSMutableDictionary *tempMinUnits = [[[splitView minUnits] mutableCopy] autorelease];
[tempMinUnits setObject:minUnit forKey:[NSNumber numberWithInt:[self subviewPopupSelection]]];
[splitView setMinUnits:tempMinUnits];
}
Expand All @@ -204,7 +204,7 @@ - (void)setMaxUnitPopupSelection:(int)index

NSNumber *maxUnit = [NSNumber numberWithInt:index];

NSMutableDictionary *tempMaxUnits = [[splitView maxUnits] mutableCopy];
NSMutableDictionary *tempMaxUnits = [[[splitView maxUnits] mutableCopy] autorelease];
[tempMaxUnits setObject:maxUnit forKey:[NSNumber numberWithInt:[self subviewPopupSelection]]];
[splitView setMaxUnits:tempMaxUnits];
}
Expand All @@ -216,13 +216,13 @@ - (void)controlTextDidChange:(NSNotification *)aNotification
if ([minField stringValue] != nil && [[minField stringValue] isEqualToString:@""] == NO && [[minField stringValue] isEqualToString:@" "] == NO)
{
NSNumber *minValue = [NSNumber numberWithInt:[minField intValue]];
NSMutableDictionary *tempMinValues = [[splitView minValues] mutableCopy];
NSMutableDictionary *tempMinValues = [[[splitView minValues] mutableCopy] autorelease];
[tempMinValues setObject:minValue forKey:[NSNumber numberWithInt:[self subviewPopupSelection]]];
[splitView setMinValues:tempMinValues];
}
else
{
NSMutableDictionary *tempMinValues = [[splitView minValues] mutableCopy];
NSMutableDictionary *tempMinValues = [[[splitView minValues] mutableCopy] autorelease];
[tempMinValues removeObjectForKey:[NSNumber numberWithInt:[self subviewPopupSelection]]];
[splitView setMinValues:tempMinValues];
}
Expand All @@ -232,13 +232,13 @@ - (void)controlTextDidChange:(NSNotification *)aNotification
if ([maxField stringValue] != nil && [[maxField stringValue] isEqualToString:@""] == NO && [[maxField stringValue] isEqualToString:@" "] == NO)
{
NSNumber *maxValue = [NSNumber numberWithInt:[maxField intValue]];
NSMutableDictionary *tempMaxValues = [[splitView maxValues] mutableCopy];
NSMutableDictionary *tempMaxValues = [[[splitView maxValues] mutableCopy] autorelease];
[tempMaxValues setObject:maxValue forKey:[NSNumber numberWithInt:[self subviewPopupSelection]]];
[splitView setMaxValues:tempMaxValues];
}
else
{
NSMutableDictionary *tempMaxValues = [[splitView maxValues] mutableCopy];
NSMutableDictionary *tempMaxValues = [[[splitView maxValues] mutableCopy] autorelease];
[tempMaxValues removeObjectForKey:[NSNumber numberWithInt:[self subviewPopupSelection]]];
[splitView setMaxValues:tempMaxValues];
}
Expand Down

0 comments on commit 3179749

Please sign in to comment.