Commit cba5cfdd authored by Roman Alifanov's avatar Roman Alifanov

settings: add timer cleanup to prevent memory leaks

parent ec0fa632
......@@ -41,6 +41,8 @@ class BaseSetting:
self._busy_count = 0
self._widget_ready = False
self._executor = get_executor()
self._timer_id = None
self._destroyed = False
self.search_target = setting_data.get("search_target", None)
......@@ -261,10 +263,18 @@ class BaseSetting:
return
def _poll():
if self._destroyed:
return False
self._fetch_value_async(force=True)
return True
GLib.timeout_add(int(interval * 1000), _poll)
self._timer_id = GLib.timeout_add(int(interval * 1000), _poll)
def destroy(self):
self._destroyed = True
if self._timer_id is not None:
GLib.source_remove(self._timer_id)
self._timer_id = None
def _update_widget(self):
if self.widget and self._widget_ready:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment