Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(936)

Unified Diff: base/win/scoped_hdc.h

Issue 10545045: Make ScopedGetDC() CHECK fail if GetDC(NULL) returns NULL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/views/omnibox/omnibox_view_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/win/scoped_hdc.h
===================================================================
--- base/win/scoped_hdc.h (revision 140592)
+++ base/win/scoped_hdc.h (working copy)
@@ -21,8 +21,15 @@
explicit ScopedGetDC(HWND hwnd)
: hwnd_(hwnd),
hdc_(GetDC(hwnd)) {
- DCHECK(!hwnd_ || IsWindow(hwnd_));
- DCHECK(hdc_);
+ if (hwnd_) {
+ DCHECK(IsWindow(hwnd_));
+ DCHECK(hdc_);
+ } else {
+ // If GetDC(NULL) returns NULL, something really bad has happened, like
+ // GDI handle exhaustion. In this case Chrome is going to behave badly no
+ // matter what, so we may as well just force a crash now.
+ CHECK(hdc_);
+ }
}
~ScopedGetDC() {
« no previous file with comments | « no previous file | chrome/browser/ui/views/omnibox/omnibox_view_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698