Revision: 5174
http://skim-app.svn.sourceforge.net/skim-app/?rev=5174&view=rev
Author: hofman
Date: 2009-01-27 22:12:33 +0000 (Tue, 27 Jan 2009)
Log Message:
-----------
simplify checking whether dvi conversion task should keep running, separate
accessor for check
Modified Paths:
--------------
trunk/SKConversionProgressController.m
Modified: trunk/SKConversionProgressController.m
===================================================================
--- trunk/SKConversionProgressController.m 2009-01-27 19:00:44 UTC (rev
5173)
+++ trunk/SKConversionProgressController.m 2009-01-27 22:12:33 UTC (rev
5174)
@@ -327,7 +327,7 @@
OSMemoryBarrier();
if (convertingPS)
[super cancel:sender];
- else if (taskShouldStop)
+ else if (taskShouldStop == 0)
OSAtomicCompareAndSwap32Barrier(0, 1, (int32_t *)&taskShouldStop);
else
[self converterWasStopped];
@@ -355,6 +355,11 @@
return [pdfData autorelease];
}
+- (BOOL)shouldKeepRunning {
+ OSMemoryBarrier();
+ return taskShouldStop == 0;
+}
+
- (void)doConversionWithInfo:(NSDictionary *)info {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
@@ -369,31 +374,20 @@
NSInvocation *invocation;
- OSMemoryBarrier();
- if (SKFileExistsAtPath(dviFile) && taskShouldStop == 0) {
+ if (SKFileExistsAtPath(dviFile) && [self shouldKeepRunning]) {
NSTask *task = [[NSTask launchedTaskWithLaunchPath:commandPath
arguments:arguments currentDirectoryPath:[dviFile
stringByDeletingLastPathComponent]] retain];
- invocation = [NSInvocation invocationWithTarget:self
selector:@selector(conversionStarted)];
- [invocation performSelectorOnMainThread:@selector(invoke)
withObject:nil waitUntilDone:NO];
+ if (task) {
+ invocation = [NSInvocation invocationWithTarget:self
selector:@selector(conversionStarted)];
+ [invocation performSelectorOnMainThread:@selector(invoke)
withObject:nil waitUntilDone:NO];
- OSMemoryBarrier();
- if (task && taskShouldStop == 0) {
- while ([task isRunning]) {
- OSMemoryBarrier();
- if (taskShouldStop) {
- if ([task isRunning])
- [task terminate];
- break;
- } else {
- [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
- }
- }
- if ([task isRunning]) {
+ while ([task isRunning] && [self shouldKeepRunning])
+ [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
+ if ([task isRunning])
[task terminate];
- } else {
- success = (0 == [task terminationStatus]);
- }
+ else if ([self shouldKeepRunning])
+ success = ([task terminationStatus] == 0);
}
[task release];
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit