diff --git a/src/xpra/gtk_common/quit.py b/src/xpra/gtk_common/quit.py index b20651999c..807a399261 100644 --- a/src/xpra/gtk_common/quit.py +++ b/src/xpra/gtk_common/quit.py @@ -48,12 +48,13 @@ def gtk_main_quit_forever(): # propagate it from Python code. Sigh.) But sys.excepthook will still get # called with such exceptions. _hooked = False +_oldhook = None def gtk_main_quit_on_fatal_exceptions_enable(): - global _hooked + global _hooked, _oldhook if _hooked: return _hooked = True - oldhook = sys.excepthook + _oldhook = sys.excepthook def gtk_main_quit_on_fatal_exception(etype, val, tb): if issubclass(etype, (KeyboardInterrupt, SystemExit)): print("Shutting down main-loop") @@ -67,5 +68,12 @@ def gtk_main_quit_on_fatal_exception(etype, val, tb): print(traceback.print_exception(etype, val, tb)) print("Maximum recursion depth exceeded") else: - return oldhook(etype, val, tb) + return _oldhook(etype, val, tb) sys.excepthook = gtk_main_quit_on_fatal_exception + +def gtk_main_quit_on_fatal_exceptions_disable(): + global __oldhook + oh = _oldhook + if oh: + _oldhook = None + sys.excepthook = oh diff --git a/src/xpra/server/gtk_server_base.py b/src/xpra/server/gtk_server_base.py index f72f2fdfa3..5d1caea77d 100644 --- a/src/xpra/server/gtk_server_base.py +++ b/src/xpra/server/gtk_server_base.py @@ -15,7 +15,8 @@ screenlog = Logger("server", "screen") from xpra.gtk_common.quit import (gtk_main_quit_really, - gtk_main_quit_on_fatal_exceptions_enable) + gtk_main_quit_on_fatal_exceptions_enable, + gtk_main_quit_on_fatal_exceptions_disable) from xpra.server.server_base import ServerBase from xpra.gtk_common.gtk_util import get_gtk_version_info, gtk_main from xpra.util import updict @@ -40,8 +41,13 @@ def watch_keymap_changes(self): ### Set up keymap change notification: gtk.gdk.keymap_get_default().connect("keys-changed", self._keys_changed) + def signal_quit(self, signum, frame): + gtk_main_quit_on_fatal_exceptions_disable() + ServerBase.signal_quit(self, signum, frame) + def do_quit(self): log("do_quit: calling gtk_main_quit_really") + gtk_main_quit_on_fatal_exceptions_disable() gtk_main_quit_really() log("do_quit: gtk_main_quit_really done")