Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gdk::ContentProvider#value must accept a GType somehow #61

Open
hugopl opened this issue Nov 4, 2023 · 0 comments
Open

Gdk::ContentProvider#value must accept a GType somehow #61

hugopl opened this issue Nov 4, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@hugopl
Copy link
Owner

hugopl commented Nov 4, 2023

Using Gtk::TextBuffer#selection_content returns a Gdk::ContentProvider object, this object can return its contents wrapped in a GValue, however the called must initialize the GValue to the right type before calling Gdk::ContentProvider#value, otherwise an error is thrown when e.g. a call for #as_s is done in the returned GValue:

Unhandled exception: Cannot obtain raw value for g_type 0 (ArgumentError)
  from lib/gi-crystal/src/bindings/g_object/value.cr:113:9 in 'raw'
  from lib/gi-crystal/src/bindings/g_object/value.cr:120:7 in 'raw'
  from lib/gi-crystal/src/bindings/g_object/value.cr:123:5 in 'as_s'

Current Gdk::ContentProvider#value generated binding implementation:

    def value : GObject::Value
      # gdk_content_provider_get_value: (Method | Throws)
      # @value: (out) (caller-allocates)
      # Returns: (transfer none)

      _error = Pointer(LibGLib::Error).null

      # Generator::CallerAllocatesPlan
      value = GObject::Value.new
      # C call
      _retval = LibGdk.gdk_content_provider_get_value(to_unsafe, value, pointerof(_error))

      # Error check
      Gdk.raise_gerror(_error) unless _error.null?

      # Return value handling
      value
    end

Note that the return value is also lost... i.e. I need to decide what to do with the tons of out values the GTK API has.

@hugopl hugopl added the bug Something isn't working label Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant