From 7b9204a88b5978954816ddcb4b308eaefc9e8c46 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Wed, 20 Apr 2016 12:32:28 +0300 Subject: [PATCH] bug fixes --- src/callbacks.py | 5 ++++- src/file_transfers.py | 3 ++- src/mainscreen.py | 2 ++ src/profile.py | 1 - src/tox.py | 2 +- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/callbacks.py b/src/callbacks.py index a6d139f..ee38f0c 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -147,7 +147,10 @@ def tox_file_recv(window, tray): settings = Settings.get_instance() if file_type == TOX_FILE_KIND['DATA']: print 'file' - file_name = file_name[:file_name_size] + try: + file_name = unicode(file_name[:file_name_size].decode('utf-8')) + except: + file_name = u'toxygen_file' invoke_in_main_thread(profile.incoming_file_transfer, friend_number, file_number, diff --git a/src/file_transfers.py b/src/file_transfers.py index bc4c36a..24f04af 100644 --- a/src/file_transfers.py +++ b/src/file_transfers.py @@ -1,7 +1,7 @@ from toxcore_enums_and_consts import TOX_FILE_KIND, TOX_FILE_CONTROL from os.path import basename, getsize, exists from os import remove -from time import time +from time import time, sleep from tox import Tox import settings from PySide import QtCore @@ -56,6 +56,7 @@ class FileTransfer(QtCore.QObject): def cancelled(self): if hasattr(self, '_file'): + sleep(0.1) self._file.close() self._state_changed.signal.emit(TOX_FILE_CONTROL['CANCEL'], 1) diff --git a/src/mainscreen.py b/src/mainscreen.py index ce2cab4..ed6fb24 100644 --- a/src/mainscreen.py +++ b/src/mainscreen.py @@ -222,6 +222,8 @@ class MainWindow(QtGui.QMainWindow): self.messages = QtGui.QListWidget(widget) self.messages.setGeometry(0, 0, 620, 250) self.messages.setObjectName("messages") + self.messages.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) + self.messages.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) def load(pos): if not pos: diff --git a/src/profile.py b/src/profile.py index fadd653..331dbf7 100644 --- a/src/profile.py +++ b/src/profile.py @@ -759,7 +759,6 @@ class Profile(Contact, Singleton): """ settings = Settings.get_instance() friend = self.get_friend_by_number(friend_number) - file_name = file_name.decode('utf-8') auto = settings['allow_auto_accept'] and friend.tox_id in settings['auto_accept_from_friends'] inline = (file_name == 'toxygen_inline.png' or file_name == 'utox-inline.png') and settings['allow_inline'] if inline and size < 1024 * 1024: diff --git a/src/tox.py b/src/tox.py index b1fb202..172f98a 100644 --- a/src/tox.py +++ b/src/tox.py @@ -573,7 +573,7 @@ class Tox(object): :return: friend number """ tox_err_friend_by_public_key = c_int() - result = Tox.libtoxcore.tox_friend_by_public_key(self._tox_pointer, c_char_p(public_key), + result = Tox.libtoxcore.tox_friend_by_public_key(self._tox_pointer, string_to_bin(public_key), addressof(tox_err_friend_by_public_key)) tox_err_friend_by_public_key = tox_err_friend_by_public_key.value if tox_err_friend_by_public_key == TOX_ERR_FRIEND_BY_PUBLIC_KEY['OK']: