@@ -119,16 +119,16 @@ def set_type! gtype, name, value
119
119
120
120
# libvips 8.9.1 had a terrible misfeature which would block metadata
121
121
# modification unless the object had a ref_count of 1. MutableImage
122
- # will always have a ref_count of at least 2 (the parent gobject keeps a
123
- # ref, and we keep a ref to the copy ready to return to our caller),
122
+ # will always have a ref_count of at least 2 (the parent gobject keeps a
123
+ # ref, and we keep a ref to the copy ready to return to our caller),
124
124
# so we must temporarily drop the refs to 1 around metadata changes.
125
125
#
126
126
# See https://github.com/libvips/ruby-vips/issues/291
127
127
begin
128
- ::GObject . g_object_unref self . ptr
128
+ ::GObject . g_object_unref ptr
129
129
Vips . vips_image_set self , name , gvalue
130
130
ensure
131
- ::GObject . g_object_ref self . ptr
131
+ ::GObject . g_object_ref ptr
132
132
end
133
133
134
134
gvalue . unset
@@ -163,13 +163,11 @@ def set! name, value
163
163
#
164
164
# @param name [String] Metadata field to remove
165
165
def remove! name
166
- # See set_type! for an explanation.
167
- begin
168
- ::GObject . g_object_unref self . ptr
169
- Vips . vips_image_remove self , name
170
- ensure
171
- ::GObject . g_object_ref self . ptr
172
- end
166
+ # See set_type! for an explanation. Image#remove can't throw an
167
+ # exception, so there's no need to ensure we unref.
168
+ ::GObject . g_object_unref ptr
169
+ Vips . vips_image_remove self , name
170
+ ::GObject . g_object_ref ptr
173
171
end
174
172
end
175
173
end
0 commit comments