[meld] dirdiff: Re-evaluate cursor-based state on model change (bgo#785859)
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] dirdiff: Re-evaluate cursor-based state on model change (bgo#785859)
- Date: Sat, 12 Aug 2017 20:02:20 +0000 (UTC)
commit bb80114ec8a0b6e7a72cb0eb0d8be7f4796698f3
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sun Aug 13 05:55:29 2017 +1000
dirdiff: Re-evaluate cursor-based state on model change (bgo#785859)
Because of the linear search we do to find the prev/next file to jump
to, we aggressively cache that particular bit of state so that it
doesn't need to be re-evaluated every time the cursor changes. However,
this can bite us when the model changes under us.
The solution in this patch is to simply force a state re-evaluation when
this happens, both on initial load and when individual items in the tree
change.
This also gets rid of the slightly odd allowance we had for forcing a
re-evaluation by manually calling the cursor-changed callback, in favour
of just using this re-evaluation toggle.
meld/dirdiff.py | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index cd8314e..7ba4416 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -360,6 +360,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
handler_id = treeview.connect("focus-out-event", self.on_treeview_focus_out_event)
self.focus_out_events.append(handler_id)
treeview.set_search_equal_func(self.model.treeview_search_cb, None)
+ self.force_cursor_recalculate = False
self.current_path, self.prev_path, self.next_path = None, None, None
self.on_treeview_focus_out_event(None, None)
self.focus_pane = None
@@ -821,9 +822,9 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
self.treeview[0].expand_to_path(Gtk.TreePath(path))
yield _("[%s] Done") % self.label_text
- self.scheduler.add_task(self.on_treeview_cursor_changed)
self._scan_in_progress -= 1
self.treeview[0].get_selection().select_path(Gtk.TreePath.new_first())
+ self.force_cursor_recalculate = True
self._update_diffmaps()
def _show_identical_status(self):
@@ -1076,9 +1077,11 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
self.current_path = cursor_path
return
- # If invoked directly rather than through a callback, we always check
- if not args:
+ if self.force_cursor_recalculate:
+ # We force cursor recalculation on initial load, and when
+ # we handle model change events.
skip = False
+ self.force_cursor_recalculate = False
else:
try:
old_cursor = self.model.get_iter(self.current_path)
@@ -1550,6 +1553,7 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
for path in changed_paths:
self._update_item_state( model.get_iter(path) )
self._update_diffmaps()
+ self.force_cursor_recalculate = True
def next_diff(self, direction):
if self.focus_pane:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]