Ignore close events that occur after shutdown has started

This commit is contained in:
Kovid Goyal 2016-07-27 12:06:52 +05:30
parent 34bbb6ab17
commit 14acd78494

View File

@ -129,6 +129,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
proceed_requested = pyqtSignal(object, object) proceed_requested = pyqtSignal(object, object)
book_converted = pyqtSignal(object, object) book_converted = pyqtSignal(object, object)
shutting_down = False
def __init__(self, opts, parent=None, gui_debug=None): def __init__(self, opts, parent=None, gui_debug=None):
global _gui global _gui
@ -883,6 +884,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
return True return True
def shutdown(self, write_settings=True): def shutdown(self, write_settings=True):
self.shutting_down = True
self.show_shutdown_message() self.show_shutdown_message()
from calibre.customize.ui import has_library_closed_plugins from calibre.customize.ui import has_library_closed_plugins
@ -970,6 +972,8 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
QApplication.instance().quit() QApplication.instance().quit()
def closeEvent(self, e): def closeEvent(self, e):
if self.shutting_down:
return
self.write_settings() self.write_settings()
if self.system_tray_icon is not None and self.system_tray_icon.isVisible(): if self.system_tray_icon is not None and self.system_tray_icon.isVisible():
if not dynamic['systray_msg'] and not isosx: if not dynamic['systray_msg'] and not isosx: