From d498b07533d9a14d72cdbb44f3f7a07f1c9e86ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 2 May 2011 15:35:09 +0200 Subject: fix REcorePipe pointer mangement --- lib/efl/ecore.rb | 11 +++++++++-- spec/ecore_spec.rb | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/efl/ecore.rb b/lib/efl/ecore.rb index b4d8aaa..4938651 100644 --- a/lib/efl/ecore.rb +++ b/lib/efl/ecore.rb @@ -17,9 +17,16 @@ module Efl # class REcorePipe def initialize cb, data - @ptr = Efl::Ecore.ecore_pipe_add cb, data + @ptr = FFI::AutoPointer.new Efl::Ecore.ecore_pipe_add(cb, data), REcorePipe.method(:release) + end + def self.release p + Efl::Ecore.ecore_pipe_del p + end + def del + @ptr.autorelease=false + REcorePipe.release @ptr + @ptr=nil end - def del; Efl::Ecore.ecore_pipe_del @ptr; end def read_close; Efl::Ecore.ecore_pipe_read_close @ptr; end def write_close; Efl::Ecore.ecore_pipe_write_close @ptr; end def write data diff --git a/spec/ecore_spec.rb b/spec/ecore_spec.rb index 58a5387..6633156 100644 --- a/spec/ecore_spec.rb +++ b/spec/ecore_spec.rb @@ -55,7 +55,7 @@ describe Efl::Ecore do Ecore.main_loop_iterate pipe.read_close pipe.write_close - pipe.del.address.should == data.address + pipe.del Ecore.shutdown end # -- cgit v1.1-2-g2b99