From ff04bf072e9703f607b4a2aff695eb02a2cf5ac2 Mon Sep 17 00:00:00 2001
From: Dmitri Bogomolov <4glitch@gmail.com>
Date: Fri, 6 Jul 2018 15:16:22 +0300
Subject: [PATCH] Allow re-call of MyForm.quit() if user selected to wait at
 first

---
 src/bitmessageqt/__init__.py | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py
index 16d7a506..4f3efc18 100644
--- a/src/bitmessageqt/__init__.py
+++ b/src/bitmessageqt/__init__.py
@@ -627,8 +627,8 @@ class MyForm(settingsmixin.SMainWindow):
         self.replyFromTab = None
 
         # so that quit won't loop
-        self.quitAccepted = False
-        
+        self.wait = self.quitAccepted = False
+
         self.init_file_menu()
         self.init_inbox_popup_menu()
         self.init_identities_popup_menu()
@@ -2709,7 +2709,7 @@ class MyForm(settingsmixin.SMainWindow):
     # Quit selected from menu or application indicator
     def quit(self):
         """Quit the bitmessageqt application"""
-        if self.quitAccepted:
+        if self.quitAccepted and not self.wait:
             return
 
         self.show()
@@ -2761,7 +2761,7 @@ class MyForm(settingsmixin.SMainWindow):
                 QtGui.QMessageBox.Cancel
             )
             if reply == QtGui.QMessageBox.Yes:
-                waitForSync = True
+                self.wait = waitForSync = True
             elif reply == QtGui.QMessageBox.Cancel:
                 return
 
@@ -2781,7 +2781,7 @@ class MyForm(settingsmixin.SMainWindow):
             )
             if reply == QtGui.QMessageBox.Yes:
                 waitForConnection = True
-                waitForSync = True
+                self.wait = waitForSync = True
             elif reply == QtGui.QMessageBox.Cancel:
                 return
 
@@ -2904,11 +2904,6 @@ class MyForm(settingsmixin.SMainWindow):
         trayonclose = BMConfigParser().safeGetBoolean(
             'bitmessagesettings', 'trayonclose')
 
-        # always ignore, it shuts down by itself
-        if self.quitAccepted:
-            event.accept()
-            return
-
         event.ignore()
         if not trayonclose:
             # quit the application