diff options
author | Thomas White <taw@physics.org> | 2024-01-04 10:50:40 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2024-02-06 16:59:35 +0100 |
commit | 0273eb0b50ff17feb12a0a1e0ac7ee5dc1233622 (patch) | |
tree | 48d01eabebb16bcbbd875db2b407ecf60966295f /julia/CrystFEL | |
parent | 1f2185b46932d2a3c107a3f823b90a46a84ce202 (diff) |
Julia: Make a copy of the cell when creating a Crystal
We could do some more reference tracking stuff here, but it seems a
little excessive.
Diffstat (limited to 'julia/CrystFEL')
-rw-r--r-- | julia/CrystFEL/src/crystal.jl | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/julia/CrystFEL/src/crystal.jl b/julia/CrystFEL/src/crystal.jl index 1ab2a068..129c028c 100644 --- a/julia/CrystFEL/src/crystal.jl +++ b/julia/CrystFEL/src/crystal.jl @@ -23,9 +23,14 @@ function Crystal(cell::UnitCell; profileradius=2e6, mosaicity=0) throw(ArgumentError("Failed to create crystal")) end + # We make a copy of the cell, to avoid memory model shenanigans + uccopy = ccall((:cell_new_from_cell, libcrystfel), + Ptr{InternalUnitCell}, (Ptr{InternalUnitCell},), + cell.internalptr) + ccall((:crystal_set_cell, libcrystfel), Cvoid, (Ptr{InternalCrystal},Ptr{InternalUnitCell}), - out, cell.internalptr) + out, uccopy) ccall((:crystal_set_profile_radius, libcrystfel), Cvoid, (Ptr{InternalCrystal},Cdouble), |