From c1d97a4b9d7ce275949136cd3ad95a166f34b760 Mon Sep 17 00:00:00 2001 From: "ere%atp.fi" Date: Mon, 6 Dec 2004 15:29:25 +0000 Subject: [PATCH] Fix for bug 270812: Cannot print after printer was renamed Patch by Masayuki Nakano, r=emaijala sr=bzbarsky --- .../printingui/src/win/nsPrintDialogUtil.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/embedding/components/printingui/src/win/nsPrintDialogUtil.cpp b/embedding/components/printingui/src/win/nsPrintDialogUtil.cpp index 18a30420d4c..474b5994740 100644 --- a/embedding/components/printingui/src/win/nsPrintDialogUtil.cpp +++ b/embedding/components/printingui/src/win/nsPrintDialogUtil.cpp @@ -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");