fix: disconnect signals and config callbacks on destroy
- dock/main.py: off_config_change in destroy() - switcher/main.py: add destroy() for capture signals + config - panel/main.py: disconnect fullscreen-changed signal - notification_center.py: add destroy() for 4 notification signals
This commit is contained in:
4 files changed
+25
No files matched your search
@@ -176,6 +176,9 @@ class Dock(Window):
|
||||
def destroy(self) -> None:
|
||||
self._destroyed = True
|
||||
self._disconnect_occlusion_signals()
|
||||
from services.config import off_config_change
|
||||
|
||||
off_config_change(self._on_config_change)
|
||||
|
||||
if hasattr(self, "canvas") and self.canvas:
|
||||
self.canvas.destroy()
|
||||
|
||||
@@ -1003,6 +1003,16 @@ class NotificationCenter(AppletWindow):
|
||||
def _on_escape_pressed(self, *_):
|
||||
self.hide()
|
||||
|
||||
def destroy(self) -> None:
|
||||
try:
|
||||
notification_service.disconnect_by_func(self.on_notification_added)
|
||||
notification_service.disconnect_by_func(self.on_notification_removed)
|
||||
notification_service.disconnect_by_func(self.on_clear_all)
|
||||
notification_service.disconnect_by_func(self.on_count_changed)
|
||||
except Exception:
|
||||
pass
|
||||
super().destroy()
|
||||
|
||||
def set_visible(self, visible: bool):
|
||||
"""Control notification center visibility with slide-left animation"""
|
||||
super().set_visible(visible)
|
||||
|
||||
@@ -383,6 +383,7 @@ class Panel(Window):
|
||||
"""Clean up all signals and components"""
|
||||
try:
|
||||
modus_service.disconnect_by_func(self.on_dnd_changed)
|
||||
modus_service.disconnect_by_func(self._on_fullscreen_changed)
|
||||
notification_service.disconnect_by_func(self.on_notification_count_changed)
|
||||
from services.config import off_config_change
|
||||
|
||||
|
||||
@@ -578,6 +578,17 @@ class ApplicationSwitcher(Window):
|
||||
except Exception:
|
||||
logger.exception("_on_frame_ready error")
|
||||
|
||||
def destroy(self) -> None:
|
||||
from services.config import off_config_change
|
||||
|
||||
off_config_change(self._on_config_changed)
|
||||
try:
|
||||
self._capture.disconnect_by_func(self._on_frame_ready)
|
||||
self._capture.disconnect_by_func(self._on_frame_failed)
|
||||
except Exception:
|
||||
pass
|
||||
super().destroy()
|
||||
|
||||
def _on_frame_failed(self, _capture, addr, reason):
|
||||
full_addr = addr if addr.startswith("0x") else f"0x{addr}"
|
||||
logger.debug(f"AppCapture frame-failed for {full_addr}: {reason}")
|
||||
|
||||
Reference in new issue
Block a user