require 'qml/c_lib'
module QML
  class QtObjectBase

    def initialize(ptr)
      self.pointer = ptr
      @_gc_protected = []
    end

    def pointer
      @_pointer
    end

    def pointer=(ptr)
      @_pointer = FFI::AutoPointer.new(ptr, CLib.method(:qobject_destroy))
    end

    def gc_protect(obj)
      @_gc_protected << obj
    end

  end
end
require 'qml/c_lib'
module QML
  class QtObjectBase

    attr_reader :pointer

    def initialize(ptr, destroy: true)
      fail TypeError, 'ptr must be a FFI::Pointer' unless ptr.is_a? FFI::Pointer
      @pointer = destroy ? FFI::AutoPointer.new(ptr, CLib.method(:qobject_destroy)) : ptr
      @gc_protected = []
    end

    def gc_protect(obj)
      @gc_protected << obj
    end

  end
end
Add destroy: option to QtObjectBase.new
Add destroy: option to QtObjectBase.new
