Revision: 6354
          http://skim-app.svn.sourceforge.net/skim-app/?rev=6354&view=rev
Author:   hofman
Date:     2010-03-21 17:59:51 +0000 (Sun, 21 Mar 2010)

Log Message:
-----------
start observation after loading nib

Modified Paths:
--------------
    trunk/SKGeneralPreferences.m

Modified: trunk/SKGeneralPreferences.m
===================================================================
--- trunk/SKGeneralPreferences.m        2010-03-21 13:26:29 UTC (rev 6353)
+++ trunk/SKGeneralPreferences.m        2010-03-21 17:59:51 UTC (rev 6354)
@@ -44,7 +44,11 @@
 #import "NSGeometry_SKExtensions.h"
 
 #define UPDATEINTERVAL_KEY @"updateInterval"
+#define AUTOMATICALLYCHECKSFORUPDATES_KEY @"automaticallyChecksForUpdates"
+#define UPDATECHECKINTERVAL_KEY @"updateCheckInterval"
 
+#define SUScheduledCheckIntervalKey @"SUScheduledCheckInterval"
+
 static char SKGeneralPreferencesDefaultsObservationContext;
 static char SKGeneralPreferencesUpdaterObservationContext;
 
@@ -55,19 +59,13 @@
 
 @implementation SKGeneralPreferences
 
-- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle 
*)nibBundleOrNil {
-    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
-        [[NSUserDefaultsController sharedUserDefaultsController] 
addObserver:self forKeys:[NSArray 
arrayWithObjects:SKDefaultPDFDisplaySettingsKey, 
SKDefaultFullScreenPDFDisplaySettingsKey, nil] 
context:&SKGeneralPreferencesDefaultsObservationContext];
-        [[SUUpdater sharedUpdater] addObserver:self 
forKeyPath:@"automaticallyChecksForUpdates" options:0 
context:&SKGeneralPreferencesUpdaterObservationContext];
-        [[SUUpdater sharedUpdater] addObserver:self 
forKeyPath:@"updateCheckInterval" options:0 
context:&SKGeneralPreferencesUpdaterObservationContext];
+- (void)dealloc {
+    @try {
+        [[NSUserDefaultsController sharedUserDefaultsController] 
removeObserver:self forKeys:[NSArray 
arrayWithObjects:SKDefaultPDFDisplaySettingsKey, 
SKDefaultFullScreenPDFDisplaySettingsKey, nil]];
+        [[SUUpdater sharedUpdater] removeObserver:self 
forKeyPath:AUTOMATICALLYCHECKSFORUPDATES_KEY];
+        [[SUUpdater sharedUpdater] removeObserver:self 
forKeyPath:UPDATECHECKINTERVAL_KEY];
     }
-    return self;
-}
-
-- (void)dealloc {
-    [[NSUserDefaultsController sharedUserDefaultsController] 
removeObserver:self forKeys:[NSArray 
arrayWithObjects:SKDefaultPDFDisplaySettingsKey, 
SKDefaultFullScreenPDFDisplaySettingsKey, nil]];
-    [[SUUpdater sharedUpdater] removeObserver:self 
forKeyPath:@"automaticallyChecksForUpdates"];
-    [[SUUpdater sharedUpdater] removeObserver:self 
forKeyPath:@"updateCheckInterval"];
+    @catch(id e) {}
     [super dealloc];
 }
 
@@ -86,6 +84,10 @@
     
     [self synchronizeUpdateInterval];
     [self updateRevertButtons];
+    
+    [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self 
forKeys:[NSArray arrayWithObjects:SKDefaultPDFDisplaySettingsKey, 
SKDefaultFullScreenPDFDisplaySettingsKey, nil] 
context:&SKGeneralPreferencesDefaultsObservationContext];
+    [[SUUpdater sharedUpdater] addObserver:self 
forKeyPath:AUTOMATICALLYCHECKSFORUPDATES_KEY options:0 
context:&SKGeneralPreferencesUpdaterObservationContext];
+    [[SUUpdater sharedUpdater] addObserver:self 
forKeyPath:UPDATECHECKINTERVAL_KEY options:0 
context:&SKGeneralPreferencesUpdaterObservationContext];
 }
 
 #pragma mark Accessors
@@ -147,7 +149,7 @@
 #pragma mark Hooks
 
 - (void)defaultsDidRevert {
-    NSTimeInterval interval = [[[NSBundle mainBundle] 
objectForInfoDictionaryKey:@"SUScheduledCheckInterval"] doubleValue];
+    NSTimeInterval interval = [[[NSBundle mainBundle] 
objectForInfoDictionaryKey:SUScheduledCheckIntervalKey] doubleValue];
     [[SUUpdater sharedUpdater] setUpdateCheckInterval:interval];
     [[SUUpdater sharedUpdater] setAutomaticallyChecksForUpdates:interval > 
0.0];
 }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to