def __init__(self): self.config = coreaux_api.get_interface_configuration('wxgui') wx.App.__init__(self, False) self.artprovider = art.ArtProvider() self.root = MainFrame() self.logs_configuration = logs.LogsConfiguration() self.menu = self.root.menu self.nb_left = self.root.mainpanes.nb_left self.nb_right = self.root.mainpanes.nb_right self.uncaught_max = self.config.get_int('max_exceptions') self.uncaught_counter = 0 self.uncaught_event = threading.Event() core_api.bind_to_blocked_databases(self._handle_blocked_databases) if self.uncaught_max > 0: coreaux_api.bind_to_uncaught_exception( self._handle_uncaught_exception) # Window managers like i3 and awesome need MainFrame to be shown here, # not at the end of its constructor, or EVT_WINDOW_CREATE will be sent # too early (bug #366) self.root.Centre() self.root.Show(True)
def exit_app(self, event): self._export_options() # Refresh the session also when exiting, in order to save the order of # visualization of the tabs # Do it *before* closing the databases self.root.sessionmanager.refresh_session() # close_all_databases() already blocks the databases if self.menu.file.close_all_databases(event, exit_=True): core_api.exit_() coreaux_api.bind_to_uncaught_exception( self._handle_uncaught_exception, False) self.root.Destroy()
def _show_uncaught_dialog(self, kwargs): msgboxes.uncaught_exception(kwargs['exc_info']).ShowModal() if self.uncaught_counter == 1: # Only unbind here, otherwise another thread that crashes would # bypass this whole mechanism coreaux_api.bind_to_uncaught_exception( self._handle_uncaught_exception, False) self.root.Destroy() # No need to set self.uncaught_counter = 0 self.uncaught_event.set() # No need to call self.uncaught_event.clear() else: self.uncaught_counter -= 1