Revision: 6924
http://skim-app.svn.sourceforge.net/skim-app/?rev=6924&view=rev
Author: hofman
Date: 2010-12-03 14:45:11 +0000 (Fri, 03 Dec 2010)
Log Message:
-----------
improve thread safety for ps/dvi converter
Modified Paths:
--------------
trunk/SKConversionProgressController.m
Modified: trunk/SKConversionProgressController.m
===================================================================
--- trunk/SKConversionProgressController.m 2010-12-03 12:18:33 UTC (rev
6923)
+++ trunk/SKConversionProgressController.m 2010-12-03 14:45:11 UTC (rev
6924)
@@ -235,7 +235,7 @@
}
- (NSData *)PDFDataWithPostScriptData:(NSData *)psData {
- NSAssert(NULL == converter, @"attempted to reenter SKPSProgressController,
but this is not supported");
+ NSAssert(NULL == converter, @"attempted to reenter
SKConversionProgressController, but this is not supported");
fileType = SKPostScriptDocumentType;
@@ -350,12 +350,8 @@
NSMutableData *pdfData = [info objectForKey:PDFDATA_KEY];
if (outputPS && success) {
- NSAssert(NULL == converter, @"attempted to reenter
SKPSProgressController, but this is not supported");
+ NSAssert(NULL != converter, @"PS converter was not created");
- // pass self as info
- converter = CGPSConverterCreate((void *)self, &SKPSConverterCallbacks,
NULL);
- NSAssert(converter != NULL, @"unable to create PS converter");
-
CGDataProviderRef provider =
CGDataProviderCreateWithCFData((CFDataRef)outData);
CGDataConsumerRef consumer =
CGDataConsumerCreateWithCFData((CFMutableDataRef)pdfData);
@@ -383,6 +379,8 @@
}
- (NSData *)PDFDataWithDVIFile:(NSString *)dviFile toolPath:(NSString
*)toolPath fileType:(NSString *)aFileType {
+ NSAssert(NULL == converter, @"attempted to reenter
SKConversionProgressController, but this is not supported");
+
NSMutableData *pdfData = nil;
fileType = aFileType;
@@ -390,6 +388,12 @@
taskShouldStop = 0;
pdfData = [[NSMutableData alloc] init];
+ if ([[toolPath lastPathComponent] isEqualToString:@"dvips"]) {
+ // create this on the main thread for thread safety, as we may access
this ivar from cancel:
+ converter = CGPSConverterCreate((void *)self, &SKPSConverterCallbacks,
NULL);
+ NSAssert(converter != NULL, @"unable to create PS converter");
+ }
+
NSDictionary *dictionary = [NSDictionary
dictionaryWithObjectsAndKeys:dviFile, INPUTFILE_KEY, pdfData, PDFDATA_KEY,
toolPath, TOOLPATH_KEY, nil];
NSInteger rv = [self runModalSelector:@selector(doDVIConversionWithInfo:)
withObject:dictionary];
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit