Revision: 15543
          http://sourceforge.net/p/skim-app/code/15543
Author:   hofman
Date:     2025-06-24 16:16:49 +0000 (Tue, 24 Jun 2025)
Log Message:
-----------
add app delegate as notification observer rather than sending notification 
directly

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

Modified: trunk/SKApplication.m
===================================================================
--- trunk/SKApplication.m       2025-06-24 16:10:55 UTC (rev 15542)
+++ trunk/SKApplication.m       2025-06-24 16:16:49 UTC (rev 15543)
@@ -74,10 +74,7 @@
 }
 
 - (IBAction)terminate:(id)sender {
-    NSNotification *notification = [NSNotification 
notificationWithName:SKApplicationStartsTerminatingNotification object:self];
-    [[NSNotificationCenter defaultCenter] postNotification:notification];
-    if ([[self delegate] 
respondsToSelector:@selector(applicationStartsTerminating:)])
-        [[self delegate] applicationStartsTerminating:notification];
+    [[NSNotificationCenter defaultCenter] postNotification:[NSNotification 
notificationWithName:SKApplicationStartsTerminatingNotification object:self]];
     [super terminate:sender];
 }
 
@@ -92,6 +89,14 @@
     return NSEventTypeLeftMouseDragged == [[self 
nextEventMatchingMask:(NSEventMaskLeftMouseUp | NSEventMaskLeftMouseDragged) 
untilDate:[NSDate distantFuture] inMode:NSEventTrackingRunLoopMode dequeue:NO] 
type];
 }
 
+- (void)setDelegate:(id<SKApplicationDelegate>)delegate {
+    if ([[self delegate] 
respondsToSelector:@selector(applicationStartsTerminating:)])
+        [[NSNotificationCenter defaultCenter] removeObserver:[self delegate] 
name:SKApplicationStartsTerminatingNotification object:self];
+    [super setDelegate:delegate];
+    if ([delegate respondsToSelector:@selector(applicationStartsTerminating:)])
+        [[NSNotificationCenter defaultCenter] addObserver:[self delegate] 
selector:@selector(applicationStartsTerminating:) 
name:SKApplicationStartsTerminatingNotification object:self];
+}
+
 #pragma mark Windows menu
 
 - (void)reorganizeWindowsItem:(NSWindow *)aWindow {

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