From 0b9801d7b69efdc388097c2f0339eed625b05e1e Mon Sep 17 00:00:00 2001 From: totaam Date: Mon, 20 Feb 2023 16:46:15 +0700 Subject: [PATCH] objc crashes if these objects are garbage collected --- xpra/platform/darwin/gui.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xpra/platform/darwin/gui.py b/xpra/platform/darwin/gui.py index f575121b39..583ece885e 100644 --- a/xpra/platform/darwin/gui.py +++ b/xpra/platform/darwin/gui.py @@ -584,10 +584,10 @@ def normalize_precision(distance): @objc.python_method def register_sleep_handlers(self): log("register_sleep_handlers()") - workspace = NSWorkspace.sharedWorkspace() - notificationCenter = workspace.notificationCenter() + self.workspace = NSWorkspace.sharedWorkspace() + self.notificationCenter = self.workspace.notificationCenter() def add_observer(fn, val): - notificationCenter.addObserver_selector_name_object_(self, fn, val, None) + self.notificationCenter.addObserver_selector_name_object_(self, fn, val, None) #NSWorkspaceWillPowerOffNotification add_observer(self.receiveSleepNotification_, NSWorkspaceWillSleepNotification) add_observer(self.receiveWakeNotification_, NSWorkspaceDidWakeNotification)