GNOME Bugzilla – Bug 708675
set_filename & set_uri broken in FileChooserDialog
Last modified: 2018-04-15 00:21:20 UTC
I have a Gtk::FileChooserDialog build with Gtk::Builder and want to use the same instance multiple times. Setting the uri with set_uri the first time works well. The second time nothing is selected and recent files are opened and the following error occured: (lt-titania:5803): Gtk-CRITICAL **: _gtk_file_system_model_get_iter_for_file: assertion `GTK_IS_FILE_SYSTEM_MODEL (model)' failed Source code: void BrowserWindow::on_save_as () { getFileSaveDialog () .set_uri (worldURL .filename () .str ()); auto response_id = getFileSaveDialog () .run (); getFileSaveDialog () .hide (); ... } Not the same instance is used multiple times. Neither set_filename, set_uri, select_filename, select_uri work the second time. I used libgtkmm-3.0-1 (3.6.0-0ubuntu1).
It's rather unlikely that this is a real bug in gtkmm or GTK+ because this would probably have been noticed by now. But even if it is, we would need a simple but complete test case to compile, please. Alternatively, running your application under valgrind might show you a problem in your application code.
My code is clean. I made a quick and small test with python and it does not work. Here the source code (replace the path with a path that exists on your system): --- #!/usr/bin/python from gi.repository import Gtk path = "file:///path_that_exists_on_your_system" dialog = Gtk .FileChooserDialog () dialog .set_uri (path) dialog .run () dialog .hide () dialog .set_uri (path) dialog .run () dialog .hide () --- On my system the dialog opens and selects the file as expected. The second time the recent files entry is shown. An error is not shown in the console.
So it's almost certainly not a bug in gtkmm. Reassigning to GTK+. However, I'm sure they would appreciate a test case in C. Maybe you can start with one of the existing GTK+ tests.
There have been issues with reusing the filechooser dialog for a while now. I created a bug to track all the different issue report a while back bug# 702853. I'll add this bug as a blocker but it could well be a duplicate, I don't have time to read the other bugs right now.
We're moving to gitlab! As part of this move, we are moving bugs to NEEDINFO if they haven't seen activity in more than a year. If this issue is still important to you and still relevant with GTK+ 3.22 or master, please reopen it and we will migrate it to gitlab.
As announced a while ago, we are migrating to gitlab, and bugs that haven't seen activity in the last year or so will be not be migrated, but closed out in bugzilla. If this bug is still relevant to you, you can open a new issue describing the symptoms and how to reproduce it with gtk 3.22.x or master in gitlab: https://gitlab.gnome.org/GNOME/gtk/issues/new