[gnome-builder] html-preview: disconnect signals to avoid leaking



commit bca7cc077f15d3ac9c63274f4a862479637e49cd
Author: Christian Hergert <chergert redhat com>
Date:   Mon Apr 16 16:32:22 2018 -0700

    html-preview: disconnect signals to avoid leaking
    
    We need to clear this state or PyGObject will leak our preview
    addin when the view is destroyed.

 src/plugins/html-preview/html_preview.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/src/plugins/html-preview/html_preview.py b/src/plugins/html-preview/html_preview.py
index b4a979e88..c23d4c18c 100644
--- a/src/plugins/html-preview/html_preview.py
+++ b/src/plugins/html-preview/html_preview.py
@@ -189,6 +189,7 @@ class HtmlPreviewAddin(GObject.Object, Ide.EditorViewAddin):
     def do_load(self, view):
         self.workbench = view.get_ancestor(Ide.Workbench)
         self.view = view
+
         self.can_preview = False
         self.sphinx_basedir = None
         self.sphinx_builddir = None
@@ -196,7 +197,7 @@ class HtmlPreviewAddin(GObject.Object, Ide.EditorViewAddin):
         group = view.get_action_group('editor-view')
 
         self.action = Gio.SimpleAction(name='preview-as-html', enabled=True)
-        self.action.connect('activate', self.preview_activated)
+        self.activate_handler = self.action.connect('activate', self.preview_activated)
         group.add_action(self.action)
 
         document = view.get_buffer()
@@ -213,9 +214,12 @@ class HtmlPreviewAddin(GObject.Object, Ide.EditorViewAddin):
                                       'editor-view.preview-as-html')
 
     def do_unload(self, view):
+        self.action.disconnect(self.activate_handler)
+
         group = view.get_action_group('editor-view')
         group.remove_action('preview-as-html')
 
+        self.action = None
         self.view = None
         self.workbench = None
 


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