Place1 / node-gir

Node bindings to libgirepository
http://live.gnome.org/GObjectIntrospection
MIT License
27 stars 6 forks source link

Connecting a notify::property-name signal segfaults #40

Closed BinaryMuse closed 6 years ago

BinaryMuse commented 6 years ago

Calling connect with a signal that starts with "notify::" causes Node to segfault.

Here is a case that reproduces on my machine (uncomment the commented line to see the segfault):

const Gtk = require('node-gir').Gtk
const Gdk = require('node-gir').load('Gdk', '3.0')

const win = new Gtk.Window({
  type: Gtk.WindowType.TOPLEVEL,
  title: 'Signal Crash',
})

// Not sure if this is necessary on the window or button;
// have added it to both.
win.addEvents(Gdk.EventMask.PROPERTY_CHANGE_MASK)
win.connect('destroy', () => Gtk.mainQuit())

const button = new Gtk.ColorButton()
button.addEvents(Gdk.EventMask.PROPERTY_CHANGE_MASK)
win.add(button)

button.connect('color-set', () => console.log(button.rgba.toString()))
// button.connect('notify::color', () => console.log(button.rgba.toString()))

win.showAll()
Gtk.main()

I tried digging into why this is happening with no luck (though to be frank I know little to nothing about GTK).

Working off 9668a34fc8aa67e581063f091718ec4b266be752.

Place1 commented 6 years ago

I've opened a PR that fixes this bug. One caveat is that the arguments passed to the notify:: signal callback aren't correct just yet. the callback will be called correctly but the arguments it receives should be considered incorrect/wrong because I haven't implemented that correctly.

clayrisser commented 6 years ago

So @BinaryMuse, is GitHub using node-gir, or is it personal projects?

BinaryMuse commented 6 years ago

@Place1 Awesome, thanks for tackling this!

@codejamninja Personal project :)