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._save_profile()
self._settings.close()
self._calls_manager.set_toxav(None)
del self._tox
# -----------------------------------------------------------------------------------------------------------------
@ -202,7 +203,7 @@ class App:
def _start_threads(self, initial_start=True):
# 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()
# starting threads for tox iterate and toxav iterate

View file

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

View file

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

View file

@ -7,3 +7,12 @@ class ToxSave:
def set_tox(self, 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):
def __init__(self, tox, plugin_loader, settings):
def __init__(self, tox, plugin_loader, settings, is_first_start):
super().__init__()
self._tox, self._plugin_loader, self._settings = tox, plugin_loader, settings
self._is_first_start = is_first_start
def run(self):
if self._is_first_start:
# download list of nodes if needed
download_nodes_list(self._settings)
# start plugins
self._plugin_loader.load()
# bootstrap
try:
for data in generate_nodes():
@ -56,10 +59,12 @@ class InitThread(BaseThread):
self._tox.add_tcp_relay(*data)
except:
pass
for _ in range(10):
if self._stop_thread:
return
time.sleep(1)
while not self._tox.self_get_connection_status():
try:
for data in generate_nodes(None):