Fix for re-entrant main window close when user hits 'x' again (#724)

Fixes #10897
This commit is contained in:
Paul Culley 2018-11-28 01:33:06 -06:00 committed by Sam Manzi
parent 999a3937d1
commit a02d7d0176

View File

@ -496,7 +496,7 @@ class ViewManager(CLIManager):
"""
Connects the signals needed
"""
self.window.connect('delete-event', self.quit)
self.del_event = self.window.connect('delete-event', self.quit)
self.notebook.connect('switch-page', self.view_changed)
if _GTKOSXAPPLICATION:
self.macapp.connect('NSApplicationWillTerminate', self.quit)
@ -801,12 +801,22 @@ class ViewManager(CLIManager):
self.dbstate.no_database()
self.post_close_db()
def no_del_event(self, *obj):
""" Routine to prevent window destroy with default handler if user
hits 'x' multiple times. """
return True
def quit(self, *obj):
"""
Closes out the program, backing up data
"""
# mark interface insenstitive to prevent unexpected events
self.uistate.set_sensitive(False)
# the following prevents reentering quit if user hits 'x' again
self.window.disconnect(self.del_event)
# the following prevents premature closing of main window if user
# hits 'x' multiple times.
self.window.connect('delete-event', self.no_del_event)
# backup data
if config.get('database.backup-on-exit'):