diff options
author | Thomas White <taw@physics.org> | 2023-11-14 10:52:46 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2024-02-06 16:59:34 +0100 |
commit | 769915be06260591e2bdf5a04849dac269a2d3af (patch) | |
tree | dbec48265969ff830361017dd806c8f10760f165 | |
parent | b22775e1e512a28c6918a3f77cc91e55ef8a1750 (diff) |
Julia: Avoid segfault if image doesn't have a peak list
-rw-r--r-- | julia/CrystFEL/src/image.jl | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/julia/CrystFEL/src/image.jl b/julia/CrystFEL/src/image.jl index ca0a3da0..0ffb8474 100644 --- a/julia/CrystFEL/src/image.jl +++ b/julia/CrystFEL/src/image.jl @@ -33,7 +33,7 @@ mutable struct InternalImage div::Cdouble bw::Cdouble peak_resolution::Cdouble - peaks::Ptr{InternalPeakList} + peaklist::Ptr{InternalPeakList} ida::Ptr{Cvoid} end @@ -48,7 +48,17 @@ function Base.getproperty(image::Image, name::Symbol) getfield(image, :internalptr) else idata = unsafe_load(image.internalptr) - getproperty(idata, name) + if name === :peaklist + let pl = getproperty(idata, :peaklist) + if pl == C_NULL + throw(ErrorException("Image doesn't have a peak list")) + else + PeakList(pl) + end + end + else + getproperty(idata, name) + end end end |