file transfers bug fix, settings load fix

This commit is contained in:
ingvar1995 2016-05-10 13:08:44 +03:00
parent 8d3db9f897
commit 177e180e37
3 changed files with 17 additions and 8 deletions

View File

@ -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)

View File

@ -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
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,6 +949,8 @@ class Profile(Contact, Singleton):
tr.cancel()
else:
tr.cancelled()
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'])

View File

@ -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())