Blender 2.80-compatible unregistration

This commit is contained in:
Sybren A. Stüvel 2018-09-04 14:56:10 +02:00
parent a04137ec6a
commit 2f5f82b1a8
3 changed files with 37 additions and 29 deletions

View File

@ -955,6 +955,9 @@ def deactivate():
pass pass
_rna_classes = [cls for cls in locals() if isinstance(cls, type) and hasattr(cls, 'bl_rna')]
def register(): def register():
bpy.types.Sequence.atc_is_synced = bpy.props.BoolProperty(name="Is Synced") 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") 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.types.SEQUENCER_PT_edit.append(draw_strip_movie_meta)
bpy.utils.register_class(AttractToolsPanel) for cls in _rna_classes:
bpy.utils.register_class(AttractShotRelink) bpy.utils.register_class(cls)
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)
def unregister(): def unregister():
deactivate() 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_is_synced
del bpy.types.Sequence.atc_object_id del bpy.types.Sequence.atc_object_id
del bpy.types.Sequence.atc_object_id_conflict del bpy.types.Sequence.atc_object_id_conflict

View File

@ -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) 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(): def register():
from ..utils import redraw from ..utils import redraw
bpy.utils.register_class(FlamencoManagerGroup) for cls in _rna_classes:
bpy.utils.register_class(FLAMENCO_OT_fmanagers) bpy.utils.register_class(cls)
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)
scene = bpy.types.Scene scene = bpy.types.Scene
scene.flamenco_render_fchunk_size = IntProperty( scene.flamenco_render_fchunk_size = IntProperty(
@ -917,7 +917,11 @@ def register():
def unregister(): def unregister():
deactivate() 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', for name in ('flamenco_render_fchunk_size',
'flamenco_render_schunk_count', 'flamenco_render_schunk_count',

View File

@ -323,20 +323,25 @@ def window_menu(self, context):
props.screenshot_full = True props.screenshot_full = True
def register(): def get_topbar_menu():
bpy.utils.register_class(PILLAR_OT_image_share) """Return the topbar menu in a Blender 2.79 and 2.80 compatible way."""
bpy.types.IMAGE_MT_image.append(image_editor_menu)
try: try:
menu = bpy.types.TOPBAR_MT_window menu = bpy.types.TOPBAR_MT_window
except AttributeError: except AttributeError:
# Blender < 2.80 # Blender < 2.80
menu = bpy.types.INFO_MT_window 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(): def unregister():
bpy.utils.unregister_class(PILLAR_OT_image_share) bpy.utils.unregister_class(PILLAR_OT_image_share)
bpy.types.IMAGE_MT_image.remove(image_editor_menu) bpy.types.IMAGE_MT_image.remove(image_editor_menu)
bpy.types.INFO_MT_window.remove(window_menu) get_topbar_menu().remove(window_menu)