Skip to content

Commit

Permalink
Merge pull request #196 from heuer/check_null
Browse files Browse the repository at this point in the history
Fixed Renderer.autocreate() return value check
  • Loading branch information
flacjacket committed May 12, 2024
2 parents ae5399d + b88019b commit 7a005d9
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions wlroots/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ def __init__(self, ptr) -> None:
@staticmethod
def autocreate(backend: Backend) -> Renderer:
"""Creates a suitable renderer for a backend."""
ret = lib.wlr_renderer_autocreate(backend._ptr)
if not ret:
renderer_ptr = lib.wlr_renderer_autocreate(backend._ptr)
if renderer_ptr == ffi.NULL:
raise RuntimeError("Unable to create a renderer.")
return Renderer(ret)
return Renderer(renderer_ptr)

def init_display(self, display: Display) -> None:
"""Creates necessary shm and invokes the initialization of the implementation
Expand Down Expand Up @@ -66,25 +66,19 @@ def clear(self, color: ColorType) -> None:

def render_texture(
self, texture: Texture, projection: Matrix, x: int, y: int, alpha: float
) -> None:
) -> bool:
"""Renders the requested texture"""
ret = lib.wlr_render_texture(
return lib.wlr_render_texture(
self._ptr, texture._ptr, projection._ptr, x, y, alpha
)
if not ret:
# TODO: get a better exception type
raise Exception("Bad render")

def render_texture_with_matrix(
self, texture: Texture, matrix: Matrix, alpha: float
) -> None:
) -> bool:
"""Renders the requested texture using the provided matrix"""
ret = lib.wlr_render_texture_with_matrix(
return lib.wlr_render_texture_with_matrix(
self._ptr, texture._ptr, matrix._ptr, alpha
)
if not ret:
# TODO: get a better exception type
raise Exception("Bad render")

def render_rect(self, box: Box, color: ColorType, projection: Matrix) -> None:
"""Renders a solid rectangle in the specified color."""
Expand Down

0 comments on commit 7a005d9

Please sign in to comment.