Ignore:
Timestamp:
03/10/03 05:48:21 (21 years ago)
Author:
Nicholas Riley
Message:

PSTimer.m: Fix bug 15, leaking PSTimer from NSInvocation argument retention.

Read Me.rtfd: Updated release notes.

PSAlarm.[hm]: Removed obsolete comment. Changed 1m-59m times to
display without `0h'. Moved code from deserialization to -resetTimer
to be used for alarm deletion undo - fix bug 14.

PSAlarmsController.m: Fix bug 14 - implement _restoreAlarms:,
_removeAlarms and _undoManager. Need to add localized string.

PSAlarmAlertController.m: Fix bug 17, move alert triggering from
constructor to -performAlertsForAlarm: to avoid nested notifications
delivering in wrong order.

PSAlarms.[hm]: Fix bug 14 - implement -restoreAlarms, invokes [PSAlarm
resetTimer]. Clarified a comment. Uncommented some debug logging.

package-Pester.sh: Implemented partition map-less disk image, saves a
few K on distribution. Removed obsolete comments. Added agvtool
bump.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cocoa/Pester/Source/PSAlarmAlertController.m

    r105 r113  
    5050}
    5151
     52- (void)performAlertsForAlarm:(PSAlarm *)alarm;
     53{
     54    PSAlerts *alerts = [alarm alerts];
     55    NSArray *allAlerts = [alerts allAlerts];
     56    if ([allAlerts count] == 0) {
     57        [self _resumeAlarm: alarm];
     58    } else {
     59        pendingAlerts = [[NSMutableSet alloc] init];
     60        [pendingAlerts addObjectsFromArray: allAlerts];
     61        [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(_alertCompleted:)
     62                                                     name: PSAlarmAlertCompletedNotification object: alarm];
     63        [self retain]; // release in _alertCompleted:
     64    }
     65    [alerts triggerForAlarm: alarm];
     66    if ([alerts requirePesterFrontmost] && ![NSApp isActive]) { // restore frontmost process afterward
     67        NSDictionary *activeProcessInfo = [[NSWorkspace sharedWorkspace] activeApplication];
     68        frontmostApp.highLongOfPSN = [[activeProcessInfo objectForKey: @"NSApplicationProcessSerialNumberHigh"] longValue];
     69        frontmostApp.lowLongOfPSN = [[activeProcessInfo objectForKey: @"NSApplicationProcessSerialNumberLow"] longValue];
     70        appWasHidden = [NSApp isHidden];
     71        [NSApp activateIgnoringOtherApps: YES];
     72    }
     73}
     74
    5275- (id)initWithAlarm:(PSAlarm *)alarm;
    5376{
    5477    if ( (self = [super init]) != nil) {
    55         PSAlerts *alerts = [alarm alerts];
    56         NSArray *allAlerts = [alerts allAlerts];
    57         if ([allAlerts count] == 0) {
    58             [self _resumeAlarm: alarm];
    59         } else {
    60             pendingAlerts = [[NSMutableSet alloc] init];
    61             [pendingAlerts addObjectsFromArray: allAlerts];
    62             [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(_alertCompleted:)
    63                                                          name: PSAlarmAlertCompletedNotification object: alarm];
    64             [self retain]; // release in _alertCompleted:
    65         }
    66         [alerts triggerForAlarm: alarm];
    67         if ([alerts requirePesterFrontmost] && ![NSApp isActive]) { // restore frontmost process afterward
    68             NSDictionary *activeProcessInfo = [[NSWorkspace sharedWorkspace] activeApplication];
    69             frontmostApp.highLongOfPSN = [[activeProcessInfo objectForKey: @"NSApplicationProcessSerialNumberHigh"] longValue];
    70             frontmostApp.lowLongOfPSN = [[activeProcessInfo objectForKey: @"NSApplicationProcessSerialNumberLow"] longValue];
    71             appWasHidden = [NSApp isHidden];
    72             [NSApp activateIgnoringOtherApps: YES];
    73         }
     78        // because we're called within a notification, and alerts may deliver further notifications, make sure the rest of the notification clients are able to execute first
     79        [self performSelector: @selector(performAlertsForAlarm:) withObject: alarm afterDelay: 0];
    7480    }
    7581    return self;
Note: See TracChangeset for help on using the changeset viewer.