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

Unified Diff: content/common/font_cache_dispatcher_win.cc

Issue 9834032: fix GDI usage errors in font precache (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/font_cache_dispatcher_win.cc
diff --git a/content/common/font_cache_dispatcher_win.cc b/content/common/font_cache_dispatcher_win.cc
index bbdad9f1855d8007c372faaf6c43fa8764ad2c0b..31d4f9bd45e285fc3700dab508f532df1f3d6b9c 100644
--- a/content/common/font_cache_dispatcher_win.cc
+++ b/content/common/font_cache_dispatcher_win.cc
@@ -56,11 +56,13 @@ class FontCache {
if (cache_[font_name].ref_count_ == 0) { // Requested font is new to cache.
cache_[font_name].ref_count_ = 1;
} else { // Requested font is already in cache, release old handles.
+ SelectObject(cache_[font_name].dc_, cache_[font_name].old_font_);
DeleteObject(cache_[font_name].font_);
- DeleteDC(cache_[font_name].dc_);
+ ReleaseDC(NULL, cache_[font_name].dc_);
}
cache_[font_name].font_ = font_handle;
cache_[font_name].dc_ = hdc;
+ cache_[font_name].old_font_ = old_font;
cache_[font_name].ref_count_ += ref_count_inc;
}
@@ -97,19 +99,23 @@ class FontCache {
private:
struct CacheElement {
CacheElement()
- : font_(NULL), dc_(NULL), ref_count_(0) {
+ : font_(NULL), old_font_(NULL), dc_(NULL), ref_count_(0) {
}
~CacheElement() {
if (font_) {
+ if (dc_ && old_font_) {
+ SelectObject(dc_, old_font_);
+ }
DeleteObject(font_);
}
if (dc_) {
- DeleteDC(dc_);
+ ReleaseDC(NULL, dc_);
}
}
HFONT font_;
+ HGDIOBJ old_font_;
HDC dc_;
int ref_count_;
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698