From d826eabb4a3716873ab8f3d938896dda5eefbaab Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Sat, 13 Mar 2010 22:04:52 +0000 Subject: Add additional thread cancellation checking when generating HTML for printing to ensure the current thread is not the main thread. --- Source/SPPrintController.m | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'Source/SPPrintController.m') diff --git a/Source/SPPrintController.m b/Source/SPPrintController.m index 2c40eda9..64354076 100644 --- a/Source/SPPrintController.m +++ b/Source/SPPrintController.m @@ -98,9 +98,7 @@ * Loads the print document interface. The actual printing is done in the doneLoading delegate. */ - (IBAction)printDocument:(id)sender -{ - NSString *HTMLString = @""; - +{ if (printThread) [printThread release]; [self startTaskWithDescription:NSLocalizedString(@"Generating print document...", @"generating print document status message")]; @@ -234,7 +232,7 @@ rows = [[NSArray alloc] initWithArray: [data objectsAtIndexes: [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1, ([data count] - 1))]] - ]; + ]; } [engine setObject:connection forKey:@"c"]; @@ -250,7 +248,7 @@ NSString *HTMLString = [engine processTemplateInFileAtPath:[[NSBundle mainBundle] pathForResource:SPHTMLPrintTemplate ofType:@"html"] withVariables:printData]; // Check if the operation has been cancelled - if ([printThread isCancelled]) { + if ((printThread != nil) && (![NSThread isMainThread]) && ([printThread isCancelled])) { [pool drain]; [self endTask]; @@ -288,7 +286,7 @@ [printData setObject:[[NSUnarchiver unarchiveObjectWithData:[prefs objectForKey:SPCustomQueryEditorFont]] fontName] forKey:@"font"]; // Check if the operation has been cancelled - if ([printThread isCancelled]) { + if ((printThread != nil) && (![NSThread isMainThread]) && ([printThread isCancelled])) { [pool drain]; [self endTask]; -- cgit v1.2.3