[geary] Don't hang on exit when forcing composer closed



commit 080becfc98b5de9ee7c60a2a6e8117f9399ca20a
Author: Jim Nelson <jim yorba org>
Date:   Tue Jan 13 13:19:30 2015 -0800

    Don't hang on exit when forcing composer closed
    
    Issue introduced with recent move to DraftManager.  When Geary is
    closed with an open composer, the window would hide but the app
    itself would hang.  This was due to telling the GearyController that
    a close was pending when it was not.  Now, when PENDING is returned,
    the draft is saved or discarded (based on user input) and the
    DraftManager fully closed, ensuring the I/O operation is flushed and
    completed.

 src/client/composer/composer-widget.vala |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index 0767dc0..b4b3689 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -915,13 +915,13 @@ public class ComposerWidget : Gtk.EventBox {
             return CloseStatus.CANCEL_CLOSE; // Cancel
         } else if (response == Gtk.ResponseType.OK) {
             if (try_to_save) {
-                save_and_exit(); // Save
+                save_and_exit_async.begin(); // Save
                 return CloseStatus.PENDING_CLOSE;
             } else {
                 return CloseStatus.DO_CLOSE;
             }
         } else {
-            discard_and_exit(); // Discard
+            discard_and_exit_async.begin(); // Discard
             return CloseStatus.PENDING_CLOSE;
         }
     }
@@ -1217,20 +1217,30 @@ public class ComposerWidget : Gtk.EventBox {
         cancel_draft_timer();
     }
     
-    private void save_and_exit() {
+    private async void save_and_exit_async() {
         make_gui_insensitive();
         
         save_draft();
+        try {
+            yield close_draft_manager_async(null);
+        } catch (Error err) {
+            // ignored
+        }
         
         container.close_container();
     }
     
-    private void discard_and_exit() {
+    private async void discard_and_exit_async() {
         make_gui_insensitive();
         
         discard_draft();
         if (draft_manager != null)
             draft_manager.discard_on_close = true;
+        try {
+            yield close_draft_manager_async(null);
+        } catch (Error err) {
+            // ignored
+        }
         
         container.close_container();
     }


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