Fix for bug 270812: Cannot print after printer was renamed

Patch by Masayuki Nakano,
r=emaijala
sr=bzbarsky
This commit is contained in:
ere%atp.fi 2004-12-06 15:29:25 +00:00
parent aa29f4d8ea
commit cadee8d48a

View File

@ -861,6 +861,17 @@ ShowNativePrintDialog(HWND aHWnd,
// If there is no name then use the default printer
if (!printerName || (printerName && !*printerName)) {
printerName = GetDefaultPrinterNameFromGlobalPrinters();
} else {
HANDLE hPrinter = NULL;
nsCAutoString printerNameNative;
NS_CopyUnicodeToNative(nsDependentString(printerName), printerNameNative);
LPTSTR tempPrinterName = NS_CONST_CAST(char*, printerNameNative.get());
if(!::OpenPrinter(tempPrinterName, &hPrinter, NULL)) {
// If the last used printer is not found, we should use default printer.
printerName = GetDefaultPrinterNameFromGlobalPrinters();
} else {
::ClosePrinter(hPrinter);
}
}
NS_ASSERTION(printerName, "We have to have a printer name");