[meld] sourceview: Remove animation source on MeldSourceView unrealize (#565)



commit 3cddda57be65e61c18c1b9ace594355a40352d4d
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Mon Apr 12 07:52:56 2021 +1000

    sourceview: Remove animation source on MeldSourceView unrealize (#565)
    
    Because we only removed the animation source in do_draw_layer, when the
    animation was finished, we could get in to a state where the source view
    was unrealized (and therefore no longer getting draw events) while there
    was still an animation source running. This could lead to the main
    Meld process polling in a tight loop for a source that did nothing other
    than constantly requesting draws for a widget that wasn't displayed.
    
    The easy fix here is to remove the source when the widget unrealizes.
    Ideally, we'd use a better animation model instead, but... that's a
    bigger change.

 meld/sourceview.py | 5 +++++
 1 file changed, 5 insertions(+)
---
diff --git a/meld/sourceview.py b/meld/sourceview.py
index 0e1a9dc4..e8646688 100644
--- a/meld/sourceview.py
+++ b/meld/sourceview.py
@@ -316,6 +316,11 @@ class MeldSourceView(GtkSource.View, SourceViewHelperMixin):
 
         return GtkSource.View.do_realize(self)
 
+    def do_unrealize(self):
+        if self.anim_source_id:
+            GLib.source_remove(self.anim_source_id)
+        return GtkSource.View.do_unrealize(self)
+
     def do_draw_layer(self, layer, context):
         if layer != Gtk.TextViewLayer.BELOW_TEXT:
             return GtkSource.View.do_draw_layer(self, layer, context)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]