Skip to content

Commit

Permalink
#2211: verify that we only access the gtk X11 context manager from th…
Browse files Browse the repository at this point in the history
…e main thread

git-svn-id: https://xpra.org/svn/Xpra/trunk@22114 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Mar 18, 2019
1 parent 196d146 commit e65287e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/xpra/gtk_common/error.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is part of Xpra.
# Copyright (C) 2008, 2009 Nathaniel Smith <njs@pobox.com>
# Copyright (C) 2012-2014 Antoine Martin <antoine@xpra.org>
# Copyright (C) 2012-2019 Antoine Martin <antoine@xpra.org>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

Expand All @@ -27,6 +27,7 @@
# super-fast connections to the X server, everything running on fast
# computers... does being this careful to avoid sync's actually matter?)

import threading
import traceback

from xpra.util import envbool
Expand All @@ -38,13 +39,27 @@
#run xpra in synchronized mode to debug X11 errors:
XPRA_SYNCHRONIZE = envbool("XPRA_SYNCHRONIZE", False)
XPRA_LOG_SYNC = envbool("XPRA_LOG_SYNC", False)
VERIFY_MAIN_THREAD = envbool("XPRA_VERIFY_MAIN_THREAD", True)

log = Logger("x11", "util")
elog = Logger("x11", "util", "error")

gdk = import_gdk()


if not VERIFY_MAIN_THREAD:
def verify_main_thread():
return
else:
main_thread = threading.current_thread()
def verify_main_thread():
ct = threading.current_thread()
if main_thread != ct:
log.error("Error: invalid access from thread %s", ct)
traceback.print_stack()
verify_main_thread()


class XError(Exception):
def __init__(self, message):
Exception.__init__(self)
Expand Down Expand Up @@ -90,6 +105,7 @@ def __init__(self):

def _enter(self):
assert self.depth >= 0
verify_main_thread()
gdk.error_trap_push()
if XPRA_LOG_SYNC:
log("X11trap.enter at level %i", self.depth)
Expand Down

0 comments on commit e65287e

Please sign in to comment.