Skip to content

Commit

Permalink
minor fill bug fix and put register_quit in top level
Browse files Browse the repository at this point in the history
  • Loading branch information
Rizziepit committed Mar 11, 2014
1 parent 4a8bb8b commit 5e1266c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
6 changes: 4 additions & 2 deletions pygame/__init__.py
Expand Up @@ -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
Expand All @@ -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

Expand Down
8 changes: 4 additions & 4 deletions pygame/display.py
Expand Up @@ -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):
Expand Down Expand Up @@ -123,7 +123,7 @@ def autoinit():

def autoquit():
global _display_surface
_display_surface = None
_display_surface = None


def init():
Expand Down
4 changes: 2 additions & 2 deletions pygame/font.py
Expand Up @@ -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
Expand Down
17 changes: 9 additions & 8 deletions pygame/surface.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 5e1266c

Please sign in to comment.