Revision: 15516
          http://sourceforge.net/p/skim-app/code/15516
Author:   hofman
Date:     2025-06-21 16:42:26 +0000 (Sat, 21 Jun 2025)
Log Message:
-----------
Restart current documents timer and notification observing when the document 
controller cancels terminate

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

Modified: trunk/SKApplication.h
===================================================================
--- trunk/SKApplication.h       2025-06-20 22:12:44 UTC (rev 15515)
+++ trunk/SKApplication.h       2025-06-21 16:42:26 UTC (rev 15516)
@@ -45,6 +45,7 @@
 @protocol SKApplicationDelegate <NSApplicationDelegate>
 @optional
 - (void)applicationStartsTerminating:(NSNotification *)aNotification;
+- (void)applicationDocumentControllerCanceledTerminate:(NSApplication 
*)application;
 @end
 
 @class SPUStandardUpdaterController;

Modified: trunk/SKApplication.m
===================================================================
--- trunk/SKApplication.m       2025-06-20 22:12:44 UTC (rev 15515)
+++ trunk/SKApplication.m       2025-06-21 16:42:26 UTC (rev 15516)
@@ -46,6 +46,10 @@
 
 NSString *SKApplicationStartsTerminatingNotification = 
@"SKApplicationStartsTerminatingNotification";
 
+@interface NSApplication (SKPrivateDeclarations)
+- (void)_docController:(NSDocumentController *)docController 
shouldTerminate:(BOOL)shouldTerminate;
+@end
+
 @implementation SKApplication
 
 @synthesize updaterController, userAttentionDisabled;
@@ -81,6 +85,12 @@
     [super terminate:sender];
 }
 
+- (void)_docController:(NSDocumentController *)docController 
shouldTerminate:(BOOL)shouldTerminate {
+    [super _docController:docController shouldTerminate:shouldTerminate];
+    if (shouldTerminate == NO && [[self delegate] 
respondsToSelector:@selector(applicationDocumentControllerCanceledTerminate:)])
+        [[self delegate] applicationDocumentControllerCanceledTerminate:self];
+}
+
 - (BOOL)willDragMouse {
     return NSEventTypeLeftMouseDragged == [[self 
nextEventMatchingMask:(NSEventMaskLeftMouseUp | NSEventMaskLeftMouseDragged) 
untilDate:[NSDate distantFuture] inMode:NSEventTrackingRunLoopMode dequeue:NO] 
type];
 }

Modified: trunk/SKApplicationController.m
===================================================================
--- trunk/SKApplicationController.m     2025-06-20 22:12:44 UTC (rev 15515)
+++ trunk/SKApplicationController.m     2025-06-21 16:42:26 UTC (rev 15516)
@@ -316,9 +316,20 @@
     NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
     [nc removeObserver:self name:SKDocumentDidShowNotification object:nil];
     [nc removeObserver:self 
name:SKDocumentControllerDidRemoveDocumentNotification object:nil];
-    [nc removeObserver:self name:NSWindowDidBecomeMainNotification object:nil];
 }
 
+- (void)applicationDocumentControllerCanceledTerminate:(NSApplication 
*)application {
+    if (currentDocumentsTimer == nil) {
+        currentDocumentsTimer = [NSTimer 
scheduledTimerWithTimeInterval:CURRENTDOCUMENTSETUP_INTERVAL target:self 
selector:@selector(registerCurrentDocuments:) userInfo:nil repeats:YES];
+        
+        NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
+        [nc addObserver:self selector:@selector(registerCurrentDocuments:)
+                                 name:SKDocumentDidShowNotification 
object:nil];
+        [nc addObserver:self selector:@selector(registerCurrentDocuments:)
+                                 
name:SKDocumentControllerDidRemoveDocumentNotification object:nil];
+    }
+}
+
 #pragma mark Updater
 
 - (void)updaterWillRelaunchApplication:(SPUUpdater *)updater {

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