[nautilus/wip/oholy/encrypted-archive-crashes: 3/3] file-operations: Return NULL if password dialog was cancelled




commit 17e1cd13d5f1ae6834fa87e57f5379d151553854
Author: Ondrej Holy <oholy redhat com>
Date:   Wed Apr 21 09:41:01 2021 +0200

    file-operations: Return NULL if password dialog was cancelled
    
    Currently, an empty string is passed to gnome-autoar if the archive
    extraction password dialog is cancelled. This is not problem currently
    as immediately the `abort_job` function is called, however, it would
    be nice to return `NULL` to make obvious that the prompt dialog was
    cancelled.
    
    https://gitlab.gnome.org/GNOME/nautilus/-/merge_requests/657#note_1084750

 src/nautilus-file-operations.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c
index 09424b139..59beecd7e 100644
--- a/src/nautilus-file-operations.c
+++ b/src/nautilus-file-operations.c
@@ -8372,6 +8372,7 @@ typedef struct
     GtkWidget *passphrase_entry;
     GMutex mutex;
     GCond cond;
+    gboolean completed;
 } PassphraseRequestData;
 
 static void
@@ -8386,8 +8387,12 @@ on_request_passphrase_cb (GtkDialog *dialog,
     {
         abort_job ((CommonJob *) data->extract_job);
     }
+    else
+    {
+        data->passphrase = g_strdup (gtk_entry_get_text (GTK_ENTRY (data->passphrase_entry)));
+    }
 
-    data->passphrase = g_strdup (gtk_entry_get_text (GTK_ENTRY (data->passphrase_entry)));
+    data->completed = TRUE;
 
     gtk_widget_destroy (GTK_WIDGET (dialog));
 
@@ -8467,7 +8472,7 @@ extract_job_on_request_passphrase (AutoarExtractor *extractor,
                            run_passphrase_dialog,
                            data);
 
-    while (data->passphrase == NULL)
+    while (!data->completed)
     {
         g_cond_wait (&data->cond, &data->mutex);
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]