From 42f1952e15511cce3c5cc42d58ab65f618e19db6 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Tue, 9 Mar 2010 21:48:57 +0100 Subject: [PATCH] don't print a second DB error message if a first one is already shown. Fixes #5637 --- src/common/connection.py | 4 +++- src/common/connection_handlers.py | 17 +++++++++-------- src/gui_interface.py | 11 +++++++++++ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/common/connection.py b/src/common/connection.py index d9eda34f4..4a025f42c 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -430,13 +430,15 @@ class CommonConnection: try: gajim.logger.write(kind, jid, log_msg) except exceptions.PysqliteOperationalError, e: - self.dispatch('ERROR', (_('Disk Write Error'), str(e))) + self.dispatch('DB_ERROR', (_('Disk Write Error'), + str(e))) except exceptions.DatabaseMalformed: pritext = _('Database Error') sectext = _('The database file (%s) cannot be read. Try to ' 'repair it (see http://trac.gajim.org/wiki/DatabaseBackup)' ' or remove it (all history will be lost).') % \ common.logger.LOG_DB_PATH + self.dispatch('DB_ERROR', (pritext, sectext)) def ack_subscribed(self, jid): """ diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index 6cdb182ae..816dc3a91 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -1566,13 +1566,13 @@ ConnectionCaps, ConnectionHandlersBase, ConnectionJingle): gajim.logger.write('error', frm, error_msg, tim=tim, subject=subject) except exceptions.PysqliteOperationalError, e: - self.dispatch('ERROR', (_('Disk Write Error'), str(e))) + self.dispatch('DB_ERROR', (_('Disk Write Error'), str(e))) except exceptions.DatabaseMalformed: pritext = _('Database Error') sectext = _('The database file (%s) cannot be read. Try to repair ' 'it (see http://trac.gajim.org/wiki/DatabaseBackup) or remove ' 'it (all history will be lost).') % common.logger.LOG_DB_PATH - self.dispatch('ERROR', (pritext, sectext)) + self.dispatch('DB_ERROR', (pritext, sectext)) self.dispatch('MSGERROR', (frm, msg.getErrorCode(), error_msg, msgtxt, tim, session)) @@ -1617,13 +1617,13 @@ ConnectionCaps, ConnectionHandlersBase, ConnectionJingle): self.last_history_time[jid] = mktime(tim) except exceptions.PysqliteOperationalError, e: - self.dispatch('ERROR', (_('Disk Write Error'), str(e))) + self.dispatch('DB_ERROR', (_('Disk Write Error'), str(e))) except exceptions.DatabaseMalformed: pritext = _('Database Error') sectext = _('The database file (%s) cannot be read. Try to repair ' 'it (see http://trac.gajim.org/wiki/DatabaseBackup) or remove ' 'it (all history will be lost).') % common.logger.LOG_DB_PATH - self.dispatch('ERROR', (pritext, sectext)) + self.dispatch('DB_ERROR', (pritext, sectext)) def dispatch_invite_message(self, invite, frm): item = invite.getTag('invite') @@ -1811,14 +1811,15 @@ ConnectionCaps, ConnectionHandlersBase, ConnectionJingle): try: gajim.logger.write('gcstatus', who, st, show) except exceptions.PysqliteOperationalError, e: - self.dispatch('ERROR', (_('Disk Write Error'), str(e))) + self.dispatch('DB_ERROR', (_('Disk Write Error'), + str(e))) except exceptions.DatabaseMalformed: pritext = _('Database Error') sectext = _('The database file (%s) cannot be read. Try to ' 'repair it (see http://trac.gajim.org/wiki/DatabaseBackup)' ' or remove it (all history will be lost).') % \ common.logger.LOG_DB_PATH - self.dispatch('ERROR', (pritext, sectext)) + self.dispatch('DB_ERROR', (pritext, sectext)) if avatar_sha or avatar_sha == '': if avatar_sha == '': # contact has no avatar @@ -1961,14 +1962,14 @@ ConnectionCaps, ConnectionHandlersBase, ConnectionJingle): try: gajim.logger.write('status', jid_stripped, status, show) except exceptions.PysqliteOperationalError, e: - self.dispatch('ERROR', (_('Disk Write Error'), str(e))) + self.dispatch('DB_ERROR', (_('Disk Write Error'), str(e))) except exceptions.DatabaseMalformed: pritext = _('Database Error') sectext = _('The database file (%s) cannot be read. Try to ' 'repair it (see http://trac.gajim.org/wiki/DatabaseBackup) ' 'or remove it (all history will be lost).') % \ common.logger.LOG_DB_PATH - self.dispatch('ERROR', (pritext, sectext)) + self.dispatch('DB_ERROR', (pritext, sectext)) our_jid = gajim.get_jid_from_account(self.name) if jid_stripped == our_jid and resource == self.server_resource: # We got our own presence diff --git a/src/gui_interface.py b/src/gui_interface.py index 03ee740c6..450ac8dd3 100644 --- a/src/gui_interface.py +++ b/src/gui_interface.py @@ -119,6 +119,15 @@ class Interface: #('ERROR', account, (title_text, section_text)) dialogs.ErrorDialog(data[0], data[1]) + def handle_event_db_error(self, unused, data): + #('DB_ERROR', account, (title_text, section_text)) + if self.db_error_dialog: + return + self.db_error_dialog = dialogs.ErrorDialog(data[0], data[1]) + def destroyed(win): + self.db_error_dialog = None + self.db_error_dialog.connect('destroy', destroyed) + def handle_event_information(self, unused, data): #('INFORMATION', account, (title_text, section_text)) dialogs.InformationDialog(data[0], data[1]) @@ -2090,6 +2099,7 @@ class Interface: 'ROSTER': [self.handle_event_roster], 'WARNING': [self.handle_event_warning], 'ERROR': [self.handle_event_error], + 'DB_ERROR': [self.handle_event_db_error], 'INFORMATION': [self.handle_event_information], 'ERROR_ANSWER': [self.handle_event_error_answer], 'STATUS': [self.handle_event_status], @@ -3281,6 +3291,7 @@ class Interface: self.status_sent_to_groups = {} self.gpg_passphrase = {} self.pass_dialog = {} + self.db_error_dialog = None self.default_colors = { 'inmsgcolor': gajim.config.get('inmsgcolor'), 'outmsgcolor': gajim.config.get('outmsgcolor'),