Skip to content

Commit 48b546e

Browse files
committed
ObjectBox store close will check and set the C pointer
E.g. better prevents using closed stored references
1 parent 3e138b6 commit 48b546e

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

objectbox/objectbox.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2019-2021 ObjectBox Ltd. All rights reserved.
1+
# Copyright 2019-2023 ObjectBox Ltd. All rights reserved.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -21,8 +21,6 @@ class ObjectBox:
2121
def __init__(self, c_store: OBX_store_p):
2222
self._c_store = c_store
2323

24-
self._closed = False
25-
2624
def __del__(self):
2725
self.close()
2826

@@ -33,7 +31,7 @@ def write_tx(self):
3331
return objectbox.transaction.write(self)
3432

3533
def close(self):
36-
if not self._closed:
37-
obx_store_close(self._c_store)
38-
self._closed = True
39-
34+
c_store_to_close = self._c_store
35+
if c_store_to_close:
36+
self._c_store = None
37+
obx_store_close(c_store_to_close)

0 commit comments

Comments
 (0)