Refactor of UnitCell management
The aims of this merge are
- Eliminating the segfaults appearing during refinement in
SubframePredictPeaks
andSubframeRefiner
- Refactoring the management of
UnitCells
to avoid such segfaults in the future.
Now, all Peak3D
objects contain a std::weak_ptr<UnitCell>
instead of a UnitCell*
, pointing to a std::shared_ptr<UnitCell>
instead of a std::unique_ptr<UnitCell>
. The latter is a necessary change to implement the former. Problems were arising because thanks to the refiner, it was necessary to delete old unit cells assigned to batches, and create new unit cells. The UnitCell
underlying std::unique_ptr<UnitCell>
was deleted, but raw pointers to it remained. With the implementation of std::weak_ptr<UnitCell>
, every time a UnitCell*
is requested from a Peak3D
, the weak_ptr
checks that the underlying object has not been destroyed via std::weak_ptr::lock
.
Resolves #128 (closed)