@ -20,6 +20,10 @@ from . import bl_types, delayable, environment, presence, ui, utils
|
|||||||
from .libs.replication.replication.data import ReplicatedDataFactory
|
from .libs.replication.replication.data import ReplicatedDataFactory
|
||||||
from .libs.replication.replication.exception import NonAuthorizedOperationError
|
from .libs.replication.replication.exception import NonAuthorizedOperationError
|
||||||
from .libs.replication.replication.interface import Session
|
from .libs.replication.replication.interface import Session
|
||||||
|
from .libs.replication.replication.constants import (
|
||||||
|
STATE_ACTIVE,
|
||||||
|
STATE_INITIAL,
|
||||||
|
STATE_SYNCING)
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logger.setLevel(logging.ERROR)
|
logger.setLevel(logging.ERROR)
|
||||||
@ -335,13 +339,21 @@ classes = (
|
|||||||
SessionApply,
|
SessionApply,
|
||||||
SessionCommit,
|
SessionCommit,
|
||||||
)
|
)
|
||||||
|
@persistent
|
||||||
|
def load_pre_handler(dummy):
|
||||||
|
global client
|
||||||
|
|
||||||
|
if client and client.state in [STATE_ACTIVE, STATE_SYNCING]:
|
||||||
|
bpy.ops.session.stop()
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
from bpy.utils import register_class
|
from bpy.utils import register_class
|
||||||
for cls in classes:
|
for cls in classes:
|
||||||
register_class(cls)
|
register_class(cls)
|
||||||
|
|
||||||
|
bpy.app.handlers.load_pre.append(load_pre_handler)
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
global client
|
global client
|
||||||
|
|
||||||
@ -352,6 +364,8 @@ def unregister():
|
|||||||
from bpy.utils import unregister_class
|
from bpy.utils import unregister_class
|
||||||
for cls in reversed(classes):
|
for cls in reversed(classes):
|
||||||
unregister_class(cls)
|
unregister_class(cls)
|
||||||
|
|
||||||
|
bpy.app.handlers.load_pre.remove(load_pre_handler)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
register()
|
register()
|
||||||
|
Reference in New Issue
Block a user