Skip to content

Commit 8874537

Browse files
author
BoboTiG
committed
Linux: move _cleanup() content to __del__()
1 parent 4e97da1 commit 8874537

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

mss/linux.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,20 @@ class MSS(MSSBase):
7373

7474
# pylint: disable=R0902
7575

76+
display = None
77+
7678
def __del__(self):
77-
''' Quit. '''
79+
''' Disconnect from X server. '''
7880

79-
self._cleanup()
81+
if self.display:
82+
self.xlib.XCloseDisplay(self.display)
83+
self.display = None
8084

8185
def __init__(self):
8286
''' GNU/Linux initialisations. '''
8387

8488
self.use_mss = False
8589
disp = None
86-
self.display = None
8790
try:
8891
if version > '3':
8992
disp = bytes(environ['DISPLAY'], 'utf-8')
@@ -123,16 +126,6 @@ def __init__(self):
123126
self.screen = self.xlib.XDefaultScreen(self.display)
124127
self.root = self.xlib.XDefaultRootWindow(self.display, self.screen)
125128

126-
def _cleanup(self):
127-
''' Disconnect from X server. '''
128-
129-
try:
130-
if self.display:
131-
self.xlib.XCloseDisplay(self.display)
132-
self.display = None
133-
except AttributeError:
134-
pass
135-
136129
def _set_argtypes(self):
137130
''' Functions arguments.
138131

0 commit comments

Comments
 (0)