Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent data corruption during a migration if components are removed. #286

Merged
merged 1 commit into from
May 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion addons/io_hubs_addon/components/handlers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import bpy
from bpy.app.handlers import persistent
from .components_registry import get_components_registry
from .utils import redirect_c_stdout, get_host_components, is_linked, get_host_reference_message
from .utils import redirect_c_stdout, get_host_components, is_linked, get_host_reference_message, has_component
from .gizmos import update_gizmos
from .types import MigrationType, PanelType
import io
Expand Down Expand Up @@ -65,6 +65,9 @@ def migrate_components(

for scene in bpy.data.scenes:
for component in get_host_components(scene):
if not has_component(scene, component.get_name()):
# The component was removed in a previous migration
continue
try:
was_migrated = migrate(
component, migration_type, PanelType.SCENE, scene, migration_report)
Expand All @@ -83,6 +86,9 @@ def migrate_components(

for ob in bpy.data.objects:
for component in get_host_components(ob):
if not has_component(ob, component.get_name()):
# The component was removed in a previous migration
continue
try:
was_migrated = migrate(
component, migration_type, PanelType.OBJECT, ob, migration_report, ob=ob)
Expand Down Expand Up @@ -112,6 +118,9 @@ def migrate_components(
ob = armature_objects.get(armature.name_full, armature)
for bone in armature.bones:
for component in get_host_components(bone):
if not has_component(bone, component.get_name()):
# The component was removed in a previous migration
continue
try:
was_migrated = migrate(
component, migration_type, PanelType.BONE, bone, migration_report, ob=ob)
Expand All @@ -130,6 +139,9 @@ def migrate_components(

for material in bpy.data.materials:
for component in get_host_components(material):
if not has_component(material, component.get_name()):
# The component was removed in a previous migration
continue
try:
was_migrated = migrate(
component, migration_type, PanelType.MATERIAL, material, migration_report)
Expand Down
Loading