Merge branch 'master' into blender2.8
authorBastien Montagne <montagne29@wanadoo.fr>
Wed, 19 Apr 2017 20:11:53 +0000 (22:11 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Wed, 19 Apr 2017 20:11:53 +0000 (22:11 +0200)
1  2 
source/blender/blenkernel/intern/library_query.c
source/blender/editors/object/object_add.c

index 4852ae0741ea2ada4f83c02bc61af206d2deee3b,b278d6e1e87dde2e7d609c03e17c9dce30b65b87..410a3fecbf0a0968c42ca76b65ba642d74be7a2a
@@@ -1143,21 -1140,35 +1143,35 @@@ static int object_delete_exec(bContext 
        if (CTX_data_edit_object(C)) 
                return OPERATOR_CANCELLED;
  
 -      CTX_DATA_BEGIN (C, Base *, base, selected_bases)
 +      CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
        {
 -              const bool is_indirectly_used = BKE_library_ID_is_indirectly_used(bmain, base->object);
 -              if (base->object->id.tag & LIB_TAG_INDIRECT) {
 +              const bool is_indirectly_used = BKE_library_ID_is_indirectly_used(bmain, ob);
 +              if (ob->id.tag & LIB_TAG_INDIRECT) {
                        /* Can this case ever happen? */
 -                      BKE_reportf(op->reports, RPT_WARNING, "Cannot delete indirectly linked object '%s'", base->object->id.name + 2);
 +                      BKE_reportf(op->reports, RPT_WARNING, "Cannot delete indirectly linked object '%s'", ob->id.name + 2);
                        continue;
                }
 -              else if (is_indirectly_used && ID_REAL_USERS(base->object) <= 1 && ID_EXTRA_USERS(base->object) == 0) {
 +              else if (is_indirectly_used && ID_REAL_USERS(ob) <= 1 && ID_EXTRA_USERS(ob) == 0) {
                        BKE_reportf(op->reports, RPT_WARNING,
                                "Cannot delete object '%s' from scene '%s', indirectly used objects need at least one user",
 -                              base->object->id.name + 2, scene->id.name + 2);
 +                              ob->id.name + 2, scene->id.name + 2);
                        continue;
                }
+               /* This is sort of a quick hack to address T51243 - Proper thing to do here would be to nuke most of all this
+                * custom scene/object/base handling, and use generic lib remap/query for that.
+                * But this is for later (aka 2.8, once layers & co are settled and working).
+                */
+               if (use_global && base->object->id.lib == NULL) {
+                       /* We want to nuke the object, let's nuke it the easy way (not for linked data though)... */
+                       BKE_libblock_delete(bmain, &base->object->id);
+                       changed = true;
+                       continue;
+               }
                /* remove from Grease Pencil parent */
+               /* XXX This is likely not correct? Will also remove parent from grease pencil from other scenes,
+                *     even when use_global is false... */
                for (bGPdata *gpd = bmain->gpencil.first; gpd; gpd = gpd->id.next) {
                        for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
                                if (gpl->parent != NULL) {