From 177e180e37f1d169cf304db63642c798113716fd Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Tue, 10 May 2016 13:08:44 +0300 Subject: [PATCH] file transfers bug fix, settings load fix --- src/list_items.py | 4 ++-- src/profile.py | 15 ++++++++++----- src/settings.py | 6 +++++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/list_items.py b/src/list_items.py index 1478fd0..1dde736 100644 --- a/src/list_items.py +++ b/src/list_items.py @@ -150,7 +150,7 @@ class FileTransferItem(QtGui.QListWidget): self.state = state self.name = DataLabel(self) - self.name.setGeometry(QtCore.QRect(7, 5, 95, 20)) + self.name.setGeometry(QtCore.QRect(3, 7, 95, 20)) self.name.setTextFormat(QtCore.Qt.PlainText) font = QtGui.QFont() font.setFamily("Times New Roman") @@ -160,7 +160,7 @@ class FileTransferItem(QtGui.QListWidget): self.name.setText(user) self.time = QtGui.QLabel(self) - self.time.setGeometry(QtCore.QRect(width - 50, 7, 50, 20)) + self.time.setGeometry(QtCore.QRect(width - 53, 7, 50, 20)) font.setPointSize(10) font.setBold(False) self.time.setFont(font) diff --git a/src/profile.py b/src/profile.py index f9a0290..497b862 100644 --- a/src/profile.py +++ b/src/profile.py @@ -387,6 +387,7 @@ class Profile(Contact, Singleton): def set_active(self, value=None): """ + Change current active friend or update info :param value: number of new active friend in friend's list or None to update active user's data """ if value is None and self._active_friend == -1: # nothing to update @@ -420,10 +421,12 @@ class Profile(Contact, Singleton): elif message.get_type() == 2: item = self.create_file_transfer_item(message) if message.get_status() >= 2: # active file transfer - # TODO: fix bug with file_number == 65536L - ft = self._file_transfers[(message.get_friend_number(), message.get_file_number())] - ft.set_state_changed_handler(item.update) - ft.signal() + try: + ft = self._file_transfers[(message.get_friend_number(), message.get_file_number())] + ft.set_state_changed_handler(item.update) + ft.signal() + except: + print 'Incoming not started transfer - no info found' else: # inline self.create_inline_item(message.get_data()) self._messages.scrollToBottom() @@ -946,7 +949,9 @@ class Profile(Contact, Singleton): tr.cancel() else: tr.cancelled() - del self._file_transfers[(friend_number, file_number)] + if (friend_number, file_number) in self._file_transfers: + del tr + del self._file_transfers[(friend_number, file_number)] else: self._tox.file_control(friend_number, file_number, TOX_FILE_CONTROL['CANCEL']) diff --git a/src/settings.py b/src/settings.py index 52442f2..b0c7c31 100644 --- a/src/settings.py +++ b/src/settings.py @@ -14,7 +14,11 @@ class Settings(Singleton, dict): if os.path.isfile(self.path): with open(self.path) as fl: data = fl.read() - super(self.__class__, self).__init__(json.loads(data)) + try: + info = json.loads(data) + except: + info = Settings.get_default_settings() + super(self.__class__, self).__init__(info) self.upgrade() else: super(self.__class__, self).__init__(Settings.get_default_settings())