fix: session quit on server lost

This commit is contained in:
Swann Martinez 2020-01-22 18:37:46 +01:00
parent 8b7716ac3c
commit ece88f3dda
No known key found for this signature in database
GPG Key ID: 414CCAFD8DA720E1
2 changed files with 9 additions and 0 deletions

View File

@ -194,6 +194,7 @@ class DrawClient(Draw):
def execute(self):
session = getattr(operators, 'client', None)
renderer = getattr(presence, 'renderer', None)
if session and renderer:
settings = bpy.context.window_manager.session
users = session.online_users
@ -220,6 +221,10 @@ class ClientUpdate(Timer):
renderer = getattr(presence, 'renderer', None)
if session and renderer:
# Check if session has been closes prematurely
if session.state == 0:
bpy.ops.session.stop()
local_user = operators.client.online_users.get(
session_info.username)
if not local_user:

View File

@ -155,8 +155,12 @@ class DrawFactory(object):
self.register_handlers()
def stop(self):
self.flush_users()
self.flush_selection()
self.unregister_handlers()
refresh_3d_view()
def register_handlers(self):
self.draw3d_handle = bpy.types.SpaceView3D.draw_handler_add(
self.draw3d_callback, (), 'WINDOW', 'POST_VIEW')