asweigart / pyscreeze

PyScreeze is a simple, cross-platform screenshot module for Python 2 and 3.
BSD 3-Clause "New" or "Revised" License
194 stars 96 forks source link

fix memory leak at pixel() #33

Closed ijknabla closed 5 years ago

ijknabla commented 6 years ago

device context handler, acquired by win32 API function "GetDC" must be released by win32 API function "ReleaseDC". there is no "ReleaseDC" call in pixel(x, y) function. so, add contextmanager __win32_openDC(hWnd)

usage: |with __win32_openDC(hWnd) as hDC: | # -- codes -- | raise Exception("some error") |#windll.gdi32.ReleaseDC(hWnd, hDC) automatically called

↓this is testcase testcase.zip

asweigart commented 5 years ago

Sorry for how long it took to merge this, and thanks for your contribution!