hugopl / gi-crystal

Tool to generate Crystal bindings for gobject-based libraries (i.e. GTK)
BSD 3-Clause "New" or "Revised" License
45 stars 3 forks source link

transfer full interface parameters don't get their reference increased. #120

Closed hugopl closed 1 year ago

hugopl commented 1 year ago

Gtk::SingleSelection class has this generated constructor:

    def self.new(model : Gio::ListModel?) : self
      # gtk_single_selection_new: (Constructor)
      # @model: (transfer full) (nullable)
      # Returns: (transfer full)

      # Generator::NullableArrayPlan
      model = if model.nil?
                Pointer(Void).null
              else
                model.to_unsafe
              end

      # C call
      _retval = LibGtk.gtk_single_selection_new(model)

      # Return value handling

      Gtk::SingleSelection.new(_retval, GICrystal::Transfer::Full)
    end

model is an interface, but for some reason ArgStrategy clas schoose NullableArrayPlan for it and generated wrong code.

correct code must use the TransferFullArgPlan and increase the object reference.