Skip to content

Commit f40b948

Browse files
committed
DSSContext disposal: just mark it with CFFI's gc function; works great.
Doing this, all the user needs to do is keep the ctx pointer reference alive to keep the context alive. No need to further complicate tracking it.
1 parent 622d443 commit f40b948

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

dss/IDSS.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ def NewContext(self) -> Self:
322322
'''
323323
ffi = self._api_util.ffi
324324
lib = self._api_util.lib_unpatched
325-
new_ctx = lib.ctx_New()
325+
new_ctx = ffi.gc(lib.ctx_New(), lib.ctx_Dispose)
326326
new_api_util = CffiApiUtil(ffi, lib, new_ctx)
327327
return IDSS(new_api_util)
328328

dss/_cffi_api_util.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,12 @@ def __init__(self, ffi, lib, ctx=None):
205205
CffiApiUtil._ADV_TYPES = self.lib.DSS_Get_EnableArrayDimensions()
206206

207207

208-
def __delete__(self):
209-
if self.ctx is None:
210-
return
208+
# def __delete__(self):
209+
# if self.ctx is None:
210+
# return
211211

212-
if self.lib.ctx_Get_Prime() != self.ctx and self.owns_ctx:
213-
self.lib.ctx_Dispose(self.ctx)
212+
# if self.lib.ctx_Get_Prime() != self.ctx and self.owns_ctx:
213+
# self.lib.ctx_Dispose(self.ctx)
214214

215215
def init_buffers(self):
216216
tmp_string_pointers = (self.ffi.new('char****'), self.ffi.new('int32_t**'))

0 commit comments

Comments
 (0)