Skip to content

Commit fb2f7e0

Browse files
author
janhgm
committed
Applied solution for tracker ID: 3075791.
GDI objects leaking. Reported and solved by mlt_msk
1 parent 2277432 commit fb2f7e0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

CamStudio/Recorder/Screen.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,20 +534,26 @@ bool CCamera::CaptureFrame(const CRect& rectView)
534534

535535
// HIER_BEN_IK
536536

537+
// UNDER CONSTRUCTION...
537538
// == REMEMBER ======================================
538539
// Topleft position on screen is 0:0 not 1:1
539540
// Hence, Maxscreen size is logical size (e.g. 1650). Last pos is than 1650 minus 1
540541
// Width = right - left + 1
541542
// Height = bottom - top - 1
542543
// ==================================================
543544
// Conclusion (for our Camstudio application) Weight and Height are one to low here..!
544-
// But where is the cause ???
545+
// But where is this caused ???
545546
/////////////////////////////////////////////
546547
TRACE( _T("## CCamera::CaptureFrame m_rectView.Width()=%d\n"), m_rectView.Width() );
547548

548549
m_rectFrame = CRect(0, 0, m_rectView.Width(), m_rectView.Height());
549550
// setup DC's
550-
CDC* pScreenDC = CDC::FromHandle(::GetDC(0));
551+
// CDC* pScreenDC = CDC::FromHandle(::GetDC(0));
552+
553+
// Applied bug fix, tracker ID: 3075791 / memory leak, reported and solved by mlt_msk, hScreenDC is released afterwards.
554+
HDC hScreenDC = ::GetDC(0);
555+
CDC* pScreenDC = CDC::FromHandle(hScreenDC);
556+
551557
CDC cMemDC;
552558
cMemDC.CreateCompatibleDC(pScreenDC);
553559
CBitmap cBitmap;
@@ -579,6 +585,7 @@ bool CCamera::CaptureFrame(const CRect& rectView)
579585
//m_cImage.GrayScale();
580586

581587
++m_uFrameCount;
588+
ReleaseDC(0,hScreenDC);
582589

583590
return true;
584591
}

0 commit comments

Comments
 (0)