Crash on ListBoxRow.get_index
We received an issue in the gtk4 rust bindings where get_index
of Gtk.ListBoxRow causes a crash
Upstream issue: https://github.com/gtk-rs/gtk4-rs/issues/447
I managed to reproduce it with Python
from gi import require_version
require_version("Gtk", "4.0")
from gi.repository import Gtk
class App(Gtk.Application):
def __init__(self):
super().__init__()
def do_activate(self):
window = Gtk.ApplicationWindow.new(self)
vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
self.listbox = Gtk.ListBox.new()
self.listbox.append(Gtk.Label.new("Crash"))
button = Gtk.Button.new_with_label("Click me")
button.connect("clicked", self.on_clicked)
vbox.append(self.listbox)
vbox.append(button)
window.set_child(vbox)
window.show()
def on_clicked(self, button):
row = self.listbox.get_selected_row()
self.listbox.remove(row)
print(row.get_index())
def main():
app = App()
app.run()
main()
The crash only happens from time to time whenever you click on the button. Normally, if the row isn't part of the listbox anymore, it should return an index of -1 instead of crashing.
The backtrace doesn't contain anything useful other than the issue happening on glib side, at 0 0x00007fffe9fc9b28 in node_get_pos () at /lib64/libglib-2.0.so.0
. I assume there's a missing g_return_if_fail
that validates the GSequenceIter
.