| Summary: | PrintDialog crashes on xp if no printers are installed | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Steve Xu <steve.xu> |
| Component: | SWT | Assignee: | Carolyn MacLeod <carolynmacleod4> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | carolynmacleod4, eclipse.felipe, remy.suen, steve.xu |
| Version: | 4.1 | ||
| Target Milestone: | 3.7 M7 | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
|
Description
Steve Xu
The crash can't be happening when the PrintDialog is created - it looks like it is crashing when the dialog is opened, i.e. on this line:
dialog.open();
I will try to replicate this, but in the meantime, you might want to add something like the following to your code before creating (or opening) the PrintDialog:
PrinterData printerList[] = Printer.getPrinterList();
if (printerList.length == 0) {
// There are no printers. Warn the user, or disable the menu item, etc.
// i.e. do not try to open a print dialog
return;
}
Also, are you by any chance using PrintDialog.setPrinterData(data) with data that was stored from a real printer originally? I can see that that might cause a problem. I will try to protect against that.
Fixed > 20110411 OK, I have protected against anyone giving old PrinterData before opening the PrintDialog. I believe this will fix your problem. This code is in HEAD now. I did not try it without any printers because I do not want to delete all of my printers <g>. However I am pretty sure that this is the correct fix. If you still crash using a build created after today, please reopen this bug. |