From f531d4b029b2e5040ffa20869f391fb131c2334a Mon Sep 17 00:00:00 2001 From: Sassan Haradji Date: Tue, 19 Dec 2023 10:25:39 +0400 Subject: [PATCH] feat: cancel clock event when kivy app stops --- CHANGELOG.md | 4 ++++ headless_kivy_pi/__init__.py | 5 ++++- pyproject.toml | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed221f1..d596907 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## Version 0.5.7 + +- feat: cancel clock event when kivy app stops + ## Version 0.5.6 - fix: ignore data hash and render a single frame after resume diff --git a/headless_kivy_pi/__init__.py b/headless_kivy_pi/__init__.py index 97f4ee8..dcac967 100644 --- a/headless_kivy_pi/__init__.py +++ b/headless_kivy_pi/__init__.py @@ -24,7 +24,7 @@ import kivy import numpy as np -from kivy.app import ObjectProperty, Widget +from kivy.app import App, ObjectProperty, Widget from kivy.clock import Clock from kivy.config import Config from kivy.graphics import ( @@ -305,6 +305,9 @@ def __init__(self: HeadlessWidget, **kwargs: Any) -> None: # noqa: ANN401 True, ) self.render_on_display_event() + App.get_running_app().bind( + on_stop=lambda _: self.render_on_display_event.cancel(), + ) def add_widget( self: HeadlessWidget, diff --git a/pyproject.toml b/pyproject.toml index 1e040d3..2a8dac8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "headless-kivy-pi" -version = "0.5.6" +version = "0.5.7" description = "Headless renderer for Kivy framework on Raspberry Pi" authors = ["Sassan Haradji "] license = "Apache-2.0"