xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #2211: verify-main-thread.patch

File verify-main-thread.patch, 6.9 KB (added by Antoine Martin, 2 years ago)

verify that we are in the main thread in more places

  • xpra/server/mixins/window_server.py

     
    66#pylint: disable-msg=E1101
    77
    88from xpra.util import typedict
     9from xpra.server.server_core import verify_main_thread
    910from xpra.server.mixins.stub_server_mixin import StubServerMixin
    1011from xpra.log import Logger
    1112
     
    7677    def get_info(self, _proto):
    7778        return {
    7879            "state" : {
    79                 "windows" : len([window for window in tuple(self._id_to_window.values()) if window.is_managed()]),
     80                "windows" : len(tuple(window for window in tuple(self._id_to_window.values()) if window.is_managed())),
    8081                },
    8182            "filters" : tuple((uuid,repr(f)) for uuid, f in self.window_filters),
    8283            }
     
    140141
    141142
    142143    def get_windows_info(self, window_ids):
     144        verify_main_thread()
    143145        info = {}
    144146        for wid, window in self._id_to_window.items():
    145147            if window_ids is not None and wid not in window_ids:
  • xpra/server/server_core.py

     
    177177    raise NotImplementedError()
    178178
    179179
     180def verify_main_thread():
     181    ct = threading.current_thread()
     182    if main_thread != ct:
     183        log.error("Error: invalid access from thread %s", ct)
     184        traceback.print_stack()
     185verify_main_thread()
     186
     187
    180188class ServerCore(object):
    181189    """
    182190        This is the simplest base class for servers.
  • xpra/x11/bindings/ximage.pyx

     
    750750            return self.pixels
    751751        cdef XImage *image = self.image             #
    752752        if image==NULL:
    753             xshmdebug.warn("Warning: XShm get_pixels_ptr XImage is NULL")
     753            xshmdebug("XShm get_pixels_ptr XImage is NULL")
    754754            return NULL
    755755        assert self.height>0
    756756        #calculate offset (assuming 4 bytes "pixelstride"):
  • xpra/x11/server.py

     
    1515from xpra.util import updict, rindex, envbool, envint
    1616from xpra.os_util import memoryview_to_bytes, strtobytes, bytestostr, monotonic_time
    1717from xpra.server import server_features
     18from xpra.server.server_core import verify_main_thread
    1819from xpra.gtk_common.gobject_util import one_arg_signal
    1920from xpra.gtk_common.gtk_util import (
    2021    get_default_root_window, get_xwindow, pixbuf_new_from_data, is_realized,
     
    379380        return info
    380381
    381382    def get_window_info(self, window):
     383        verify_main_thread()
    382384        info = X11ServerBase.get_window_info(self, window)
    383385        info.update({
    384386                     "focused"  : self._has_focus and self._window_to_id.get(window, -1)==self._has_focus,
     
    468470        return self._id_to_window.get(wid)
    469471
    470472    def get_transient_for(self, window):
     473        verify_main_thread()
    471474        transient_for = window.get_property("transient-for")
    472475        log("get_transient_for window=%s, transient_for=%s", window, transient_for)
    473476        if transient_for is None:
  • xpra/x11/x11_server_base.py

     
    66# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
    77# later version. See the file COPYING for details.
    88
    9 from xpra.os_util import bytestostr, strtobytes
     9from xpra.os_util import bytestostr, strtobytes, hexstr
    1010from xpra.util import nonl, typedict, envbool, iround
    1111from xpra.gtk_common.error import xswallow, xsync
    12 from xpra.os_util import hexstr
    1312from xpra.x11.x11_server_core import X11ServerCore, XTestPointerDevice
    1413from xpra.x11.bindings.keyboard_bindings import X11KeyboardBindings #@UnresolvedImport
    1514from xpra.log import Logger
  • xpra/x11/x11_server_core.py

     
    77# later version. See the file COPYING for details.
    88
    99import os
     10import threading
    1011
    1112from xpra.gtk_common.gobject_compat import import_gdk
    1213from xpra.x11.bindings.core_bindings import set_context_check, X11CoreBindings     #@UnresolvedImport
     
    1617from xpra.gtk_common.error import XError, xswallow, xsync, trap, verify_sync
    1718from xpra.gtk_common.gtk_util import get_xwindow, display_get_default, get_default_root_window
    1819from xpra.server.server_uuid import save_uuid, get_uuid
     20from xpra.server.server_core import verify_main_thread
    1921from xpra.x11.fakeXinerama import find_libfakeXinerama, save_fakeXinerama_config, cleanup_fakeXinerama
    2022from xpra.x11.gtk_x11.prop import prop_get, prop_set
    2123from xpra.x11.common import MAX_WINDOW_SIZE
     
    363365        return info
    364366
    365367    def get_ui_info(self, proto, wids=None, *args):
    366         import threading
    367368        log("do_get_info thread=%s", threading.current_thread())
    368369        info = GTKServerBase.get_ui_info(self, proto, wids, *args)
    369370        #this is added here because the server keyboard config doesn't know about "keys_pressed"..
     
    423424        return cinfo
    424425
    425426    def get_window_info(self, window):
     427        verify_main_thread()
    426428        info = super(X11ServerCore, self).get_window_info(window)
    427429        info["XShm"] = window.uses_XShm()
    428430        info["geometry"] = window.get_geometry()
     
    515517
    516518
    517519    def get_max_screen_size(self):
     520        verify_main_thread()
    518521        max_w, max_h = self.root_window.get_geometry()[2:4]
    519522        sizes = RandR.get_xrr_screen_sizes()
    520523        if self.randr and len(sizes)>=1:
     
    528531
    529532
    530533    def configure_best_screen_size(self):
     534        verify_main_thread()
    531535        #return ServerBase.set_best_screen_size(self)
    532536        """ sets the screen size to use the largest width and height used by any of the clients """
    533537        root_w, root_h = self.root_window.get_geometry()[2:4]
     
    572576        return self.do_get_best_screen_size(desired_w, desired_h, bigger)
    573577
    574578    def do_get_best_screen_size(self, desired_w, desired_h, bigger=True):
     579        verify_main_thread()
    575580        screen_sizes = RandR.get_xrr_screen_sizes()
    576581        if (desired_w, desired_h) in screen_sizes:
    577582            return desired_w, desired_h
     
    619624        return w, h
    620625
    621626    def set_screen_size(self, desired_w, desired_h, bigger=True):
     627        verify_main_thread()
    622628        screenlog("set_screen_size%s", (desired_w, desired_h, bigger))
    623629        root_w, root_h = self.root_window.get_geometry()[2:4]
    624630        if not self.randr: