Skip to content

Commit

Permalink
Merge pull request #18 from kyamagu/check-config-get-current
Browse files Browse the repository at this point in the history
Add owner prop in config
  • Loading branch information
kyamagu committed Sep 4, 2023
2 parents 944494e + a1d6c7f commit 8dd1312
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/fontconfig/fontconfig.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,14 @@ cdef class Config:
fonts = config.font_list(pattern, object_set)
"""
cdef c_impl.FcConfig* _ptr
cdef bint _owner

def __cinit__(self, ptr: int = 0):
def __cinit__(self, ptr: int, owner: bool = True):
self._ptr = <c_impl.FcConfig*>(<intptr_t>(ptr))
self._owner = owner

def __dealloc__(self):
if self._ptr is not NULL:
if self._ptr is not NULL and self._owner:
c_impl.FcConfigDestroy(self._ptr)

cdef intptr_t ptr(self):
Expand All @@ -108,7 +110,7 @@ cdef class Config:
@classmethod
def get_current(cls) -> Config:
"""Return current configuration"""
return cls(<intptr_t>c_impl.FcConfigReference(NULL))
return cls(<intptr_t>c_impl.FcConfigGetCurrent(), False)

def upto_date(self) -> bool:
"""Check timestamps on config files"""
Expand Down

0 comments on commit 8dd1312

Please sign in to comment.