mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-08 18:13:04 +02:00
QbyteArray().data() is always bytes and does not need to be cast to it
a dbus.ByteArray() can simply be initialized from the QByteArray directly.
This commit is contained in:
parent
d0a30b1f84
commit
96c71e7ae4
6 changed files with 6 additions and 6 deletions
|
|
@ -67,7 +67,7 @@ def __call__(self, ok):
|
|||
buf = QBuffer(ba)
|
||||
buf.open(QBuffer.WriteOnly)
|
||||
image.save(buf, 'JPEG')
|
||||
self.data = bytes(ba.data())
|
||||
self.data = ba.data()
|
||||
except Exception as e:
|
||||
self.exception = e
|
||||
self.traceback = traceback.format_exc()
|
||||
|
|
|
|||
|
|
@ -464,7 +464,7 @@ def add_image(self, img, cache_key):
|
|||
ba = QByteArray()
|
||||
buf = QBuffer(ba)
|
||||
image.save(buf, 'jpeg', 94)
|
||||
data = bytes(ba.data())
|
||||
data = ba.data()
|
||||
|
||||
if has_alpha:
|
||||
soft_mask = self.write_image(tmask, w, h, 8)
|
||||
|
|
|
|||
|
|
@ -687,7 +687,7 @@ def pixmap_to_data(pixmap, format='JPEG', quality=None):
|
|||
buf = QBuffer(ba)
|
||||
buf.open(QBuffer.WriteOnly)
|
||||
pixmap.save(buf, format, quality=quality)
|
||||
return bytes(ba.data())
|
||||
return ba.data()
|
||||
|
||||
|
||||
def decouple(prefix):
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ def icon_to_dbus_menu_icon(icon, size=32):
|
|||
buf = QBuffer(ba)
|
||||
buf.open(QBuffer.WriteOnly)
|
||||
icon.pixmap(32).save(buf, 'PNG')
|
||||
return dbus.ByteArray(bytes((ba.data())))
|
||||
return dbus.ByteArray(ba)
|
||||
|
||||
|
||||
def setup_for_cli_run():
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ def image_to_data(image): # {{{
|
|||
buf.open(QBuffer.WriteOnly)
|
||||
if not image.save(buf, CACHE_FORMAT):
|
||||
raise EncodeError('Failed to encode thumbnail')
|
||||
ret = bytes(ba.data())
|
||||
ret = ba.data()
|
||||
buf.close()
|
||||
return ret
|
||||
# }}}
|
||||
|
|
|
|||
|
|
@ -68,4 +68,4 @@ def to_png(bmp):
|
|||
buf = QBuffer(ba)
|
||||
buf.open(QBuffer.WriteOnly)
|
||||
i.save(buf, 'png')
|
||||
return bytes(ba.data())
|
||||
return ba.data()
|
||||
|
|
|
|||
Loading…
Reference in a new issue