Guest User

Untitled

a guest
Feb 21st, 2018
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. From b4baba34869b3c1306634cd1329398cd3028b58c Mon Sep 17 00:00:00 2001
  2. From: Pieter de Bie <pdebie@ai.rug.nl>
  3. Date: Wed, 26 Nov 2008 17:02:23 +0100
  4. Subject: [PATCH] Fix memory leaks
  5.  
  6. ---
  7. PBGitHistoryController.m | 4 ++++
  8. PBGitRepository.m | 5 +++++
  9. PBGitWindowController.m | 6 ++++++
  10. PBViewController.m | 1 +
  11. PBWebHistoryController.m | 6 ++++++
  12. 5 files changed, 22 insertions(+), 0 deletions(-)
  13.  
  14. diff --git a/PBGitHistoryController.m b/PBGitHistoryController.m
  15. index 64758bb..fea0bb5 100644
  16. --- a/PBGitHistoryController.m
  17. +++ b/PBGitHistoryController.m
  18. @@ -190,6 +190,10 @@
  19. - (void) removeView
  20. {
  21. [webView close];
  22. + [commitController removeObserver:self forKeyPath:@"selection"];
  23. + [treeController removeObserver:self forKeyPath:@"selection"];
  24. + [repository removeObserver:self forKeyPath:@"currentBranch"];
  25. +
  26. [super removeView];
  27. }
  28.  
  29. diff --git a/PBGitRepository.m b/PBGitRepository.m
  30. index 4dd33f8..a5d3a92 100644
  31. --- a/PBGitRepository.m
  32. +++ b/PBGitRepository.m
  33. @@ -375,4 +375,9 @@ NSString* PBGitRepositoryErrorDomain = @"GitXErrorDomain";
  34. return nil;
  35. }
  36.  
  37. +- (void) finalize
  38. +{
  39. + NSLog(@"Dealloc of repository");
  40. + [super finalize];
  41. +}
  42. @end
  43. diff --git a/PBGitWindowController.m b/PBGitWindowController.m
  44. index 7495b78..6cf01b5 100644
  45. --- a/PBGitWindowController.m
  46. +++ b/PBGitWindowController.m
  47. @@ -33,6 +33,11 @@
  48. return self;
  49. }
  50.  
  51. +- (void)windowWillClose:(NSNotification *)notification
  52. +{
  53. + [viewController removeView];
  54. +}
  55. +
  56. - (void) setSelectedViewIndex: (int) i
  57. {
  58. selectedViewIndex = i;
  59. @@ -70,6 +75,7 @@
  60.  
  61. - (void)awakeFromNib
  62. {
  63. + [[self window] setDelegate:self];
  64. [[self window] setAutorecalculatesContentBorderThickness:NO forEdge:NSMinYEdge];
  65. [[self window] setContentBorderThickness:35.0f forEdge:NSMinYEdge];
  66. [self showHistoryView:nil];
  67. diff --git a/PBViewController.m b/PBViewController.m
  68. index 971eb36..38d9af1 100644
  69. --- a/PBViewController.m
  70. +++ b/PBViewController.m
  71. @@ -27,6 +27,7 @@
  72.  
  73. - (void) removeView
  74. {
  75. + [self unbind:@"repository"];
  76. [[self view] removeFromSuperview]; // remove the current view
  77. }
  78.  
  79. diff --git a/PBWebHistoryController.m b/PBWebHistoryController.m
  80. index e3f5575..1b49fa4 100644
  81. --- a/PBWebHistoryController.m
  82. +++ b/PBWebHistoryController.m
  83. @@ -108,4 +108,10 @@ contextMenuItemsForElement:(NSDictionary *)element
  84. return [historyController valueForKeyPath:[@"repository.config." stringByAppendingString:config]];
  85. }
  86.  
  87. +- (void) finalize
  88. +{
  89. + [historyController removeObserver:self forKeyPath:@"webCommit"];
  90. + [super finalize];
  91. +}
  92. +
  93. @end
  94. --
  95. 1.6.0.3.875.g5bf73+GitX
Add Comment
Please, Sign In to add comment