After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 732567 - Run with closed Window (was: Restore Disk Image completes only partially if gnome-disks is closed)
Run with closed Window (was: Restore Disk Image completes only partially if g...
Status: RESOLVED OBSOLETE
Product: gnome-disk-utility
Classification: Core
Component: general
3.25.x
Other Linux
: Normal enhancement
: ---
Assigned To: Kai Lüke
gnome-disk-utility-maint
Depends on:
Blocks:
 
 
Reported: 2014-07-01 17:42 UTC by Michael Catanzaro
Modified: 2018-05-24 10:29 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Prompt to cancel jobs when closing (4.62 KB, patch)
2017-05-15 16:00 UTC, Kai Lüke
none Details | Review
backtrace of segfault after click to ok (36.99 KB, text/plain)
2017-05-16 09:37 UTC, Ondrej Holy
  Details
Prompt to stop jobs when closing (3.93 KB, patch)
2017-05-16 17:55 UTC, Kai Lüke
committed Details | Review

Description Michael Catanzaro 2014-07-01 17:42:46 UTC
* Begin writing a disk image to a device using Restore Disk Image
* Close gnome-disks

Expected: either a warning message appears to tell me that the operation will be canceled, OR the operation continues in the background and I can see the progress when I reopen gnome-disks

Actual: it looks like it just gets canceled without any warning

I did this accidentally once (not sure what possessed me, I should have known better), nearing the end of a long write, and was not happy.
Comment 1 drws 2015-09-25 17:38:11 UTC
Confirming this also on v3.14.0!
Comment 2 Kai Lüke 2017-05-15 16:00:55 UTC
Created attachment 351898 [details] [review]
Prompt to cancel jobs when closing

Closing Disks used to silently discontinue running
jobs like restoring or creating disk images.

Now a message dialog warns that closing Disk will
cancel the jobs. Also they are canceled explicitly
if the user decides to close Disks.
Comment 3 Ondrej Holy 2017-05-16 09:37:39 UTC
Review of attachment 351898 [details] [review]:

Thanks for the patch!

::: src/disks/gduapplication.c
@@ +84,3 @@
+    {
+      GHashTableIter iter;
+      GList *local_jobs, *jobs_to_cancel = NULL, *l;

nitpick: I would reorder the declarations to move the initializer to the end, or add it on the new line...:
GList *l, *local_jobs, *jobs_to_cancel = NULL;

@@ +88,3 @@
+      g_hash_table_iter_init (&iter, app->local_jobs);
+
+      while (g_hash_table_iter_next (&iter, NULL /* object*/, (gpointer) &local_jobs))

nitpick: /* object*/ -> /* object */

@@ +101,3 @@
+gdu_application_should_exit (GduApplication *app)
+{
+  GtkDialogFlags flags = GTK_DIALOG_DESTROY_WITH_PARENT;

nitpick: Why not use this directly in the gtk_message_dialog_new?

@@ +113,3 @@
+                                       _("Cancel running jobs?"));
+      gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+                                                _("Closing the application now will cancel the running jobs."));

I think that this needs better wording, because you are asking on canceling of jobs and then you have two options cancel and ok, but the cancel means canceling of dialog, not the jobs, which is pretty confusing to me... Try to find what other applications do in similar situation.

@@ +121,3 @@
+        return FALSE;
+
+      cancel_jobs (app);

Hmm, it seems to me that this is probably not needed, because it more or less just calls gdu_application_destroy_local_job, which will be called from gdu_application_finalize anyway... what do you think?

@@ +377,3 @@
                 gpointer       user_data)
 {
   GduApplication *app = GDU_APPLICATION (user_data);

nitpick: I would add an empty line between declaration and the following code since we are going to enlarge the code...
Comment 4 Ondrej Holy 2017-05-16 09:37:46 UTC
Created attachment 351956 [details]
backtrace of segfault after click to ok

It segfaulted once when I clicked to ok in the new dialog. Please take a look at the attached backtrace...
Comment 5 Kai Lüke 2017-05-16 17:55:57 UTC
Created attachment 351987 [details] [review]
Prompt to stop jobs when closing

Thanks, trying to cancel or destroy the jobs during the close phase is indeed a bad idea and triggers also assertions to fail in some cases. For that to work it would need to first reject the delete-event, wait for all job cancel signals to be processed and then close the window.
But since canceling jobs and finalize is all about cleaning memory I think we can just leave this unnecessary complexity.

I chose »stop« as new term instead of having »cancel« appear twice.
Comment 6 Ondrej Holy 2017-05-19 08:30:19 UTC
Review of attachment 351987 [details] [review]:

Looks good to me, however, I still see segfaults when closing... I think we can push this, because the segfaults are not caused by this patch, however, it would be nice to fix them as a part of this bug report...

note: Nautilus shows notification "1 file operation active" after closing without any dialog and continue with the operation... this would be nice also for Disks for future :-)

::: src/disks/gduapplication.c
@@ +89,3 @@
+                                       GTK_DIALOG_DESTROY_WITH_PARENT,
+                                       GTK_MESSAGE_WARNING,
+                                       GTK_BUTTONS_OK_CANCEL,

note: "Close" is usually used instead of "Ok" in such case (e.g. "Close without saving"), but "Ok" makes sense in this context as an answer to the question, so ok :-)
Comment 7 Kai Lüke 2017-05-19 15:13:20 UTC
Acutally the AppData description tells that jobs would continue when being closed. But that only make sense if closing the window does not quit the whole gapplication as currently happening – either is was keeping it running was never working or just broken some day during code rewrites… Anyway there must be a notification like with Nautilus.

I think it's good to keep the current patch until we have it. Should I rename this bug?
Comment 8 Kai Lüke 2017-05-19 15:16:37 UTC
Ah, no. This bug is older than the AppData text.
Comment 9 Kai Lüke 2017-06-26 20:33:24 UTC
As a simple solution the window could just be hidden and later shown again from gduapplication.

Then it would be possible to do what Nautilus does.

Canceling should still be shown as possible reaction on closing the window (maybe in the notification, maybe as question whether to run in the background or cancel the jobs).
Comment 10 GNOME Infrastructure Team 2018-05-24 10:29:55 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gnome-disk-utility/issues/22.