From 00d63ed591b58d724a738398f20669e6a8f0487c Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Mon, 2 Oct 2006 02:10:12 +0000 Subject: [PATCH] 2006-10-01 Don Allingham * src/Utils.py: catch divide by zero case * src/ViewManager.py: change change to same page (#410) svn: r7339 --- gramps2/ChangeLog | 4 ++++ gramps2/src/Utils.py | 8 ++++++-- gramps2/src/ViewManager.py | 15 ++++++++++++--- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 830da37bf..7f7f1e320 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,7 @@ +2006-10-01 Don Allingham + * src/Utils.py: catch divide by zero case + * src/ViewManager.py: change change to same page (#410) + 2006-09-29 Don Allingham * src/FilterEditor/_EditRule.py: limit source name in menu display to 40 characters (#451) diff --git a/gramps2/src/Utils.py b/gramps2/src/Utils.py index 9f8130883..464a86b01 100644 --- a/gramps2/src/Utils.py +++ b/gramps2/src/Utils.py @@ -972,10 +972,14 @@ class ProgressMeter: """Click the progress bar over to the next value. Be paranoid and insure that it doesn't go over 100%.""" self.pbar_index = self.pbar_index + 1.0 - if (self.pbar_index > self.pbar_max): + + if self.pbar_index > self.pbar_max: self.pbar_index = self.pbar_max - val = int(100*self.pbar_index/self.pbar_max) + try: + val = int(100*self.pbar_index/self.pbar_max) + except ZeroDivisionError: + val = 0 if val != self.old_val: self.pbar.set_text("%d%%" % val) diff --git a/gramps2/src/ViewManager.py b/gramps2/src/ViewManager.py index 633d726cb..9c04a74bb 100644 --- a/gramps2/src/ViewManager.py +++ b/gramps2/src/ViewManager.py @@ -185,6 +185,7 @@ class ViewManager: """ Initialize the ViewManager """ + self.page_is_changing = False self.state = state self.active_page = None self.views = [] @@ -690,6 +691,11 @@ class ViewManager: self.buttons[ix].handler_unblock(self.button_handlers[ix]) def change_page(self, obj, page, num=-1): + + if self.page_is_changing: + return + self.page_is_changing = True + if num == -1: num = self.notebook.get_current_page() @@ -709,7 +715,7 @@ class ViewManager: if grp in self.uimanager.get_action_groups(): self.uimanager.remove_action_group(grp) - if len(self.pages) > 0: + if len(self.pages) > 0 and self.active_page != self.pages[num]: self.active_page = self.pages[num] self.active_page.set_active() Config.set(Config.LAST_VIEW,num) @@ -741,8 +747,11 @@ class ViewManager: self.active_page.change_page() if self._key: self.uistate.disconnect(self._key) - self._key = self.uistate.connect('nameformat-changed', - self.active_page.build_tree) + self._key = self.uistate.connect( + 'nameformat-changed', + self.active_page.build_tree) + + self.page_is_changing = False def import_data(self, obj): if self.state.db.db_is_open: