summaryrefslogtreecommitdiffstats
path: root/printing/backend/win_helper.h
diff options
context:
space:
mode:
Diffstat (limited to 'printing/backend/win_helper.h')
-rw-r--r--printing/backend/win_helper.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/printing/backend/win_helper.h b/printing/backend/win_helper.h
index db66bf8..0f6b7ef 100644
--- a/printing/backend/win_helper.h
+++ b/printing/backend/win_helper.h
@@ -46,10 +46,9 @@ class ScopedPrinterHandle
base::win::VerifierTraits> {
public:
bool OpenPrinter(const wchar_t* printer) {
- HANDLE temp_handle;
// ::OpenPrinter may return error but assign some value into handle.
- if (::OpenPrinter(const_cast<LPTSTR>(printer), &temp_handle, NULL)) {
- Set(temp_handle);
+ if (!::OpenPrinter(const_cast<LPTSTR>(printer), Receive(), NULL)) {
+ Take();
}
return IsValid();
}
@@ -57,6 +56,10 @@ class ScopedPrinterHandle
private:
typedef base::win::GenericScopedHandle<PrinterHandleTraits,
base::win::VerifierTraits> Base;
+ // Hide Receive to avoid assigning handle when ::OpenPrinter returned error.
+ Base::Receiver Receive() {
+ return Base::Receive();
+ }
};
class PrinterChangeHandleTraits {