Skip to content

Commit 07f04ea

Browse files
author
Mat Gadd
committed
Fix observer in PBWebChangesController not checking for its context
1 parent cc4e621 commit 07f04ea

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Classes/Controllers/PBWebChangesController.m

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
#import "PBWebChangesController.h"
1010
#import "PBGitIndex.h"
1111

12+
static void * const UnstagedFileSelectedContext = @"UnstagedFileSelectedContext";
13+
static void * const CachedFileSelectedContext = @"CachedFileSelectedContext";
14+
1215
@interface PBWebChangesController () <WebEditingDelegate, WebUIDelegate>
1316
@end
1417

@@ -22,8 +25,8 @@ - (void) awakeFromNib
2225
startFile = @"commit";
2326
[super awakeFromNib];
2427

25-
[unstagedFilesController addObserver:self forKeyPath:@"selection" options:0 context:@"UnstagedFileSelected"];
26-
[stagedFilesController addObserver:self forKeyPath:@"selection" options:0 context:@"cachedFileSelected"];
28+
[unstagedFilesController addObserver:self forKeyPath:@"selection" options:0 context:UnstagedFileSelectedContext];
29+
[stagedFilesController addObserver:self forKeyPath:@"selection" options:0 context:CachedFileSelectedContext];
2730

2831
self.view.editingDelegate = self;
2932
self.view.UIDelegate = self;
@@ -49,6 +52,10 @@ - (void)observeValueForKeyPath:(NSString *)keyPath
4952
change:(NSDictionary *)change
5053
context:(void *)context
5154
{
55+
if (context != UnstagedFileSelectedContext && context != CachedFileSelectedContext) {
56+
return [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
57+
}
58+
5259
NSArrayController *otherController;
5360
otherController = object == unstagedFilesController ? stagedFilesController : unstagedFilesController;
5461
NSUInteger count = [object selectedObjects].count;

0 commit comments

Comments
 (0)