Commit d6b7916f authored by Philipp Hörist's avatar Philipp Hörist

Prevent callbacks on destroyed objects

Fixes #9560
parent e994b8f4
Pipeline #2998 failed with stages
in 47 seconds
......@@ -15,6 +15,7 @@
import logging
import nbxmpp
from gi.repository import Gdk
from gi.repository import Gtk
from gajim.common import app
......@@ -25,6 +26,7 @@ from gajim.common.caps_cache import muc_caps_cache
from gajim.gtk.dialogs import ErrorDialog
from gajim.gtk.dataform import DataFormWidget
from gajim.gtk.util import get_builder
from gajim.gtk.util import ensure_not_destroyed
log = logging.getLogger('gajim.gtk.groupchat_config')
......@@ -36,6 +38,7 @@ class GroupchatConfig(Gtk.ApplicationWindow):
self.set_title(_('Group Chat Configuration'))
self._destroyed = False
self.account = account
self.jid = jid
......@@ -77,6 +80,8 @@ class GroupchatConfig(Gtk.ApplicationWindow):
self.connect('delete-event', self._cancel)
self.connect('destroy', self._on_destroy)
self.connect('key-press-event', self._on_key_press)
......@@ -291,6 +296,10 @@ class GroupchatConfig(Gtk.ApplicationWindow):
return add, remove, modified
def _on_key_press(self, _widget, event):
if event.keyval == Gdk.KEY_Escape:
def _on_cancel(self, *args):
......@@ -300,6 +309,9 @@ class GroupchatConfig(Gtk.ApplicationWindow):
con = app.connections[self.account]
def _on_destroy(self, *args):
self._destroyed = True
def _set_affiliations(self):
add, remove, modified = self._get_diff()
......@@ -339,6 +351,7 @@ class GroupchatConfig(Gtk.ApplicationWindow):
con = app.connections[self.account]
con.get_module('MUC').set_affiliation(self.jid, diff_dict)
def _on_affiliations_received(self, result):
if result.is_error:'Error while requesting %s affiliations: %s',
......@@ -25,6 +25,7 @@ import sys
import logging
import xml.etree.ElementTree as ET
from pathlib import Path
from functools import wraps
from gi.repository import Gdk
from gi.repository import Gtk
......@@ -489,3 +490,12 @@ def get_hardware_key_codes(keyval):
if not valid:
return []
return [key.keycode for key in key_map_keys]
def ensure_not_destroyed(func):
def func_wrapper(self, *args, **kwargs):
if self._destroyed:
return func(self, *args, **kwargs)
return func_wrapper
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment