[meld] filediff: Fix race condition on scrolling to first chunk (bgo#780625)
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] filediff: Fix race condition on scrolling to first chunk (bgo#780625)
- Date: Sat, 29 Apr 2017 22:06:39 +0000 (UTC)
commit d6b8d24132b38327406c05fbae97937d11047a16
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sun Apr 30 07:58:03 2017 +1000
filediff: Fix race condition on scrolling to first chunk (bgo#780625)
When we load a comparison, we scroll to the first difference. If the
first difference is on the first line of the file, we hit a race
condition (though reliably triggerable in some cases) where we set the
`next` attribute of our cursor and schedule a go_to_chunk on it, but
then our cursor changed callback kicks in and re-sets the `next`
attribute, causing us to go to the *second* difference.
There's no obvious reason why we need to set the cursor chunk here.
History vaguely suggests that it's because we weren't getting cursor
callbacks, so set up the necessary state manually. However, we can
just pass the actual chunk we have decided we want to go to, instead
of modifying the cursor itself, which seems a lot safer.
meld/filediff.py | 12 ++++--------
1 files changed, 4 insertions(+), 8 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index 0dba4da..4001b05 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -1109,17 +1109,13 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
yield 1
if not refresh:
- chunk, prev, next_ = self.linediffer.locate_chunk(1, 0)
- self.cursor.next = chunk
- if self.cursor.next is None:
- self.cursor.next = next_
for buf in self.textbuffer:
buf.place_cursor(buf.get_start_iter())
- if self.cursor.next is not None:
- self.scheduler.add_task(
- lambda: self.go_to_chunk(self.cursor.next, centered=True),
- True)
+ chunk, prev, next_ = self.linediffer.locate_chunk(1, 0)
+ target_chunk = chunk if chunk is not None else next_
+ self.scheduler.add_task(
+ lambda: self.go_to_chunk(target_chunk, centered=True), True)
self.queue_draw()
self._connect_buffer_handlers()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]