Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cleanup the views when the repository window closes and stop memory l…

…eaks.

    - make sure to remove themselves from KV and notification center observers
    - add the PBWebHistoryController to PBHistoryController so it can be told to close
    - replaced the -removeView methods with -closeView (-removeView was not being used)
    - clear any obj-c objects set in web scripting objects

This last item seems to be the reason that the web controllers and the current commit did not get collected which then held the repository document from being collected as well.
  • Loading branch information...
commit 53d92fb73e8224b474f4891358c089658f26a23e 1 parent a849424
@brotherbard brotherbard authored
View
2  PBGitCommitController.m
@@ -64,7 +64,7 @@ - (void)awakeFromNib
[unstagedFilesController setAutomaticallyRearrangesObjects:NO];
}
-- (void)removeView
+- (void)closeView
{
[webController closeView];
}
View
2  PBGitHistoryController.h
@@ -13,6 +13,7 @@
#import "PBCollapsibleSplitView.h"
@class PBGitSidebarController;
+@class PBWebHistoryController;
@class PBGitGradientBarView;
@class PBRefController;
@class QLPreviewPanel;
@@ -28,6 +29,7 @@
NSArray *currentFileBrowserSelectionPath;
IBOutlet PBCommitList* commitList;
IBOutlet PBCollapsibleSplitView *historySplitView;
+ IBOutlet PBWebHistoryController *webHistoryController;
QLPreviewPanel* previewPanel;
IBOutlet PBGitGradientBarView *upperToolbarView;
View
22 PBGitHistoryController.m
@@ -7,6 +7,7 @@
//
#import "PBGitHistoryController.h"
+#import "PBWebHistoryController.h"
#import "CWQuickLook.h"
#import "PBGitGrapher.h"
#import "PBGitRevisionCell.h"
@@ -415,17 +416,26 @@ - (BOOL) hasNonlinearPath
return [commitController filterPredicate] || [[commitController sortDescriptors] count] > 0;
}
-- (void) removeView
+- (void)closeView
{
float position = [[[historySplitView subviews] objectAtIndex:0] frame].size.height;
[[NSUserDefaults standardUserDefaults] setFloat:position forKey:@"PBGitSplitViewPosition"];
[[NSUserDefaults standardUserDefaults] synchronize];
- [webView close];
- [commitController removeObserver:self forKeyPath:@"selection"];
- [treeController removeObserver:self forKeyPath:@"selection"];
- [repository removeObserver:self forKeyPath:@"currentBranch"];
- [super removeView];
+ if (commitController) {
+ [commitController removeObserver:self forKeyPath:@"selection"];
+ [commitController removeObserver:self forKeyPath:@"arrangedObjects.@count"];
+ [treeController removeObserver:self forKeyPath:@"selection"];
+
+ [repository.revisionList removeObserver:self forKeyPath:@"isUpdating"];
+ [repository.revisionList removeObserver:self forKeyPath:@"updatedGraph"];
+ [repository removeObserver:self forKeyPath:@"currentBranch"];
+ [repository removeObserver:self forKeyPath:@"refs"];
+ }
+
+ [webHistoryController closeView];
+
+ [super closeView];
}
#pragma mark Table Column Methods
View
129 PBGitHistoryView.xib
@@ -2,10 +2,10 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1050</int>
- <string key="IBDocument.SystemVersion">10C540</string>
- <string key="IBDocument.InterfaceBuilderVersion">740</string>
- <string key="IBDocument.AppKitVersion">1038.25</string>
- <string key="IBDocument.HIToolboxVersion">458.00</string>
+ <string key="IBDocument.SystemVersion">10F569</string>
+ <string key="IBDocument.InterfaceBuilderVersion">762</string>
+ <string key="IBDocument.AppKitVersion">1038.29</string>
+ <string key="IBDocument.HIToolboxVersion">461.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
@@ -15,8 +15,8 @@
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
- <string>740</string>
- <string>740</string>
+ <string>762</string>
+ <string>762</string>
</object>
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
@@ -25,8 +25,8 @@
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
- <string>com.apple.WebKitIBPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.WebKitIBPlugin</string>
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -436,7 +436,7 @@
<string key="NSColorName">controlBackgroundColor</string>
<object class="NSColor" key="NSColor" id="827382333">
<int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MC42NjY2NjY2ODY1AA</bytes>
+ <bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
</object>
</object>
<object class="NSColor" key="NSTextColor" id="57062640">
@@ -1906,6 +1906,14 @@
</object>
<int key="connectionID">398</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">webHistoryController</string>
+ <reference key="source" ref="1001"/>
+ <reference key="destination" ref="568231003"/>
+ </object>
+ <int key="connectionID">402</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -2686,7 +2694,7 @@
</object>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{463, 486}, {852, 432}}</string>
+ <string>{{9, 486}, {852, 432}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSMutableDictionary">
@@ -2722,7 +2730,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">398</int>
+ <int key="maxID">402</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -2842,6 +2850,7 @@
<string>selectedBranchFilterItem</string>
<string>treeController</string>
<string>upperToolbarView</string>
+ <string>webHistoryController</string>
<string>webView</string>
</object>
<object class="NSMutableArray" key="dict.values">
@@ -2849,7 +2858,7 @@
<string>NSButton</string>
<string>NSButton</string>
<string>NSArrayController</string>
- <string>NSTableView</string>
+ <string>PBCommitList</string>
<string>NSOutlineView</string>
<string>PBCollapsibleSplitView</string>
<string>NSButton</string>
@@ -2861,6 +2870,7 @@
<string>NSButton</string>
<string>NSTreeController</string>
<string>PBGitGradientBarView</string>
+ <string>PBWebHistoryController</string>
<string>id</string>
</object>
</object>
@@ -2980,9 +2990,6 @@
<string>commitController</string>
<string>commitList</string>
<string>historyController</string>
- <string>pullItem</string>
- <string>pushItem</string>
- <string>rebaseItem</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -2990,9 +2997,6 @@
<string>NSArrayController</string>
<string>PBCommitList</string>
<string>PBGitHistoryController</string>
- <string>KBPopUpToolbarItem</string>
- <string>KBPopUpToolbarItem</string>
- <string>KBPopUpToolbarItem</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
@@ -3480,69 +3484,6 @@
<string key="className">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">ImageKit.framework/Headers/IKImageBrowserView.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">ImageKit.framework/Headers/IKSaveOptions.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">ImageKit.framework/Headers/ImageKitDeprecated.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">PDFKit.framework/Headers/PDFDocument.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">PDFKit.framework/Headers/PDFView.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">QuartzComposer.framework/Headers/QCCompositionParameterView.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">QuartzComposer.framework/Headers/QCCompositionPickerView.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">QuartzFilters.framework/Headers/QuartzFilterManager.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
- <string key="minorKey">QuickLookUI.framework/Headers/QLPreviewPanel.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
- <string key="className">NSObject</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">Sparkle.framework/Headers/SUAppcast.h</string>
</object>
</object>
@@ -3869,13 +3810,14 @@
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
+ <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
<integer value="1050" key="NS.object.0"/>
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
- <integer value="1060" key="NS.object.0"/>
+ <integer value="1050" key="NS.object.0"/>
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
@@ -3884,5 +3826,30 @@
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<string key="IBDocument.LastKnownRelativeProjectPath">GitX.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
+ <object class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>AddBranchTemplate</string>
+ <string>AddLabelTemplate</string>
+ <string>CherryPickTemplate</string>
+ <string>DetailViewTemplate</string>
+ <string>MergeTemplate</string>
+ <string>NSPathTemplate</string>
+ <string>NSQuickLookTemplate</string>
+ <string>RebaseTemplate</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>{20, 12}</string>
+ <string>{23, 12}</string>
+ <string>{18.5143, 12.3429}</string>
+ <string>{17, 17}</string>
+ <string>{16.4571, 12.3429}</string>
+ <string>{16, 9}</string>
+ <string>{19, 11}</string>
+ <string>{16.4571, 13.3714}</string>
+ </object>
+ </object>
</data>
</archive>
View
11 PBGitSidebarController.m
@@ -59,6 +59,17 @@ - (void)awakeFromNib
[self selectCurrentBranch];
}
+- (void)closeView
+{
+ [historyViewController closeView];
+ [commitViewController closeView];
+
+ [repository removeObserver:self forKeyPath:@"currentBranch"];
+ [repository removeObserver:self forKeyPath:@"branches"];
+
+ [super closeView];
+}
+
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if ([@"currentBranchChange" isEqualToString:context]) {
View
5 PBGitWindowController.m
@@ -33,7 +33,10 @@ - (void)windowWillClose:(NSNotification *)notification
NSLog(@"Window will close!");
if (sidebarController)
- [sidebarController removeView];
+ [sidebarController closeView];
+
+ if (contentController)
+ [contentController removeObserver:self forKeyPath:@"status"];
}
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
View
6 PBGraphCellInfo.m
@@ -19,6 +19,12 @@ - (id)initWithPosition:(int)p andLines:(struct PBGitGraphLine *)l
return self;
}
+- (void)setLines:(struct PBGitGraphLine *)l
+{
+ free(lines);
+ lines = l;
+}
+
-(void) finalize
{
free(lines);
View
6 PBViewController.h
@@ -25,10 +25,8 @@
- (id)initWithRepository:(PBGitRepository *)theRepository superController:(PBGitWindowController *)controller;
-/* removeView is called whenever the view is removed, either to be swapped
- * with a different view, or when the repository window will be destroyed
- */
-- (void) removeView;
+/* closeView is called when the repository window will be closed */
+- (void)closeView;
/* Updateview is called every time it is loaded into the main view */
- (void) updateView;
View
2  PBViewController.m
@@ -27,7 +27,7 @@ - (id)initWithRepository:(PBGitRepository *)theRepository superController:(PBGit
return self;
}
-- (void)removeView
+- (void)closeView
{
[self unbind:@"repository"];
if (hasViewLoaded)
View
9 PBWebChangesController.m
@@ -24,6 +24,15 @@ - (void) awakeFromNib
[cachedFilesController addObserver:self forKeyPath:@"selection" options:0 context:@"cachedFileSelected"];
}
+- (void)closeView
+{
+ [[self script] removeWebScriptKey:@"Index"];
+ [unstagedFilesController removeObserver:self forKeyPath:@"selection"];
+ [cachedFilesController removeObserver:self forKeyPath:@"selection"];
+
+ [super closeView];
+}
+
- (void) didLoad
{
[[self script] setValue:controller.index forKey:@"Index"];
View
8 PBWebController.m
@@ -46,10 +46,14 @@ - (WebScriptObject *) script
return [view windowScriptObject];
}
-- (void) closeView
+- (void)closeView
{
- if (view)
+ if (view) {
+ [[self script] setValue:nil forKey:@"Controller"];
[view close];
+ }
+
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
}
# pragma mark Delegate methods
View
8 PBWebDiffController.m
@@ -18,6 +18,14 @@ - (void) awakeFromNib
[diffController addObserver:self forKeyPath:@"diff" options:0 context:@"ChangedDiff"];
}
+- (void)closeView
+{
+ [diffController removeObserver:self forKeyPath:@"diff"];
+
+ [super closeView];
+}
+
+
- (void) didLoad
{
[self showDiff:diffController.diff];
View
11 PBWebHistoryController.m
@@ -22,6 +22,14 @@ - (void) awakeFromNib
[historyController addObserver:self forKeyPath:@"webCommit" options:0 context:@"ChangedCommit"];
}
+- (void)closeView
+{
+ [[self script] setValue:nil forKey:@"commit"];
+ [historyController removeObserver:self forKeyPath:@"webCommit"];
+
+ [super closeView];
+}
+
- (void) didLoad
{
currentSha = nil;
@@ -161,9 +169,8 @@ - (void)webView:(WebView *)sender decidePolicyForNewWindowAction:(NSDictionary
return [historyController valueForKeyPath:[@"repository.config." stringByAppendingString:config]];
}
-- (void) finalize
+- (void)finalize
{
- [historyController removeObserver:self forKeyPath:@"webCommit"];
[super finalize];
}
Please sign in to comment.
Something went wrong with that request. Please try again.