Skip to content

Refactor of UnitCell management

Raza, Zamaan requested to merge unit_cell_management into develop

The aims of this merge are

  1. Eliminating the segfaults appearing during refinement in SubframePredictPeaks and SubframeRefiner
  2. 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)

Merge request reports