File tree Expand file tree Collapse file tree 2 files changed +18
-14
lines changed Expand file tree Collapse file tree 2 files changed +18
-14
lines changed Original file line number Diff line number Diff line change 4
4
5
5
4.0.0 201x/xx/xx
6
6
- MSS: renamed MSSBase to MSSMixin in base.py
7
+ - Linux: ensure resources are freed in grab()
7
8
- MSS: fix Flake8 C408: Unnecessary dict call - rewrite as a literal, in exceptions.py
8
9
- MSS: fix Flake8 I100: Import statements are in the wrong order
9
10
- MSS: fix Flake8 I201: Missing newline before sections or imports
Original file line number Diff line number Diff line change @@ -406,22 +406,25 @@ def grab(self, monitor):
406
406
ZPIXMAP ,
407
407
)
408
408
409
- bits_per_pixel = ximage .contents .bits_per_pixel
410
- if bits_per_pixel != 32 :
411
- raise ScreenShotError (
412
- "[XImage] bits per pixel value not (yet?) implemented: {}." .format (
413
- bits_per_pixel
409
+ try :
410
+ bits_per_pixel = ximage .contents .bits_per_pixel
411
+ if bits_per_pixel != 32 :
412
+ raise ScreenShotError (
413
+ "[XImage] bits per pixel value not (yet?) implemented: {}." .format (
414
+ bits_per_pixel
415
+ )
414
416
)
415
- )
416
417
417
- data = ctypes .cast (
418
- ximage .contents .data ,
419
- ctypes .POINTER (ctypes .c_ubyte * monitor ["height" ] * monitor ["width" ] * 4 ),
420
- )
421
- data = bytearray (data .contents )
422
-
423
- # Free
424
- self .xlib .XDestroyImage (ximage )
418
+ data = ctypes .cast (
419
+ ximage .contents .data ,
420
+ ctypes .POINTER (
421
+ ctypes .c_ubyte * monitor ["height" ] * monitor ["width" ] * 4
422
+ ),
423
+ )
424
+ data = bytearray (data .contents )
425
+ finally :
426
+ # Free
427
+ self .xlib .XDestroyImage (ximage )
425
428
426
429
return self .cls_image (data , monitor )
427
430
You can’t perform that action at this time.
0 commit comments