@@ -25,13 +25,12 @@ from caca.font import _Font | |||||
class _CanvasStruct(ctypes.Structure): | class _CanvasStruct(ctypes.Structure): | ||||
pass | pass | ||||
class _Canvas(object): | class _Canvas(object): | ||||
""" Model for Canvas objects. | """ Model for Canvas objects. | ||||
""" | """ | ||||
def __init__(self): | def __init__(self): | ||||
self._cv = 0 | |||||
self._cv = None | |||||
def from_param(self): | def from_param(self): | ||||
""" Required by ctypes module to call object as parameter of | """ Required by ctypes module to call object as parameter of | ||||
@@ -43,7 +42,7 @@ class _Canvas(object): | |||||
return "<CacaCanvas %dx%d>" % (self.get_width(), self.get_height()) | return "<CacaCanvas %dx%d>" % (self.get_width(), self.get_height()) | ||||
def __del__(self): | def __del__(self): | ||||
if self._cv > 0 and _lib is not None: | |||||
if self._cv and _lib is not None: | |||||
self._free() | self._free() | ||||
def _free(self): | def _free(self): | ||||
@@ -19,6 +19,7 @@ import ctypes | |||||
from caca import _lib, _PYTHON3, _str_to_bytes | from caca import _lib, _PYTHON3, _str_to_bytes | ||||
from caca.canvas import _Canvas, Canvas | from caca.canvas import _Canvas, Canvas | ||||
class _DisplayStruct(ctypes.Structure): | class _DisplayStruct(ctypes.Structure): | ||||
pass | pass | ||||
@@ -36,7 +37,7 @@ class _Display(object): | |||||
return "<CacaDisplay>" | return "<CacaDisplay>" | ||||
def __del__(self): | def __del__(self): | ||||
if self._dp > 0 and _lib is not None: | |||||
if self._dp and _lib is not None: | |||||
self._free() | self._free() | ||||
def _free(self): | def _free(self): | ||||
@@ -205,9 +206,11 @@ class Display(_Display): | |||||
return _lib.caca_get_mouse_y(self) | return _lib.caca_get_mouse_y(self) | ||||
class DisplayError(Exception): | class DisplayError(Exception): | ||||
pass | pass | ||||
class Event(ctypes.Structure): | class Event(ctypes.Structure): | ||||
""" Object to store libcaca event. | """ Object to store libcaca event. | ||||
""" | """ | ||||
@@ -27,7 +27,7 @@ class _Dither(object): | |||||
""" Model for Dither object. | """ Model for Dither object. | ||||
""" | """ | ||||
def __init__(self): | def __init__(self): | ||||
self._dither = 0 | |||||
self._dither = None | |||||
def from_param(self): | def from_param(self): | ||||
""" Required by ctypes module to call object as parameter of | """ Required by ctypes module to call object as parameter of | ||||
@@ -36,7 +36,7 @@ class _Dither(object): | |||||
return self._dither | return self._dither | ||||
def __del__(self): | def __del__(self): | ||||
if self._dither > 0: | |||||
if self._dither: | |||||
self._free() | self._free() | ||||
def __str__(self): | def __str__(self): | ||||
@@ -27,7 +27,7 @@ class _Font(object): | |||||
""" Model for Font object. | """ Model for Font object. | ||||
""" | """ | ||||
def __init__(self): | def __init__(self): | ||||
self._font = 0 | |||||
self._font = None | |||||
def from_param(self): | def from_param(self): | ||||
""" Required by ctypes module to call object as parameter of | """ Required by ctypes module to call object as parameter of | ||||
@@ -37,7 +37,7 @@ class _Font(object): | |||||
def __del__(self): | def __del__(self): | ||||
if hasattr(self, "_font"): | if hasattr(self, "_font"): | ||||
if self._font > 0: | |||||
if self._font: | |||||
self._free() | self._free() | ||||
def __str__(self): | def __str__(self): | ||||