GNOME Bugzilla – Bug 721278
format does not work when --xid option is present (breaks formatting from nautilus)
Last modified: 2014-01-09 18:07:46 UTC
When you right-click your USB stick in the nautilus sidebar and select format, nautilus calls gnome-disks like this (as verified by looking at /proc/`pgrep gnome-disks`/cmdline): gnome-disks --block-device /dev/sdb1 --format-device --xid 60817414 A dialog pops up and everything, but in the end, the disk is not formatted (no error message either). This is reported against nautilus in https://bugzilla.gnome.org/show_bug.cgi?id=703424 , however, the bug seems to be in gnome-disks as it can be reproduced by calling gnome-disks manually: 1) Open terminal window 2) Get the window id using xwininfo, convert to decimal 3) gnome-disks --block-device /dev/sdb1 --format-device --xid $WINDOWID 4) Click through dialogs 5) See that disk was not formatted
*** Bug 703424 has been marked as a duplicate of this bug. ***
Created attachment 265804 [details] [review] Be more careful with XIDs When an invalid XID is specified, we end up calling gdk_window_set_transient_for with a NULL window. This leads to a crash, so don't do it, and instead silently ignore the invalid XID.
This is just a robustness fix. The actual problem is that gnome-disks is using a GApplicationCommandline to implement the format when --xid is specified. And it is starting an async operation (gdu_utils_ensure_unused ) without calling g_application_hold. Thus, when gdu_format_volume_dialog_show_for_xid returns, the application exists without waiting for the async operation to complete.
Created attachment 265806 [details] [review] Make dialog work with --xid again When triggering an async operation from a GApplicationCommandline, we must use g_application_hold/release to ensure the application instance stays around until the operation is done.
Review of attachment 265804 [details] [review]: LGTM, thanks!
Review of attachment 265806 [details] [review]: Excellent catch, thanks!
Attachment 265804 [details] pushed as 62253c5 - Be more careful with XIDs Attachment 265806 [details] pushed as 0eb9516 - Make dialog work with --xid again