ruby-vips 2.1.0 → 2.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -53,8 +53,9 @@ module Vips
53
53
  # it's the thing we return at the end of the mutate block.
54
54
  copy_image = image.copy
55
55
 
56
- # use ptr since we need the raw unwrapped pointer inside the image ...
57
- # and make the ref that gobject will unref when it finishes
56
+ # Use ptr since we need the raw unwrapped pointer inside the image ...
57
+ # and make the ref that gobject will unref when it finishes.
58
+ # See also the comment on set_type! before changing this.
58
59
  pointer = copy_image.ptr
59
60
  ::GObject.g_object_ref pointer
60
61
  super pointer
@@ -79,7 +80,7 @@ module Vips
79
80
  end
80
81
 
81
82
  def respond_to_missing? name, include_all = false
82
- # respond to all vips operations by nickname
83
+ # Respond to all vips operations by nickname.
83
84
  return true if Vips.type_find("VipsOperation", name.to_s) != 0
84
85
 
85
86
  super
@@ -115,7 +116,21 @@ module Vips
115
116
  gvalue = GObject::GValue.alloc
116
117
  gvalue.init gtype
117
118
  gvalue.set value
118
- Vips.vips_image_set self, name, gvalue
119
+
120
+ # libvips 8.9.1 had a terrible misfeature which would block metadata
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),
124
+ # so we must temporarily drop the refs to 1 around metadata changes.
125
+ #
126
+ # See https://github.com/libvips/ruby-vips/issues/291
127
+ begin
128
+ ::GObject.g_object_unref ptr
129
+ Vips.vips_image_set self, name, gvalue
130
+ ensure
131
+ ::GObject.g_object_ref ptr
132
+ end
133
+
119
134
  gvalue.unset
120
135
  end
121
136
 
@@ -148,7 +163,11 @@ module Vips
148
163
  #
149
164
  # @param name [String] Metadata field to remove
150
165
  def remove! name
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
151
169
  Vips.vips_image_remove self, name
170
+ ::GObject.g_object_ref ptr
152
171
  end
153
172
  end
154
173
  end
data/lib/vips/object.rb CHANGED
@@ -64,11 +64,8 @@ module Vips
64
64
 
65
65
  MARSHAL_PROGRESS = proc do |handler|
66
66
  FFI::Function.new(:void, [:pointer, :pointer, :pointer]) do |vi, prog, cb|
67
- begin
68
- handler.call(Progress.new(prog))
69
- rescue Exception => e
70
- puts "progress: #{e}"
71
- end
67
+ # this can't throw an exception, so no catch is necessary
68
+ handler.call(Progress.new(prog))
72
69
  end
73
70
  end
74
71
 
@@ -113,11 +110,8 @@ module Vips
113
110
 
114
111
  MARSHAL_FINISH = proc do |handler|
115
112
  FFI::Function.new(:void, [:pointer, :pointer]) do |i, cb|
116
- begin
117
- handler.call
118
- rescue Exception => e
119
- puts "finish: #{e}"
120
- end
113
+ # this can't throw an exception, so no catch is necessary
114
+ handler.call
121
115
  end
122
116
  end
123
117
 
@@ -48,7 +48,8 @@ module Vips
48
48
  class Introspect
49
49
  attr_reader :name, :description, :flags, :args, :required_input,
50
50
  :optional_input, :required_output, :optional_output, :member_x,
51
- :method_args, :vips_name, :destructive
51
+ :method_args, :vips_name, :destructive, :doc_optional_input,
52
+ :doc_optional_output
52
53
 
53
54
  @@introspect_cache = {}
54
55
 
@@ -142,6 +143,8 @@ module Vips
142
143
  @flags = Vips.vips_operation_get_flags @op
143
144
  @member_x = nil
144
145
  @method_args = []
146
+ @doc_optional_input = {}
147
+ @doc_optional_output = {}
145
148
 
146
149
  @args.each do |details|
147
150
  arg_name = details[:arg_name]
@@ -164,6 +167,17 @@ module Vips
164
167
  end
165
168
  end
166
169
  end
170
+
171
+ # and make the arg sets to document by filtering out deprecated args
172
+ @optional_input.each do |arg_name, details|
173
+ next if (details[:flags] & ARGUMENT_DEPRECATED) != 0
174
+ @doc_optional_input[details[:arg_name]] = details
175
+ end
176
+
177
+ @optional_output.each do |arg_name, details|
178
+ next if (details[:flags] & ARGUMENT_DEPRECATED) != 0
179
+ @doc_optional_output[details[:arg_name]] = details
180
+ end
167
181
  end
168
182
 
169
183
  def self.get name
data/lib/vips/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Vips
2
- VERSION = "2.1.0"
2
+ VERSION = "2.1.4"
3
3
  end
data/lib/vips.rb CHANGED
@@ -575,10 +575,17 @@ module Vips
575
575
  LOG_DOMAIN = "VIPS"
576
576
  GLib.set_log_domain LOG_DOMAIN
577
577
 
578
- typedef :ulong, :GType
578
+ # we can't just use ulong, windows has different int sizing rules
579
+ if FFI::Platform::ADDRESS_SIZE == 64
580
+ typedef :uint64, :GType
581
+ else
582
+ typedef :uint32, :GType
583
+ end
579
584
 
580
585
  attach_function :vips_error_buffer, [], :string
581
586
  attach_function :vips_error_clear, [], :void
587
+ attach_function :vips_error_freeze, [], :void
588
+ attach_function :vips_error_thaw, [], :void
582
589
 
583
590
  # The ruby-vips error class.
584
591
  class Error < RuntimeError
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-vips
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Cupitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-08 00:00:00.000000000 Z
11
+ date: 2021-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -204,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
204
204
  - !ruby/object:Gem::Version
205
205
  version: '0'
206
206
  requirements: []
207
- rubygems_version: 3.1.2
207
+ rubygems_version: 3.2.5
208
208
  signing_key:
209
209
  specification_version: 4
210
210
  summary: A fast image processing library with low memory needs