From a34b2b4c512bea4f0083b601115a48bfc511d870 Mon Sep 17 00:00:00 2001 From: PeterPetrik Date: Thu, 18 Jan 2024 09:38:00 +0100 Subject: [PATCH] add __del__ to lib --- pygeodiff/geodifflib.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pygeodiff/geodifflib.py b/pygeodiff/geodifflib.py index 94cd72e..10abfc0 100644 --- a/pygeodiff/geodifflib.py +++ b/pygeodiff/geodifflib.py @@ -80,12 +80,16 @@ def __init__(self, name): self.check_version() self._register_functions() + def __del__(self): + self.shutdown() + def shutdown(self): - if platform.system() == "Windows": - from _ctypes import FreeLibrary + if self.lib is not None: + if platform.system() == "Windows": + from _ctypes import FreeLibrary - FreeLibrary(self.lib._handle) - self.lib = None + FreeLibrary(self.lib._handle) + self.lib = None def _register_functions(self): self._readChangeset = self.lib.GEODIFF_readChangeset