Replace of (id->lib != NULL) check by meaningful macro.
authorBastien Montagne <montagne29@wanadoo.fr>
Wed, 6 Jul 2016 12:11:01 +0000 (14:11 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Wed, 6 Jul 2016 12:11:01 +0000 (14:11 +0200)
Idea is to replace hard-to-track (id->lib != NULL) 'is linked datablock' check everywhere in Blender
by a macro doing the same thing. This will allow to easily spot those checks in future, and more importantly,
to easily change it (see work done in asset-engine branch).

Note: did not touch to readfile.c, since there most of the time 'id->lib' check actually concerns the pointer,
and not a check whether ID is linked or not. Will have a closer look at it later.

Reviewers: campbellbarton, brecht, sergey

Differential Revision: https://developer.blender.org/D2082

71 files changed:
source/blender/blenkernel/intern/action.c
source/blender/blenkernel/intern/armature.c
source/blender/blenkernel/intern/armature_update.c
source/blender/blenkernel/intern/bpath.c
source/blender/blenkernel/intern/brush.c
source/blender/blenkernel/intern/camera.c
source/blender/blenkernel/intern/constraint.c
source/blender/blenkernel/intern/curve.c
source/blender/blenkernel/intern/group.c
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/key.c
source/blender/blenkernel/intern/lamp.c
source/blender/blenkernel/intern/lattice.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/library_query.c
source/blender/blenkernel/intern/linestyle.c
source/blender/blenkernel/intern/mask.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/mball.c
source/blender/blenkernel/intern/mesh.c
source/blender/blenkernel/intern/modifier.c
source/blender/blenkernel/intern/node.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/object_update.c
source/blender/blenkernel/intern/packedFile.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/speaker.c
source/blender/blenkernel/intern/text.c
source/blender/blenkernel/intern/texture.c
source/blender/blenkernel/intern/world.c
source/blender/editors/animation/anim_filter.c
source/blender/editors/animation/keyframes_draw.c
source/blender/editors/armature/pose_edit.c
source/blender/editors/armature/pose_lib.c
source/blender/editors/interface/interface_eyedropper.c
source/blender/editors/interface/interface_ops.c
source/blender/editors/interface/interface_regions.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/mesh/mesh_data.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_constraint.c
source/blender/editors/object/object_data_transfer.c
source/blender/editors/object/object_edit.c
source/blender/editors/object/object_modifier.c
source/blender/editors/object/object_relations.c
source/blender/editors/object/object_shapekey.c
source/blender/editors/object/object_transform.c
source/blender/editors/object/object_vgroup.c
source/blender/editors/physics/particle_edit.c
source/blender/editors/physics/particle_object.c
source/blender/editors/screen/screen_ops.c
source/blender/editors/sculpt_paint/paint_image.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/space_logic/logic_ops.c
source/blender/editors/space_outliner/outliner_draw.c
source/blender/editors/space_outliner/outliner_edit.c
source/blender/editors/space_outliner/outliner_tools.c
source/blender/editors/space_outliner/outliner_tree.c
source/blender/editors/space_text/text_ops.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/space_view3d/view3d_fly.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/editors/space_view3d/view3d_walk.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/util/ed_util.c
source/blender/makesdna/DNA_ID.h
source/blender/makesrna/intern/rna_access.c
source/blender/makesrna/intern/rna_object.c
source/blender/windowmanager/intern/wm_operators.c

index 46ee8a4d888aa3a6e038efbbbabcfa180165a7f7..9d6b2a0568189b0fcadf13049cd57b48cf6db99f 100644 (file)
@@ -107,7 +107,7 @@ static void make_localact_init_cb(ID *id, AnimData *adt, void *mlac_ptr)
        tMakeLocalActionContext *mlac = (tMakeLocalActionContext *)mlac_ptr;
        
        if (adt->action == mlac->act) {
-               if (id->lib) mlac->is_lib = true;
+               if (ID_IS_LINKED_DATABLOCK(id)) mlac->is_lib = true;
                else mlac->is_local = true;
        }
 }
@@ -118,7 +118,7 @@ static void make_localact_apply_cb(ID *id, AnimData *adt, void *mlac_ptr)
        tMakeLocalActionContext *mlac = (tMakeLocalActionContext *)mlac_ptr;
        
        if (adt->action == mlac->act) {
-               if (id->lib == NULL) {
+               if (!ID_IS_LINKED_DATABLOCK(id)) {
                        adt->action = mlac->act_new;
                        
                        id_us_plus(&mlac->act_new->id);
@@ -133,7 +133,7 @@ void BKE_action_make_local(bAction *act)
        tMakeLocalActionContext mlac = {act, NULL, false, false};
        Main *bmain = G.main;
        
-       if (act->id.lib == NULL)
+       if (!ID_IS_LINKED_DATABLOCK(act))
                return;
        
        /* XXX: double-check this; it used to be just single-user check, but that was when fake-users were still default */
@@ -213,7 +213,7 @@ bAction *BKE_action_copy(bAction *src)
                }
        }
        
-       if (src->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(src)) {
                BKE_id_lib_local_paths(G.main, src->id.lib, &dst->id);
        }
 
index b59618f46b26856d14fa4805942535846c0370e7..572490f937c8b83e616ea47cc53c1ae51ca0ff1b 100644 (file)
@@ -148,7 +148,7 @@ void BKE_armature_make_local(bArmature *arm)
        bool is_local = false, is_lib = false;
        Object *ob;
 
-       if (arm->id.lib == NULL)
+       if (!ID_IS_LINKED_DATABLOCK(arm))
                return;
        if (arm->id.us == 1) {
                id_clear_lib_data(bmain, &arm->id);
@@ -157,7 +157,7 @@ void BKE_armature_make_local(bArmature *arm)
 
        for (ob = bmain->object.first; ob && ELEM(0, is_lib, is_local); ob = ob->id.next) {
                if (ob->data == arm) {
-                       if (ob->id.lib)
+                       if (ID_IS_LINKED_DATABLOCK(ob))
                                is_lib = true;
                        else
                                is_local = true;
@@ -176,7 +176,7 @@ void BKE_armature_make_local(bArmature *arm)
 
                for (ob = bmain->object.first; ob; ob = ob->id.next) {
                        if (ob->data == arm) {
-                               if (ob->id.lib == NULL) {
+                               if (!ID_IS_LINKED_DATABLOCK(ob)) {
                                        ob->data = arm_new;
                                        id_us_plus(&arm_new->id);
                                        id_us_min(&arm->id);
@@ -231,7 +231,7 @@ bArmature *BKE_armature_copy(bArmature *arm)
        newArm->act_edbone = NULL;
        newArm->sketch = NULL;
 
-       if (arm->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(arm)) {
                BKE_id_lib_local_paths(G.main, arm->id.lib, &newArm->id);
        }
 
index 826bb12a91251aeb47bc1c79e1a1b9bc77b06c22..ece17335fa0fe304df651df39eb90c972481e9a8 100644 (file)
@@ -696,7 +696,7 @@ void BKE_pose_eval_flush(EvaluationContext *UNUSED(eval_ctx),
 
 void BKE_pose_eval_proxy_copy(EvaluationContext *UNUSED(eval_ctx), Object *ob)
 {
-       BLI_assert(ob->id.lib != NULL && ob->proxy_from != NULL);
+       BLI_assert(ID_IS_LINKED_DATABLOCK(ob) && ob->proxy_from != NULL);
        DEBUG_PRINT("%s on %s\n", __func__, ob->id.name);
        if (BKE_pose_copy_result(ob->pose, ob->proxy_from->pose) == false) {
                printf("Proxy copy error, lib Object: %s proxy Object: %s\n",
index 76544e5ed42bb1b4ae51af7862e69b0ac0afeff1..a708c59fa971820be3e3119f7277553852a233e2 100644 (file)
@@ -424,7 +424,7 @@ void BKE_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int
 {
        const char *absbase = (flag & BKE_BPATH_TRAVERSE_ABS) ? ID_BLEND_PATH(bmain, id) : NULL;
 
-       if ((flag & BKE_BPATH_TRAVERSE_SKIP_LIBRARY) && id->lib) {
+       if ((flag & BKE_BPATH_TRAVERSE_SKIP_LIBRARY) && ID_IS_LINKED_DATABLOCK(id)) {
                return;
        }
 
index 44cacffb71f3700e515bdbd357fc301c13aba769..4a5be1d3d92c8ad33994c94a8dfc02e3b7cfaef1 100644 (file)
@@ -195,7 +195,7 @@ Brush *BKE_brush_copy(Brush *brush)
        /* enable fake user by default */
        id_fake_user_set(&brush->id);
 
-       if (brush->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(brush)) {
                BKE_id_lib_local_paths(G.main, brush->id.lib, &brushn->id);
        }
 
@@ -237,7 +237,7 @@ void BKE_brush_make_local(Brush *brush)
        Scene *scene;
        bool is_local = false, is_lib = false;
 
-       if (brush->id.lib == NULL) return;
+       if (!ID_IS_LINKED_DATABLOCK(brush)) return;
 
        if (brush->clone.image) {
                /* special case: ima always local immediately. Clone image should only
@@ -248,7 +248,7 @@ void BKE_brush_make_local(Brush *brush)
 
        for (scene = bmain->scene.first; scene && ELEM(0, is_lib, is_local); scene = scene->id.next) {
                if (BKE_paint_brush(&scene->toolsettings->imapaint.paint) == brush) {
-                       if (scene->id.lib) is_lib = true;
+                       if (ID_IS_LINKED_DATABLOCK(scene)) is_lib = true;
                        else is_local = true;
                }
        }
@@ -269,7 +269,7 @@ void BKE_brush_make_local(Brush *brush)
                
                for (scene = bmain->scene.first; scene; scene = scene->id.next) {
                        if (BKE_paint_brush(&scene->toolsettings->imapaint.paint) == brush) {
-                               if (scene->id.lib == NULL) {
+                               if (!ID_IS_LINKED_DATABLOCK(scene)) {
                                        BKE_paint_brush_set(&scene->toolsettings->imapaint.paint, brush_new);
                                }
                        }
index eabee742327e602f55c478c7e04f502401946dbf..9fd2c2ddd1409460e0a89c386e88f0e0165a4ed1 100644 (file)
@@ -99,7 +99,7 @@ Camera *BKE_camera_copy(Camera *cam)
 
        id_lib_extern((ID *)camn->dof_ob);
 
-       if (cam->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(cam)) {
                BKE_id_lib_local_paths(G.main, cam->id.lib, &camn->id);
        }
 
@@ -117,7 +117,7 @@ void BKE_camera_make_local(Camera *cam)
         * - mixed: make copy
         */
        
-       if (cam->id.lib == NULL) return;
+       if (!ID_IS_LINKED_DATABLOCK(cam)) return;
        if (cam->id.us == 1) {
                id_clear_lib_data(bmain, &cam->id);
                return;
@@ -125,7 +125,7 @@ void BKE_camera_make_local(Camera *cam)
        
        for (ob = bmain->object.first; ob && ELEM(0, is_lib, is_local); ob = ob->id.next) {
                if (ob->data == cam) {
-                       if (ob->id.lib) is_lib = true;
+                       if (ID_IS_LINKED_DATABLOCK(ob)) is_lib = true;
                        else is_local = true;
                }
        }
@@ -143,7 +143,7 @@ void BKE_camera_make_local(Camera *cam)
 
                for (ob = bmain->object.first; ob; ob = ob->id.next) {
                        if (ob->data == cam) {
-                               if (ob->id.lib == NULL) {
+                               if (!ID_IS_LINKED_DATABLOCK(ob)) {
                                        ob->data = cam_new;
                                        id_us_plus(&cam_new->id);
                                        id_us_min(&cam->id);
index c88b24aa3816d7ee20d01422cf5d0730732fc0b8..4c9ddd495e321ef1765af9bd3b97df20c8c93ea3 100644 (file)
@@ -4649,7 +4649,7 @@ void BKE_constraints_id_loop(ListBase *conlist, ConstraintIDFunc func, void *use
 /* helper for BKE_constraints_copy(), to be used for making sure that ID's are valid */
 static void con_extern_cb(bConstraint *UNUSED(con), ID **idpoin, bool UNUSED(is_reference), void *UNUSED(userData))
 {
-       if (*idpoin && (*idpoin)->lib)
+       if (*idpoin && ID_IS_LINKED_DATABLOCK(*idpoin))
                id_lib_extern(*idpoin);
 }
 
index c52b0f6a8847be86032bc33798c50460c838f55e..face3ae112fe059987175e7e1ec2e99115fc2091 100644 (file)
@@ -207,7 +207,7 @@ Curve *BKE_curve_copy(Curve *cu)
        id_us_plus((ID *)cun->vfonti);
        id_us_plus((ID *)cun->vfontbi);
 
-       if (cu->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(cu)) {
                BKE_id_lib_local_paths(G.main, cu->id.lib, &cun->id);
        }
 
@@ -237,7 +237,7 @@ void BKE_curve_make_local(Curve *cu)
         * - mixed: do a copy
         */
 
-       if (cu->id.lib == NULL)
+       if (!ID_IS_LINKED_DATABLOCK(cu))
                return;
 
        if (cu->id.us == 1) {
@@ -248,7 +248,7 @@ void BKE_curve_make_local(Curve *cu)
 
        for (ob = bmain->object.first; ob && ELEM(0, is_lib, is_local); ob = ob->id.next) {
                if (ob->data == cu) {
-                       if (ob->id.lib) is_lib = true;
+                       if (ID_IS_LINKED_DATABLOCK(ob)) is_lib = true;
                        else is_local = true;
                }
        }
@@ -265,7 +265,7 @@ void BKE_curve_make_local(Curve *cu)
 
                for (ob = bmain->object.first; ob; ob = ob->id.next) {
                        if (ob->data == cu) {
-                               if (ob->id.lib == NULL) {
+                               if (!ID_IS_LINKED_DATABLOCK(ob)) {
                                        ob->data = cu_new;
                                        id_us_plus(&cu_new->id);
                                        id_us_min(&cu->id);
index 4fdee7e36333e1906e085df377a8d9d12a769ec0..ce7ef1f710a46a195f51d0a39119951a6b1a4fb3 100644 (file)
@@ -97,7 +97,7 @@ Group *BKE_group_copy(Group *group)
        /* Do not copy group's preview (same behavior as for objects). */
        groupn->preview = NULL;
 
-       if (group->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(group)) {
                BKE_id_lib_local_paths(G.main, group->id.lib, &groupn->id);
        }
 
index 69384a709691dba27bf66e1ff20b7137fd29f605..790b6c6854bc93a91d86974e6db8d8ac01209eed 100644 (file)
@@ -457,7 +457,7 @@ Image *BKE_image_copy(Main *bmain, Image *ima)
        nima->stereo3d_format = MEM_dupallocN(ima->stereo3d_format);
        BLI_duplicatelist(&nima->views, &ima->views);
 
-       if (ima->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(ima)) {
                BKE_id_lib_local_paths(bmain, ima->id.lib, &nima->id);
        }
 
@@ -483,7 +483,7 @@ void BKE_image_make_local(struct Image *ima)
         * - mixed: make copy
         */
 
-       if (ima->id.lib == NULL) return;
+       if (!ID_IS_LINKED_DATABLOCK(ima)) return;
 
        /* Can't take short cut here: must check meshes at least because of bogus
         * texface ID refs. - z0r */
@@ -497,13 +497,13 @@ void BKE_image_make_local(struct Image *ima)
 
        for (tex = bmain->tex.first; tex; tex = tex->id.next) {
                if (tex->ima == ima) {
-                       if (tex->id.lib) is_lib = true;
+                       if (ID_IS_LINKED_DATABLOCK(tex)) is_lib = true;
                        else is_local = true;
                }
        }
        for (brush = bmain->brush.first; brush; brush = brush->id.next) {
                if (brush->clone.image == ima) {
-                       if (brush->id.lib) is_lib = true;
+                       if (ID_IS_LINKED_DATABLOCK(brush)) is_lib = true;
                        else is_local = true;
                }
        }
@@ -518,7 +518,7 @@ void BKE_image_make_local(struct Image *ima)
 
                                        for (a = 0; a < me->totface; a++, tface++) {
                                                if (tface->tpage == ima) {
-                                                       if (me->id.lib) is_lib = true;
+                                                       if (ID_IS_LINKED_DATABLOCK(me)) is_lib = true;
                                                        else is_local = true;
                                                }
                                        }
@@ -536,7 +536,7 @@ void BKE_image_make_local(struct Image *ima)
 
                                        for (a = 0; a < me->totpoly; a++, mtpoly++) {
                                                if (mtpoly->tpage == ima) {
-                                                       if (me->id.lib) is_lib = true;
+                                                       if (ID_IS_LINKED_DATABLOCK(me)) is_lib = true;
                                                        else is_local = true;
                                                }
                                        }
@@ -560,7 +560,7 @@ void BKE_image_make_local(struct Image *ima)
 
                tex = bmain->tex.first;
                while (tex) {
-                       if (tex->id.lib == NULL) {
+                       if (!ID_IS_LINKED_DATABLOCK(tex)) {
                                if (tex->ima == ima) {
                                        tex->ima = ima_new;
                                        id_us_plus(&ima_new->id);
@@ -571,7 +571,7 @@ void BKE_image_make_local(struct Image *ima)
                }
                brush = bmain->brush.first;
                while (brush) {
-                       if (brush->id.lib == NULL) {
+                       if (!ID_IS_LINKED_DATABLOCK(brush)) {
                                if (brush->clone.image == ima) {
                                        brush->clone.image = ima_new;
                                        id_us_plus(&ima_new->id);
index 2517e2cc197637a677ffca542b9d221f0c837eb7..79d42ed6e06da1fbf90de2a8141185d03722f053 100644 (file)
@@ -171,7 +171,7 @@ Key *BKE_key_copy(Key *key)
                kb = kb->next;
        }
 
-       if (key->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(key)) {
                BKE_id_lib_local_paths(G.main, key->id.lib, &keyn->id);
        }
 
index 692b703f721edf23e5e3848413840aa2354d2171..433968346507d41a39b89808d88c4d2f87c534d1 100644 (file)
@@ -137,7 +137,7 @@ Lamp *BKE_lamp_copy(Lamp *la)
        if (la->preview)
                lan->preview = BKE_previewimg_copy(la->preview);
        
-       if (la->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(la)) {
                BKE_id_lib_local_paths(G.main, la->id.lib, &lan->id);
        }
 
@@ -181,7 +181,7 @@ void BKE_lamp_make_local(Lamp *la)
         * - mixed: make copy
         */
        
-       if (la->id.lib == NULL) return;
+       if (!ID_IS_LINKED_DATABLOCK(la)) return;
        if (la->id.us == 1) {
                id_clear_lib_data(bmain, &la->id);
                return;
@@ -190,7 +190,7 @@ void BKE_lamp_make_local(Lamp *la)
        ob = bmain->object.first;
        while (ob) {
                if (ob->data == la) {
-                       if (ob->id.lib) is_lib = true;
+                       if (ID_IS_LINKED_DATABLOCK(ob)) is_lib = true;
                        else is_local = true;
                }
                ob = ob->id.next;
@@ -210,7 +210,7 @@ void BKE_lamp_make_local(Lamp *la)
                while (ob) {
                        if (ob->data == la) {
                                
-                               if (ob->id.lib == NULL) {
+                               if (!ID_IS_LINKED_DATABLOCK(ob)) {
                                        ob->data = la_new;
                                        id_us_plus(&la_new->id);
                                        id_us_min(&la->id);
index 58c0a5671165ad10aea4d569bc59c4e88ea07c3a..07e6ba9062e3dfb672efe2f6aeb55f4ab9d6b52c 100644 (file)
@@ -293,7 +293,7 @@ Lattice *BKE_lattice_copy(Lattice *lt)
 
        ltn->editlatt = NULL;
 
-       if (lt->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(lt)) {
                BKE_id_lib_local_paths(G.main, lt->id.lib, &ltn->id);
        }
 
@@ -336,7 +336,7 @@ void BKE_lattice_make_local(Lattice *lt)
         * - mixed: make copy
         */
        
-       if (lt->id.lib == NULL) return;
+       if (!ID_IS_LINKED_DATABLOCK(lt)) return;
        if (lt->id.us == 1) {
                id_clear_lib_data(bmain, &lt->id);
                return;
@@ -344,7 +344,7 @@ void BKE_lattice_make_local(Lattice *lt)
        
        for (ob = bmain->object.first; ob && ELEM(false, is_lib, is_local); ob = ob->id.next) {
                if (ob->data == lt) {
-                       if (ob->id.lib) is_lib = true;
+                       if (ID_IS_LINKED_DATABLOCK(ob)) is_lib = true;
                        else is_local = true;
                }
        }
@@ -361,7 +361,7 @@ void BKE_lattice_make_local(Lattice *lt)
 
                for (ob = bmain->object.first; ob; ob = ob->id.next) {
                        if (ob->data == lt) {
-                               if (ob->id.lib == NULL) {
+                               if (!ID_IS_LINKED_DATABLOCK(ob)) {
                                        ob->data = lt_new;
                                        id_us_plus(&lt_new->id);
                                        id_us_min(&lt->id);
index fe16df18813596cd061bfe55a60ae8b36f585e08..553dd1761b87d50f267c6387a8353b6fe512e74a 100644 (file)
@@ -630,7 +630,7 @@ void BKE_main_lib_objects_recalc_all(Main *bmain)
 
        /* flag for full recalc */
        for (ob = bmain->object.first; ob; ob = ob->id.next) {
-               if (ob->id.lib) {
+               if (ID_IS_LINKED_DATABLOCK(ob)) {
                        DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME);
                }
        }
@@ -1061,7 +1061,7 @@ static int id_relink_looper(void *UNUSED(user_data), ID *UNUSED(self_id), ID **i
 
 void BKE_libblock_relink(ID *id)
 {
-       if (id->lib)
+       if (ID_IS_LINKED_DATABLOCK(id))
                return;
 
        BKE_library_foreach_ID_link(id, id_relink_looper, NULL, 0);
@@ -1275,7 +1275,7 @@ static ID *is_dupid(ListBase *lb, ID *id, const char *name)
        
        for (idtest = lb->first; idtest; idtest = idtest->next) {
                /* if idtest is not a lib */ 
-               if (id != idtest && idtest->lib == NULL) {
+               if (id != idtest && !ID_IS_LINKED_DATABLOCK(idtest)) {
                        /* do not test alphabetic! */
                        /* optimized */
                        if (idtest->name[2] == name[0]) {
@@ -1335,7 +1335,7 @@ static bool check_for_dupid(ListBase *lb, ID *id, char *name)
                for (idtest = lb->first; idtest; idtest = idtest->next) {
                        int nrtest;
                        if ( (id != idtest) &&
-                            (idtest->lib == NULL) &&
+                            !ID_IS_LINKED_DATABLOCK(idtest) &&
                             (*name == *(idtest->name + 2)) &&
                             STREQLEN(name, idtest->name + 2, left_len) &&
                             (BLI_split_name_num(leftest, &nrtest, idtest->name + 2, '.') == left_len)
@@ -1417,7 +1417,7 @@ bool new_id(ListBase *lb, ID *id, const char *tname)
        char name[MAX_ID_NAME - 2];
 
        /* if library, don't rename */
-       if (id->lib)
+       if (ID_IS_LINKED_DATABLOCK(id))
                return false;
 
        /* if no libdata given, look up based on ID */
@@ -1522,7 +1522,7 @@ static void lib_indirect_test_id(ID *id, const Library *lib)
 #define LIBTAG(a) \
        if (a && a->id.lib) { a->id.tag &= ~LIB_TAG_INDIRECT; a->id.tag |= LIB_TAG_EXTERN; } (void)0
        
-       if (id->lib) {
+       if (ID_IS_LINKED_DATABLOCK(id)) {
                /* datablocks that were indirectly related are now direct links
                 * without this, appending data that has a link to other data will fail to write */
                if (lib && id->lib->parent == lib) {
index 8373ad0123fca3ae18d1dc555a8c67fdf1be8ded..adde5229a9b7b87c5bf6d95c7e9b5c38807eac85 100644 (file)
@@ -895,7 +895,7 @@ bool BKE_library_ID_is_indirectly_used(Main *bmain, void *idv)
                ID *id_curr = lb_array[i]->first;
 
                for (; id_curr; id_curr = id_curr->next) {
-                       if (!id_curr->lib) {
+                       if (!ID_IS_LINKED_DATABLOCK(id_curr)) {
                                continue;
                        }
 
index 30dc48819e92c0510c893edbb054aeccf8b4b6c6..2985038bcae1b6a13a046d92d4bde48499060bff 100644 (file)
@@ -218,7 +218,7 @@ FreestyleLineStyle *BKE_linestyle_copy(struct Main *bmain, FreestyleLineStyle *l
        for (m = (LineStyleModifier *)linestyle->geometry_modifiers.first; m; m = m->next)
                BKE_linestyle_geometry_modifier_copy(new_linestyle, m);
 
-       if (linestyle->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(linestyle)) {
                BKE_id_lib_local_paths(G.main, linestyle->id.lib, &new_linestyle->id);
        }
 
index 94e53755ac447e403b3305b12975d73b04b3e115..dabdb4c81c63a0c8bc08ff5800074053e5f7e0ee 100644 (file)
@@ -861,7 +861,7 @@ Mask *BKE_mask_copy(Mask *mask)
        /* enable fake user by default */
        id_fake_user_set(&mask->id);
 
-       if (mask->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(mask)) {
                BKE_id_lib_local_paths(G.main, mask->id.lib, &mask_new->id);
        }
 
index db5ac54ada906016ca86f5d733cfff8f2c380f4d..7231620550ec6e9ac8b614092e76ccf61ea316a1 100644 (file)
@@ -245,7 +245,7 @@ Material *BKE_material_copy(Material *ma)
 
        BLI_listbase_clear(&man->gpumaterial);
        
-       if (ma->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(ma)) {
                BKE_id_lib_local_paths(G.main, ma->id.lib, &man->id);
        }
 
@@ -305,7 +305,7 @@ void BKE_material_make_local(Material *ma)
         * - mixed: make copy
         */
        
-       if (ma->id.lib == NULL) return;
+       if (!ID_IS_LINKED_DATABLOCK(ma)) return;
 
        /* One local user; set flag and return. */
        if (ma->id.us == 1) {
@@ -322,7 +322,7 @@ void BKE_material_make_local(Material *ma)
                if (ob->mat) {
                        for (a = 0; a < ob->totcol; a++) {
                                if (ob->mat[a] == ma) {
-                                       if (ob->id.lib) is_lib = true;
+                                       if (ID_IS_LINKED_DATABLOCK(ob)) is_lib = true;
                                        else is_local = true;
                                }
                        }
@@ -335,7 +335,7 @@ void BKE_material_make_local(Material *ma)
                if (me->mat) {
                        for (a = 0; a < me->totcol; a++) {
                                if (me->mat[a] == ma) {
-                                       if (me->id.lib) is_lib = true;
+                                       if (ID_IS_LINKED_DATABLOCK(me)) is_lib = true;
                                        else is_local = true;
                                }
                        }
@@ -348,7 +348,7 @@ void BKE_material_make_local(Material *ma)
                if (cu->mat) {
                        for (a = 0; a < cu->totcol; a++) {
                                if (cu->mat[a] == ma) {
-                                       if (cu->id.lib) is_lib = true;
+                                       if (ID_IS_LINKED_DATABLOCK(cu)) is_lib = true;
                                        else is_local = true;
                                }
                        }
@@ -361,7 +361,7 @@ void BKE_material_make_local(Material *ma)
                if (mb->mat) {
                        for (a = 0; a < mb->totcol; a++) {
                                if (mb->mat[a] == ma) {
-                                       if (mb->id.lib) is_lib = true;
+                                       if (ID_IS_LINKED_DATABLOCK(mb)) is_lib = true;
                                        else is_local = true;
                                }
                        }
@@ -389,7 +389,7 @@ void BKE_material_make_local(Material *ma)
                        if (ob->mat) {
                                for (a = 0; a < ob->totcol; a++) {
                                        if (ob->mat[a] == ma) {
-                                               if (ob->id.lib == NULL) {
+                                               if (!ID_IS_LINKED_DATABLOCK(ob)) {
                                                        ob->mat[a] = ma_new;
                                                        id_us_plus(&ma_new->id);
                                                        id_us_min(&ma->id);
@@ -405,7 +405,7 @@ void BKE_material_make_local(Material *ma)
                        if (me->mat) {
                                for (a = 0; a < me->totcol; a++) {
                                        if (me->mat[a] == ma) {
-                                               if (me->id.lib == NULL) {
+                                               if (!ID_IS_LINKED_DATABLOCK(me)) {
                                                        me->mat[a] = ma_new;
                                                        id_us_plus(&ma_new->id);
                                                        id_us_min(&ma->id);
@@ -421,7 +421,7 @@ void BKE_material_make_local(Material *ma)
                        if (cu->mat) {
                                for (a = 0; a < cu->totcol; a++) {
                                        if (cu->mat[a] == ma) {
-                                               if (cu->id.lib == NULL) {
+                                               if (!ID_IS_LINKED_DATABLOCK(cu)) {
                                                        cu->mat[a] = ma_new;
                                                        id_us_plus(&ma_new->id);
                                                        id_us_min(&ma->id);
@@ -437,7 +437,7 @@ void BKE_material_make_local(Material *ma)
                        if (mb->mat) {
                                for (a = 0; a < mb->totcol; a++) {
                                        if (mb->mat[a] == ma) {
-                                               if (mb->id.lib == NULL) {
+                                               if (!ID_IS_LINKED_DATABLOCK(mb)) {
                                                        mb->mat[a] = ma_new;
                                                        id_us_plus(&ma_new->id);
                                                        id_us_min(&ma->id);
@@ -852,8 +852,8 @@ void assign_material(Object *ob, Material *ma, short act, int assign_type)
        if (act < 1) act = 1;
        
        /* prevent crashing when using accidentally */
-       BLI_assert(ob->id.lib == NULL);
-       if (ob->id.lib) return;
+       BLI_assert(!ID_IS_LINKED_DATABLOCK(ob));
+       if (ID_IS_LINKED_DATABLOCK(ob)) return;
        
        /* test arraylens */
        
@@ -1121,7 +1121,7 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb)
                Group *group;
 
                for (group = G.main->group.first; group; group = group->id.next) {
-                       if (!group->id.lib && STREQ(group->id.name, ma->group->id.name)) {
+                       if (!ID_IS_LINKED_DATABLOCK(group) && STREQ(group->id.name, ma->group->id.name)) {
                                ma->group = group;
                        }
                }
@@ -2230,7 +2230,7 @@ int do_version_tface(Main *main)
        
        /* 1st part: marking mesh materials to update */
        for (me = main->mesh.first; me; me = me->id.next) {
-               if (me->id.lib) continue;
+               if (ID_IS_LINKED_DATABLOCK(me)) continue;
 
                /* get the active tface layer */
                index = CustomData_get_active_layer_index(&me->fdata, CD_MTFACE);
@@ -2284,7 +2284,7 @@ int do_version_tface(Main *main)
                                 * at doversion time: direct_link might not have happened on it,
                                 * so ma->mtex is not pointing to valid memory yet.
                                 * later we could, but it's better not */
-                               else if (ma->id.lib)
+                               else if (ID_IS_LINKED_DATABLOCK(ma))
                                        continue;
                                
                                /* material already marked as disputed */
@@ -2349,7 +2349,7 @@ int do_version_tface(Main *main)
 
        /* we shouldn't loop through the materials created in the loop. make the loop stop at its original length) */
        for (ma = main->mat.first, a = 0; ma; ma = ma->id.next, a++) {
-               if (ma->id.lib) continue;
+               if (ID_IS_LINKED_DATABLOCK(ma)) continue;
 
                /* disputed material */
                if (ma->game.flag == MAT_BGE_DISPUTED) {
index 685cd35fc20664288e8d64cefc2752bfd9264eb8..877937eb7269faae199443336b15343887f3580a 100644 (file)
@@ -117,7 +117,7 @@ MetaBall *BKE_mball_copy(MetaBall *mb)
        mbn->editelems = NULL;
        mbn->lastelem = NULL;
        
-       if (mb->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(mb)) {
                BKE_id_lib_local_paths(G.main, mb->id.lib, &mbn->id);
        }
 
@@ -142,7 +142,7 @@ void BKE_mball_make_local(MetaBall *mb)
         * - mixed: make copy
         */
        
-       if (mb->id.lib == NULL) return;
+       if (!ID_IS_LINKED_DATABLOCK(mb)) return;
        if (mb->id.us == 1) {
                id_clear_lib_data(bmain, &mb->id);
                extern_local_mball(mb);
@@ -152,7 +152,7 @@ void BKE_mball_make_local(MetaBall *mb)
 
        for (ob = G.main->object.first; ob && ELEM(0, is_lib, is_local); ob = ob->id.next) {
                if (ob->data == mb) {
-                       if (ob->id.lib) is_lib = true;
+                       if (ID_IS_LINKED_DATABLOCK(ob)) is_lib = true;
                        else is_local = true;
                }
        }
@@ -170,7 +170,7 @@ void BKE_mball_make_local(MetaBall *mb)
 
                for (ob = G.main->object.first; ob; ob = ob->id.next) {
                        if (ob->data == mb) {
-                               if (ob->id.lib == NULL) {
+                               if (!ID_IS_LINKED_DATABLOCK(ob)) {
                                        ob->data = mb_new;
                                        id_us_plus(&mb_new->id);
                                        id_us_min(&mb->id);
index 706902ef3cf37af5e7423f66fd3a7b8e959e4f50..129f89c2b8e968f10aed3bf86b9dcfd392a7bc66 100644 (file)
@@ -549,7 +549,7 @@ Mesh *BKE_mesh_copy_ex(Main *bmain, Mesh *me)
        men->key = BKE_key_copy(me->key);
        if (men->key) men->key->from = (ID *)men;
 
-       if (me->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(me)) {
                BKE_id_lib_local_paths(bmain, me->id.lib, &men->id);
        }
 
@@ -628,7 +628,7 @@ void BKE_mesh_make_local(Mesh *me)
         * - mixed: make copy
         */
 
-       if (me->id.lib == NULL) return;
+       if (!ID_IS_LINKED_DATABLOCK(me)) return;
        if (me->id.us == 1) {
                id_clear_lib_data(bmain, &me->id);
                expand_local_mesh(me);
@@ -637,7 +637,7 @@ void BKE_mesh_make_local(Mesh *me)
 
        for (ob = bmain->object.first; ob && ELEM(0, is_lib, is_local); ob = ob->id.next) {
                if (me == ob->data) {
-                       if (ob->id.lib) is_lib = true;
+                       if (ID_IS_LINKED_DATABLOCK(ob)) is_lib = true;
                        else is_local = true;
                }
        }
@@ -656,7 +656,7 @@ void BKE_mesh_make_local(Mesh *me)
 
                for (ob = bmain->object.first; ob; ob = ob->id.next) {
                        if (me == ob->data) {
-                               if (ob->id.lib == NULL) {
+                               if (!ID_IS_LINKED_DATABLOCK(ob)) {
                                        BKE_mesh_assign_object(ob, me_new);
                                }
                        }
index 716da14cae6bcd0fee5e6ebba66d90ffb7cf6faa..41e4c21d8141615832b04040513934b53d2e1294 100644 (file)
@@ -707,7 +707,7 @@ void test_object_modifiers(Object *ob)
  */
 const char *modifier_path_relbase(Object *ob)
 {
-       if (G.relbase_valid || ob->id.lib) {
+       if (G.relbase_valid || ID_IS_LINKED_DATABLOCK(ob)) {
                return ID_BLEND_PATH(G.main, &ob->id);
        }
        else {
index d78ddc41e9770aefa686bf4991d7267cdbde4ae4..cf70159a3294a4315cfaf9e9d3918e9738640656 100644 (file)
@@ -1289,7 +1289,7 @@ static bNodeTree *ntreeCopyTree_internal(bNodeTree *ntree, Main *bmain, bool ski
        /* node tree will generate its own interface type */
        newtree->interface_type = NULL;
        
-       if (ntree->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(ntree)) {
                BKE_id_lib_local_paths(bmain, ntree->id.lib, &newtree->id);
        }
 
@@ -1967,7 +1967,7 @@ void ntreeMakeLocal(bNodeTree *ntree, bool id_in_mainlist)
         * - mixed: make copy
         */
        
-       if (ntree->id.lib == NULL) return;
+       if (!ID_IS_LINKED_DATABLOCK(ntree)) return;
        if (ntree->id.us == 1) {
                id_clear_lib_data_ex(bmain, (ID *)ntree, id_in_mainlist);
                extern_local_ntree(ntree);
@@ -2715,7 +2715,7 @@ void BKE_node_clipboard_add_node(bNode *node)
        node_info->id = node->id;
        if (node->id) {
                BLI_strncpy(node_info->id_name, node->id->name, sizeof(node_info->id_name));
-               if (node->id->lib) {
+               if (ID_IS_LINKED_DATABLOCK(node->id)) {
                        BLI_strncpy(node_info->library_name, node->id->lib->filepath, sizeof(node_info->library_name));
                }
                else {
index d4ba70ee0a613917e4e1aee8f067097f13ccc8f9..316e74625f0bdbdbc3d44f7ed280d9dafaa17b1c 100644 (file)
@@ -1168,7 +1168,7 @@ Object *BKE_object_copy_ex(Main *bmain, Object *ob, bool copy_caches)
        /* Copy runtime surve data. */
        obn->curve_cache = NULL;
 
-       if (ob->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(ob)) {
                BKE_id_lib_local_paths(bmain, ob->id.lib, &obn->id);
        }
 
@@ -1226,7 +1226,7 @@ void BKE_object_make_local(Object *ob)
         * - mixed: make copy
         */
 
-       if (ob->id.lib == NULL) return;
+       if (!ID_IS_LINKED_DATABLOCK(ob)) return;
        
        ob->proxy = ob->proxy_from  = ob->proxy_group = NULL;
        
@@ -1237,7 +1237,7 @@ void BKE_object_make_local(Object *ob)
        else {
                for (sce = bmain->scene.first; sce && ELEM(0, is_lib, is_local); sce = sce->id.next) {
                        if (BKE_scene_base_find(sce, ob)) {
-                               if (sce->id.lib) is_lib = true;
+                               if (ID_IS_LINKED_DATABLOCK(sce)) is_lib = true;
                                else is_local = true;
                        }
                }
@@ -1256,7 +1256,7 @@ void BKE_object_make_local(Object *ob)
 
                        sce = bmain->scene.first;
                        while (sce) {
-                               if (sce->id.lib == NULL) {
+                               if (!ID_IS_LINKED_DATABLOCK(sce)) {
                                        base = sce->base.first;
                                        while (base) {
                                                if (base->object == ob) {
@@ -1280,7 +1280,7 @@ bool BKE_object_is_libdata(Object *ob)
 {
        if (!ob) return false;
        if (ob->proxy) return false;
-       if (ob->id.lib) return true;
+       if (ID_IS_LINKED_DATABLOCK(ob)) return true;
        return false;
 }
 
@@ -1288,10 +1288,10 @@ bool BKE_object_is_libdata(Object *ob)
 bool BKE_object_obdata_is_libdata(Object *ob)
 {
        if (!ob) return false;
-       if (ob->proxy && (ob->data == NULL || ((ID *)ob->data)->lib == NULL)) return false;
-       if (ob->id.lib) return true;
+       if (ob->proxy && (ob->data == NULL || !ID_IS_LINKED_DATABLOCK(ob->data))) return false;
+       if (ID_IS_LINKED_DATABLOCK(ob)) return true;
        if (ob->data == NULL) return false;
-       if (((ID *)ob->data)->lib) return true;
+       if (ID_IS_LINKED_DATABLOCK(ob->data)) return true;
 
        return false;
 }
@@ -1340,7 +1340,7 @@ void BKE_object_copy_proxy_drivers(Object *ob, Object *target)
                                                        /* only on local objects because this causes indirect links
                                                         * 'a -> b -> c', blend to point directly to a.blend
                                                         * when a.blend has a proxy thats linked into c.blend  */
-                                                       if (ob->id.lib == NULL)
+                                                       if (!ID_IS_LINKED_DATABLOCK(ob))
                                                                id_lib_extern((ID *)dtar->id);
                                                }
                                        }
@@ -1358,7 +1358,7 @@ void BKE_object_copy_proxy_drivers(Object *ob, Object *target)
 void BKE_object_make_proxy(Object *ob, Object *target, Object *gob)
 {
        /* paranoia checks */
-       if (ob->id.lib || target->id.lib == NULL) {
+       if (ID_IS_LINKED_DATABLOCK(ob) || !ID_IS_LINKED_DATABLOCK(target)) {
                printf("cannot make proxy\n");
                return;
        }
@@ -2735,7 +2735,7 @@ void BKE_object_handle_update_ex(EvaluationContext *eval_ctx,
                                printf("recalcob %s\n", ob->id.name + 2);
                        
                        /* handle proxy copy for target */
-                       if (ob->id.lib && ob->proxy_from) {
+                       if (ID_IS_LINKED_DATABLOCK(ob) && ob->proxy_from) {
                                // printf("ob proxy copy, lib ob %s proxy %s\n", ob->id.name, ob->proxy_from->id.name);
                                if (ob->proxy_from->proxy_group) { /* transform proxy into group space */
                                        Object *obg = ob->proxy_from->proxy_group;
index 6d41c5c29757100f72c6865c3a1be945b77379a6..457263f854b5647acff82ec608af49245fe7e699 100644 (file)
@@ -203,7 +203,7 @@ void BKE_object_handle_data_update(EvaluationContext *eval_ctx,
                        break;
                }
                case OB_ARMATURE:
-                       if (ob->id.lib && ob->proxy_from) {
+                       if (ID_IS_LINKED_DATABLOCK(ob) && ob->proxy_from) {
                                if (BKE_pose_copy_result(ob->pose, ob->proxy_from->pose) == false) {
                                        printf("Proxy copy error, lib Object: %s proxy Object: %s\n",
                                               ob->id.name + 2, ob->proxy_from->id.name + 2);
@@ -315,7 +315,7 @@ void BKE_object_eval_uber_transform(EvaluationContext *UNUSED(eval_ctx),
        // XXX: it's almost redundant now...
 
        /* Handle proxy copy for target, */
-       if (ob->id.lib && ob->proxy_from) {
+       if (ID_IS_LINKED_DATABLOCK(ob) && ob->proxy_from) {
                if (ob->proxy_from->proxy_group) {
                        /* Transform proxy into group space. */
                        Object *obg = ob->proxy_from->proxy_group;
index 1c318dfd1153095ece7c10ba73d108d301a2510c..489fc2f371044c5c79cc45c7dc3829de811ccbb7 100644 (file)
@@ -232,7 +232,7 @@ void packAll(Main *bmain, ReportList *reports, bool verbose)
        int tot = 0;
        
        for (ima = bmain->image.first; ima; ima = ima->id.next) {
-               if (BKE_image_has_packedfile(ima) == false && ima->id.lib == NULL) {
+               if (BKE_image_has_packedfile(ima) == false && !ID_IS_LINKED_DATABLOCK(ima)) {
                        if (ima->source == IMA_SRC_FILE) {
                                BKE_image_packfiles(reports, ima, ID_BLEND_PATH(bmain, &ima->id));
                                tot ++;
@@ -245,14 +245,14 @@ void packAll(Main *bmain, ReportList *reports, bool verbose)
        }
 
        for (vfont = bmain->vfont.first; vfont; vfont = vfont->id.next) {
-               if (vfont->packedfile == NULL && vfont->id.lib == NULL && BKE_vfont_is_builtin(vfont) == false) {
+               if (vfont->packedfile == NULL && !ID_IS_LINKED_DATABLOCK(vfont) && BKE_vfont_is_builtin(vfont) == false) {
                        vfont->packedfile = newPackedFile(reports, vfont->name, bmain->name);
                        tot ++;
                }
        }
 
        for (sound = bmain->sound.first; sound; sound = sound->id.next) {
-               if (sound->packedfile == NULL && sound->id.lib == NULL) {
+               if (sound->packedfile == NULL && !ID_IS_LINKED_DATABLOCK(sound)) {
                        sound->packedfile = newPackedFile(reports, sound->name, bmain->name);
                        tot++;
                }
index d1f5afa26a61241c77b0888eecd8a66cbc5f0477..4136f866f6ad61831358e94506b63cf9af6f2adc 100644 (file)
@@ -3332,7 +3332,7 @@ ParticleSettings *BKE_particlesettings_copy(ParticleSettings *part)
 
        BLI_duplicatelist(&partn->dupliweights, &part->dupliweights);
        
-       if (part->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(part)) {
                BKE_id_lib_local_paths(G.main, part->id.lib, &partn->id);
        }
 
@@ -3360,7 +3360,7 @@ void BKE_particlesettings_make_local(ParticleSettings *part)
         * - mixed: make copy
         */
        
-       if (part->id.lib == 0) return;
+       if (!ID_IS_LINKED_DATABLOCK(part)) return;
        if (part->id.us == 1) {
                id_clear_lib_data(bmain, &part->id);
                expand_local_particlesettings(part);
@@ -3372,7 +3372,7 @@ void BKE_particlesettings_make_local(ParticleSettings *part)
                ParticleSystem *psys = ob->particlesystem.first;
                for (; psys; psys = psys->next) {
                        if (psys->part == part) {
-                               if (ob->id.lib) is_lib = true;
+                               if (ID_IS_LINKED_DATABLOCK(ob)) is_lib = true;
                                else is_local = true;
                        }
                }
@@ -3393,7 +3393,7 @@ void BKE_particlesettings_make_local(ParticleSettings *part)
                for (ob = bmain->object.first; ob; ob = ob->id.next) {
                        ParticleSystem *psys;
                        for (psys = ob->particlesystem.first; psys; psys = psys->next) {
-                               if (psys->part == part && ob->id.lib == 0) {
+                               if (psys->part == part && !ID_IS_LINKED_DATABLOCK(ob)) {
                                        psys->part = part_new;
                                        id_us_plus(&part_new->id);
                                        id_us_min(&part->id);
index e5075a2d3828190ef44fac260dd3805eb0f22f0d..58214e4a8d9e6c9eb071cf109e7d68766eabc740 100644 (file)
@@ -74,7 +74,7 @@ Speaker *BKE_speaker_copy(Speaker *spk)
        if (spkn->sound)
                id_us_plus(&spkn->sound->id);
 
-       if (spk->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(spk)) {
                BKE_id_lib_local_paths(G.main, spk->id.lib, &spkn->id);
        }
 
@@ -97,7 +97,7 @@ void BKE_speaker_make_local(Speaker *spk)
         * - mixed: make copy
         */
 
-       if (spk->id.lib == NULL) return;
+       if (!ID_IS_LINKED_DATABLOCK(spk)) return;
        if (spk->id.us == 1) {
                id_clear_lib_data(bmain, &spk->id);
                extern_local_speaker(spk);
@@ -107,7 +107,7 @@ void BKE_speaker_make_local(Speaker *spk)
        ob = bmain->object.first;
        while (ob) {
                if (ob->data == spk) {
-                       if (ob->id.lib) is_lib = true;
+                       if (ID_IS_LINKED_DATABLOCK(ob)) is_lib = true;
                        else is_local = true;
                }
                ob = ob->id.next;
@@ -128,7 +128,7 @@ void BKE_speaker_make_local(Speaker *spk)
                while (ob) {
                        if (ob->data == spk) {
 
-                               if (ob->id.lib == NULL) {
+                               if (!ID_IS_LINKED_DATABLOCK(ob)) {
                                        ob->data = spk_new;
                                        id_us_plus(&spk_new->id);
                                        id_us_min(&spk->id);
index fdc2edba57f68b04a720317ea739ba12092c1778..2b713f980d50c4b0a19cb317ce6b23f7dc07ab62 100644 (file)
@@ -491,7 +491,7 @@ Text *BKE_text_copy(Main *bmain, Text *ta)
 
        init_undo_text(tan);
 
-       if (ta->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(ta)) {
                BKE_id_lib_local_paths(bmain, ta->id.lib, &tan->id);
        }
 
index 9326ece7a4b2336b3a69a3a750b51092680bb949..a8657dd2cb0ebd015b3ee76134bd482e06ad0213 100644 (file)
@@ -870,7 +870,7 @@ Tex *BKE_texture_copy(Tex *tex)
                texn->nodetree = ntreeCopyTree(tex->nodetree);
        }
        
-       if (tex->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(tex)) {
                BKE_id_lib_local_paths(G.main, tex->id.lib, &texn->id);
        }
 
@@ -935,7 +935,7 @@ void BKE_texture_make_local(Tex *tex)
         * - mixed: make copy
         */
        
-       if (tex->id.lib == NULL) return;
+       if (!ID_IS_LINKED_DATABLOCK(tex)) return;
 
        if (tex->id.us == 1) {
                id_clear_lib_data(bmain, &tex->id);
@@ -947,7 +947,7 @@ void BKE_texture_make_local(Tex *tex)
        while (ma) {
                for (a = 0; a < MAX_MTEX; a++) {
                        if (ma->mtex[a] && ma->mtex[a]->tex == tex) {
-                               if (ma->id.lib) is_lib = true;
+                               if (ID_IS_LINKED_DATABLOCK(ma)) is_lib = true;
                                else is_local = true;
                        }
                }
@@ -957,7 +957,7 @@ void BKE_texture_make_local(Tex *tex)
        while (la) {
                for (a = 0; a < MAX_MTEX; a++) {
                        if (la->mtex[a] && la->mtex[a]->tex == tex) {
-                               if (la->id.lib) is_lib = true;
+                               if (ID_IS_LINKED_DATABLOCK(la)) is_lib = true;
                                else is_local = true;
                        }
                }
@@ -967,7 +967,7 @@ void BKE_texture_make_local(Tex *tex)
        while (wrld) {
                for (a = 0; a < MAX_MTEX; a++) {
                        if (wrld->mtex[a] && wrld->mtex[a]->tex == tex) {
-                               if (wrld->id.lib) is_lib = true;
+                               if (ID_IS_LINKED_DATABLOCK(wrld)) is_lib = true;
                                else is_local = true;
                        }
                }
@@ -976,11 +976,11 @@ void BKE_texture_make_local(Tex *tex)
        br = bmain->brush.first;
        while (br) {
                if (br->mtex.tex == tex) {
-                       if (br->id.lib) is_lib = true;
+                       if (ID_IS_LINKED_DATABLOCK(br)) is_lib = true;
                        else is_local = true;
                }
                if (br->mask_mtex.tex == tex) {
-                       if (br->id.lib) is_lib = true;
+                       if (ID_IS_LINKED_DATABLOCK(br)) is_lib = true;
                        else is_local = true;
                }
                br = br->id.next;
@@ -989,7 +989,7 @@ void BKE_texture_make_local(Tex *tex)
        while (pa) {
                for (a = 0; a < MAX_MTEX; a++) {
                        if (pa->mtex[a] && pa->mtex[a]->tex == tex) {
-                               if (pa->id.lib) is_lib = true;
+                               if (ID_IS_LINKED_DATABLOCK(pa)) is_lib = true;
                                else is_local = true;
                        }
                }
@@ -999,7 +999,7 @@ void BKE_texture_make_local(Tex *tex)
        while (ls) {
                for (a = 0; a < MAX_MTEX; a++) {
                        if (ls->mtex[a] && ls->mtex[a]->tex == tex) {
-                               if (ls->id.lib) is_lib = true;
+                               if (ID_IS_LINKED_DATABLOCK(ls)) is_lib = true;
                                else is_local = true;
                        }
                }
@@ -1022,7 +1022,7 @@ void BKE_texture_make_local(Tex *tex)
                while (ma) {
                        for (a = 0; a < MAX_MTEX; a++) {
                                if (ma->mtex[a] && ma->mtex[a]->tex == tex) {
-                                       if (ma->id.lib == NULL) {
+                                       if (!ID_IS_LINKED_DATABLOCK(ma)) {
                                                ma->mtex[a]->tex = tex_new;
                                                id_us_plus(&tex_new->id);
                                                id_us_min(&tex->id);
@@ -1035,7 +1035,7 @@ void BKE_texture_make_local(Tex *tex)
                while (la) {
                        for (a = 0; a < MAX_MTEX; a++) {
                                if (la->mtex[a] && la->mtex[a]->tex == tex) {
-                                       if (la->id.lib == NULL) {
+                                       if (!ID_IS_LINKED_DATABLOCK(la)) {
                                                la->mtex[a]->tex = tex_new;
                                                id_us_plus(&tex_new->id);
                                                id_us_min(&tex->id);
@@ -1048,7 +1048,7 @@ void BKE_texture_make_local(Tex *tex)
                while (wrld) {
                        for (a = 0; a < MAX_MTEX; a++) {
                                if (wrld->mtex[a] && wrld->mtex[a]->tex == tex) {
-                                       if (wrld->id.lib == NULL) {
+                                       if (!ID_IS_LINKED_DATABLOCK(wrld)) {
                                                wrld->mtex[a]->tex = tex_new;
                                                id_us_plus(&tex_new->id);
                                                id_us_min(&tex->id);
@@ -1060,14 +1060,14 @@ void BKE_texture_make_local(Tex *tex)
                br = bmain->brush.first;
                while (br) {
                        if (br->mtex.tex == tex) {
-                               if (br->id.lib == NULL) {
+                               if (!ID_IS_LINKED_DATABLOCK(br)) {
                                        br->mtex.tex = tex_new;
                                        id_us_plus(&tex_new->id);
                                        id_us_min(&tex->id);
                                }
                        }
                        if (br->mask_mtex.tex == tex) {
-                               if (br->id.lib == NULL) {
+                               if (!ID_IS_LINKED_DATABLOCK(br)) {
                                        br->mask_mtex.tex = tex_new;
                                        id_us_plus(&tex_new->id);
                                        id_us_min(&tex->id);
@@ -1079,7 +1079,7 @@ void BKE_texture_make_local(Tex *tex)
                while (pa) {
                        for (a = 0; a < MAX_MTEX; a++) {
                                if (pa->mtex[a] && pa->mtex[a]->tex == tex) {
-                                       if (pa->id.lib == NULL) {
+                                       if (!ID_IS_LINKED_DATABLOCK(pa)) {
                                                pa->mtex[a]->tex = tex_new;
                                                id_us_plus(&tex_new->id);
                                                id_us_min(&tex->id);
@@ -1092,7 +1092,7 @@ void BKE_texture_make_local(Tex *tex)
                while (ls) {
                        for (a = 0; a < MAX_MTEX; a++) {
                                if (ls->mtex[a] && ls->mtex[a]->tex == tex) {
-                                       if (ls->id.lib == NULL) {
+                                       if (!ID_IS_LINKED_DATABLOCK(ls)) {
                                                ls->mtex[a]->tex = tex_new;
                                                id_us_plus(&tex_new->id);
                                                id_us_min(&tex->id);
index ec021586be5dfafd5e814cc84b11b2233e8d9d83..c6ab843b38a6b452568173076583d5fd5a30aeca 100644 (file)
@@ -141,7 +141,7 @@ World *BKE_world_copy(World *wrld)
 
        BLI_listbase_clear(&wrldn->gpumaterial);
 
-       if (wrld->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(wrld)) {
                BKE_id_lib_local_paths(G.main, wrld->id.lib, &wrldn->id);
        }
 
@@ -185,7 +185,7 @@ void BKE_world_make_local(World *wrld)
         * - mixed: make copy
         */
        
-       if (wrld->id.lib == NULL) return;
+       if (!ID_IS_LINKED_DATABLOCK(wrld)) return;
        if (wrld->id.us == 1) {
                id_clear_lib_data(bmain, &wrld->id);
                return;
@@ -193,7 +193,7 @@ void BKE_world_make_local(World *wrld)
        
        for (sce = bmain->scene.first; sce && ELEM(false, is_lib, is_local); sce = sce->id.next) {
                if (sce->world == wrld) {
-                       if (sce->id.lib) is_lib = true;
+                       if (ID_IS_LINKED_DATABLOCK(sce)) is_lib = true;
                        else is_local = true;
                }
        }
@@ -210,7 +210,7 @@ void BKE_world_make_local(World *wrld)
 
                for (sce = bmain->scene.first; sce; sce = sce->id.next) {
                        if (sce->world == wrld) {
-                               if (sce->id.lib == NULL) {
+                               if (!ID_IS_LINKED_DATABLOCK(sce)) {
                                        sce->world = wrld_new;
                                        id_us_plus(&wrld_new->id);
                                        id_us_min(&wrld->id);
index 910e195173c4e89fbb568213d62c0c6511bb20d0..0a1a4787eb0c7b82a9cb9b94e04677b642db454d 100644 (file)
@@ -1255,7 +1255,7 @@ static size_t animfilter_action(bAnimContext *ac, ListBase *anim_data, bDopeShee
        /* don't include anything from this action if it is linked in from another file,
         * and we're getting stuff for editing...
         */
-       if ((filter_mode & ANIMFILTER_FOREDIT) && (act->id.lib))
+       if ((filter_mode & ANIMFILTER_FOREDIT) && ID_IS_LINKED_DATABLOCK(act))
                return 0;
                
        /* do groups */
index 6f1883cff5566169ff92f5b0e9dfa3576f9e9550..011a25ca2195cfe309d5bdd6fe8a410dd99eb87b 100644 (file)
@@ -679,7 +679,7 @@ void draw_fcurve_channel(View2D *v2d, AnimData *adt, FCurve *fcu, float ypos)
        
        short locked = (fcu->flag & FCURVE_PROTECTED) ||
                       ((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) ||
-                      ((adt && adt->action) && (adt->action->id.lib));
+                      ((adt && adt->action) && ID_IS_LINKED_DATABLOCK(adt->action));
        
        BLI_dlrbTree_init(&keys);
        BLI_dlrbTree_init(&blocks);
@@ -700,7 +700,7 @@ void draw_agroup_channel(View2D *v2d, AnimData *adt, bActionGroup *agrp, float y
        DLRBT_Tree keys, blocks;
        
        short locked = (agrp->flag & AGRP_PROTECTED) ||
-                      ((adt && adt->action) && (adt->action->id.lib));
+                      ((adt && adt->action) && ID_IS_LINKED_DATABLOCK(adt->action));
        
        BLI_dlrbTree_init(&keys);
        BLI_dlrbTree_init(&blocks);
@@ -720,7 +720,7 @@ void draw_action_channel(View2D *v2d, AnimData *adt, bAction *act, float ypos)
 {
        DLRBT_Tree keys, blocks;
        
-       short locked = (act && act->id.lib != NULL);
+       short locked = (act && ID_IS_LINKED_DATABLOCK(act));
        
        BLI_dlrbTree_init(&keys);
        BLI_dlrbTree_init(&blocks);
index a929507929fc595d433bff5370663ec86fa2afe8..5015829f86833dd4e426bf8c5f69e198429c8fa3 100644 (file)
@@ -86,7 +86,7 @@ void ED_armature_enter_posemode(bContext *C, Base *base)
        ReportList *reports = CTX_wm_reports(C);
        Object *ob = base->object;
        
-       if (ob->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(ob)) {
                BKE_report(reports, RPT_WARNING, "Cannot pose libdata");
                return;
        }
index dca9aa3e44682e772c3e22f4adae852602e4894e..d9a3efa765c6b1967b076f55a4c372c9e5eb56cf 100644 (file)
@@ -183,7 +183,7 @@ static int has_poselib_pose_data_poll(bContext *C)
 static int has_poselib_pose_data_for_editing_poll(bContext *C)
 {
        Object *ob = get_poselib_object(C);
-       return (ob && ob->poselib && !ob->poselib->id.lib);
+       return (ob && ob->poselib && !ID_IS_LINKED_DATABLOCK(ob->poselib));
 }
 
 /* ----------------------------------- */
@@ -385,7 +385,7 @@ static int poselib_add_poll(bContext *C)
        if (ED_operator_posemode(C)) {
                Object *ob = get_poselib_object(C);
                if (ob) {
-                       if ((ob->poselib == NULL) || (ob->poselib->id.lib == 0)) {
+                       if ((ob->poselib == NULL) || !ID_IS_LINKED_DATABLOCK(ob->poselib)) {
                                return true;
                        }
                }
index 2cbc56b14d3d62e4020795e0b3c860c2144a854e..ac7b6428217b9f1edada5eb652d2513d6c7cbc83 100644 (file)
@@ -805,7 +805,7 @@ static int depthdropper_init(bContext *C, wmOperator *op)
                RegionView3D *rv3d = CTX_wm_region_view3d(C);
                if (rv3d && rv3d->persp == RV3D_CAMOB) {
                        View3D *v3d = CTX_wm_view3d(C);
-                       if (v3d->camera && v3d->camera->data && (((ID *)v3d->camera->data)->lib == NULL)) {
+                       if (v3d->camera && v3d->camera->data && !ID_IS_LINKED_DATABLOCK(v3d->camera->data)) {
                                RNA_id_pointer_create(v3d->camera->data, &ddr->ptr);
                                ddr->prop = RNA_struct_find_property(&ddr->ptr, "dof_distance");
                        }
index ff29a6f8e33dc058bb91ecac9e8bbcc8f43613f1..01b10b7b032178dee889776780bee85dfe660e64 100644 (file)
@@ -416,7 +416,7 @@ bool UI_context_copy_to_selected_list(
 
                                        if ((id_data == NULL) ||
                                            (id_data->tag & LIB_TAG_DOIT) == 0 ||
-                                           (id_data->lib) ||
+                                           ID_IS_LINKED_DATABLOCK(id_data->lib) ||
                                            (GS(id_data->name) != id_code))
                                        {
                                                BLI_remlink(&lb, link);
index d4d3e1af1fd0963bbecb93d7d37c5a8415aad2f5..575b32e81e88d0a6c1c13e2bf76f7831c88c9a23 100644 (file)
@@ -454,7 +454,7 @@ static uiTooltipData *ui_tooltip_data_from_button(bContext *C, uiBut *but)
 
                if (but->rnapoin.id.data) {
                        ID *id = but->rnapoin.id.data;
-                       if (id->lib) {
+                       if (ID_IS_LINKED_DATABLOCK(id)) {
                                BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Library: %s"), id->lib->name);
                                data->format[data->totline].color_id = UI_TIP_LC_NORMAL;
                                data->totline++;
index 7f276bcc634bb908eca82ab6d418ec8cdff2c1ce..7205cdb3548f1a3ca303009c2bd8b8a7ed9b7d94 100644 (file)
@@ -974,7 +974,7 @@ static uiLayout *draw_modifier(
                        }
                        
                        UI_block_lock_clear(block);
-                       UI_block_lock_set(block, ob && ob->id.lib, ERROR_LIBDATA_MESSAGE);
+                       UI_block_lock_set(block, ob && ID_IS_LINKED_DATABLOCK(ob), ERROR_LIBDATA_MESSAGE);
                        
                        if (!ELEM(md->type, eModifierType_Fluidsim, eModifierType_Softbody, eModifierType_ParticleSystem,
                                   eModifierType_Cloth, eModifierType_Smoke))
@@ -1021,7 +1021,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr)
                return NULL;
        }
        
-       UI_block_lock_set(uiLayoutGetBlock(layout), (ob && ob->id.lib), ERROR_LIBDATA_MESSAGE);
+       UI_block_lock_set(uiLayoutGetBlock(layout), (ob && ID_IS_LINKED_DATABLOCK(ob)), ERROR_LIBDATA_MESSAGE);
        
        /* find modifier and draw it */
        cageIndex = modifiers_getCageIndex(scene, ob, &lastCageIndex, 0);
@@ -1249,7 +1249,7 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr)
                return NULL;
        }
        
-       UI_block_lock_set(uiLayoutGetBlock(layout), (ob && ob->id.lib), ERROR_LIBDATA_MESSAGE);
+       UI_block_lock_set(uiLayoutGetBlock(layout), (ob && ID_IS_LINKED_DATABLOCK(ob)), ERROR_LIBDATA_MESSAGE);
 
        /* hrms, the temporal constraint should not draw! */
        if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
@@ -1611,7 +1611,7 @@ void uiTemplateColorRamp(uiLayout *layout, PointerRNA *ptr, const char *propname
        block = uiLayoutAbsoluteBlock(layout);
 
        id = cptr.id.data;
-       UI_block_lock_set(block, (id && id->lib), ERROR_LIBDATA_MESSAGE);
+       UI_block_lock_set(block, (id && ID_IS_LINKED_DATABLOCK(id)), ERROR_LIBDATA_MESSAGE);
 
        colorband_buttons_layout(layout, block, cptr.data, &rect, cb, expand);
 
@@ -2263,7 +2263,7 @@ void uiTemplateCurveMapping(
        cb->prop = prop;
 
        id = cptr.id.data;
-       UI_block_lock_set(block, (id && id->lib), ERROR_LIBDATA_MESSAGE);
+       UI_block_lock_set(block, (id && ID_IS_LINKED_DATABLOCK(id)), ERROR_LIBDATA_MESSAGE);
 
        curvemap_buttons_layout(layout, &cptr, type, levels, brush, neg_slope, cb);
 
index 9f1602ccfaf0eeffdd835d5912d35b29eb56d19b..69db784038fd646a47d3ef739c35972562031883 100644 (file)
@@ -3292,7 +3292,7 @@ static int edbm_separate_exec(bContext *C, wmOperator *op)
                        Object *ob = base_iter->object;
                        if (ob->type == OB_MESH) {
                                Mesh *me = ob->data;
-                               if (me->id.lib == NULL) {
+                               if (!ID_IS_LINKED_DATABLOCK(me)) {
                                        BMesh *bm_old = NULL;
                                        int retval_iter = 0;
 
index e0ddc017e93982c8f46185f01af314280df9e241..772bb1bd3082bd611d1af288ccc1fa770f3d0db0 100644 (file)
@@ -511,7 +511,7 @@ static int layers_poll(bContext *C)
 {
        Object *ob = ED_object_context(C);
        ID *data = (ob) ? ob->data : NULL;
-       return (ob && !ob->id.lib && ob->type == OB_MESH && data && !data->lib);
+       return (ob && !ID_IS_LINKED_DATABLOCK(ob) && ob->type == OB_MESH && data && !ID_IS_LINKED_DATABLOCK(data));
 }
 
 static int mesh_uv_texture_add_exec(bContext *C, wmOperator *UNUSED(op))
@@ -759,7 +759,7 @@ static int mesh_customdata_mask_clear_poll(bContext *C)
                        return false;
                }
 
-               if (me->id.lib == NULL) {
+               if (!ID_IS_LINKED_DATABLOCK(me)) {
                        CustomData *data = GET_CD_DATA(me, vdata);
                        if (CustomData_has_layer(data, CD_PAINT_MASK)) {
                                return true;
@@ -813,7 +813,7 @@ static int mesh_customdata_skin_state(bContext *C)
 
        if (ob && ob->type == OB_MESH) {
                Mesh *me = ob->data;
-               if (me->id.lib == NULL) {
+               if (!ID_IS_LINKED_DATABLOCK(me)) {
                        CustomData *data = GET_CD_DATA(me, vdata);
                        return CustomData_has_layer(data, CD_MVERT_SKIN);
                }
index 0f1c72fcd55fc71f7e75f8510f5b78ea08a36b08..69950ccc9a9c30951760a9d49ad19554b2896567 100644 (file)
@@ -1162,7 +1162,7 @@ static int object_delete_exec(bContext *C, wmOperator *op)
                        Base *base_other;
 
                        for (scene_iter = bmain->scene.first; scene_iter; scene_iter = scene_iter->id.next) {
-                               if (scene_iter != scene && !(scene_iter->id.lib)) {
+                               if (scene_iter != scene && !ID_IS_LINKED_DATABLOCK(scene_iter)) {
                                        base_other = BKE_scene_base_find(scene_iter, base->object);
                                        if (base_other) {
                                                if (is_indirectly_used && ID_REAL_USERS(base->object) <= 1) {
@@ -1515,7 +1515,8 @@ static int convert_poll(bContext *C)
        Object *obact = CTX_data_active_object(C);
        Scene *scene = CTX_data_scene(C);
 
-       return (!scene->id.lib && obact && scene->obedit != obact && (obact->flag & SELECT) && !(obact->id.lib));
+       return (!ID_IS_LINKED_DATABLOCK(scene) && obact && scene->obedit != obact &&
+               (obact->flag & SELECT) && !ID_IS_LINKED_DATABLOCK(obact));
 }
 
 /* Helper for convert_exec */
@@ -2305,7 +2306,7 @@ static int join_poll(bContext *C)
 {
        Object *ob = CTX_data_active_object(C);
 
-       if (!ob || ob->id.lib) return 0;
+       if (!ob || ID_IS_LINKED_DATABLOCK(ob)) return 0;
 
        if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_ARMATURE))
                return ED_operator_screenactive(C);
@@ -2358,7 +2359,7 @@ static int join_shapes_poll(bContext *C)
 {
        Object *ob = CTX_data_active_object(C);
 
-       if (!ob || ob->id.lib) return 0;
+       if (!ob || ID_IS_LINKED_DATABLOCK(ob)) return 0;
 
        /* only meshes supported at the moment */
        if (ob->type == OB_MESH)
index d7b7fd7040e8de491d1dbde4aec5a94d482d19b9..db8a4c1960fcd9ae3ab918e207028b4578307277 100644 (file)
@@ -584,7 +584,7 @@ static int edit_constraint_poll_generic(bContext *C, StructRNA *rna_type)
                return 0;
        }
 
-       if (ob->id.lib || (ptr.id.data && ((ID *)ptr.id.data)->lib)) {
+       if (ID_IS_LINKED_DATABLOCK(ob) || (ptr.id.data && ID_IS_LINKED_DATABLOCK(ptr.id.data))) {
                CTX_wm_operator_poll_msg_set(C, "Cannot edit library data");
                return 0;
        }
index 47ee6752e51436006bcb4fcfe0f6b7514ecd708a..acee69daab76fce8edf5b8891b8a3037fdd24e4c 100644 (file)
@@ -300,7 +300,7 @@ static void data_transfer_exec_preprocess_objects(
                }
 
                me = ob->data;
-               if (me->id.lib) {
+               if (ID_IS_LINKED_DATABLOCK(me)) {
                        /* Do not transfer to linked data, not supported. */
                        BKE_reportf(op->reports, RPT_WARNING, "Skipping object '%s', linked data '%s' cannot be modified",
                                    ob->id.name + 2, me->id.name + 2);
@@ -330,7 +330,7 @@ static bool data_transfer_exec_is_object_valid(
                me->id.tag &= ~LIB_TAG_DOIT;
                return true;
        }
-       else if (me->id.lib == NULL) {
+       else if (!ID_IS_LINKED_DATABLOCK(me)) {
                /* Do not transfer apply operation more than once. */
                /* XXX This is not nice regarding vgroups, which are half-Object data... :/ */
                BKE_reportf(op->reports, RPT_WARNING,
@@ -387,7 +387,7 @@ static int data_transfer_exec(bContext *C, wmOperator *op)
                return OPERATOR_FINISHED;
        }
 
-       if (reverse_transfer && ((ID *)(ob_src->data))->lib) {
+       if (reverse_transfer && ID_IS_LINKED_DATABLOCK(ob_src->data)) {
                /* Do not transfer to linked data, not supported. */
                return OPERATOR_CANCELLED;
        }
index 01a567931b3a7797086721c1468d9ddde72eed98..3dc7d8ebd4b6e664c780505000e03d38e1587b01 100644 (file)
@@ -470,7 +470,7 @@ void ED_object_editmode_enter(bContext *C, int flag)
        View3D *v3d = NULL;
        bool ok = false;
 
-       if (scene->id.lib) return;
+       if (ID_IS_LINKED_DATABLOCK(scene)) return;
 
        if (sa && sa->spacetype == SPACE_VIEW3D)
                v3d = sa->spacedata.first;
@@ -539,7 +539,7 @@ void ED_object_editmode_enter(bContext *C, int flag)
                 * BKE_object_obdata_is_libdata that prevent the bugfix #6614, so
                 * i add this little hack here.
                 */
-               if (arm->id.lib) {
+               if (ID_IS_LINKED_DATABLOCK(arm)) {
                        error_libdata();
                        return;
                }
@@ -621,7 +621,7 @@ static int editmode_toggle_poll(bContext *C)
        Object *ob = CTX_data_active_object(C);
 
        /* covers proxies too */
-       if (ELEM(NULL, ob, ob->data) || ((ID *)ob->data)->lib)
+       if (ELEM(NULL, ob, ob->data) || ID_IS_LINKED_DATABLOCK(ob->data))
                return 0;
 
        /* if hidden but in edit mode, we still display */
@@ -848,7 +848,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event)
        Nurb *nu;
        bool do_depgraph_update = false;
        
-       if (scene->id.lib) return;
+       if (ID_IS_LINKED_DATABLOCK(scene)) return;
 
        if (!(ob = OBACT)) return;
        
@@ -1436,7 +1436,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op)
        {
                data = ob->data;
 
-               if (data && data->lib) {
+               if (data && ID_IS_LINKED_DATABLOCK(data)) {
                        linked_data = true;
                        continue;
                }
@@ -1519,7 +1519,7 @@ static void UNUSED_FUNCTION(image_aspect) (Scene *scene, View3D *v3d)
        int a, b, done;
        
        if (scene->obedit) return;  // XXX get from context
-       if (scene->id.lib) return;
+       if (ID_IS_LINKED_DATABLOCK(scene)) return;
        
        for (base = FIRSTBASE; base; base = base->next) {
                if (TESTBASELIB(v3d, base)) {
index 264945b00bfeca0dd8d2cb23dfa3e7cfc2454b00..b44ddf925a8985687808d8c4b7f8476eec191ab4 100644 (file)
@@ -817,9 +817,9 @@ int edit_modifier_poll_generic(bContext *C, StructRNA *rna_type, int obtype_flag
        PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", rna_type);
        Object *ob = (ptr.id.data) ? ptr.id.data : ED_object_active_context(C);
        
-       if (!ob || ob->id.lib) return 0;
+       if (!ob || ID_IS_LINKED_DATABLOCK(ob)) return 0;
        if (obtype_flag && ((1 << ob->type) & obtype_flag) == 0) return 0;
-       if (ptr.id.data && ((ID *)ptr.id.data)->lib) return 0;
+       if (ptr.id.data && ID_IS_LINKED_DATABLOCK(ptr.id.data)) return 0;
        
        return 1;
 }
index 94d1a2580638dbfdb4b235d1bd61296126bc4a9a..9a6fe5ae48b257bc2790e7ca9935a48b4ffca5ea 100644 (file)
@@ -291,17 +291,17 @@ static int make_proxy_invoke(bContext *C, wmOperator *op, const wmEvent *event)
        Object *ob = ED_object_active_context(C);
 
        /* sanity checks */
-       if (!scene || scene->id.lib || !ob)
+       if (!scene || ID_IS_LINKED_DATABLOCK(scene) || !ob)
                return OPERATOR_CANCELLED;
 
        /* Get object to work on - use a menu if we need to... */
-       if (ob->dup_group && ob->dup_group->id.lib) {
+       if (ob->dup_group && ID_IS_LINKED_DATABLOCK(ob->dup_group)) {
                /* gives menu with list of objects in group */
                /* proxy_group_objects_menu(C, op, ob, ob->dup_group); */
                WM_enum_search_invoke(C, op, event);
                return OPERATOR_CANCELLED;
        }
-       else if (ob->id.lib) {
+       else if (ID_IS_LINKED_DATABLOCK(ob)) {
                uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("OK?"), ICON_QUESTION);
                uiLayout *layout = UI_popup_menu_layout(pup);
 
@@ -1466,7 +1466,7 @@ static int make_links_scene_exec(bContext *C, wmOperator *op)
                return OPERATOR_CANCELLED;
        }
 
-       if (scene_to->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(scene_to)) {
                BKE_report(op->reports, RPT_ERROR, "Cannot link objects into a linked scene");
                return OPERATOR_CANCELLED;
        }
@@ -1579,7 +1579,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
                                        case MAKE_LINKS_ANIMDATA:
                                                BKE_animdata_copy_id((ID *)ob_dst, (ID *)ob_src, false);
                                                if (ob_dst->data && ob_src->data) {
-                                                       if (obdata_id->lib) {
+                                                       if (ID_IS_LINKED_DATABLOCK(obdata_id)) {
                                                                is_lib = true;
                                                                break;
                                                        }
@@ -1621,7 +1621,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
                                                Curve *cu_src = ob_src->data;
                                                Curve *cu_dst = ob_dst->data;
 
-                                               if (obdata_id->lib) {
+                                               if (ID_IS_LINKED_DATABLOCK(obdata_id)) {
                                                        is_lib = true;
                                                        break;
                                                }
@@ -1749,7 +1749,7 @@ static void single_object_users(Main *bmain, Scene *scene, View3D *v3d, const in
                ob = base->object;
 
                if ((base->flag & flag) == flag) {
-                       if (ob->id.lib == NULL && ob->id.us > 1) {
+                       if (!ID_IS_LINKED_DATABLOCK(ob) && ob->id.us > 1) {
                                /* base gets copy of object */
                                obn = BKE_object_copy(ob);
                                base->object = obn;
@@ -1828,7 +1828,7 @@ static void new_id_matar(Material **matar, const int totcol)
 
        for (a = 0; a < totcol; a++) {
                id = (ID *)matar[a];
-               if (id && id->lib == NULL) {
+               if (id && !ID_IS_LINKED_DATABLOCK(id)) {
                        if (id->newid) {
                                matar[a] = (Material *)id->newid;
                                id_us_plus(id->newid);
@@ -1857,10 +1857,10 @@ static void single_obdata_users(Main *bmain, Scene *scene, const int flag)
 
        for (base = FIRSTBASE; base; base = base->next) {
                ob = base->object;
-               if (ob->id.lib == NULL && (base->flag & flag) == flag) {
+               if (!ID_IS_LINKED_DATABLOCK(ob) && (base->flag & flag) == flag) {
                        id = ob->data;
 
-                       if (id && id->us > 1 && id->lib == NULL) {
+                       if (id && id->us > 1 && !ID_IS_LINKED_DATABLOCK(id)) {
                                DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
 
                                switch (ob->type) {
@@ -1938,7 +1938,7 @@ static void single_object_action_users(Scene *scene, const int flag)
 
        for (base = FIRSTBASE; base; base = base->next) {
                ob = base->object;
-               if (ob->id.lib == NULL && (flag == 0 || (base->flag & SELECT)) ) {
+               if (!ID_IS_LINKED_DATABLOCK(ob) && (flag == 0 || (base->flag & SELECT)) ) {
                        DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
                        BKE_animdata_copy_id_action(&ob->id);
                }
@@ -1955,7 +1955,7 @@ static void single_mat_users(Scene *scene, const int flag, const bool do_texture
 
        for (base = FIRSTBASE; base; base = base->next) {
                ob = base->object;
-               if (ob->id.lib == NULL && (flag == 0 || (base->flag & SELECT)) ) {
+               if (!ID_IS_LINKED_DATABLOCK(ob) && (flag == 0 || (base->flag & SELECT)) ) {
                        for (a = 1; a <= ob->totcol; a++) {
                                ma = give_current_material(ob, a);
                                if (ma) {
@@ -2184,7 +2184,7 @@ static bool make_local_all__instance_indirect_unused(Main *bmain, Scene *scene)
        bool changed = false;
 
        for (ob = bmain->object.first; ob; ob = ob->id.next) {
-               if (ob->id.lib && (ob->id.us == 0)) {
+               if (ID_IS_LINKED_DATABLOCK(ob) && (ob->id.us == 0)) {
                        Base *base;
 
                        id_us_plus(&ob->id);
index 39bd34456beb3317cb474d7bfb66f064f67b8339..e04114761e4971aefc81967df429dbabd26df21d 100644 (file)
@@ -225,7 +225,7 @@ static int shape_key_mode_poll(bContext *C)
 {
        Object *ob = ED_object_context(C);
        ID *data = (ob) ? ob->data : NULL;
-       return (ob && !ob->id.lib && data && !data->lib && ob->mode != OB_MODE_EDIT);
+       return (ob && !ID_IS_LINKED_DATABLOCK(ob) && data && !ID_IS_LINKED_DATABLOCK(data) && ob->mode != OB_MODE_EDIT);
 }
 
 static int shape_key_mode_exists_poll(bContext *C)
@@ -234,7 +234,7 @@ static int shape_key_mode_exists_poll(bContext *C)
        ID *data = (ob) ? ob->data : NULL;
 
        /* same as shape_key_mode_poll */
-       return (ob && !ob->id.lib && data && !data->lib && ob->mode != OB_MODE_EDIT) &&
+       return (ob && !ID_IS_LINKED_DATABLOCK(ob) && data && !ID_IS_LINKED_DATABLOCK(data) && ob->mode != OB_MODE_EDIT) &&
               /* check a keyblock exists */
               (BKE_keyblock_from_object(ob) != NULL);
 }
@@ -246,14 +246,15 @@ static int shape_key_move_poll(bContext *C)
        ID *data = (ob) ? ob->data : NULL;
        Key *key = BKE_key_from_object(ob);
 
-       return (ob && !ob->id.lib && data && !data->lib && ob->mode != OB_MODE_EDIT && key && key->totkey > 1);
+       return (ob && !ID_IS_LINKED_DATABLOCK(ob) && data && !ID_IS_LINKED_DATABLOCK(data) &&
+               ob->mode != OB_MODE_EDIT && key && key->totkey > 1);
 }
 
 static int shape_key_poll(bContext *C)
 {
        Object *ob = ED_object_context(C);
        ID *data = (ob) ? ob->data : NULL;
-       return (ob && !ob->id.lib && data && !data->lib);
+       return (ob && !ID_IS_LINKED_DATABLOCK(ob) && data && !ID_IS_LINKED_DATABLOCK(data));
 }
 
 static int shape_key_add_exec(bContext *C, wmOperator *op)
index d2bbb73b5972b649302847ca12a5bc6e3fb23322..6d80c4af292e4956e99542c895facff46fdb2e90 100644 (file)
@@ -391,7 +391,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, bool apply_l
                                changed = false;
                        }
 
-                       if (obdata->lib) {
+                       if (ID_IS_LINKED_DATABLOCK(obdata)) {
                                BKE_reportf(reports, RPT_ERROR,
                                            "Cannot apply to library data: Object \"%s\", %s \"%s\", aborting",
                                            ob->id.name + 2, BKE_idcode_to_name(GS(obdata->name)), obdata->name + 2);
@@ -792,7 +792,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
                        if (ob->data == NULL) {
                                /* special support for dupligroups */
                                if ((ob->transflag & OB_DUPLIGROUP) && ob->dup_group && (ob->dup_group->id.tag & LIB_TAG_DOIT) == 0) {
-                                       if (ob->dup_group->id.lib) {
+                                       if (ID_IS_LINKED_DATABLOCK(ob->dup_group)) {
                                                tot_lib_error++;
                                        }
                                        else {
@@ -817,7 +817,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
                                        }
                                }
                        }
-                       else if (((ID *)ob->data)->lib) {
+                       else if (ID_IS_LINKED_DATABLOCK(ob->data)) {
                                tot_lib_error++;
                        }
 
index 414cc476be57350768f6f1000c1b1f3a772fa160..6e8aaebcccc5665ad0cb21148bc28c5e2c8e1371 100644 (file)
@@ -2447,8 +2447,8 @@ static int vertex_group_poll(bContext *C)
        Object *ob = ED_object_context(C);
        ID *data = (ob) ? ob->data : NULL;
 
-       return (ob && !ob->id.lib &&
-               data && !data->lib &&
+       return (ob && !ID_IS_LINKED_DATABLOCK(ob) &&
+               data && !ID_IS_LINKED_DATABLOCK(data) &&
                OB_TYPE_SUPPORT_VGROUP(ob->type) &&
                ob->defbase.first);
 }
@@ -2457,7 +2457,8 @@ static int vertex_group_supported_poll(bContext *C)
 {
        Object *ob = ED_object_context(C);
        ID *data = (ob) ? ob->data : NULL;
-       return (ob && !ob->id.lib && OB_TYPE_SUPPORT_VGROUP(ob->type) && data && !data->lib);
+       return (ob && !ID_IS_LINKED_DATABLOCK(ob) && OB_TYPE_SUPPORT_VGROUP(ob->type) &&
+               data && !ID_IS_LINKED_DATABLOCK(data));
 }
 
 static int vertex_group_mesh_poll(bContext *C)
@@ -2465,8 +2466,8 @@ static int vertex_group_mesh_poll(bContext *C)
        Object *ob = ED_object_context(C);
        ID *data = (ob) ? ob->data : NULL;
 
-       return (ob && !ob->id.lib &&
-               data && !data->lib &&
+       return (ob && !ID_IS_LINKED_DATABLOCK(ob) &&
+               data && !ID_IS_LINKED_DATABLOCK(data) &&
                ob->type == OB_MESH &&
                ob->defbase.first);
 }
@@ -2475,7 +2476,7 @@ static int UNUSED_FUNCTION(vertex_group_mesh_supported_poll)(bContext *C)
 {
        Object *ob = ED_object_context(C);
        ID *data = (ob) ? ob->data : NULL;
-       return (ob && !ob->id.lib && ob->type == OB_MESH && data && !data->lib);
+       return (ob && !ID_IS_LINKED_DATABLOCK(ob) && ob->type == OB_MESH && data && !ID_IS_LINKED_DATABLOCK(data));
 }
 
 
@@ -2484,7 +2485,7 @@ static int UNUSED_FUNCTION(vertex_group_poll_edit) (bContext *C)
        Object *ob = ED_object_context(C);
        ID *data = (ob) ? ob->data : NULL;
 
-       if (!(ob && !ob->id.lib && data && !data->lib))
+       if (!(ob && !ID_IS_LINKED_DATABLOCK(ob) && data && !ID_IS_LINKED_DATABLOCK(data)))
                return 0;
 
        return BKE_object_is_in_editmode_vgroup(ob);
@@ -2496,7 +2497,7 @@ static int vertex_group_vert_select_poll_ex(bContext *C, const short ob_type_fla
        Object *ob = ED_object_context(C);
        ID *data = (ob) ? ob->data : NULL;
 
-       if (!(ob && !ob->id.lib && data && !data->lib))
+       if (!(ob && !ID_IS_LINKED_DATABLOCK(ob) && data && !ID_IS_LINKED_DATABLOCK(data)))
                return false;
 
        if (ob_type_flag && (((1 << ob->type) & ob_type_flag)) == 0) {
@@ -2536,7 +2537,7 @@ static int vertex_group_vert_select_unlocked_poll(bContext *C)
        Object *ob = ED_object_context(C);
        ID *data = (ob) ? ob->data : NULL;
 
-       if (!(ob && !ob->id.lib && data && !data->lib))
+       if (!(ob && !ID_IS_LINKED_DATABLOCK(ob) && data && !ID_IS_LINKED_DATABLOCK(data)))
                return 0;
 
        if (!(BKE_object_is_in_editmode_vgroup(ob) ||
@@ -2559,7 +2560,7 @@ static int vertex_group_vert_select_mesh_poll(bContext *C)
        Object *ob = ED_object_context(C);
        ID *data = (ob) ? ob->data : NULL;
 
-       if (!(ob && !ob->id.lib && data && !data->lib))
+       if (!(ob && !ID_IS_LINKED_DATABLOCK(ob) && data && !ID_IS_LINKED_DATABLOCK(data)))
                return 0;
 
        /* only difference to #vertex_group_vert_select_poll */
@@ -2748,7 +2749,7 @@ static int vertex_group_select_exec(bContext *C, wmOperator *UNUSED(op))
 {
        Object *ob = ED_object_context(C);
 
-       if (!ob || ob->id.lib)
+       if (!ob || ID_IS_LINKED_DATABLOCK(ob))
                return OPERATOR_CANCELLED;
 
        vgroup_select_verts(ob, 1);
index 30c102b70c5fb62f116241a4f2f217544144627e..e22a145b3a6bddb38363838a64a8dfb54a5ac960 100644 (file)
@@ -4693,7 +4693,7 @@ static int particle_edit_toggle_poll(bContext *C)
 
        if (ob == NULL || ob->type != OB_MESH)
                return 0;
-       if (!ob->data || ((ID *)ob->data)->lib)
+       if (!ob->data || ID_IS_LINKED_DATABLOCK(ob->data))
                return 0;
        if (CTX_data_edit_object(C))
                return 0;
index 1297133e1a2c3b751e95c27ff7f75ec08fd7e26b..d6c89b9c7a5bf9703a5ec8349abed5c46159e7ea 100644 (file)
@@ -974,7 +974,7 @@ static void remove_particle_systems_from_object(Object *ob_to)
        
        if (ob_to->type != OB_MESH)
                return;
-       if (!ob_to->data || ((ID *)ob_to->data)->lib)
+       if (!ob_to->data || ID_IS_LINKED_DATABLOCK(ob_to->data))
                return;
        
        for (md = ob_to->modifiers.first; md; md = md_next) {
@@ -1004,7 +1004,7 @@ static bool copy_particle_systems_to_object(Scene *scene, Object *ob_from, Parti
        
        if (ob_to->type != OB_MESH)
                return false;
-       if (!ob_to->data || ((ID *)ob_to->data)->lib)
+       if (!ob_to->data || ID_IS_LINKED_DATABLOCK(ob_to->data))
                return false;
        
        /* For remapping we need a valid DM.
index 0c0a6c93b3e1945fabf27ffb82fbf6072e5257ba..04a8f0a3a5188d55334bf18643090d9060a3ffc1 100644 (file)
@@ -168,7 +168,7 @@ int ED_operator_screen_mainwinactive(bContext *C)
 int ED_operator_scene_editable(bContext *C)
 {
        Scene *scene = CTX_data_scene(C);
-       if (scene && scene->id.lib == NULL)
+       if (scene && !ID_IS_LINKED_DATABLOCK(scene))
                return 1;
        return 0;
 }
@@ -178,7 +178,7 @@ int ED_operator_objectmode(bContext *C)
        Scene *scene = CTX_data_scene(C);
        Object *obact = CTX_data_active_object(C);
 
-       if (scene == NULL || scene->id.lib)
+       if (scene == NULL || ID_IS_LINKED_DATABLOCK(scene))
                return 0;
        if (CTX_data_edit_object(C))
                return 0;
@@ -279,7 +279,7 @@ int ED_operator_node_editable(bContext *C)
 {
        SpaceNode *snode = CTX_wm_space_node(C);
        
-       if (snode && snode->edittree && snode->edittree->id.lib == NULL)
+       if (snode && snode->edittree && !ID_IS_LINKED_DATABLOCK(snode->edittree))
                return 1;
        
        return 0;
@@ -341,20 +341,20 @@ int ED_operator_object_active(bContext *C)
 int ED_operator_object_active_editable(bContext *C)
 {
        Object *ob = ED_object_active_context(C);
-       return ((ob != NULL) && !(ob->id.lib) && !ed_object_hidden(ob));
+       return ((ob != NULL) && !ID_IS_LINKED_DATABLOCK(ob) && !ed_object_hidden(ob));
 }
 
 int ED_operator_object_active_editable_mesh(bContext *C)
 {
        Object *ob = ED_object_active_context(C);
-       return ((ob != NULL) && !(ob->id.lib) && !ed_object_hidden(ob) &&
-               (ob->type == OB_MESH) && !(((ID *)ob->data)->lib));
+       return ((ob != NULL) && !ID_IS_LINKED_DATABLOCK(ob) && !ed_object_hidden(ob) &&
+               (ob->type == OB_MESH) && !ID_IS_LINKED_DATABLOCK(ob->data));
 }
 
 int ED_operator_object_active_editable_font(bContext *C)
 {
        Object *ob = ED_object_active_context(C);
-       return ((ob != NULL) && !(ob->id.lib) && !ed_object_hidden(ob) &&
+       return ((ob != NULL) && !ID_IS_LINKED_DATABLOCK(ob) && !ed_object_hidden(ob) &&
                (ob->type == OB_FONT));
 }
 
index 689b89e7b693b100e3a9325a75322df0aa844923..bf344e1f7210a58af133f8e8bb2670d4b9ed08da 100644 (file)
@@ -1342,7 +1342,7 @@ static int texture_paint_toggle_poll(bContext *C)
        Object *ob = CTX_data_active_object(C);
        if (ob == NULL || ob->type != OB_MESH)
                return 0;
-       if (!ob->data || ((ID *)ob->data)->lib)
+       if (!ob->data || ID_IS_LINKED_DATABLOCK(ob->data))
                return 0;
        if (CTX_data_edit_object(C))
                return 0;
index 87855879ec52ad027b030a0824525e3af6e77918..3bcd610150c86881ac7c90a567b0b0c5a053fae5 100644 (file)
@@ -247,7 +247,7 @@ static bool make_vertexcol(Object *ob)  /* single ob */
 {
        Mesh *me;
 
-       if ((ob->id.lib) ||
+       if (ID_IS_LINKED_DATABLOCK(ob) ||
            ((me = BKE_mesh_from_object(ob)) == NULL) ||
            (me->totpoly == 0) ||
            (me->edit_btmesh))
@@ -1841,7 +1841,7 @@ static int paint_poll_test(bContext *C)
        Object *ob = CTX_data_active_object(C);
        if (ob == NULL || ob->type != OB_MESH)
                return 0;
-       if (!ob->data || ((ID *)ob->data)->lib)
+       if (!ob->data || ID_IS_LINKED_DATABLOCK(ob->data))
                return 0;
        if (CTX_data_edit_object(C))
                return 0;
index 51f4a61047df4a97764afa876b364f136e91aae0..074368a82c535608619e262df812102089e82e90 100644 (file)
@@ -65,7 +65,7 @@ static int edit_sensor_poll(bContext *C)
 {
        PointerRNA ptr = CTX_data_pointer_get_type(C, "sensor", &RNA_Sensor);
 
-       if (ptr.data && ((ID *)ptr.id.data)->lib) return 0;
+       if (ptr.data && ID_IS_LINKED_DATABLOCK(ptr.id.data)) return 0;
        return 1;
 }
 
@@ -73,7 +73,7 @@ static int edit_controller_poll(bContext *C)
 {
        PointerRNA ptr = CTX_data_pointer_get_type(C, "controller", &RNA_Controller);
 
-       if (ptr.data && ((ID *)ptr.id.data)->lib) return 0;
+       if (ptr.data && ID_IS_LINKED_DATABLOCK(ptr.id.data)) return 0;
        return 1;
 }
 
@@ -81,7 +81,7 @@ static int edit_actuator_poll(bContext *C)
 {
        PointerRNA ptr = CTX_data_pointer_get_type(C, "actuator", &RNA_Actuator);
 
-       if (ptr.data && ((ID *)ptr.id.data)->lib) return 0;
+       if (ptr.data && ID_IS_LINKED_DATABLOCK(ptr.id.data)) return 0;
        return 1;
 }
 
index 43e9c262172edb51c67416eb3bdd219f5c1ca593..b8d3e2fb1fc57cc7b8b492aaa8a599479f8efbe7 100644 (file)
@@ -402,7 +402,7 @@ void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag)
 
        if (group_restrict_flag(gr, flag)) {
                for (gob = gr->gobject.first; gob; gob = gob->next) {
-                       if (gob->ob->id.lib)
+                       if (ID_IS_LINKED_DATABLOCK(gob->ob))
                                continue;
 
                        gob->ob->restrictflag &= ~flag;
@@ -414,7 +414,7 @@ void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag)
        }
        else {
                for (gob = gr->gobject.first; gob; gob = gob->next) {
-                       if (gob->ob->id.lib)
+                       if (ID_IS_LINKED_DATABLOCK(gob->ob))
                                continue;
 
                        /* not in editmode */
@@ -655,7 +655,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                                int but_flag = UI_BUT_DRAG_LOCK;
                                gr = (Group *)tselem->id;
 
-                               if (gr->id.lib)
+                               if (ID_IS_LINKED_DATABLOCK(gr))
                                        but_flag |= UI_BUT_DISABLED;
                                
                                UI_block_emboss_set(block, UI_EMBOSS_NONE);
@@ -828,7 +828,7 @@ static void outliner_draw_userbuts(uiBlock *block, ARegion *ar, SpaceOops *soops
                                char buf[16] = "";
                                int but_flag = UI_BUT_DRAG_LOCK;
 
-                               if (id->lib)
+                               if (ID_IS_LINKED_DATABLOCK(id))
                                        but_flag |= UI_BUT_DISABLED;
 
                                UI_block_emboss_set(block, UI_EMBOSS_NONE);
@@ -993,7 +993,8 @@ static void tselem_draw_icon_uibut(struct DrawIconArg *arg, int icon)
        }
        else {
                uiBut *but = uiDefIconBut(arg->block, UI_BTYPE_LABEL, 0, icon, arg->xb, arg->yb, UI_UNIT_X, UI_UNIT_Y, NULL,
-                                         0.0, 0.0, 1.0, arg->alpha, (arg->id && arg->id->lib) ? arg->id->lib->name : "");
+                                         0.0, 0.0, 1.0, arg->alpha,
+                                         (arg->id && ID_IS_LINKED_DATABLOCK(arg->id)) ? arg->id->lib->name : "");
                
                if (arg->id)
                        UI_but_drag_set_id(but, arg->id);
@@ -1567,7 +1568,7 @@ static void outliner_draw_tree_element(
                else
                        offsx += 2 * ufac;
                
-               if (tselem->type == 0 && tselem->id->lib) {
+               if (tselem->type == 0 && ID_IS_LINKED_DATABLOCK(tselem->id)) {
                        glPixelTransferf(GL_ALPHA_SCALE, 0.5f);
                        if (tselem->id->tag & LIB_TAG_MISSING) {
                                UI_icon_draw((float)startx + offsx, (float)*starty + 2 * ufac, ICON_LIBRARY_DATA_BROKEN);
index 07608b59d2e78889800a2211056727f67f817851..b0cd3aabbfdcbdae24c867c5e733b1ea5e0f9c60 100644 (file)
@@ -232,7 +232,7 @@ static void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem,
        else if (ELEM(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) {
                BKE_report(reports, RPT_WARNING, "Cannot edit sequence name");
        }
-       else if (tselem->id->lib) {
+       else if (ID_IS_LINKED_DATABLOCK(tselem->id)) {
                BKE_report(reports, RPT_WARNING, "Cannot edit external libdata");
        }
        else if (te->idcode == ID_LI && ((Library *)tselem->id)->parent) {
@@ -423,7 +423,7 @@ static int outliner_id_remap_exec(bContext *C, wmOperator *op)
                return OPERATOR_CANCELLED;
        }
 
-       if (old_id->lib) {
+       if (ID_IS_LINKED_DATABLOCK(old_id)) {
                BKE_reportf(op->reports, RPT_WARNING,
                            "Old ID '%s' is linked from a library, indirect usages of this datablock will not be remapped",
                            old_id->name);
@@ -1982,7 +1982,7 @@ static int parent_drop_exec(bContext *C, wmOperator *op)
        RNA_string_get(op->ptr, "child", childname);
        ob = (Object *)BKE_libblock_find_name(ID_OB, childname);
 
-       if (ob->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(ob)) {
                BKE_report(op->reports, RPT_INFO, "Can't edit library linked object");
                return OPERATOR_CANCELLED;
        }
@@ -2030,7 +2030,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
                if (ob == par) {
                        return OPERATOR_CANCELLED;
                }
-               if (ob->id.lib) {
+               if (ID_IS_LINKED_DATABLOCK(ob)) {
                        BKE_report(op->reports, RPT_INFO, "Can't edit library linked object");
                        return OPERATOR_CANCELLED;
                }
@@ -2239,7 +2239,7 @@ static int scene_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
                RNA_string_get(op->ptr, "object", obname);
                ob = (Object *)BKE_libblock_find_name(ID_OB, obname);
 
-               if (ELEM(NULL, ob, scene) || scene->id.lib != NULL) {
+               if (ELEM(NULL, ob, scene) || ID_IS_LINKED_DATABLOCK(scene)) {
                        return OPERATOR_CANCELLED;
                }
 
index bfec62997e14507578ee4688b343602709097a51..13adaff5224cbdd0d0c10e6885aec9a74120d5bd 100644 (file)
@@ -435,7 +435,7 @@ static void id_local_cb(
         bContext *C, ReportList *UNUSED(reports), Scene *UNUSED(scene), TreeElement *UNUSED(te),
         TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data))
 {
-       if (tselem->id->lib && (tselem->id->tag & LIB_TAG_EXTERN)) {
+       if (ID_IS_LINKED_DATABLOCK(tselem->id) && (tselem->id->tag & LIB_TAG_EXTERN)) {
                /* if the ID type has no special local function,
                 * just clear the lib */
                if (id_make_local(tselem->id, false) == false) {
index a687f61d69f69766cff1c0b77c92a22cceb845fe..b22e6595caf746cc64dc0ee6c16ebee9c046430c 100644 (file)
@@ -490,7 +490,7 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree
        
        outliner_add_element(soops, &te->subtree, ob->poselib, te, 0, 0); // XXX FIXME.. add a special type for this
        
-       if (ob->proxy && ob->id.lib == NULL)
+       if (ob->proxy && !ID_IS_LINKED_DATABLOCK(ob))
                outliner_add_element(soops, &te->subtree, ob->proxy, te, TSE_PROXY, 0);
                
        outliner_add_element(soops, &te->subtree, ob->gpd, te, 0, 0);
index 94ed280f792bfbb0450429c4eee9e23f4439c720..e7428fd79d9995fc5e533b1e64a16b1d5a39706c 100644 (file)
@@ -92,7 +92,7 @@ static int text_edit_poll(bContext *C)
        if (!text)
                return 0;
 
-       if (text->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(text)) {
                // BKE_report(op->reports, RPT_ERROR, "Cannot edit external libdata");
                return 0;
        }
@@ -108,7 +108,7 @@ int text_space_edit_poll(bContext *C)
        if (!st || !text)
                return 0;
 
-       if (text->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(text)) {
                // BKE_report(op->reports, RPT_ERROR, "Cannot edit external libdata");
                return 0;
        }
@@ -128,7 +128,7 @@ static int text_region_edit_poll(bContext *C)
        if (!ar || ar->regiontype != RGN_TYPE_WINDOW)
                return 0;
 
-       if (text->id.lib) {
+       if (ID_IS_LINKED_DATABLOCK(text)) {
                // BKE_report(op->reports, RPT_ERROR, "Cannot edit external libdata");
                return 0;
        }
index 128adc8269b3e3b89711a6f8bc1932afb39006e7..4320699b8d7d6d42b6f86eac53b4ad23dde37bb9 100644 (file)
@@ -7334,7 +7334,7 @@ static void draw_object_wire_color(Scene *scene, Base *base, unsigned char r_ob_
        }
        else {
                /* Sets the 'colindex' */
-               if (ob->id.lib) {
+               if (ID_IS_LINKED_DATABLOCK(ob)) {
                        colindex = (base->flag & (SELECT + BA_WAS_SEL)) ? 2 : 1;
                }
                /* Sets the 'theme_id' or fallback to wire */
@@ -8090,7 +8090,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
                                    !(G.f & G_RENDER_OGL))
                                {
                                        /* check > 0 otherwise grease pencil can draw into the circle select which is annoying. */
-                                       drawcentercircle(v3d, rv3d, ob->obmat[3], do_draw_center, ob->id.lib || ob->id.us > 1);
+                                       drawcentercircle(v3d, rv3d, ob->obmat[3], do_draw_center, ID_IS_LINKED_DATABLOCK(ob) || ob->id.us > 1);
                                }
                        }
                }
index 907fe90c067c4cfe04a03b0a2a5d455095fbaf47..4d5d03d6c9b486d2e0a136c69f1f7ee632d6d89a 100644 (file)
@@ -110,7 +110,7 @@ static bool view3d_operator_offset_lock_check(bContext *C, wmOperator *op)
 bool ED_view3d_camera_lock_check(const View3D *v3d, const RegionView3D *rv3d)
 {
        return ((v3d->camera) &&
-               (v3d->camera->id.lib == NULL) &&
+               (!ID_IS_LINKED_DATABLOCK(v3d->camera)) &&
                (v3d->flag2 & V3D_LOCK_CAMERA) &&
                (rv3d->persp == RV3D_CAMOB));
 }
index 8418cf0980c72c01463599692bf5982c917e45bc..31377d0fce89d87748ee22693776d3282a47d5c8 100644 (file)
@@ -346,7 +346,7 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent
                fly->rv3d->persp = RV3D_PERSP;
        }
 
-       if (fly->rv3d->persp == RV3D_CAMOB && fly->v3d->camera->id.lib) {
+       if (fly->rv3d->persp == RV3D_CAMOB && ID_IS_LINKED_DATABLOCK(fly->v3d->camera)) {
                BKE_report(op->reports, RPT_ERROR, "Cannot fly a camera from an external library");
                return false;
        }
index c35646b9e924e0a74fa6bcf0facde40580f5e383..00fd3cd48e590fc260d44979b5a6ad6740f7343f 100644 (file)
@@ -507,7 +507,7 @@ static int view3d_camera_to_view_poll(bContext *C)
 
        if (ED_view3d_context_user_region(C, &v3d, &ar)) {
                RegionView3D *rv3d = ar->regiondata;
-               if (v3d && v3d->camera && v3d->camera->id.lib == NULL) {
+               if (v3d && v3d->camera && !ID_IS_LINKED_DATABLOCK(v3d->camera)) {
                        if (rv3d && (rv3d->viewlock & RV3D_LOCKED) == 0) {
                                if (rv3d->persp != RV3D_CAMOB) {
                                        return 1;
index 384da277612925c2edda680b962acce0395585b9..3269e0cfbfc907522d8f5e797608613dbe4ecc60 100644 (file)
@@ -505,7 +505,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op)
                walk->rv3d->persp = RV3D_PERSP;
        }
 
-       if (walk->rv3d->persp == RV3D_CAMOB && walk->v3d->camera->id.lib) {
+       if (walk->rv3d->persp == RV3D_CAMOB && ID_IS_LINKED_DATABLOCK(walk->v3d->camera)) {
                BKE_report(op->reports, RPT_ERROR, "Cannot navigate a camera from an external library");
                return false;
        }
index 707c60f8701c22f603a7d734fb46eb899645582a..fc32613c1ab9c03df8b09d1f9eea247a6d53d944 100644 (file)
@@ -6429,7 +6429,7 @@ static void createTransObject(bContext *C, TransInfo *t)
                }
                
                /* select linked objects, but skip them later */
-               if (ob->id.lib != NULL) {
+               if (ID_IS_LINKED_DATABLOCK(ob)) {
                        td->flag |= TD_SKIP;
                }
                
index e2f60955c81c18acff6582a4f4981facb45fc7e6..1f1a778cac7257d2031d67dc68eb3e76ed12d518 100644 (file)
@@ -105,7 +105,7 @@ void ED_editors_init(bContext *C)
                        ob->mode = OB_MODE_OBJECT;
                        data = ob->data;
 
-                       if (ob == obact && !ob->id.lib && !(data && data->lib))
+                       if (ob == obact && !ID_IS_LINKED_DATABLOCK(ob) && !(data && ID_IS_LINKED_DATABLOCK(data)))
                                ED_object_toggle_modes(C, mode);
                }
        }
index b0812a81ee14a08acf1d7e63ebcf87c2f8e1df61..bb5d2b4cf296edec518f6575eb6daf22190e0c58 100644 (file)
@@ -269,6 +269,8 @@ typedef struct PreviewImage {
 
 #define ID_MISSING(_id) (((_id)->tag & LIB_TAG_MISSING) != 0)
 
+#define ID_IS_LINKED_DATABLOCK(_id) (((ID *)(_id))->lib != NULL)
+
 #ifdef GS
 #  undef GS
 #endif
index 0eaeabccd9998d3a2f9d8f58cc0eeb286084a0c1..1372d2b30a2a57ff60fc907e50d5ec52dad379ba 100644 (file)
@@ -1624,7 +1624,7 @@ bool RNA_property_editable(PointerRNA *ptr, PropertyRNA *prop)
        flag = prop->editable ? prop->editable(ptr) : prop->flag;
        return ((flag & PROP_EDITABLE) &&
                (flag & PROP_REGISTER) == 0 &&
-               (!id || !id->lib || (prop->flag & PROP_LIB_EXCEPTION)));
+               (!id || !ID_IS_LINKED_DATABLOCK(id) || (prop->flag & PROP_LIB_EXCEPTION)));
 }
 
 bool RNA_property_editable_flag(PointerRNA *ptr, PropertyRNA *prop)
@@ -1656,7 +1656,7 @@ bool RNA_property_editable_index(PointerRNA *ptr, PropertyRNA *prop, int index)
 
        id = ptr->id.data;
 
-       return (flag & PROP_EDITABLE) && (!id || !id->lib || (prop->flag & PROP_LIB_EXCEPTION));
+       return (flag & PROP_EDITABLE) && (!id || !ID_IS_LINKED_DATABLOCK(id) || (prop->flag & PROP_LIB_EXCEPTION));
 }
 
 bool RNA_property_animateable(PointerRNA *ptr, PropertyRNA *prop)
index a7f5c21cc76efde7da21441729f9e509ca7f9b13..5dc4bbd83dd4860ed59f7f79edf99ef81ebd75e6 100644 (file)
@@ -718,10 +718,10 @@ static int rna_Object_active_material_editable(PointerRNA *ptr)
        bool is_editable;
 
        if ((ob->matbits == NULL) || (ob->actcol == 0) || ob->matbits[ob->actcol - 1]) {
-               is_editable = (ob->id.lib == NULL);
+               is_editable = !ID_IS_LINKED_DATABLOCK(ob);
        }
        else {
-               is_editable = ob->data ? (((ID *)ob->data)->lib == NULL) : false;
+               is_editable = ob->data ? !ID_IS_LINKED_DATABLOCK(ob->data) : false;
        }
 
        return is_editable ? PROP_EDITABLE : 0;
index 8968c2a4543c54c2d8c949aeb9ce66e5088b71a9..4bd1bddb4dced10ee3a8aa8be12c44c8c25425f1 100644 (file)
@@ -3884,7 +3884,7 @@ static void previews_id_ensure(bContext *C, Scene *scene, ID *id)
 
        /* Only preview non-library datablocks, lib ones do not pertain to this .blend file!
         * Same goes for ID with no user. */
-       if (!id->lib && (id->us != 0)) {
+       if (!ID_IS_LINKED_DATABLOCK(id) && (id->us != 0)) {
                UI_id_icon_render(C, scene, id, false, false);
                UI_id_icon_render(C, scene, id, true, false);
        }
@@ -4469,7 +4469,7 @@ static EnumPropertyItem *rna_id_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(pt
        int i = 0;
 
        for (; id; id = id->next) {
-               if (local == false || id->lib == NULL) {
+               if (local == false || !ID_IS_LINKED_DATABLOCK(id)) {
                        item_tmp.identifier = item_tmp.name = id->name + 2;
                        item_tmp.value = i++;
                        RNA_enum_item_add(&item, &totitem, &item_tmp);