get object from property does not make a reference
jcupitt opened this issue · comments
When I fetch a GObject
from a property it doesn't seem to make a reference, or drop a reference on GC. For example:
x = op.property("out").get_value
where op
is a GObject
which has a property called "out"
whose value is another GObject
.
After this line, I'd expect (I think?) x
to point to the value of out
, I'd expect that GObject
to be reffed, and I'd expect that ref to be dropped if I do:
x = nil
GC.start
Assuming nothing else is holding a pointer to that object.
Complete test program, for reference:
#!/usr/bin/ruby
require 'gir_ffi'
GirFFI.setup :Vips
Vips::init($PROGRAM_NAME)
Vips::cache_set_max 0
op = Vips::Operation.new "jpegload"
op.set_property "filename", "/data/john/pics/k2.jpg"
puts "** objects before build:"
Vips::Object::print_all
op2 = Vips::cache_operation_build op
puts "** objects after build:"
Vips::Object::print_all
GObject::Lib.g_object_unref op
op = nil
out = op2.property("out").get_value
op2.unref_outputs
op2 = nil
GC.start
puts "** objects after running operation:"
Vips::Object::print_all
out = nil
GC.start
puts "** objects after tidy up:"
Vips::Object::print_all
I think I have this completely confused. I'll close and try again when I have a better question.