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

Error: method GdkPixbuf::Pixbuf.new_from_stream must return GdkPixbuf::Pixbuf but it is returning (GdkPixbuf::Pixbuf | Nil) #103

Open
phil294 opened this issue Aug 22, 2022 · 0 comments

Comments

@phil294
Copy link

phil294 commented Aug 22, 2022

# converting your_bytes into a pixbuf
stream = Gio::MemoryInputStream.new_from_bytes(GLib::Bytes.new(your_bytes))
pixbuf = GdkPixbuf::Pixbuf.new_from_stream(stream, nil)

fails with

 65119 | def self.new_from_stream(stream : Gio::InputStream, cancellable : Gio::Cancellable?) : self
                                                                                                ^
Error: method GdkPixbuf::Pixbuf.new_from_stream must return GdkPixbuf::Pixbuf but it is returning (GdkPixbuf::Pixbuf | Nil)

And here is the relevant snippet from the generated GdkPixbuf::Pixbuf:

def self.new_from_stream(stream : Gio::InputStream, cancellable : Gio::Cancellable?) : self
      __var0 = Pointer(LibGLib::Error).null
      __var1 = LibGdkPixbuf.pixbuf_new_from_stream(stream.to_unsafe_inputstream, cancellable ? cancellable.to_unsafe_cancellable : Pointer(LibGio::Cancellable).null, pointerof(__var0))
      GLib::Error.assert(__var0)
      __var2 = cast(GdkPixbuf::Pixbuf.new(__var1)) if __var1
      __var2
    end

This __var2 = something optional; return __var2 (this must always be failing (?)) with function return type self occurs several times in other functions too.


On an unrelated note, I want to mention that I have now been using crystal-gobject not only for Gtk but also for Atspi 2.0 bindings recently and it has been a bliss! Combined with the C docs it gives you everything you could ask for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant