Revision: 15551
          http://sourceforge.net/p/skim-app/code/15551
Author:   hofman
Date:     2025-06-25 09:06:23 +0000 (Wed, 25 Jun 2025)
Log Message:
-----------
separate method to stop observing current documents, rename method

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

Modified: trunk/SKApplicationController.m
===================================================================
--- trunk/SKApplicationController.m     2025-06-25 09:02:07 UTC (rev 15550)
+++ trunk/SKApplicationController.m     2025-06-25 09:06:23 UTC (rev 15551)
@@ -160,7 +160,8 @@
     [[[NSDocumentController sharedDocumentController] documents] 
makeObjectsPerformSelector:forced ? @selector(saveRecentDocumentInfo) : 
@selector(saveRecentDocumentInfoIfNeeded)];
 }
 
-- (void)registerForCurrentDocumentsNotifications {
+
+- (void)startObservingCurrentDocuments {
     NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
     [nc addObserver:self selector:@selector(registerCurrentDocuments:)
                              name:SKDocumentDidShowNotification object:nil];
@@ -170,6 +171,15 @@
     currentDocumentsTimer = [NSTimer 
scheduledTimerWithTimeInterval:CURRENTDOCUMENTSETUP_INTERVAL target:self 
selector:@selector(registerCurrentDocuments:) userInfo:nil repeats:YES];
 }
 
+- (void)stopObservingCurrentDocuments {
+    [currentDocumentsTimer invalidate];
+    currentDocumentsTimer = nil;
+    
+    NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
+    [nc removeObserver:self name:SKDocumentDidShowNotification object:nil];
+    [nc removeObserver:self 
name:SKDocumentControllerDidRemoveDocumentNotification object:nil];
+}
+
 - (void)reopenLastOpenFiles {
     didReopen = YES;
     
@@ -226,7 +236,7 @@
         [sud setObject:versionString forKey:SKLastVersionLaunchedKey];
     }
        
-    [self performSelector:@selector(registerForCurrentDocumentsNotifications) 
withObject:nil afterDelay:1.0];
+    [self performSelector:@selector(startObservingCurrentDocuments) 
withObject:nil afterDelay:1.0];
     
     // kHIDRemoteModeExclusiveAuto lets the HIDRemote handle activation when 
the app gets or loses focus
     if ([sud boolForKey:SKEnableAppleRemoteKey]) {
@@ -306,12 +316,8 @@
     return nil;
 }
 
-- (void)applicationStartsTerminating:(NSApplication *)application; {
-    [currentDocumentsTimer invalidate];
-    currentDocumentsTimer = nil;
-    NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
-    [nc removeObserver:self name:SKDocumentDidShowNotification object:nil];
-    [nc removeObserver:self 
name:SKDocumentControllerDidRemoveDocumentNotification object:nil];
+- (void)applicationStartsTerminating:(NSApplication *)application {
+    [self stopObservingCurrentDocuments];
     
     [presentationDocument() setInteractionMode:SKNormalMode];
     
@@ -320,7 +326,7 @@
 
 - (void)applicationCanceledTerminating:(NSApplication *)application {
     if (currentDocumentsTimer == nil)
-        [self registerForCurrentDocumentsNotifications];
+        [self startObservingCurrentDocuments];
 }
 
 - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication 
*)application {

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



_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to