Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In gobject_move_ref, replace weak reference with strong reference in gc_preserve_glib #89

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/GLib/gtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,9 @@ end
function addref(@nospecialize(x::GObject))
# internal helper function
finalizer(delref, x)
gc_preserve_glib[WeakRef(x)] = false # record the existence of the object, but allow the finalizer
if !haskey(gc_preserve_glib, x)
gc_preserve_glib[WeakRef(x)] = false # record the existence of the object, but allow the finalizer
end
nothing
end
function gobject_maybe_sink(handle,owns::Bool)
Expand Down Expand Up @@ -426,6 +428,11 @@ function gobject_move_ref(new::GObject, old::GObject)
glib_ref(h)
gc_unref(old)
gc_ref(new)
# replace weak with strong reference
gc_preserve_glib_lock[] = true
filter!(x->!(isa(x.first,WeakRef) && x.first.value == new), gc_preserve_glib)
gc_preserve_glib[new] = true
gc_preserve_glib_lock[] = false
glib_unref(h)
new
end
Loading