From e8688254e2c9d494d58c0bd6f40fa211ceb5fc9e Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Tue, 16 Sep 2008 01:14:30 +0000 Subject: [PATCH] - SCR: Fix GDI/Memory leak in the screen saver. Pointed out by David Barnard. clientscr/ screensaver_win.cpp svn path=/trunk/boinc/; revision=16001 --- checkin_notes | 7 +++++++ clientscr/screensaver_win.cpp | 20 +++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/checkin_notes b/checkin_notes index 6875962eeb..6aaaf8b221 100644 --- a/checkin_notes +++ b/checkin_notes @@ -7442,3 +7442,10 @@ Charlie 14 Sep 2008 MainDocument.cpp sg_BoincSimpleGUI.cpp ViewMessages.cpp + +Rom 15 Sept 2008 + - SCR: Fix GDI/Memory leak in the screen saver. Pointed out by David + Barnard. + + clientscr/ + screensaver_win.cpp diff --git a/clientscr/screensaver_win.cpp b/clientscr/screensaver_win.cpp index 1c105de370..a4d65cf202 100644 --- a/clientscr/screensaver_win.cpp +++ b/clientscr/screensaver_win.cpp @@ -1774,9 +1774,11 @@ VOID CScreensaver::DoPaint(HWND hwnd, HDC hdc, LPPAINTSTRUCT lpps) { (INT)(pMonitorInfo->xError + pMonitorInfo->widthError), (INT)(pMonitorInfo->yError + pMonitorInfo->heightError) ); -// This fill rect is useful when testing -// FillRect(hdc, &rc, hbrushRed); - rcOrginal = rc; + + // This fill rect is useful when testing + //FillRect(hdc, &rc, hbrushRed); + + rcOrginal = rc; // Draw the bitmap rectangle and copy the bitmap into @@ -1802,11 +1804,19 @@ VOID CScreensaver::DoPaint(HWND hwnd, HDC hdc, LPPAINTSTRUCT lpps) { { SelectObject(hdc, hf); } - rc2 = rc; + + // Try using the "Arial Narrow" font, if that fails use whatever + // the system default font is. Something is better than nothing. + rc2 = rc; iTextHeight = DrawText(hdc, szError, -1, &rc, DT_CENTER | DT_CALCRECT); rc = rc2; - rc2.top+=bm.bmHeight+20; + rc2.top += bm.bmHeight+20; DrawText(hdc, szError, -1, &rc2, DT_CENTER); + + if(hf) + { + DeleteObject(hf); + } }