[gnome-tweaks/fix-additional-layout-crash: 2/2] tweak_group_xkb: Disconnect settings changed signal on destruction



commit 37319e3ccbaf8cba315ace406896a7cd120b32c9
Author: Carlos Soriano <csoriano redhat com>
Date:   Mon Jan 21 13:28:05 2019 +0100

    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)


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