fixed bugs with plugin reloading and toxav_kill

This commit is contained in:
ingvar1995 2018-08-25 13:31:43 +03:00
parent 0f9aa4f515
commit 531fa81bba
5 changed files with 26 additions and 13 deletions

View File

@ -107,6 +107,7 @@ class App:
self._tray.hide() self._tray.hide()
self._save_profile() self._save_profile()
self._settings.close() self._settings.close()
self._calls_manager.set_toxav(None)
del self._tox del self._tox
# ----------------------------------------------------------------------------------------------------------------- # -----------------------------------------------------------------------------------------------------------------
@ -202,7 +203,7 @@ class App:
def _start_threads(self, initial_start=True): def _start_threads(self, initial_start=True):
# init thread # init thread
self._init = threads.InitThread(self._tox, self._plugin_loader, self._settings) self._init = threads.InitThread(self._tox, self._plugin_loader, self._settings, initial_start)
self._init.start() self._init.start()
# starting threads for tox iterate and toxav iterate # starting threads for tox iterate and toxav iterate

View File

@ -7,12 +7,13 @@ import itertools
import numpy as np import numpy as np
from av import screen_sharing from av import screen_sharing
from av.call import Call from av.call import Call
import common.tox_save
class AV: class AV(common.tox_save.ToxAvSave):
def __init__(self, toxav, settings): def __init__(self, toxav, settings):
self._toxav = toxav super().__init__(toxav)
self._settings = settings self._settings = settings
self._running = True self._running = True
@ -36,9 +37,6 @@ class AV:
self._video_width = 640 self._video_width = 640
self._video_height = 480 self._video_height = 480
def set_toxav(self, toxav):
self._toxav = toxav
def stop(self): def stop(self):
self._running = False self._running = False
self.stop_audio_thread() self.stop_audio_thread()

View File

@ -8,8 +8,8 @@ import common.event as event
class CallsManager: class CallsManager:
def __init__(self, toxAV, settings, screen, contacts_manager): def __init__(self, toxav, settings, screen, contacts_manager):
self._call = av.calls.AV(toxAV, settings) # object with data about calls self._call = av.calls.AV(toxav, settings) # object with data about calls
self._call_widgets = {} # dict of incoming call widgets self._call_widgets = {} # dict of incoming call widgets
self._incoming_calls = set() self._incoming_calls = set()
self._settings = settings self._settings = settings

View File

@ -7,3 +7,12 @@ class ToxSave:
def set_tox(self, tox): def set_tox(self, tox):
self._tox = tox self._tox = tox
class ToxAvSave:
def __init__(self, toxav):
self._toxav = toxav
def set_toxav(self, toxav):
self._toxav = toxav

View File

@ -38,15 +38,18 @@ class BaseQThread(QtCore.QThread):
class InitThread(BaseThread): class InitThread(BaseThread):
def __init__(self, tox, plugin_loader, settings): def __init__(self, tox, plugin_loader, settings, is_first_start):
super().__init__() super().__init__()
self._tox, self._plugin_loader, self._settings = tox, plugin_loader, settings self._tox, self._plugin_loader, self._settings = tox, plugin_loader, settings
self._is_first_start = is_first_start
def run(self): def run(self):
# download list of nodes if needed if self._is_first_start:
download_nodes_list(self._settings) # download list of nodes if needed
# start plugins download_nodes_list(self._settings)
self._plugin_loader.load() # start plugins
self._plugin_loader.load()
# bootstrap # bootstrap
try: try:
for data in generate_nodes(): for data in generate_nodes():
@ -56,10 +59,12 @@ class InitThread(BaseThread):
self._tox.add_tcp_relay(*data) self._tox.add_tcp_relay(*data)
except: except:
pass pass
for _ in range(10): for _ in range(10):
if self._stop_thread: if self._stop_thread:
return return
time.sleep(1) time.sleep(1)
while not self._tox.self_get_connection_status(): while not self._tox.self_get_connection_status():
try: try:
for data in generate_nodes(None): for data in generate_nodes(None):