Errors when using set_current_name on a FileChooserNative
When using set_current_name
on a FileChooserNative
I get the following error:
(python3:753): Gtk-CRITICAL **: 16:34:31.744: gtk_widget_is_ancestor: assertion 'GTK_IS_WIDGET (widget)' failed
(python3:753): GLib-GIO-CRITICAL **: 16:34:31.744: g_list_model_get_n_items: assertion 'G_IS_LIST_MODEL (list)' failed
/usr/lib/python3.8/site-packages/gi/overrides/Gio.py:42: Warning: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
return Gio.Application.run(self, *args, **kwargs)
This error is displayed before interacting with the dialog.
A reproducer in python is
import gi
gi.require_version("Gtk", "4.0")
from gi.repository import Gtk
def on_activate(app):
window = Gtk.ApplicationWindow(application=app)
def filechooser(button):
def callback(*args):
pass
dialog = Gtk.FileChooserNative.new(
"Dialog",
window,
Gtk.FileChooserAction.SAVE,
None,
None,
)
dialog.show()
dialog.set_current_name("File")
dialog.connect("response", callback, dialog)
button = Gtk.Button().new_with_label("FileChooser")
button.connect("clicked", filechooser)
window.set_child(button)
window.show()
app = Gtk.Application()
app.connect("activate", on_activate)
app.run()
Do note that the app does not crash.
EDIT: I forgot to keep a reference to the dialog.