Skip to content

Commit

Permalink
Move Variant#constructor_wrap override to #store_pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
mvz committed Sep 17, 2015
1 parent 14a8441 commit 2b6162f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/ffi-glib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ module Lib
attach_function :g_ptr_array_foreach, [:pointer, Func, :pointer], :pointer

attach_function :g_iconv_open, [:pointer, :pointer], :pointer
attach_function :g_variant_ref_sink, [:pointer], :pointer
end
end
11 changes: 9 additions & 2 deletions lib/ffi-glib/variant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ def get_string_with_override
get_string_without_override.first
end

def self.constructor_wrap ptr
super.tap(&:ref)
# Initializing method used in constructors. For Variant, this needs to sink
# the variant's floating reference.
#
# NOTE: This is very hard to test since it is not possible to get the
# variant's ref count directely. However, there is an error when running
# the tests on 32-bit systems.
def store_pointer ptr
super
::GLib::Lib.g_variant_ref_sink ptr
end

alias_method :get_string_without_override, :get_string
Expand Down

0 comments on commit 2b6162f

Please sign in to comment.