From 66efd796c552328c8e59ea3e37c5de6be3a4a066 Mon Sep 17 00:00:00 2001 From: Michiel Nauta Date: Thu, 5 May 2011 20:02:48 +0000 Subject: [PATCH] 4669: Long transactions can cause unwanted effects in TreeViews svn: r17422 --- src/gen/db/write.py | 11 +++++++++++ src/gui/views/tags.py | 4 ++-- src/gui/views/treemodels/flatbasemodel.py | 2 ++ src/gui/views/treemodels/treebasemodel.py | 2 ++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/gen/db/write.py b/src/gen/db/write.py index 252e68365..213293952 100644 --- a/src/gen/db/write.py +++ b/src/gen/db/write.py @@ -1749,6 +1749,17 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback): self.bsddbtxn.abort() self.bsddbtxn = None self.txn = None + if not transaction.batch: + # It can occur that the listview is already updated because of + # the "model-treeview automatic update" combined with a + # "while gtk.events_pending(): gtk.main_iteration() loop" + # (typically used in a progress bar), so emit rebuild signals + # to correct that. + object_types = set([x[0] for x in transaction.keys()]) + for object_type in object_types: + if object_type == REFERENCE_KEY: + continue + self.emit('%s-rebuild' % KEY_TO_NAME_MAP[object_type], ()) self.transaction = None transaction.clear() transaction.first = None diff --git a/src/gui/views/tags.py b/src/gui/views/tags.py index f4c80928d..533323cff 100644 --- a/src/gui/views/tags.py +++ b/src/gui/views/tags.py @@ -261,7 +261,7 @@ class Tags(DbGUIElement): view = self.uistate.viewmanager.active_page selected = view.selected_handles() pmon = progressdlg.ProgressMonitor(progressdlg.GtkProgressDialog, - popup_time=2) + ("", self.uistate.window, gtk.DIALOG_MODAL), popup_time=2) status = progressdlg.LongOpStatus(msg=_("Adding Tags"), total_steps=len(selected), interval=len(selected)//20) @@ -496,7 +496,7 @@ class OrganizeTagsDialog(object): links = [link for link in self.db.find_backlink_handles(tag_handle)] pmon = progressdlg.ProgressMonitor(progressdlg.GtkProgressDialog, - popup_time=2) + ("", self.uistate.window, gtk.DIALOG_MODAL), popup_time=2) status = progressdlg.LongOpStatus(msg=_("Removing Tags"), total_steps=len(links), interval=len(links)//20) diff --git a/src/gui/views/treemodels/flatbasemodel.py b/src/gui/views/treemodels/flatbasemodel.py index 85e915a74..77bde601c 100644 --- a/src/gui/views/treemodels/flatbasemodel.py +++ b/src/gui/views/treemodels/flatbasemodel.py @@ -579,6 +579,8 @@ class FlatBaseModel(gtk.GenericTreeModel): Add a row. This is called after object with handle is created. Row is only added if search/filter data is such that it must be shown """ + if self.node_map.get_path(handle) is not None: + return # row is already displayed data = self.map(handle) insert_val = (map(conv_unicode_tosrtkey_ongtk, self.sort_func(data)), handle) diff --git a/src/gui/views/treemodels/treebasemodel.py b/src/gui/views/treemodels/treebasemodel.py index 942f6dd6e..b2afbc818 100644 --- a/src/gui/views/treemodels/treebasemodel.py +++ b/src/gui/views/treemodels/treebasemodel.py @@ -666,6 +666,8 @@ class TreeBaseModel(gtk.GenericTreeModel): """ Add a row to the model. """ + if self.get_node(handle) is not None: + return # row already exists cput = time.clock() if not self.search or \ (self.search and self.search.match(handle, self.db)):