Permalink
Browse files

Fix crash when trying to print on 10.13.4 (#3025)

  • Loading branch information...
dmoagx committed Apr 12, 2018
1 parent d5056eb commit 85d65c37ccd929c0e2ef26ddf76bebb8081c1527
Showing with 24 additions and 12 deletions.
  1. +3 −3 Source/SPBundleHTMLOutputController.m
  2. +19 −9 Source/SPDatabaseDocument.m
  3. +2 −0 Source/SPTableContent.m
@@ -197,7 +197,7 @@ - (void)sheetDidEnd:(id)sheet returnCode:(NSInteger)returnCode contextInfo:(NSSt
- (IBAction)printDocument:(id)sender
{
#warning duplicate code with -[SPDatabaseDocument webView:didFinishLoadForFrame:]
NSPrintInfo *printInfo = [NSPrintInfo sharedPrintInfo];
NSSize paperSize = [printInfo paperSize];
@@ -225,8 +225,8 @@ - (IBAction)printDocument:(id)sender
NSPrintOperation *op = [NSPrintOperation printOperationWithView:[[[webView mainFrame] frameView] documentView] printInfo:printInfo];
// Perform the print operation on a background thread
[op setCanSpawnSeparateThread:YES];
// do not try to use webkit from a background thread!
[op setCanSpawnSeparateThread:NO];
// Add the ability to select the orientation to print panel
NSPrintPanel *printPanel = [op printPanel];
@@ -79,9 +79,7 @@
#import "SPBundleHTMLOutputController.h"
#endif
#import "SPTableTriggers.h"
#ifdef SP_CODA /* headers */
#import "SPTableStructure.h"
#endif
#import "SPPrintAccessory.h"
#import "MGTemplateEngine.h"
#import "ICUTemplateMatcher.h"
@@ -7279,8 +7277,8 @@ - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
NSPrintOperation *op = [NSPrintOperation printOperationWithView:[[[printWebView mainFrame] frameView] documentView] printInfo:printInfo];
// Perform the print operation on a background thread
[op setCanSpawnSeparateThread:YES];
// do not try to use webkit from a background thread!
[op setCanSpawnSeparateThread:NO];
// Add the ability to select the orientation to print panel
NSPrintPanel *printPanel = [op printPanel];
@@ -7297,12 +7295,22 @@ - (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
[op setPrintPanel:printPanel];
[op runOperationModalForWindow:[self parentWindow]
delegate:self
didRunSelector:nil
contextInfo:nil];
/* -endTask has to be called first, since the toolbar caches the item enabled state before starting a sheet,
* disables all items and restores the cached state after the sheet ends. Because the database chooser is disabled
* during tasks, launching the sheet before calling -endTask first would result in the following flow:
* - toolbar item caches database chooser state as disabled (because of the active task)
* - sheet is shown
* - endTask reenables database chooser (has no effect because of the open sheet)
* - user dismisses sheet after some time
* - toolbar item restores cached state and disables database chooser again
* => Inconsistent UI: database chooser disabled when it should actually be enabled
*/
if ([self isWorking]) [self endTask];
[op runOperationModalForWindow:[self parentWindow]
delegate:self
didRunSelector:nil
contextInfo:nil];
}
/**
@@ -7590,6 +7598,8 @@ - (void)generateTableInfoHTMLForPrinting
/**
* Returns an array of columns for whichever view is being printed.
*
* MUST BE CALLED ON THE UI THREAD!
*/
- (NSArray *)columnNames
{
@@ -2373,6 +2373,8 @@ - (NSArray *)currentResult
/**
* Returns the current result (as shown in table content view) as array, the first object containing the field
* names as array, the following objects containing the rows as array.
*
* MUST BE CALLED ON THE UI THREAD!
*/
- (NSArray *)currentDataResultWithNULLs:(BOOL)includeNULLs hideBLOBs:(BOOL)hide
{

0 comments on commit 85d65c3

Please sign in to comment.