feat: exit the session as soon as a Timer crash
This commit is contained in:
parent
af6d54296a
commit
affab2414c
@ -28,6 +28,7 @@ from .presence import (renderer,
|
|||||||
generate_user_camera,
|
generate_user_camera,
|
||||||
get_view_matrix,
|
get_view_matrix,
|
||||||
refresh_sidebar_view)
|
refresh_sidebar_view)
|
||||||
|
from . import operators
|
||||||
from replication.constants import (FETCHED,
|
from replication.constants import (FETCHED,
|
||||||
UP,
|
UP,
|
||||||
RP_COMMON,
|
RP_COMMON,
|
||||||
@ -47,14 +48,10 @@ def is_annotating(context: bpy.types.Context):
|
|||||||
"""
|
"""
|
||||||
return bpy.context.workspace.tools.from_space_view3d_mode('OBJECT', create=False).idname == 'builtin.annotate'
|
return bpy.context.workspace.tools.from_space_view3d_mode('OBJECT', create=False).idname == 'builtin.annotate'
|
||||||
|
|
||||||
|
|
||||||
class Delayable():
|
class Delayable():
|
||||||
"""Delayable task interface
|
"""Delayable task interface
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.is_registered = False
|
|
||||||
|
|
||||||
def register(self):
|
def register(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@ -74,25 +71,30 @@ class Timer(Delayable):
|
|||||||
def __init__(self, duration=1):
|
def __init__(self, duration=1):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._timeout = duration
|
self._timeout = duration
|
||||||
self._running = True
|
self.is_running = False
|
||||||
|
|
||||||
def register(self):
|
def register(self):
|
||||||
"""Register the timer into the blender timer system
|
"""Register the timer into the blender timer system
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not self.is_registered:
|
if not self.is_running:
|
||||||
bpy.app.timers.register(self.main)
|
bpy.app.timers.register(self.main)
|
||||||
self.is_registered = True
|
self.is_running = True
|
||||||
logging.debug(f"Register {self.__class__.__name__}")
|
logging.debug(f"Register {self.__class__.__name__}")
|
||||||
else:
|
else:
|
||||||
logging.debug(
|
logging.debug(
|
||||||
f"Timer {self.__class__.__name__} already registered")
|
f"Timer {self.__class__.__name__} already registered")
|
||||||
|
|
||||||
def main(self):
|
def main(self):
|
||||||
self.execute()
|
try:
|
||||||
|
self.execute()
|
||||||
if self._running:
|
except Exception as e:
|
||||||
return self._timeout
|
logging.error(e)
|
||||||
|
self.unregister()
|
||||||
|
session.disconnect()
|
||||||
|
else:
|
||||||
|
if self.is_running:
|
||||||
|
return self._timeout
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
"""Main timer loop
|
"""Main timer loop
|
||||||
@ -105,7 +107,7 @@ class Timer(Delayable):
|
|||||||
if bpy.app.timers.is_registered(self.main):
|
if bpy.app.timers.is_registered(self.main):
|
||||||
bpy.app.timers.unregister(self.main)
|
bpy.app.timers.unregister(self.main)
|
||||||
|
|
||||||
self._running = False
|
self.is_running = False
|
||||||
|
|
||||||
|
|
||||||
class ApplyTimer(Timer):
|
class ApplyTimer(Timer):
|
||||||
@ -142,7 +144,6 @@ class DynamicRightSelectTimer(Timer):
|
|||||||
super().__init__(timout)
|
super().__init__(timout)
|
||||||
self._last_selection = []
|
self._last_selection = []
|
||||||
self._user = None
|
self._user = None
|
||||||
self._right_strategy = RP_COMMON
|
|
||||||
self._annotating = False
|
self._annotating = False
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
@ -237,7 +238,7 @@ class DynamicRightSelectTimer(Timer):
|
|||||||
logging.debug("Update selection")
|
logging.debug("Update selection")
|
||||||
|
|
||||||
# Fix deselection until right managment refactoring (with Roles concepts)
|
# Fix deselection until right managment refactoring (with Roles concepts)
|
||||||
if len(current_selection) == 0 and self._right_strategy == RP_COMMON:
|
if len(current_selection) == 0 :
|
||||||
owned_keys = session.list(
|
owned_keys = session.list(
|
||||||
filter_owner=settings.username)
|
filter_owner=settings.username)
|
||||||
for key in owned_keys:
|
for key in owned_keys:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user