From 31c644b657d3dbfaa170e5893fcd69ea5b87d670 Mon Sep 17 00:00:00 2001 From: Alexander Romanov Date: Thu, 20 Apr 2017 11:39:20 +0300 Subject: [PATCH 1/2] Fix T51198: Crash with new Datablock ID Properties --- source/blender/makesrna/intern/rna_access.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index c3d2d92fc5e..a299302f04f 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -5599,12 +5599,13 @@ static char *rna_pointer_as_string__bldata(PointerRNA *ptr) } } -char *RNA_pointer_as_string(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *prop_ptr, PointerRNA *ptr_prop) +char *RNA_pointer_as_string(bContext *C, PointerRNA *ptr, PropertyRNA *prop_ptr, PointerRNA *ptr_prop) { + IDProperty *prop; if (ptr_prop->data == NULL) { return BLI_strdup("None"); } - else if (RNA_property_flag(prop_ptr) & PROP_IDPROPERTY) { + else if ((prop = rna_idproperty_check(&prop_ptr, ptr)) && prop->type != IDP_ID) { return RNA_pointer_as_string_id(C, ptr_prop); } else { From ae79eb2105de519bcc408256d25272efa3195818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 20 Apr 2017 12:01:31 +0200 Subject: [PATCH 2/2] Alembic import: select imported objects When the Alembic import is finished, all imported objects are selected. --- source/blender/alembic/intern/alembic_capi.cc | 5 ++++- tests/python/bl_alembic_import_test.py | 22 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/source/blender/alembic/intern/alembic_capi.cc b/source/blender/alembic/intern/alembic_capi.cc index 104b19beaf0..e44f66b7e56 100644 --- a/source/blender/alembic/intern/alembic_capi.cc +++ b/source/blender/alembic/intern/alembic_capi.cc @@ -795,13 +795,16 @@ static void import_endjob(void *user_data) } else { /* Add object to scene. */ + Base *base; + BKE_scene_base_deselect_all(data->scene); for (iter = data->readers.begin(); iter != data->readers.end(); ++iter) { Object *ob = (*iter)->object(); ob->lay = data->scene->lay; - BKE_scene_base_add(data->scene, ob); + base = BKE_scene_base_add(data->scene, ob); + BKE_scene_base_select(data->scene, base); DAG_id_tag_update_ex(data->bmain, &ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); } diff --git a/tests/python/bl_alembic_import_test.py b/tests/python/bl_alembic_import_test.py index fd43e404e82..cd23183ec06 100644 --- a/tests/python/bl_alembic_import_test.py +++ b/tests/python/bl_alembic_import_test.py @@ -63,6 +63,28 @@ class SimpleImportTest(unittest.TestCase): self.assertEqual(objects['Cube_003'], objects['Cube_005'].parent) self.assertEqual(objects['Cube_003'], objects['Cube_006'].parent) + def test_select_after_import(self): + # Add a sphere, so that there is something in the scene, selected, and active, + # before we do the Alembic import. + bpy.ops.mesh.primitive_uv_sphere_add() + sphere = bpy.context.active_object + self.assertEqual('Sphere', sphere.name) + self.assertEqual([sphere], bpy.context.selected_objects) + + bpy.ops.wm.alembic_import( + filepath=str(self.testdir / "cubes-hierarchy.abc"), + as_background_job=False) + + # The active object is probably the first one that was imported, but this + # behaviour is not defined. At least it should be one of the cubes, and + # not the sphere. + self.assertNotEqual(sphere, bpy.context.active_object) + self.assertTrue('Cube' in bpy.context.active_object.name) + + # All cubes should be selected, but the sphere shouldn't be. + for ob in bpy.data.objects: + self.assertEqual('Cube' in ob.name, ob.select) + def main(): global args