diff options
| author | Pietro Gagliardi <[email protected]> | 2014-10-19 20:01:01 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-10-19 20:01:01 -0400 |
| commit | 3c4021d7d63ab99e528de6ac5b937f9ce59f7354 (patch) | |
| tree | 3631fd0e6eb0d144acee640efb44cf4055bb5f08 | |
| parent | 988c3a7dd830ea42ce019cb63eade88abdfdd235 (diff) | |
Fixed a potential bug in the WM_SETFONT handling.
| -rw-r--r-- | wintable/main.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/wintable/main.c b/wintable/main.c index d99e820..a17e45b 100644 --- a/wintable/main.c +++ b/wintable/main.c @@ -33,7 +33,7 @@ struct table { static void drawItems(struct table *t, HDC dc) { - HFONT prevfont; + HFONT thisfont, prevfont; TEXTMETRICW tm; LONG y; intptr_t i; @@ -41,7 +41,8 @@ static void drawItems(struct table *t, HDC dc) if (GetClientRect(t->hwnd, &r) == 0) abort(); - prevfont = (HFONT) SelectObject(dc, t->font); + thisfont = t->font; // in case WM_SETFONT happens before we return + prevfont = (HFONT) SelectObject(dc, thisfont); if (prevfont == NULL) abort(); if (GetTextMetricsW(dc, &tm) == 0) @@ -68,7 +69,7 @@ static void drawItems(struct table *t, HDC dc) TextOutW(dc, r.left, y, L"Item", 4); y += tm.tmHeight; } - if (SelectObject(dc, prevfont) != (HGDIOBJ) (t->font)) + if (SelectObject(dc, prevfont) != (HGDIOBJ) (thisfont)) abort(); } |
