@@ -109,16 +109,21 @@ - (void)enqueueNotification:(NSNotification*)note
109
109
110
110
- (void )fire : (NSTimer *)timer {
111
111
@synchronized (self) {
112
- /* Note 20171227 1 of 2. The following line will sometime crash on launch of BookMacster. */
113
- NSNotification * note = [timer userInfo ] ;
114
- NSString * noteName = [note name ] ;
115
- [[self fireTimers ] removeObjectForKey: noteName] ;
116
- NSArray * observations = [[self observations ] objectForKey: noteName] ;
117
- for (NSDictionary * observation in observations) {
118
- id observer = [observation objectForKey: constSSYLazyNotificationCenterObserver] ;
119
- SEL selector = NSSelectorFromString ([observation objectForKey: constSSYLazyNotificationSelectorName]) ;
120
- [observer performSelector: selector
121
- withObject: note] ;
112
+ /* Documentation of -[NSTimer userInfo] states:
113
+ Do not access this property after the timer is invalidated.
114
+ Indeed, in macOS 10.13.3 Beta 2-3, it causes a crash. So, we check
115
+ it before doing anything. */
116
+ if (timer.isValid ) {
117
+ NSNotification * note = [timer userInfo ] ;
118
+ NSString * noteName = [note name ] ;
119
+ [[self fireTimers ] removeObjectForKey: noteName] ;
120
+ NSArray * observations = [[self observations ] objectForKey: noteName] ;
121
+ for (NSDictionary * observation in observations) {
122
+ id observer = [observation objectForKey: constSSYLazyNotificationCenterObserver] ;
123
+ SEL selector = NSSelectorFromString ([observation objectForKey: constSSYLazyNotificationSelectorName]) ;
124
+ [observer performSelector: selector
125
+ withObject: note] ;
126
+ }
122
127
}
123
128
}
124
129
}
0 commit comments