comparison mac/dw.m @ 1143:b1b23de965d7

Fixed using a pointer after being free()ed on Windows and Mac.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 10 Sep 2011 18:34:25 +0000
parents 8d8c73fb27f4
children 5878dbfafbe2
comparison
equal deleted inserted replaced
1142:88cc189b5e56 1143:b1b23de965d7
9335 HPIXMAP pixmap; 9335 HPIXMAP pixmap;
9336 NSImage *image; 9336 NSImage *image;
9337 NSImageView *iv; 9337 NSImageView *iv;
9338 NSSize size; 9338 NSSize size;
9339 PMPrintSettings settings; 9339 PMPrintSettings settings;
9340 int x; 9340 int x, result = DW_ERROR_UNKNOWN;
9341 UInt32 start, end; 9341 UInt32 start, end;
9342 9342
9343 if(!p) 9343 if(!p)
9344 return DW_ERROR_UNKNOWN; 9344 return result;
9345 9345
9346 /* Figure out the printer/paper size */ 9346 /* Figure out the printer/paper size */
9347 pi = p->pi; 9347 pi = p->pi;
9348 size = [pi paperSize]; 9348 size = [pi paperSize];
9349 /* Create an image view to print and a pixmap to draw into */ 9349 /* Create an image view to print and a pixmap to draw into */
9350 iv = [[NSImageView alloc] init]; 9350 iv = [[NSImageView alloc] init];
9351 pixmap = dw_pixmap_new(iv, size.width, size.height, 8); 9351 pixmap = dw_pixmap_new(iv, (int)size.width, (int)size.height, 8);
9352 rep = pixmap->image; 9352 rep = pixmap->image;
9353 9353
9354 /* Create an image with the data from the pixmap 9354 /* Create an image with the data from the pixmap
9355 * to go into the image view. 9355 * to go into the image view.
9356 */ 9356 */
9365 [po setShowsPrintPanel:NO]; 9365 [po setShowsPrintPanel:NO];
9366 9366
9367 /* Get the page range */ 9367 /* Get the page range */
9368 settings = [pi PMPrintSettings]; 9368 settings = [pi PMPrintSettings];
9369 PMGetFirstPage(settings, &start); 9369 PMGetFirstPage(settings, &start);
9370 if(start) 9370 if(start > 0)
9371 start--; 9371 start--;
9372 PMGetLastPage(settings, &end); 9372 PMGetLastPage(settings, &end);
9373 PMSetPageRange(settings, 1, 1); 9373 PMSetPageRange(settings, 1, 1);
9374 PMSetFirstPage(settings, 1, true); 9374 PMSetFirstPage(settings, 1, true);
9375 PMSetLastPage(settings, 1, true); 9375 PMSetLastPage(settings, 1, true);
9384 [po runOperation]; 9384 [po runOperation];
9385 /* Fill the pixmap with white in case we are printing more pages */ 9385 /* Fill the pixmap with white in case we are printing more pages */
9386 dw_color_foreground_set(DW_CLR_WHITE); 9386 dw_color_foreground_set(DW_CLR_WHITE);
9387 dw_draw_rect(0, pixmap, TRUE, 0, 0, (int)size.width, (int)size.height); 9387 dw_draw_rect(0, pixmap, TRUE, 0, 0, (int)size.width, (int)size.height);
9388 } 9388 }
9389 if(p->drawfunc)
9390 result = DW_ERROR_NONE;
9389 /* Free memory */ 9391 /* Free memory */
9390 dw_pixmap_destroy(pixmap); 9392 dw_pixmap_destroy(pixmap);
9391 free(p); 9393 free(p);
9392 return p->drawfunc ? DW_ERROR_NONE : DW_ERROR_UNKNOWN; 9394 return result;
9393 } 9395 }
9394 9396
9395 /* 9397 /*
9396 * Cancels the print job, typically called from a draw page callback. 9398 * Cancels the print job, typically called from a draw page callback.
9397 * Parameters: 9399 * Parameters: