diff --git a/pygame/__init__.py b/pygame/__init__.py index a15331b..0ee239a 100644 --- a/pygame/__init__.py +++ b/pygame/__init__.py @@ -4,7 +4,8 @@ 'constants', 'sprite', 'Rect', 'Surface', 'QUIT', 'init', 'mouse', 'locals', 'image', 'font', 'mixer', 'transform', 'pkgdata', 'init', 'quit', 'HAVE_NEWBUF', 'get_sdl_version', - 'get_sdl_byteorder', 'get_error', 'set_error', 'error'] + 'get_sdl_byteorder', 'get_error', 'set_error', 'error', + 'register_quit'] from pygame.color import Color from pygame.rect import Rect @@ -15,7 +16,8 @@ mouse, locals, image, transform, pkgdata, font, mixer, ) from pygame.base import ( - init, quit, HAVE_NEWBUF, get_sdl_version, get_sdl_byteorder + init, quit, HAVE_NEWBUF, get_sdl_version, get_sdl_byteorder, + register_quit ) from pygame._error import get_error, set_error, SDLError diff --git a/pygame/display.py b/pygame/display.py index f1dd667..d79e23c 100644 --- a/pygame/display.py +++ b/pygame/display.py @@ -46,17 +46,17 @@ def blit_hw_A(self): @property def blit_sw(self): # XXX: sw swapped with hw in pygame - return self._c_vidinfo.blit_hw + return self._c_vidinfo.blit_sw @property def blit_sw_CC(self): # XXX: sw swapped with hw in pygame - return self._c_vidinfo.blit_hw_CC + return self._c_vidinfo.blit_sw_CC @property def blit_sw_A(self): # XXX: sw swapped with hw in pygame - return self._c_vidinfo.blit_hw_A + return self._c_vidinfo.blit_sw_A @property def blit_fill(self): @@ -123,7 +123,7 @@ def autoinit(): def autoquit(): global _display_surface - _display_surface = None + _display_surface = None def init(): diff --git a/pygame/font.py b/pygame/font.py index b07118e..c29cbb8 100644 --- a/pygame/font.py +++ b/pygame/font.py @@ -129,9 +129,9 @@ def __init__(self, font, fontsize): #def __del__(self): # # XXX: causes a seg fault in tests sometimes - # if _font_initialised: + # if _font_initialised and self._sdl_font: # sdl.TTF_CloseFont(self._sdl_font) - # self._sdl_font = ffi.NULL + # self._sdl_font = ffi.NULL def set_bold(self, bold): """Font.set_bold(bool): return None diff --git a/pygame/surface.py b/pygame/surface.py index c45fe91..cfe3ce7 100644 --- a/pygame/surface.py +++ b/pygame/surface.py @@ -176,13 +176,12 @@ def __init__(self, size, flags=0, depth=0, masks=None): sdl.SDL_FreeSurface(self._c_surface) raise ValueError("Invalid mask values") - #def __del__(self): # # XXX: causes C errors - # if sdl.SDL_WasInit(sdl.SDL_INIT_VIDEO) or not \ + # if self._c_surface and sdl.SDL_WasInit(sdl.SDL_INIT_VIDEO) or not \ # (self._c_surface.flags & sdl.SDL_HWSURFACE): # sdl.SDL_FreeSurface(self._c_surface) - # self._c_surface = ffi.NULL + # self._c_surface = ffi.NULL def __repr__(self): surface_type = ('HW' if (self._c_surface.flags & sdl.SDL_HWSURFACE) @@ -266,12 +265,14 @@ def fill(self, color, rect=None, special_flags=0): if special_flags: res = sdl.surface_fill_blend(self._c_surface, sdlrect, c_color, special_flags) + else: + with locked(self._c_surface): + # TODO: prep/unprep + res = sdl.SDL_FillRect(self._c_surface, sdlrect, c_color) + + if res == -1: + raise SDLError.from_sdl_error() - with locked(self._c_surface): - # TODO: prep/unprep - res = sdl.SDL_FillRect(self._c_surface, sdlrect, c_color) - if res == -1: - raise SDLError.from_sdl_error() return Rect(sdlrect.x, sdlrect.y, sdlrect.w, sdlrect.h) def _fill(self, c_color, sdlrect, flags):