| 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_;
|
| };
|
|
|