bug fixes

This commit is contained in:
ingvar1995 2016-03-15 22:42:24 +03:00
parent ab419eddda
commit ae50efa2e6
2 changed files with 15 additions and 7 deletions

View file

@ -85,8 +85,9 @@ class Toxygen(object):
:return: tox instance
"""
self.mainloop.stop = True
self.init.stop = True
self.mainloop.wait()
self.init.terminate()
self.init.wait()
data = self.tox.get_savedata()
ProfileHelper.save_profile(data)
del self.tox
@ -110,6 +111,7 @@ class Toxygen(object):
def __init__(self, tox, ms, tray):
QtCore.QThread.__init__(self)
self.tox, self.ms, self.tray = tox, ms, tray
self.stop = False
def run(self):
# initializing callbacks
@ -118,7 +120,7 @@ class Toxygen(object):
for data in node_generator():
self.tox.bootstrap(*data)
self.msleep(10000)
while not self.tox.self_get_connection_status():
while not self.tox.self_get_connection_status() and not self.stop:
for data in node_generator():
self.tox.bootstrap(*data)
self.msleep(5000)

View file

@ -608,8 +608,10 @@ class Profile(Contact, Singleton):
result = self.tox.friend_add(tox_id, message.encode('utf-8'))
tox_id = tox_id[:TOX_PUBLIC_KEY_SIZE * 2]
item = self.create_friend_item()
friend = Friend(result, tox_id, '', item, tox_id)
self.history.add_friend_to_db(tox_id) # add friend to db
if not self.history.friend_exists_in_db(tox_id):
self.history.add_friend_to_db(tox_id)
message_getter = self.history.messages_getter(tox_id)
friend = Friend(message_getter, result, tox_id, '', item, tox_id)
self._friends.append(friend)
return True
except Exception as ex: # wrong data
@ -628,8 +630,12 @@ class Profile(Contact, Singleton):
if reply == QtGui.QMessageBox.Yes: # accepted
num = self.tox.friend_add_norequest(tox_id) # num - friend number
item = self.create_friend_item()
friend = Friend(num, tox_id, '', item, tox_id)
self.history.add_friend_to_db(tox_id) # add friend to db
if not self.history.friend_exists_in_db(tox_id):
self.history.add_friend_to_db(tox_id)
if not self.history.friend_exists_in_db(tox_id):
self.history.add_friend_to_db(tox_id)
message_getter = self.history.messages_getter(tox_id)
friend = Friend(message_getter, num, tox_id, '', item, tox_id)
self._friends.append(friend)
except Exception as ex: # something is wrong
log('Accept friend request failed! ' + str(ex))