Skip to content

Commit

Permalink
add a detach method to server objects, since the order of dealloc is …
Browse files Browse the repository at this point in the history
…not defined we may need to detach before removing objects and properties to ensure we don't have activity on properties that no longer exist
  • Loading branch information
charleseidsness committed Dec 13, 2023
1 parent 2511b0b commit fe6da8a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion adbus/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# == Copyright: 2017-2023, CCX Technologies

__version__ = "1.2.6"
__version__ = "1.2.7"
3 changes: 3 additions & 0 deletions adbus/sdbus/object.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ cdef class Object:
self._populate_vtable()
self._register_vtable()

def detach(self):
self._slot = sdbus_h.sd_bus_slot_unref(self._slot)

def __dealloc__(self):
self._slot = sdbus_h.sd_bus_slot_unref(self._slot)
PyMem_Free(self._vtable)
Expand Down
3 changes: 3 additions & 0 deletions adbus/server/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ def defer_property_updates(self, enable):

self._deferred_property_signals = {}

def detach(self):
self.sdbus.detach()

def __enter__(self):
self.defer_property_updates(True)
return self
Expand Down

0 comments on commit fe6da8a

Please sign in to comment.