Revision: 4993
http://skim-app.svn.sourceforge.net/skim-app/?rev=4993&view=rev
Author: hofman
Date: 2008-11-25 16:10:33 +0000 (Tue, 25 Nov 2008)
Log Message:
-----------
Ignore exceptions due to unregistering as KVO observation. This may happen when
a window was never loaded.
Modified Paths:
--------------
trunk/SKBookmarkOutlineView.m
trunk/SKMainWindowController.m
trunk/SKNotesDocument.m
Modified: trunk/SKBookmarkOutlineView.m
===================================================================
--- trunk/SKBookmarkOutlineView.m 2008-11-25 11:20:10 UTC (rev 4992)
+++ trunk/SKBookmarkOutlineView.m 2008-11-25 16:10:33 UTC (rev 4993)
@@ -49,7 +49,8 @@
#define SEPARATOR_RIGHT_INDENT 2.0
- (void)dealloc {
- [[NSUserDefaultsController sharedUserDefaultsController]
removeObserver:self forKey:SKTableFontSizeKey];
+ @try { [[NSUserDefaultsController sharedUserDefaultsController]
removeObserver:self forKey:SKTableFontSizeKey]; }
+ @catch (id e) {}
[super dealloc];
}
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2008-11-25 11:20:10 UTC (rev 4992)
+++ trunk/SKMainWindowController.m 2008-11-25 16:10:33 UTC (rev 4993)
@@ -3304,12 +3304,15 @@
}
- (void)unregisterAsObserver {
- [[NSUserDefaultsController sharedUserDefaultsController]
removeObserver:self forKeys:
- [NSArray arrayWithObjects:SKBackgroundColorKey,
SKFullScreenBackgroundColorKey,
- SKSearchHighlightColorKey,
SKShouldHighlightSearchResultsKey,
- SKThumbnailSizeKey,
SKSnapshotThumbnailSizeKey,
- SKShouldAntiAliasKey,
SKGreekingThresholdKey,
- SKTableFontSizeKey, nil]];
+ @try {
+ [[NSUserDefaultsController sharedUserDefaultsController]
removeObserver:self forKeys:
+ [NSArray arrayWithObjects:SKBackgroundColorKey,
SKFullScreenBackgroundColorKey,
+ SKSearchHighlightColorKey,
SKShouldHighlightSearchResultsKey,
+ SKThumbnailSizeKey,
SKSnapshotThumbnailSizeKey,
+ SKShouldAntiAliasKey,
SKGreekingThresholdKey,
+ SKTableFontSizeKey, nil]];
+ }
+ @catch (id e) {}
}
#pragma mark Undo
Modified: trunk/SKNotesDocument.m
===================================================================
--- trunk/SKNotesDocument.m 2008-11-25 11:20:10 UTC (rev 4992)
+++ trunk/SKNotesDocument.m 2008-11-25 16:10:33 UTC (rev 4993)
@@ -61,6 +61,7 @@
#import "SKAnnotationTypeImageCell.h"
#import "SKPrintableView.h"
#import "SKPDFView.h"
+#import "NSUserDefaultsController_SKExtensions.h"
static NSString *SKNotesDocumentWindowFrameAutosaveName =
@"SKNotesDocumentWindow";
@@ -76,6 +77,8 @@
static NSString *SKNotesDocumentTypeColumnIdentifier = @"type";
static NSString *SKNotesDocumentPageColumnIdentifier = @"page";
+static void *SKNotesDocumentDefaultsObservationContext = (void
*)@"SKNotesDocumentDefaultsObservationContext";
+
@implementation SKNotesDocument
- (id)init {
@@ -88,6 +91,8 @@
}
- (void)dealloc {
+ @try { [[NSUserDefaultsController sharedUserDefaultsController]
removeObserver:self forKey:SKTableFontSizeKey]; }
+ @catch (id e) {}
[notes release];
CFRelease(rowHeights);
[toolbarItems release];
@@ -131,6 +136,8 @@
[outlineView reloadData];
[outlineView setTypeSelectHelper:[SKTypeSelectHelper
typeSelectHelperWithMatchOption:SKSubstringMatch]];
+
+ [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self
forKey:SKTableFontSizeKey context:SKNotesDocumentDefaultsObservationContext];
}
- (NSArray *)writableTypesForSaveOperation:(NSSaveOperationType)saveOperation {
@@ -676,4 +683,18 @@
return YES;
}
+#pragma mark KVO
+
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary *)change context:(void *)context {
+ if (context == SKNotesDocumentDefaultsObservationContext) {
+ NSString *key = [keyPath substringFromIndex:7];
+ if ([key isEqualToString:SKTableFontSizeKey]) {
+ NSFont *font = [NSFont systemFontOfSize:[[NSUserDefaults
standardUserDefaults] floatForKey:SKTableFontSizeKey]];
+ [outlineView setFont:font];
+ }
+ } else {
+ [super observeValueForKeyPath:keyPath ofObject:object change:change
context:context];
+ }
+}
+
@end
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit