diff --git a/blender_cloud/attract/__init__.py b/blender_cloud/attract/__init__.py index 3b15361..26bca74 100644 --- a/blender_cloud/attract/__init__.py +++ b/blender_cloud/attract/__init__.py @@ -955,6 +955,9 @@ def deactivate(): pass +_rna_classes = [cls for cls in locals() if isinstance(cls, type) and hasattr(cls, 'bl_rna')] + + def register(): bpy.types.Sequence.atc_is_synced = bpy.props.BoolProperty(name="Is Synced") bpy.types.Sequence.atc_object_id = bpy.props.StringProperty(name="Attract Object ID") @@ -980,22 +983,18 @@ def register(): bpy.types.SEQUENCER_PT_edit.append(draw_strip_movie_meta) - bpy.utils.register_class(AttractToolsPanel) - bpy.utils.register_class(AttractShotRelink) - bpy.utils.register_class(AttractShotDelete) - bpy.utils.register_class(AttractStripUnlink) - bpy.utils.register_class(AttractShotFetchUpdate) - bpy.utils.register_class(AttractShotSubmitSelected) - bpy.utils.register_class(ATTRACT_OT_submit_all) - bpy.utils.register_class(ATTRACT_OT_open_meta_blendfile) - bpy.utils.register_class(ATTRACT_OT_shot_open_in_browser) - bpy.utils.register_class(ATTRACT_OT_make_shot_thumbnail) - bpy.utils.register_class(ATTRACT_OT_copy_id_to_clipboard) + for cls in _rna_classes: + bpy.utils.register_class(cls) def unregister(): deactivate() - bpy.utils.unregister_module(__name__) + for cls in _rna_classes: + try: + bpy.utils.unregister_class(cls) + except RuntimeError: + log.warning('Unable to unregister class %r, probably already unregistered', cls) + del bpy.types.Sequence.atc_is_synced del bpy.types.Sequence.atc_object_id del bpy.types.Sequence.atc_object_id_conflict diff --git a/blender_cloud/flamenco/__init__.py b/blender_cloud/flamenco/__init__.py index c840b30..4882702 100644 --- a/blender_cloud/flamenco/__init__.py +++ b/blender_cloud/flamenco/__init__.py @@ -814,19 +814,19 @@ def flamenco_do_override_output_path_updated(scene, context): log.info('Setting Override Output Path to %s', scene.flamenco_override_output_path) +# FlamencoManagerGroup needs to be registered before classes that use it. +_rna_classes = [FlamencoManagerGroup] +_rna_classes.extend( + cls for cls in locals() + if isinstance(cls, type) and hasattr(cls, 'bl_rna') and cls not in _rna_classes +) + + def register(): from ..utils import redraw - bpy.utils.register_class(FlamencoManagerGroup) - bpy.utils.register_class(FLAMENCO_OT_fmanagers) - bpy.utils.register_class(FLAMENCO_OT_render) - bpy.utils.register_class(FLAMENCO_OT_scene_to_frame_range) - bpy.utils.register_class(FLAMENCO_OT_copy_files) - bpy.utils.register_class(FLAMENCO_OT_explore_file_path) - bpy.utils.register_class(FLAMENCO_OT_enable_output_path_override) - bpy.utils.register_class(FLAMENCO_OT_disable_output_path_override) - bpy.utils.register_class(FLAMENCO_OT_abort) - bpy.utils.register_class(FLAMENCO_PT_render) + for cls in _rna_classes: + bpy.utils.register_class(cls) scene = bpy.types.Scene scene.flamenco_render_fchunk_size = IntProperty( @@ -917,7 +917,11 @@ def register(): def unregister(): deactivate() - bpy.utils.unregister_module(__name__) + for cls in _rna_classes: + try: + bpy.utils.unregister_class(cls) + except RuntimeError: + log.warning('Unable to unregister class %r, probably already unregistered', cls) for name in ('flamenco_render_fchunk_size', 'flamenco_render_schunk_count', diff --git a/blender_cloud/image_sharing.py b/blender_cloud/image_sharing.py index 779ff1e..b64cdd4 100644 --- a/blender_cloud/image_sharing.py +++ b/blender_cloud/image_sharing.py @@ -323,20 +323,25 @@ def window_menu(self, context): props.screenshot_full = True -def register(): - bpy.utils.register_class(PILLAR_OT_image_share) - - bpy.types.IMAGE_MT_image.append(image_editor_menu) +def get_topbar_menu(): + """Return the topbar menu in a Blender 2.79 and 2.80 compatible way.""" try: menu = bpy.types.TOPBAR_MT_window except AttributeError: # Blender < 2.80 menu = bpy.types.INFO_MT_window - menu.append(window_menu) + return menu + + +def register(): + bpy.utils.register_class(PILLAR_OT_image_share) + + bpy.types.IMAGE_MT_image.append(image_editor_menu) + get_topbar_menu().append(window_menu) def unregister(): bpy.utils.unregister_class(PILLAR_OT_image_share) bpy.types.IMAGE_MT_image.remove(image_editor_menu) - bpy.types.INFO_MT_window.remove(window_menu) + get_topbar_menu().remove(window_menu)