Skip to content

Commit

Permalink
fix: opening a moc from a pickle now increments the number of refs to…
Browse files Browse the repository at this point in the history
… the object in store
  • Loading branch information
ManonMarchand committed May 30, 2024
1 parent 03fd87f commit a017ef9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* `MOC.border` no does not attempt on plotting the border when the MOc is out of the
view anymore.
* fix an issue where the number of references to the rust side was not
incremented when a moc was created from a pickle file. This also solves a lot of issues
with the multiprocessing module that calls pickle behind the scenes.

### Added

Expand Down
6 changes: 6 additions & 0 deletions python/mocpy/abstract_moc.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ def __copy__(self):
def __deepcopy__(self, memo):
return self.__copy__()

def __setstate__(self, state):
# this is called when a MOC is unpickled
# we create a new ref count with copy
mocpy.copy(state["store_index"])
self.__dict__ = state

@staticmethod
def _store_index_dtype():
"""Store the datatype of the index.
Expand Down

0 comments on commit a017ef9

Please sign in to comment.