Skip to content

Commit

Permalink
make sure value wrapped in mutable is not garbage collected (#682)
Browse files Browse the repository at this point in the history
Co-authored-by: Kristoffer Carlsson <kcarlsson89@gmail.com>
Co-authored-by: Valentin Churavy <vchuravy@mit.edu>
  • Loading branch information
3 people committed Dec 27, 2022
1 parent 57c3bfe commit c3828bd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Gtk"
uuid = "4c0ca9eb-093a-5379-98c5-f87ac0bbbf44"
version = "1.2.2"
version = "1.2.3"

[deps]
Cairo = "159f3aea-2a34-519c-b102-8c37f9878175"
Expand Down
4 changes: 2 additions & 2 deletions src/GLib/MutableTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ mutable(x::Ptr{T}, i = 1) where {T} = x + (i - 1) * sizeof(T)
mutable(x::T, i) where {T} = (i == 1 ? mutable(x) : error("Object only has one element"))

_addrof(b::T) where {T} = pointer_from_objref(b)
Base.cconvert(::Type{P}, b::MutableX{T}) where {P <: Ptr, T} = isbitstype(T) ? convert(P, _addrof(b)) : convert(P, _addrof(b.x))
Base.cconvert(::Type{P}, b::MutableA{T, N}) where {P <: Ptr, T, N} = convert(P, pointer(b.x, b.i))
Base.unsafe_convert(::Type{P}, b::MutableX{T}) where {P <: Ptr, T} = isbitstype(T) ? convert(P, _addrof(b)) : convert(P, _addrof(b.x))
Base.unsafe_convert(::Type{P}, b::MutableA{T, N}) where {P <: Ptr, T, N} = convert(P, pointer(b.x, b.i))

deref(b::Ptr) = unsafe_load(b)
deref(b::MutableX) = b.x
Expand Down

2 comments on commit c3828bd

@timholy
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/74672

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.2.3 -m "<description of version>" c3828bdb2f0d2cc59e7dc864d131818c21431d34
git push origin v1.2.3

Please sign in to comment.