`Attempting to call back into JSAPI during the sweeping phase of GC` when Gtk.SignalListItemFactory unbinding.
System information
- GNOME OS (Nightly)
- GJS: 1.81.1
- GTK: 4.15.1
Bug information
Steps to reproduce
- Run the following program in terminal (
gjs -m test.js
):
// test.js
import System from 'system';
import GObject from 'gi://GObject';
import Gtk from 'gi://Gtk?version=4.0';
const App = GObject.registerClass(class extends Gtk.Application {
vfunc_activate() {
super.vfunc_activate();
const win = new Gtk.ApplicationWindow({application: this});
let dropDown = Gtk.DropDown.new_from_strings(Array.from({ length: 30 }, (_x, i) => `Option${i}`));
let listFactory = new Gtk.SignalListItemFactory();
listFactory.connect('setup', (_factory, entry) => entry.set_child(new Gtk.CheckButton({sensitive: false})))
listFactory.connect('bind', (_factory, entry) => {
entry.child.set_label(entry.item.string);
// let onSelect = () => entry.child.set_active(dropDown.get_selected_item() === entry.item);
// entry._handler = dropDown.connect('notify::selected-item', onSelect);
// onSelect();
});
listFactory.connect('unbind', (_factory, entry) => {
// dropDown.disconnect(entry._handler);
// delete entry._handler;
});
dropDown.set_list_factory(listFactory);
win.set_child(dropDown);
win.set_default_size(200, 200);
win.present();
}
});
new App().run([imports.system.programInvocationName, ...System.programArgs]);
- Close the app window and see the output.
Current behaviour
...
(gjs:3103): Gjs-CRITICAL **: 23:42:53.960: Attempting to call back into JSAPI during the sweeping phase of GC. This is most likely caused by not destroying a Clutter actor or Gtk+ widget with ::destroy signals connected, but can also be caused by using the destroy(), dispose(), or remove() vfuncs. Because it would crash the application, it has been blocked and the JS callback not invoked.
The offending signal was unbind on GtkSignalListItemFactory 0x55683cc49330.
== Stack trace for context 0x55683c967210 ==
...
The same error is mentioned here.
Expected behaviour
As error-free as without connecting unbind
.
Edited by tuberry