This repository was archived by the owner on Jul 18, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -136,14 +136,24 @@ @implementation SyPCanonDSLR
136
136
137
137
+ (void )load
138
138
{
139
- EdsInitializeSDK ();
140
- EdsSetCameraAddedHandler (SyPCanonDSLRHandleCameraAdded, NULL );
141
- SyPCanonDSLRHandleCameraAdded (NULL );
142
- }
143
-
144
- __attribute__ ((destructor)) static void finalizer()
145
- {
146
- EdsTerminateSDK ();
139
+ [[NSNotificationCenter defaultCenter ] addObserverForName: NSApplicationDidFinishLaunchingNotification object: nil queue: [NSOperationQueue mainQueue ] usingBlock: ^(NSNotification * _Nonnull note) {
140
+ EdsInitializeSDK ();
141
+ EdsSetCameraAddedHandler (SyPCanonDSLRHandleCameraAdded, NULL );
142
+ SyPCanonDSLRHandleCameraAdded (NULL );
143
+ }];
144
+ [[NSNotificationCenter defaultCenter ] addObserverForName: NSApplicationWillTerminateNotification object: nil queue: [NSOperationQueue mainQueue ] usingBlock: ^(NSNotification * _Nonnull note) {
145
+ NSMutableSet *remove = [NSMutableSet setWithCapacity: 1 ];
146
+ for (SyPCamera *camera in [SyPCamera cameras ]) {
147
+ if ([camera isKindOfClass: [SyPCanonDSLR class ]])
148
+ {
149
+ [remove addObject: camera];
150
+ }
151
+ }
152
+ for (SyPCamera *camera in remove) {
153
+ [SyPCamera removeCamera: camera];
154
+ }
155
+ EdsTerminateSDK ();
156
+ }];
147
157
}
148
158
149
159
+ (NSError *)errorForEDSError : (EdsError)code
You can’t perform that action at this time.
0 commit comments