-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathSSYDocChildObject.m
57 lines (45 loc) · 1.42 KB
/
SSYDocChildObject.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#import "SSYDocChildObject.h"
#import "BkmxGlobals.h"
#import "SSYDooDooUndoManager.h"
@implementation SSYDocChildObject
- (Bkmslf*)document {
Bkmslf* document ;
@synchronized(self) {
document = [[m_document retain] autorelease] ;
}
return document ;
}
- (void)setDocument:(Bkmslf *)document {
@synchronized(self) {
m_document = document ;
}
// During document opening, during -viewDidMoveToWindow, this class
// will be sent an -initWithDocument: with argument nil.
// If that were passed to the following method as the object: argument,
// we would get notifications when ^any^ document closed. We only
// want notifications when ^our^ document closes. Thus, the following if()...
if (document != nil) {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(docWillClose:)
name:SSYUndoManagerDocumentWillCloseNotification
object:document] ;
}
}
- (id)initWithDocument:(Bkmslf*)document_ {
self = [super init];
if (self != 0) {
[self setDocument:document_] ;
}
return self;
}
- (void)dealloc {
[super dealloc] ;
}
- (void)docWillClose:(NSNotification*)note {
[[NSNotificationCenter defaultCenter] removeObserver:self] ;
// To keep from crashing, in particular if I am a Broker, because
// my timers will keep invoking gotHeaders: and other methods
// which send messages to _doc as responses are received.
[self setDocument:nil] ;
}
@end