Blob Blame History Raw
From 37319e3ccbaf8cba315ace406896a7cd120b32c9 Mon Sep 17 00:00:00 2001
From: Carlos Soriano <csoriano@redhat.com>
Date: Mon, 21 Jan 2019 13:28:05 +0100
Subject: [PATCH] tweak_group_xkb: Disconnect settings changed signal on
 destruction

Otherwise when the dialog is destructed, when the settings change it
will call the callback and make the application crash.
---
 gtweak/tweaks/tweak_group_xkb.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gtweak/tweaks/tweak_group_xkb.py b/gtweak/tweaks/tweak_group_xkb.py
index 9cb3670..b41a627 100644
--- a/gtweak/tweaks/tweak_group_xkb.py
+++ b/gtweak/tweaks/tweak_group_xkb.py
@@ -147,7 +147,7 @@ class TypingTweakGroup(Gtk.Box):
         ok = False
         try:
             self._kbdsettings = GSettingsSetting(self.XKB_GSETTINGS_SCHEMA)
-            self._kbdsettings.connect("changed::"+self.XKB_GSETTINGS_NAME, self._on_changed)
+            self._kdb_settings_id = self._kbdsettings.connect("changed::"+self.XKB_GSETTINGS_NAME, self._on_changed)
             self._xkb_info = GnomeDesktop.XkbInfo()
             ok = True
             self.loaded = True
@@ -165,6 +165,12 @@ class TypingTweakGroup(Gtk.Box):
                     self.pack_start(obj, False, False, 0)
         TweakGroup.__init__(self, _("Typing"), *self._option_objects)
 
+        self.connect("destroy", self._on_destroy)
+
     def _on_changed(self, *args):
         for obj in self._option_objects:
             obj.reload()
+
+    def _on_destroy(self, event):
+        if (self._kdb_settings_id):
+            self._kbdsettings.disconnect(self._kdb_settings_id)
-- 
2.19.0