xpra icon
Bug tracker and wiki

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


Ticket #2851: scrolldata-check-thread.patch

File scrolldata-check-thread.patch, 3.0 KB (added by Antoine Martin, 7 months ago)

debug patch: checks the current thread in all methods calls

  • xpra/server/window/motion.pyx

     
    77#cython: auto_pickle=False, boundscheck=False, wraparound=False, cdivision=True, language_level=3
    88
    99import struct
     10import threading
    1011
    1112from xpra.util import envbool, repr_ellipsized, csv
    1213from xpra.log import Logger
     
    6061        self.y = y
    6162        self.width = width
    6263        self.height = height
     64        self.thread = threading.current_thread()
    6365
     66    def check_thread(self):
     67        log("check_thread()")
     68        if self.thread!=threading.current_thread():
     69            log.error("wrong thread!")
     70            import traceback
     71            traceback.print_stack()
     72
    6473    def __repr__(self):
    6574        return "ScrollDistances(%ix%i)" % (self.width, self.height)
    6675
     
    8594            checksum its rows into a2,
    8695            and push existing values (if we had any) into a1.
    8796        """
     97        self.check_thread()
    8898        if DEBUG:
    8999            log("%s.update%s a1=%#x, a2=%#x, distances=%#x, current size: %ix%i", self, (repr_ellipsized(pixels), x, y, width, height, rowstride, bpp), <uintptr_t> self.a1, <uintptr_t> self.a2, <uintptr_t> self.distances, self.width, self.height)
    90100        assert width>0 and height>0, "invalid dimensions: %ix%i" % (width, height)
     
    133143            The same lines may be accounted for multiple times.
    134144            The result is stored in the "distances" array.
    135145        """
     146        self.check_thread()
    136147        if DEBUG:
    137148            log("calculate(%i) a1=%#x, a2=%#x, distances=%#x", max_distance, <uintptr_t> self.a1, <uintptr_t> self.a2, <uintptr_t> self.distances)
    138149        if self.a1==NULL or self.a2==NULL:
     
    180191            * scrolls dictionary contains scroll definitions
    181192            * non-scrolls dictionary is everything else (that will need to be repainted)
    182193        """
     194        self.check_thread()
    183195        DEF MAX_MATCHES = 20
    184196        if self.a1==NULL or self.a2==NULL:
    185197            return None
     
    257269        return scrolls, line_defs
    258270
    259271    cdef match_distance(self, uint8_t *line_state, int16_t distance, const uint8_t min_line_count):
     272        self.check_thread()
    260273        """
    261274            find the lines that match the given scroll distance,
    262275            return a dictionary with the starting line as key
     
    306319
    307320
    308321    def invalidate(self, int16_t x, int16_t y, uint16_t w, uint16_t h):
     322        self.check_thread()
    309323        if self.a2==NULL:
    310324            #nothing to invalidate!
    311325            return
     
    335349
    336350
    337351    def get_best_match(self):
     352        self.check_thread()
    338353        if self.a1==NULL or self.a2==NULL:
    339354            return 0, 0
    340355        cdef uint16_t max_hits = 0
     
    351366        self.free()
    352367
    353368    def free(self):
     369        self.check_thread()
    354370        cdef void* ptr = <void*> self.distances
    355371        if ptr:
    356372            self.distances = NULL