Skip to content

Commit

Permalink
support Sudden Termination directly
Browse files Browse the repository at this point in the history
* no ugly hack / checking OS version
* X.6 and above only
  • Loading branch information
ssp committed Jun 28, 2012
1 parent 3e14623 commit 7d854b7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
2 changes: 0 additions & 2 deletions delimport/DIBookmarksController.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,4 @@
+ (NSString *) userAgentName;
+ (NSString *) DIApplicationSupportFolderPath;

+ (void) enableSuddenTermination;
+ (void) disableSuddenTermination;
@end
25 changes: 4 additions & 21 deletions delimport/DIBookmarksController.m
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ - (void) updateList: (NSTimer *) timer {
}

// the work gets done here and data could be lost, so disable sudden termination
[DIBookmarksController disableSuddenTermination];
[[NSProcessInfo processInfo] disableSuddenTermination];

NSXMLDocument *allPostsDoc = [self deliciousAPIResponseToRequest:@"posts/all"];
if (allPostsDoc != nil) {
NSXMLElement *root = [allPostsDoc rootElement];
Expand Down Expand Up @@ -313,7 +314,8 @@ - (void) updateList: (NSTimer *) timer {
[self setBookmarks:updatedPosts];
}
}
[DIBookmarksController enableSuddenTermination];

[[NSProcessInfo processInfo] enableSuddenTermination];
}


Expand Down Expand Up @@ -471,23 +473,4 @@ - (BOOL) application: (NSApplication *) theApplication openFile: (NSString *) fi
}


/*
uglyuglyugly but sudden termination seems worth the hassle
*/
+ (void) enableSuddenTermination {
NSProcessInfo * pI = [NSProcessInfo processInfo];
SEL enableSuddenTerminationSelector = @selector(enableSuddenTermination);
if ([pI respondsToSelector:enableSuddenTerminationSelector]) { // we're running X.6 or higher
[pI performSelector:enableSuddenTerminationSelector];
}
}

+ (void) disableSuddenTermination {
NSProcessInfo * pI = [NSProcessInfo processInfo];
SEL enableSuddenTerminationSelector = @selector(disableSuddenTermination);
if ([pI respondsToSelector:enableSuddenTerminationSelector]) { // we're running X.6 or higher
[pI performSelector:enableSuddenTerminationSelector];
}
}

@end

0 comments on commit 7d854b7

Please sign in to comment.