4669: Long transactions can cause unwanted effects in TreeViews

svn: r17423
This commit is contained in:
Michiel Nauta 2011-05-05 20:03:54 +00:00
parent f4f1deb9f7
commit 70496ae707
4 changed files with 17 additions and 2 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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)):