Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filechooser: Fix crash when opening a file chooser with single filter set #448

Merged
merged 1 commit into from
Oct 18, 2023

Conversation

sidt4
Copy link
Contributor

@sidt4 sidt4 commented Oct 14, 2023

gtk_file_filter_new_from_gvariant () returns a GtkFileFilter which is a floating reference in GTK3. gtk_file_chooser_set_filter () takes ownership of this floating reference. So, we take a ref to the filter to account for the autoptr cleanup.

Note that this happens only when we have a single filter ( with 1 or more rules ) set via gtk_file_chooser_set_filter () in the app.

@sidt4
Copy link
Contributor Author

sidt4 commented Oct 15, 2023

Steps to reproduce in GNOME.

  1. Stop portal service using below command
$ systemctl --user stop xdg-desktop-portal*.service
  1. Disable xdg-desktop-portal-gnome portal using below command.
# cd /usr/share/xdg-desktop-portal/portals/
# mv gnome.portal gnome-disabled.portal
  1. Install and start GNOME Boxes flatpak
$ flatpak install org.gnome.Boxes
$ flatpak run org.gnome.Boxes
  1. Click + button in top left and select Install from file menu option.
  2. There should be no response, as xdg-desktop-portal-gtk has crashed.
  3. Verify from journalctl that xdg-desktop-portal-gtk has crashed.
  4. Undo step [2].

src/filechooser.c Outdated Show resolved Hide resolved
src/filechooser.c Outdated Show resolved Hide resolved
Copy link
Member

@GeorgesStavracas GeorgesStavracas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@GeorgesStavracas GeorgesStavracas enabled auto-merge (rebase) October 18, 2023 19:33
… set

'gtk_file_filter_new_from_gvariant()' returns a 'GtkFileFilter' which
is a floating reference in GTK3.

Since the portal is taking ownership of the file filter through
'g_autoptr', we call 'g_object_ref_sink()' unconditionally when
creating the filter instance.
@GeorgesStavracas GeorgesStavracas merged commit 1c09aaf into flatpak:main Oct 18, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants