From 9d939e7439e260fb43da6bedfa46ba4fac379553 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Sat, 24 Dec 2016 14:36:49 +0300 Subject: [PATCH] avatars handler fix --- toxygen/basecontact.py | 7 +++---- toxygen/profile.py | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/toxygen/basecontact.py b/toxygen/basecontact.py index 0963f2a..4657944 100644 --- a/toxygen/basecontact.py +++ b/toxygen/basecontact.py @@ -84,11 +84,10 @@ class BaseContact: """ Tries to load avatar of contact or uses default avatar """ - avatar_path = '{}.png'.format(self._tox_id[:TOX_PUBLIC_KEY_SIZE * 2]) - os.chdir(ProfileHelper.get_path() + 'avatars/') + prefix = ProfileHelper.get_path() + 'avatars/' + avatar_path = prefix + '{}.png'.format(self._tox_id[:TOX_PUBLIC_KEY_SIZE * 2]) if not os.path.isfile(avatar_path) or not os.path.getsize(avatar_path): # load default image - avatar_path = 'avatar.png' - os.chdir(curr_directory() + '/images/') + avatar_path = curr_directory() + '/images/avatar.png' width = self._widget.avatar_label.width() pixmap = QtGui.QPixmap(avatar_path) self._widget.avatar_label.setPixmap(pixmap.scaled(width, width, QtCore.Qt.KeepAspectRatio, diff --git a/toxygen/profile.py b/toxygen/profile.py index ad1bcda..f534c4b 100644 --- a/toxygen/profile.py +++ b/toxygen/profile.py @@ -1151,7 +1151,6 @@ class Profile(basecontact.BaseContact, Singleton): if not os.path.isfile(avatar_path): # reset image avatar_path = None sa = SendAvatar(avatar_path, self._tox, friend_number) - sa.set_transfer_finished_handler(self.transfer_finished) self._file_transfers[(friend_number, sa.get_file_number())] = sa def incoming_avatar(self, friend_number, file_number, size): @@ -1164,6 +1163,7 @@ class Profile(basecontact.BaseContact, Singleton): ra = ReceiveAvatar(self._tox, friend_number, size, file_number) if ra.state != TOX_FILE_TRANSFER_STATE['CANCELLED']: self._file_transfers[(friend_number, file_number)] = ra + ra.set_transfer_finished_handler(self.transfer_finished) else: self.get_friend_by_number(friend_number).load_avatar() if self.get_active_number() == friend_number: