Skip to content

Commit

Permalink
#1568: py3k / GTK3 fixes
Browse files Browse the repository at this point in the history
* py3k strings byte again
* gtk quit recursion detection needs to use exception.args (no such thing as "message" in py3k)
* mmap_pipe must use bytes
* window source: fix race during cleanup (list concurrency error)
* reduce moved to functools in py3k

git-svn-id: https://xpra.org/svn/Xpra/trunk@17027 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Oct 2, 2017
1 parent 9cd9d4f commit c6d7aca
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/xpra/codecs/jpeg/encoder.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ log = Logger("encoder", "jpeg")
from xpra.codecs.image_wrapper import ImageWrapper
from xpra.buffers.membuf cimport makebuf, object_as_buffer
from xpra.net.compression import Compressed
from xpra.os_util import bytestostr

from libc.stdint cimport uint8_t, uint32_t, uintptr_t

Expand Down Expand Up @@ -106,7 +107,7 @@ def encode(image, int quality=50, int speed=50, options={}):
cdef const unsigned char* buf
cdef Py_ssize_t buf_len
pixels = image.get_pixels()
pfstr = image.get_pixel_format()
pfstr = bytestostr(image.get_pixel_format())
assert object_as_buffer(pixels, <const void**> &buf, &buf_len)==0, "unable to convert %s to a buffer" % type(pixels)
assert buf_len>=stride*height, "%s buffer is too small: %i bytes, %ix%i=%i bytes required" % (pfstr, buf_len, stride, height, stride*height)
pf = TJPF_VAL.get(pfstr)
Expand Down
4 changes: 2 additions & 2 deletions src/xpra/codecs/pillow/encode.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
log = Logger("encoder", "pillow")

from xpra.util import envbool
from xpra.os_util import BytesIOClass, memoryview_to_bytes, _buffer
from xpra.os_util import BytesIOClass, memoryview_to_bytes, bytestostr, _buffer
from xpra.net.compression import Compressed

from PIL import Image, ImagePalette #@UnresolvedImport
Expand Down Expand Up @@ -49,7 +49,7 @@ def get_info():

def encode(coding, image, quality, speed, supports_transparency):
log("pillow.encode%s", (coding, image, quality, speed, supports_transparency))
pixel_format = image.get_pixel_format()
pixel_format = bytestostr(image.get_pixel_format())
palette = None
w = image.get_width()
h = image.get_height()
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/gtk_common/quit.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def gtk_main_quit_on_fatal_exception(etype, val, tb):
print("Shutting down main-loop")
gtk_main_quit_really()
return
if issubclass(etype, RuntimeError) and "recursion" in val.message:
if issubclass(etype, RuntimeError) and val.args and "recursion" in val.args[0]:
# We weren't getting tracebacks from this -- maybe calling oldhook
# was hitting the limit again or something? -- so try this
# instead. (I don't know why print_exception wouldn't trigger the
Expand Down
6 changes: 3 additions & 3 deletions src/xpra/net/mmap_pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,12 @@ def mmap_read(mmap_area, *descr_data):
data_start.value = offset+length
return arraytype.from_buffer(mmap_area, offset)
#re-construct the buffer from discontiguous chunks:
data = ""
data = []
for offset, length in descr_data:
mmap_area.seek(offset)
data += mmap_area.read(length)
data.append(mmap_area.read(length))
data_start.value = offset+length
return data
return b"".join(data)


def mmap_write(mmap_area, mmap_size, data):
Expand Down
2 changes: 1 addition & 1 deletion src/xpra/server/window/window_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,7 @@ def cancel_damage(self):
self.delta_pixel_data = [None for _ in range(self.delta_buckets)]
#make sure we don't account for those as they will get dropped
#(generally before encoding - only one may still get encoded):
for sequence in self.statistics.encoding_pending.keys():
for sequence in list(self.statistics.encoding_pending.keys()):
if self._damage_cancelled>=sequence:
try:
del self.statistics.encoding_pending[sequence]
Expand Down
8 changes: 5 additions & 3 deletions src/xpra/server/window/window_video_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
from xpra.server.window.video_scoring import get_pipeline_score
from xpra.codecs.loader import PREFERED_ENCODING_ORDER, EDGE_ENCODING_ORDER
from xpra.util import parse_scaling_value, engs, envint, envbool, csv, roundup, print_nested_dict
from xpra.os_util import monotonic_time
from xpra.os_util import monotonic_time, strtobytes, PYTHON3
from xpra.log import Logger
if PYTHON3:
from functools import reduce

log = Logger("encoding")
csclog = Logger("csc")
Expand Down Expand Up @@ -297,12 +299,12 @@ def set_new_encoding(self, encoding, strict=None):

def update_encoding_selection(self, encoding=None, exclude=[], init=False):
#override so we don't use encodings that don't have valid csc modes:
log("wvs.update_encoding_selection(%s, %s, %s)", encoding, exclude, init)
log("wvs.update_encoding_selection(%s, %s, %s) full_csc_modes=%s", encoding, exclude, init, self.full_csc_modes)
for x in self.video_encodings:
if x not in self.core_encodings:
exclude.append(x)
continue
csc_modes = self.full_csc_modes.get(x)
csc_modes = self.full_csc_modes.get(strtobytes(x))
if not csc_modes or x not in self.core_encodings:
exclude.append(x)
if not init:
Expand Down

0 comments on commit c6d7aca

Please sign in to comment.