1
1

Compare commits

...

98 Commits

Author SHA1 Message Date
f609e01fb5 Cleanup & comments from review. 2015-10-20 14:24:30 +02:00
a7869babcd Minor changes & sync with master 2015-10-20 20:18:51 +11:00
91809c0217 Cleanup: naming, typo 2015-10-20 20:02:44 +11:00
444a755d86 Missing from last commit 2015-10-20 19:56:21 +11:00
ee18a70864 Move memory-zero-checking to BLI_memory_utils
Add a new BLI module since this isn't typical use for BLI_array
(where element size is taken into account).
2015-10-20 19:49:58 +11:00
88040b928c Merge branch 'master' into missing-libs 2015-10-20 17:41:12 +11:00
177295f856 Merge branch 'master' into missing-libs 2015-10-17 11:34:29 +02:00
59ff3b5498 Merge branch 'master' into missing-libs 2015-10-15 16:12:57 +02:00
3ffc5c9209 Moar cleanup. 2015-10-14 20:24:05 +02:00
f15741f830 Merge branch 'master' into missing-libs 2015-10-14 17:17:30 +02:00
b89530845a Cleanup. 2015-10-14 16:22:57 +02:00
4dac0afa9c Merge branch 'free-refcount-ids' into missing-libs 2015-10-13 15:48:18 +02:00
168604ecbe Revert to master - those changes are globally valid, but remain incomplete,
and total new code is being done in id-remap anyway, not worth bothering with this for now...
2015-10-13 15:44:58 +02:00
9d5cdf92b2 Merge branch 'master' into free-refcount-ids 2015-10-13 15:41:54 +02:00
67d922f61a Merge branch 'master' into free-refcount-ids 2015-10-13 14:41:33 +02:00
5f2276a553 Merge branch 'free-refcount-ids' into missing-libs 2015-10-12 20:46:28 +02:00
e95ba11ce6 Merge branch 'master' into free-refcount-ids 2015-10-12 20:31:39 +02:00
6188d17623 Merge branch 'lib-link-rework-temp' into missing-libs 2015-10-08 12:13:43 +02:00
a219728914 Merge branch 'free-refcount-ids' into missing-libs 2015-10-08 12:13:28 +02:00
92bcc7dd19 Merge branch 'master' into missing-libs 2015-10-08 12:08:29 +02:00
32d9f75660 Merge branch 'master' into lib-link-rework-temp 2015-10-08 12:06:57 +02:00
249aa6c649 Merge branch 'master' into free-refcount-ids 2015-10-08 12:03:03 +02:00
7a7b5bc6d3 Merge branch 'master' into missing-libs 2015-10-06 12:23:50 +02:00
2a3e261554 Merge branch 'master' into lib-link-rework-temp 2015-10-06 12:20:57 +02:00
913938514d Merge branch 'master' into free-refcount-ids 2015-10-06 12:19:29 +02:00
a33cc08a99 Fix for object freeing. 2015-10-05 13:58:21 +02:00
8bb7031dec Minor cleanup. 2015-10-05 12:17:51 +02:00
d7d236ce5c Merge branch 'master' into lib-link-rework-temp 2015-10-05 12:09:19 +02:00
a5d1709771 Merge branch 'master' into missing-libs 2015-10-05 12:05:50 +02:00
794a977bad Merge branch 'master' into free-refcount-ids 2015-10-05 12:05:00 +02:00
44e62635c5 Cleanup , and remove public '_release_datablocks' funcs for now.
On second thaought, will end up doing this differently in id-remap branch,
so for now just make this branch a cleanup, consistency-fixing one.
2015-10-05 10:59:38 +02:00
f00f3496a0 Merge branch 'master' into free-refcount-ids 2015-10-05 09:23:08 +02:00
a4c3d645ed Add note about object release func... 2015-10-01 17:44:02 +02:00
b63872cd5e Free IDs: MovieClip & Mask.
Mask freeing was doing really bad (as in, not consistent with other ID freeing code) things (unlinking, and even not freeing animdata!).
2015-10-01 17:38:04 +02:00
e734bef9d6 Free IDs: Nodes & Groups. 2015-10-01 17:13:16 +02:00
105c6a6c26 Free IDs: Action & Armature. 2015-10-01 16:57:28 +02:00
45f25c6241 Free IDs: Sound & Speaker.
Also cleanup, removed horrible `BKE_sound_delete()`!
2015-10-01 16:47:12 +02:00
1a8727fea0 Free IDs: vfont & text. 2015-10-01 16:34:09 +02:00
ad6495d14b ID free: another round of cleanup & fixes (mostly insconsitancies among IDs code)... 2015-09-30 21:59:24 +02:00
fe3c796c31 Free ID: Brush & World. 2015-09-30 21:34:57 +02:00
099eb3111e ID free: GP & particles... 2015-09-30 21:15:20 +02:00
dd266202b0 ID free: freestylelinestyle & other minor types, some cleanups (mostly use MEM_SAFE_FREE where possible). 2015-09-30 20:52:33 +02:00
1636b12d4d Merge branch 'master' into free-refcount-ids 2015-09-30 20:23:47 +02:00
9e64ad1ad5 Merge branch 'lib-link-rework-temp' into missing-libs 2015-09-30 20:23:14 +02:00
6fb87bc545 Merge branch 'master' into missing-libs 2015-09-30 20:23:07 +02:00
919a887399 Merge branch 'master' into lib-link-rework-temp 2015-09-30 20:22:37 +02:00
921a86b51f Free IDs; lattice & camera. 2015-09-27 15:50:28 +02:00
5b02b2429a Free IDs: images & lamps. 2015-09-27 15:28:57 +02:00
2282a80697 ID freeing: materials and textures. 2015-09-27 15:12:27 +02:00
931570b480 ID free: tackle Scene (and Library, but not much to do there). 2015-09-27 14:43:49 +02:00
ff7b6d36e3 Merge branch 'master' into free-refcount-ids 2015-09-27 11:26:46 +02:00
0b8a47d1b0 Merge branch 'lib-link-rework-temp' into missing-libs 2015-09-27 11:24:50 +02:00
9960295484 Merge branch 'master' into missing-libs 2015-09-27 11:24:42 +02:00
113979e658 Merge branch 'master' into lib-link-rework-temp 2015-09-27 11:19:31 +02:00
a7e540d7c8 Clean up BKE_object_free() and add BKE_object_release_datablocks().
Similar changed to those done for mesh/curve/mball.

Also, systematically nullify pointers in `_free()` functions, this does not cost
much and can help troubleshooting later.

And tag `BKE_object_unlink()` as an horrible piece of code...
2015-09-24 20:43:35 +02:00
56dae06c56 Cleanup of free/unlink/release of ID: mesh/curve/mball.
Renamed their `_unlink()` functions to `_release_datablocks()`, since they do not
unlink anything (not in the sense `BKE_object_unklink()` does, at least)!

Also, added a `const bool do_id_user` to their `_free()`, for consistency, now
relevant `_release_datablocks()` func only gets called when this option is set.
2015-09-24 19:53:38 +02:00
19f05f274a Merge branch 'lib-link-rework-temp' into missing-libs 2015-09-24 13:15:24 +02:00
4c486c075e Merge branch 'master' into missing-libs 2015-09-24 13:14:48 +02:00
6b49cc1221 Merge branch 'master' into lib-link-rework-temp 2015-09-24 13:13:02 +02:00
5186e5a0c9 Merge branch 'lib-link-rework-temp' into missing-libs 2015-09-22 10:00:28 +02:00
cf7e75ad53 Merge branch 'master' into missing-libs 2015-09-22 10:00:20 +02:00
1b75f74086 We do not require anymore linking datablocks grouped by types, makes code even simpler. 2015-09-22 09:58:59 +02:00
7a5edf3b45 Merge branch 'master' into lib-link-rework-temp 2015-09-22 09:49:24 +02:00
06eb69b892 Correct handling of name in placeholder generator (this is a name, not an idname...). 2015-09-21 21:37:05 +02:00
f0d843cf56 Sort placeholder in its listbase! 2015-09-21 21:25:28 +02:00
62fdf030c6 Change ID placeholder generator to not need an ID as reference (we only need type, name and flag here). 2015-09-21 21:08:25 +02:00
bcf4cc37ff Make placeholder ID creation its own function (we'll need it too in reload context...). 2015-09-21 18:02:56 +02:00
e6a84d5a48 Merge branch 'lib-link-rework-temp' into missing-libs 2015-09-21 17:50:27 +02:00
3391a5ed2f Merge branch 'master' into missing-libs 2015-09-21 17:48:12 +02:00
e91d614e4e Merge branch 'master' into lib-link-rework-temp 2015-09-21 17:46:09 +02:00
ac797f03ef Fix broken multi-lib linking, and remove Main locking around core linking code for now.
We need to append to linklist, or our library indices would be reversed compared to lib list...

As for locking, we need reentrant one here if we want to use it. :(
2015-09-21 17:42:32 +02:00
c18849bb1b Lock bmain around core part of linking code now, this is much safer imho!
This also means we need to ensure no code called from there tries to lock again bmain
(no reentrant spinlock, arg :/).
2015-09-21 16:35:29 +02:00
33b7772563 Merge branch 'master' into missing-libs 2015-09-21 15:10:39 +02:00
f7a3ead1c7 Merge branch 'master' into lib-link-rework-temp 2015-09-21 15:10:20 +02:00
1d4e36a4c9 Merge branch 'master' into lib-link-rework-temp 2015-09-20 15:41:37 +02:00
bcbbee4f73 Merge branch 'master' into missing-libs 2015-09-20 14:54:33 +02:00
5ac9844083 Some naming cleanup. 2015-09-18 22:27:35 +02:00
856ef065b2 Rework a bit new liblink code, to use our beloved memarena instead of ugly pile of malloc.
Performances are not an issue at all here, but it makes code slightly simpler, avoids
a loop over ghash of libs, avoids some potential mem fragmentation, and will be easier
with lib relocate code too in future...
2015-09-18 22:22:56 +02:00
1ba2646706 Some cleanup & tweaks. 2015-09-18 16:11:55 +02:00
c7e14ac1f8 Merge branch 'master' into lib-link-rework-temp 2015-09-18 15:47:07 +02:00
87a3de5852 Merge branch 'master' into missing-libs 2015-09-18 15:44:10 +02:00
49156ee77b Serious rework (again) of append/link code, to make it more generic.
Making the code in WM area more generic (will be used by relocate libs feature too in future).
And multi-append/link shall no more close & re-open lib files for each and every idcode!

Also, serious cleanup of BLO_append_... API (renamed BLO_link_..., since it links and never appends!),
main real changes there are removing the bContext arg in favor of scene/v3d (a bit more verbose, but does
not requires a valid context anymore to be able to instanciate ob/groups!). And logic behind instanciating
or not has been simplified, previous code was really obscure and sometimes redondant, from quick tests
it still works as expected.

This is temp branch for until 2.76 is over, shall be merged in master asap then.
2015-09-17 20:45:51 +02:00
6fda73fe0e Merge branch 'master' into missing-libs 2015-09-13 15:19:31 +02:00
0abb0ee156 Merge branch 'master' into missing-libs 2015-09-10 22:39:39 +02:00
65a108cf35 Merge branch 'master' into missing-libs 2015-09-03 16:16:26 +02:00
75db37e80f Merge branch 'master' into missing-libs 2015-08-30 11:55:38 +02:00
6711e9d15f Merge branch 'master' into missing-libs 2015-08-22 15:11:32 +02:00
d2bdc66143 Merge branch 'master' into missing-libs 2015-08-02 17:50:29 +02:00
313fabd310 Merge branch 'master' into missing-libs 2015-07-21 08:07:42 +02:00
aee44d5070 Merge branch 'master' into missing-libs 2015-07-17 21:13:03 +02:00
09787f03b7 Merge branch 'master' into missing-libs 2015-07-16 19:53:31 +02:00
610a04ab5d Fix rebase mess :/ 2015-07-15 20:38:51 +02:00
222a199f99 Add outliner's visualization for broken libs, and also tag lib ID itself as missing. 2015-07-15 20:36:22 +02:00
82d166df72 Add remaning 'init' callbacks for needed ID types.
Note all this remains a bit theoretical, some cases (ID types) are a bit delicate to handle here.7
Time and tests will say if it's OK as is.
2015-07-15 20:36:22 +02:00
83dd16a6d6 Add some checks in BKE_xxx_init() that data is really NULLified.
Needed, since trying to (re)init data already set could lead to many issues,
and handling this is not in the scope of this function.

Note that definition of BLI_memcmp_null stuff is rather bad currently, no good idea where to place this. :|
2015-07-15 20:36:22 +02:00
4181f35014 Handling missing libs: changed idea, now adding 'real' empty data.
Just having 'NULL' data as placeholder is not really possible, too much places
to check against that.

WIP commit, still much to be done!

See T43351 for details.

Differential Revision: https://developer.blender.org/D1394
2015-07-15 20:36:22 +02:00
266f0d3e77 Very first step to handle missing libs/datablocks when reading a file.
Idea is, instead of ignoring completely missing linked datablocks, to
create void placeholders for them.

That way, you can work on your file, save it, and find again your missing data once
lib becomes available again.

Plans are also to be able to locate missing libs and reload them at runtime.

To support all that, we must be able to make Blender survive those missing data
(i.e. empty datablocks) all over the place. This commit contains some early work
in that direction, but this will need much much more work!
2015-07-15 20:36:21 +02:00
9a2ae72156 Icons: Add new 'library_data_broken' one. 2015-07-15 20:36:21 +02:00
42 changed files with 518 additions and 114 deletions

View File

@@ -40,6 +40,7 @@ void BKE_brush_system_init(void);
void BKE_brush_system_exit(void);
/* datablock functions */
void BKE_brush_init(struct Brush *brush);
struct Brush *BKE_brush_add(struct Main *bmain, const char *name, short ob_mode);
struct Brush *BKE_brush_first_search(struct Main *bmain, short ob_mode);
struct Brush *BKE_brush_copy(struct Brush *brush);

View File

@@ -50,6 +50,7 @@ struct GPUFXSettings;
/* Camera Datablock */
void BKE_camera_init(struct Camera *cam);
void *BKE_camera_add(struct Main *bmain, const char *name);
struct Camera *BKE_camera_copy(struct Camera *cam);
void BKE_camera_make_local(struct Camera *cam);

View File

@@ -69,6 +69,7 @@ typedef struct CurveCache {
void BKE_curve_unlink(struct Curve *cu);
void BKE_curve_free(struct Curve *cu);
void BKE_curve_editfont_free(struct Curve *cu);
void BKE_curve_init(struct Curve *cu);
struct Curve *BKE_curve_add(struct Main *bmain, const char *name, int type);
struct Curve *BKE_curve_copy(struct Curve *cu);
void BKE_curve_make_local(struct Curve *cu);

View File

@@ -79,6 +79,7 @@ void BKE_vfont_builtin_register(void *mem, int size);
void BKE_vfont_free_data(struct VFont *vfont);
void BKE_vfont_free(struct VFont *sc);
void BKE_vfont_init(struct VFont *vfont);
struct VFont *BKE_vfont_builtin_get(void);
struct VFont *BKE_vfont_load(struct Main *bmain, const char *filepath);
struct VFont *BKE_vfont_load_exists_ex(struct Main *bmain, const char *filepath, bool *r_exists);

View File

@@ -42,6 +42,7 @@ struct Lamp;
struct Main;
struct Scene;
void BKE_lamp_init(struct Lamp *la);
struct Lamp *BKE_lamp_add(struct Main *bmain, const char *name) ATTR_WARN_UNUSED_RESULT;
struct Lamp *BKE_lamp_copy(struct Lamp *la) ATTR_WARN_UNUSED_RESULT;
struct Lamp *localize_lamp(struct Lamp *la) ATTR_WARN_UNUSED_RESULT;

View File

@@ -45,6 +45,7 @@ struct BPoint;
struct MDeformVert;
void BKE_lattice_resize(struct Lattice *lt, int u, int v, int w, struct Object *ltOb);
void BKE_lattice_init(struct Lattice *lt);
struct Lattice *BKE_lattice_add(struct Main *bmain, const char *name);
struct Lattice *BKE_lattice_copy(struct Lattice *lt);
void BKE_lattice_free(struct Lattice *lt);

View File

@@ -49,7 +49,9 @@ struct bContext;
struct PointerRNA;
struct PropertyRNA;
void *BKE_libblock_alloc_notest(short type);
void *BKE_libblock_alloc(struct Main *bmain, short type, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
void BKE_libblock_init_empty(struct ID *id);
void *BKE_libblock_copy_ex(struct Main *bmain, struct ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
void *BKE_libblock_copy_nolib(struct ID *id, const bool do_action) ATTR_NONNULL();
void *BKE_libblock_copy(struct ID *id) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();

View File

@@ -49,6 +49,7 @@ struct Object;
struct ColorBand;
struct bContext;
void BKE_linestyle_init(struct FreestyleLineStyle *linestyle);
FreestyleLineStyle *BKE_linestyle_new(struct Main *bmain, const char *name);
void BKE_linestyle_free(FreestyleLineStyle *linestyle);
FreestyleLineStyle *BKE_linestyle_copy(struct Main *bmain, FreestyleLineStyle *linestyle);

View File

@@ -49,7 +49,7 @@ void BKE_material_free(struct Material *sc);
void BKE_material_free_ex(struct Material *ma, bool do_id_user);
void test_object_materials(struct Main *bmain, struct ID *id);
void BKE_material_resize_object(struct Object *ob, const short totcol, bool do_id_user);
void init_material(struct Material *ma);
void BKE_material_init(struct Material *ma);
void BKE_material_remap_object(struct Object *ob, const unsigned int *remap);
struct Material *BKE_material_add(struct Main *bmain, const char *name);
struct Material *BKE_material_copy(struct Material *ma);

View File

@@ -40,6 +40,7 @@ struct MetaElem;
void BKE_mball_unlink(struct MetaBall *mb);
void BKE_mball_free(struct MetaBall *mb);
void BKE_mball_init(struct MetaBall *mb);
struct MetaBall *BKE_mball_add(struct Main *bmain, const char *name);
struct MetaBall *BKE_mball_copy(struct MetaBall *mb);

View File

@@ -82,6 +82,7 @@ int BKE_mesh_edge_other_vert(const struct MEdge *e, int v);
void BKE_mesh_unlink(struct Mesh *me);
void BKE_mesh_free(struct Mesh *me, int unlink);
void BKE_mesh_init(struct Mesh *me);
struct Mesh *BKE_mesh_add(struct Main *bmain, const char *name);
struct Mesh *BKE_mesh_copy_ex(struct Main *bmain, struct Mesh *me);
struct Mesh *BKE_mesh_copy(struct Mesh *me);

View File

@@ -337,6 +337,7 @@ struct GHashIterator *ntreeTypeGetIterator(void);
void ntreeSetTypes(const struct bContext *C, struct bNodeTree *ntree);
void ntreeInitDefault(struct bNodeTree *ntree);
struct bNodeTree *ntreeAddTree(struct Main *bmain, const char *name, const char *idname);
/* copy/free funcs, need to manage ID users */

View File

@@ -85,6 +85,7 @@ bool BKE_object_is_in_editmode(struct Object *ob);
bool BKE_object_is_in_editmode_vgroup(struct Object *ob);
bool BKE_object_is_in_wpaint_select_vert(struct Object *ob);
void BKE_object_init(struct Object *ob);
struct Object *BKE_object_add_only_object(
struct Main *bmain,
int type, const char *name)

View File

@@ -67,6 +67,7 @@ void free_avicodecdata(struct AviCodecData *acd);
void free_qtcodecdata(struct QuicktimeCodecData *acd);
void BKE_scene_free(struct Scene *sce);
void BKE_scene_init(struct Scene *sce);
struct Scene *BKE_scene_add(struct Main *bmain, const char *name);
/* base functions */

View File

@@ -29,7 +29,9 @@
*/
struct Main;
struct Speaker;
void BKE_speaker_init(struct Speaker *spk);
void *BKE_speaker_add(struct Main *bmain, const char *name);
struct Speaker *BKE_speaker_copy(struct Speaker *spk);
void BKE_speaker_make_local(struct Speaker *spk);

View File

@@ -44,6 +44,7 @@ struct TextLine;
void BKE_text_free (struct Text *text);
void txt_set_undostate (int u);
int txt_get_undostate (void);
void BKE_text_init(struct Text *ta);
struct Text *BKE_text_add (struct Main *bmain, const char *name);
int txt_extended_ascii_as_utf8(char **str);
bool BKE_text_reload(struct Text *text);

View File

@@ -38,6 +38,7 @@ struct World;
void BKE_world_free(struct World *sc);
void BKE_world_free_ex(struct World *sc, bool do_id_user);
void BKE_world_init(struct World *wrld);
struct World *add_world(struct Main *bmian, const char *name);
struct World *BKE_world_copy(struct World *wrld);
struct World *localize_world(struct World *wrld);

View File

@@ -131,11 +131,9 @@ static void brush_defaults(Brush *brush)
/* Datablock add/copy/free/make_local */
Brush *BKE_brush_add(Main *bmain, const char *name, short ob_mode)
void BKE_brush_init(Brush *brush)
{
Brush *brush;
brush = BKE_libblock_alloc(bmain, ID_BR, name);
BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(brush, id));
/* enable fake user by default */
brush->id.flag |= LIB_FAKEUSER;
@@ -143,10 +141,20 @@ Brush *BKE_brush_add(Main *bmain, const char *name, short ob_mode)
brush_defaults(brush);
brush->sculpt_tool = SCULPT_TOOL_DRAW; /* sculpting defaults to the draw tool for new brushes */
brush->ob_mode = ob_mode;
/* the default alpha falloff curve */
BKE_brush_curve_preset(brush, CURVE_PRESET_SMOOTH);
}
Brush *BKE_brush_add(Main *bmain, const char *name, short ob_mode)
{
Brush *brush;
brush = BKE_libblock_alloc(bmain, ID_BR, name);
BKE_brush_init(brush);
brush->ob_mode = ob_mode;
return brush;
}

View File

@@ -57,11 +57,9 @@
/****************************** Camera Datablock *****************************/
void *BKE_camera_add(Main *bmain, const char *name)
void BKE_camera_init(Camera *cam)
{
Camera *cam;
cam = BKE_libblock_alloc(bmain, ID_CA, name);
BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(cam, id));
cam->lens = 35.0f;
cam->sensor_x = DEFAULT_SENSOR_WIDTH;
@@ -78,6 +76,15 @@ void *BKE_camera_add(Main *bmain, const char *name)
/* stereoscopy 3d */
cam->stereo.interocular_distance = 0.065f;
cam->stereo.convergence_distance = 30.f * 0.065f;
}
void *BKE_camera_add(Main *bmain, const char *name)
{
Camera *cam;
cam = BKE_libblock_alloc(bmain, ID_CA, name);
BKE_camera_init(cam);
return cam;
}

View File

@@ -161,15 +161,14 @@ void BKE_curve_free(Curve *cu)
MEM_freeN(cu->tb);
}
Curve *BKE_curve_add(Main *bmain, const char *name, int type)
void BKE_curve_init(Curve *cu)
{
Curve *cu;
/* BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(cu, id)); */ /* cu->type is already initialized... */
cu = BKE_libblock_alloc(bmain, ID_CU, name);
copy_v3_fl(cu->size, 1.0f);
cu->flag = CU_FRONT | CU_BACK | CU_DEFORM_BOUNDS_OFF | CU_PATH_RADIUS;
cu->pathlen = 100;
cu->resolu = cu->resolv = (type == OB_SURF) ? 4 : 12;
cu->resolu = cu->resolv = (cu->type == OB_SURF) ? 4 : 12;
cu->width = 1.0;
cu->wordspace = 1.0;
cu->spacing = cu->linedist = 1.0;
@@ -179,7 +178,6 @@ Curve *BKE_curve_add(Main *bmain, const char *name, int type)
cu->smallcaps_scale = 0.75f;
/* XXX: this one seems to be the best one in most cases, at least for curve deform... */
cu->twist_mode = CU_TWIST_MINIMUM;
cu->type = type;
cu->bevfac1 = 0.0f;
cu->bevfac2 = 1.0f;
cu->bevfac1_mapping = CU_BEVFAC_MAP_RESOLU;
@@ -187,7 +185,7 @@ Curve *BKE_curve_add(Main *bmain, const char *name, int type)
cu->bb = BKE_boundbox_alloc_unit();
if (type == OB_FONT) {
if (cu->type == OB_FONT) {
cu->vfont = cu->vfontb = cu->vfonti = cu->vfontbi = BKE_vfont_builtin_get();
cu->vfont->id.us += 4;
cu->str = MEM_mallocN(12, "str");
@@ -198,6 +196,16 @@ Curve *BKE_curve_add(Main *bmain, const char *name, int type)
cu->tb = MEM_callocN(MAXTEXTBOX * sizeof(TextBox), "textbox");
cu->tb[0].w = cu->tb[0].h = 0.0;
}
}
Curve *BKE_curve_add(Main *bmain, const char *name, int type)
{
Curve *cu;
cu = BKE_libblock_alloc(bmain, ID_CU, name);
cu->type = type;
BKE_curve_init(cu);
return cu;
}

View File

@@ -203,6 +203,26 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont)
return vfont->data;
}
/* Bad naming actually in this case... */
void BKE_vfont_init(VFont *vfont)
{
PackedFile *pf = get_builtin_packedfile();
if (pf) {
VFontData *vfd;
vfd = BLI_vfontdata_from_freetypefont(pf);
if (vfd) {
vfont->data = vfd;
BLI_strncpy(vfont->name, FO_BUILTIN_NAME, sizeof(vfont->name));
}
/* Free the packed file */
freePackedFile(pf);
}
}
VFont *BKE_vfont_load(Main *bmain, const char *filepath)
{
char filename[FILE_MAXFILE];

View File

@@ -53,12 +53,10 @@
#include "BKE_main.h"
#include "BKE_node.h"
Lamp *BKE_lamp_add(Main *bmain, const char *name)
void BKE_lamp_init(Lamp *la)
{
Lamp *la;
la = BKE_libblock_alloc(bmain, ID_LA, name);
BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(la, id));
la->r = la->g = la->b = la->k = 1.0f;
la->haint = la->energy = 1.0f;
la->dist = 25.0f;
@@ -100,6 +98,16 @@ Lamp *BKE_lamp_add(Main *bmain, const char *name)
la->shadow_frustum_size = 10.0f;
curvemapping_initialize(la->curfalloff);
}
Lamp *BKE_lamp_add(Main *bmain, const char *name)
{
Lamp *la;
la = BKE_libblock_alloc(bmain, ID_LA, name);
BKE_lamp_init(la);
return la;
}

View File

@@ -251,12 +251,10 @@ void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
MEM_freeN(vertexCos);
}
Lattice *BKE_lattice_add(Main *bmain, const char *name)
void BKE_lattice_init(Lattice *lt)
{
Lattice *lt;
lt = BKE_libblock_alloc(bmain, ID_LT, name);
BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(lt, id));
lt->flag = LT_GRID;
lt->typeu = lt->typev = lt->typew = KEY_BSPLINE;
@@ -264,7 +262,16 @@ Lattice *BKE_lattice_add(Main *bmain, const char *name)
lt->def = MEM_callocN(sizeof(BPoint), "lattvert"); /* temporary */
BKE_lattice_resize(lt, 2, 2, 2, NULL); /* creates a uniform lattice */
lt->actbp = LT_ACTBP_NONE;
}
Lattice *BKE_lattice_add(Main *bmain, const char *name)
{
Lattice *lt;
lt = BKE_libblock_alloc(bmain, ID_LT, name);
BKE_lattice_init(lt);
return lt;
}

View File

@@ -59,6 +59,7 @@
#include "DNA_movieclip_types.h"
#include "DNA_mask_types.h"
#include "DNA_node_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_speaker_types.h"
@@ -648,7 +649,7 @@ int set_listbasepointers(Main *main, ListBase **lb)
* Allocates and returns memory of the right size for the specified block type,
* initialized to zero.
*/
static ID *alloc_libblock_notest(short type)
void *BKE_libblock_alloc_notest(short type)
{
ID *id = NULL;
@@ -770,7 +771,7 @@ void *BKE_libblock_alloc(Main *bmain, short type, const char *name)
ID *id = NULL;
ListBase *lb = which_libbase(bmain, type);
id = alloc_libblock_notest(type);
id = BKE_libblock_alloc_notest(type);
if (id) {
BKE_main_lock(bmain);
BLI_addtail(lb, id);
@@ -785,6 +786,121 @@ void *BKE_libblock_alloc(Main *bmain, short type, const char *name)
return id;
}
/**
* Initialize an ID of given type, such that it has valid 'empty' data.
* ID is assumed to be just calloc'ed.
*/
void BKE_libblock_init_empty(ID *id)
{
/* Note that only ID types that are not valid when filled of zero should have a callback here. */
switch (GS(id->name)) {
case ID_SCE:
BKE_scene_init((Scene *)id);
break;
case ID_LI:
/* Nothing to do. */
break;
case ID_OB:
{
Object *ob = (Object *)id;
ob->type = OB_EMPTY;
BKE_object_init(ob);
break;
}
case ID_ME:
BKE_mesh_init((Mesh *)id);
break;
case ID_CU:
BKE_curve_init((Curve *)id);
break;
case ID_MB:
BKE_mball_init((MetaBall *)id);
break;
case ID_MA:
BKE_material_init((Material *)id);
break;
case ID_TE:
BKE_texture_default((Tex *)id);
break;
case ID_IM:
/* Image is a bit complicated, for now assume NULLified im is OK. */
break;
case ID_LT:
BKE_lattice_init((Lattice *)id);
break;
case ID_LA:
BKE_lamp_init((Lamp *)id);
break;
case ID_SPK:
BKE_speaker_init((Speaker *)id);
break;
case ID_CA:
BKE_camera_init((Camera *)id);
break;
case ID_IP:
/* Should not be needed - animation from lib pre-2.5 is broken anyway. */
BLI_assert(0);
break;
case ID_KE:
/* Shapekeys are a complex topic too - they depend on their 'user' data type...
* They are not linkable, though, so it should never reach here anyway. */
BLI_assert(0);
break;
case ID_WO:
BKE_world_init((World *)id);
break;
case ID_SCR:
/* Nothing to do. */
break;
case ID_VF:
BKE_vfont_init((VFont *)id);
break;
case ID_TXT:
BKE_text_init((Text *)id);
break;
case ID_SCRIPT:
BLI_assert(0);
break;
case ID_SO:
/* Another fuzzy case, think NULLified content is OK here... */
break;
case ID_GR:
/* Nothing to do. */
break;
case ID_AR:
/* Nothing to do. */
break;
case ID_AC:
/* Nothing to do. */
break;
case ID_NT:
ntreeInitDefault((bNodeTree *)id);
break;
case ID_BR:
BKE_brush_init((Brush *)id);
break;
case ID_PA:
/* Nothing to do. */
break;
case ID_PC:
/* Nothing to do. */
break;
case ID_WM:
/* We should never reach this. */
BLI_assert(0);
break;
case ID_GD:
/* Nothing to do. */
break;
case ID_MSK:
/* Nothing to do. */
break;
case ID_LS:
BKE_linestyle_init((FreestyleLineStyle *)id);
break;
}
}
/* by spec, animdata is first item after ID */
/* and, trust that BKE_animdata_from_id() will only find AnimData for valid ID-types */
static void id_copy_animdata(ID *id, const bool do_action)
@@ -838,7 +954,7 @@ void *BKE_libblock_copy_nolib(ID *id, const bool do_action)
ID *idn;
size_t idn_len;
idn = alloc_libblock_notest(GS(id->name));
idn = BKE_libblock_alloc_notest(GS(id->name));
assert(idn != NULL);
BLI_strncpy(idn->name, id->name, sizeof(idn->name));
@@ -1720,7 +1836,7 @@ void rename_id(ID *id, const char *name)
*/
void name_uiprefix_id(char *name, const ID *id)
{
name[0] = id->lib ? 'L' : ' ';
name[0] = id->lib ? (ID_MISSING(id) ? 'M' : 'L') : ' ';
name[1] = (id->flag & LIB_FAKEUSER) ? 'F' : ((id->us == 0) ? '0' : ' ');
name[2] = ' ';

View File

@@ -80,8 +80,10 @@ static const char *modifier_name[LS_MODIFIER_NUM] = {
"3D Curvature",
};
static void default_linestyle_settings(FreestyleLineStyle *linestyle)
void BKE_linestyle_init(FreestyleLineStyle *linestyle)
{
BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(linestyle, id));
linestyle->panel = LS_PANEL_STROKES;
linestyle->r = linestyle->g = linestyle->b = 0.0f;
linestyle->alpha = 1.0f;
@@ -118,7 +120,7 @@ FreestyleLineStyle *BKE_linestyle_new(struct Main *bmain, const char *name)
linestyle = (FreestyleLineStyle *)BKE_libblock_alloc(bmain, ID_LS, name);
default_linestyle_settings(linestyle);
BKE_linestyle_init(linestyle);
return linestyle;
}

View File

@@ -78,7 +78,7 @@ Material defmaterial;
/* called on startup, creator.c */
void init_def_material(void)
{
init_material(&defmaterial);
BKE_material_init(&defmaterial);
}
/* not material itself */
@@ -122,8 +122,10 @@ void BKE_material_free_ex(Material *ma, bool do_id_user)
GPU_material_free(&ma->gpumaterial);
}
void init_material(Material *ma)
void BKE_material_init(Material *ma)
{
BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(ma, id));
ma->r = ma->g = ma->b = ma->ref = 0.8;
ma->specr = ma->specg = ma->specb = 1.0;
ma->mirr = ma->mirg = ma->mirb = 1.0;
@@ -221,7 +223,7 @@ Material *BKE_material_add(Main *bmain, const char *name)
ma = BKE_libblock_alloc(bmain, ID_MA, name);
init_material(ma);
BKE_material_init(ma);
return ma;
}

View File

@@ -91,19 +91,26 @@ void BKE_mball_free(MetaBall *mb)
if (mb->disp.first) BKE_displist_free(&mb->disp);
}
MetaBall *BKE_mball_add(Main *bmain, const char *name)
void BKE_mball_init(MetaBall *mb)
{
MetaBall *mb;
mb = BKE_libblock_alloc(bmain, ID_MB, name);
BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(mb, id));
mb->size[0] = mb->size[1] = mb->size[2] = 1.0;
mb->texflag = MB_AUTOSPACE;
mb->wiresize = 0.4f;
mb->rendersize = 0.2f;
mb->thresh = 0.6f;
}
MetaBall *BKE_mball_add(Main *bmain, const char *name)
{
MetaBall *mb;
mb = BKE_libblock_alloc(bmain, ID_MB, name);
BKE_mball_init(mb);
return mb;
}

View File

@@ -490,12 +490,10 @@ static void mesh_tessface_clear_intern(Mesh *mesh, int free_customdata)
mesh->totface = 0;
}
Mesh *BKE_mesh_add(Main *bmain, const char *name)
void BKE_mesh_init(Mesh *me)
{
Mesh *me;
me = BKE_libblock_alloc(bmain, ID_ME, name);
BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(me, id));
me->size[0] = me->size[1] = me->size[2] = 1.0;
me->smoothresh = 30;
me->texflag = ME_AUTOSPACE;
@@ -511,6 +509,15 @@ Mesh *BKE_mesh_add(Main *bmain, const char *name)
CustomData_reset(&me->fdata);
CustomData_reset(&me->pdata);
CustomData_reset(&me->ldata);
}
Mesh *BKE_mesh_add(Main *bmain, const char *name)
{
Mesh *me;
me = BKE_libblock_alloc(bmain, ID_ME, name);
BKE_mesh_init(me);
return me;
}

View File

@@ -1151,6 +1151,11 @@ void nodeDetachNode(struct bNode *node)
}
}
void ntreeInitDefault(bNodeTree *ntree)
{
ntree_set_typeinfo(ntree, NULL);
}
bNodeTree *ntreeAddTree(Main *bmain, const char *name, const char *idname)
{
bNodeTree *ntree;

View File

@@ -972,19 +972,10 @@ void *BKE_object_obdata_add_from_type(Main *bmain, int type, const char *name)
}
}
/* more general add: creates minimum required data, but without vertices etc. */
Object *BKE_object_add_only_object(Main *bmain, int type, const char *name)
void BKE_object_init(Object *ob)
{
Object *ob;
/* BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(ob, id)); */ /* ob->type is already initialized... */
if (!name)
name = get_obdata_defname(type);
ob = BKE_libblock_alloc(bmain, ID_OB, name);
/* default object vars */
ob->type = type;
ob->col[0] = ob->col[1] = ob->col[2] = 1.0;
ob->col[3] = 1.0;
@@ -1012,7 +1003,7 @@ Object *BKE_object_add_only_object(Main *bmain, int type, const char *name)
ob->empty_drawtype = OB_PLAINAXES;
ob->empty_drawsize = 1.0;
if (ELEM(type, OB_LAMP, OB_CAMERA, OB_SPEAKER)) {
if (ELEM(ob->type, OB_LAMP, OB_CAMERA, OB_SPEAKER)) {
ob->trackflag = OB_NEGZ;
ob->upflag = OB_POSY;
}
@@ -1053,6 +1044,22 @@ Object *BKE_object_add_only_object(Main *bmain, int type, const char *name)
/* Animation Visualization defaults */
animviz_settings_init(&ob->avs);
}
/* more general add: creates minimum required data, but without vertices etc. */
Object *BKE_object_add_only_object(Main *bmain, int type, const char *name)
{
Object *ob;
if (!name)
name = get_obdata_defname(type);
ob = BKE_libblock_alloc(bmain, ID_OB, name);
/* default object vars */
ob->type = type;
BKE_object_init(ob);
return ob;
}

View File

@@ -464,15 +464,15 @@ void BKE_scene_free(Scene *sce)
BKE_previewimg_free(&sce->preview);
}
Scene *BKE_scene_add(Main *bmain, const char *name)
void BKE_scene_init(Scene *sce)
{
Scene *sce;
ParticleEditSettings *pset;
int a;
const char *colorspace_name;
SceneRenderView *srv;
sce = BKE_libblock_alloc(bmain, ID_SCE, name);
BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(sce, id));
sce->lay = sce->layact = 1;
sce->r.mode = R_GAMMA | R_OSA | R_SHADOW | R_SSS | R_ENVMAP | R_RAYTRACE;
@@ -743,6 +743,15 @@ Scene *BKE_scene_add(Main *bmain, const char *name)
copy_v2_fl2(sce->safe_areas.action_center, 15.0f / 100.0f, 5.0f / 100.0f);
sce->preview = NULL;
}
Scene *BKE_scene_add(Main *bmain, const char *name)
{
Scene *sce;
sce = BKE_libblock_alloc(bmain, ID_SCE, name);
BKE_scene_init(sce);
return sce;
}

View File

@@ -37,11 +37,9 @@
#include "BKE_main.h"
#include "BKE_speaker.h"
void *BKE_speaker_add(Main *bmain, const char *name)
void BKE_speaker_init(Speaker *spk)
{
Speaker *spk;
spk = BKE_libblock_alloc(bmain, ID_SPK, name);
BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(spk, id));
spk->attenuation = 1.0f;
spk->cone_angle_inner = 360.0f;
@@ -55,6 +53,15 @@ void *BKE_speaker_add(Main *bmain, const char *name)
spk->volume = 1.0f;
spk->volume_max = 1.0f;
spk->volume_min = 0.0f;
}
void *BKE_speaker_add(Main *bmain, const char *name)
{
Speaker *spk;
spk = BKE_libblock_alloc(bmain, ID_SPK, name);
BKE_speaker_init(spk);
return spk;
}

View File

@@ -171,14 +171,12 @@ void BKE_text_free(Text *text)
#endif
}
Text *BKE_text_add(Main *bmain, const char *name)
void BKE_text_init(Text *ta)
{
Text *ta;
TextLine *tmp;
ta = BKE_libblock_alloc(bmain, ID_TXT, name);
ta->id.us = 1;
BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(ta, id));
ta->name = NULL;
init_undo_text(ta);
@@ -206,6 +204,15 @@ Text *BKE_text_add(Main *bmain, const char *name)
ta->curc = 0;
ta->sell = ta->lines.first;
ta->selc = 0;
}
Text *BKE_text_add(Main *bmain, const char *name)
{
Text *ta;
ta = BKE_libblock_alloc(bmain, ID_TXT, name);
BKE_text_init(ta);
return ta;
}

View File

@@ -580,6 +580,8 @@ void BKE_texture_free(Tex *tex)
void BKE_texture_default(Tex *tex)
{
/* BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(tex, id)); */ /* Not here, can be called with some pointers set. :/ */
tex->type = TEX_IMAGE;
tex->ima = NULL;
tex->stype = 0;

View File

@@ -31,6 +31,7 @@
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include "MEM_guardedalloc.h"
@@ -83,12 +84,10 @@ void BKE_world_free(World *wrld)
BKE_world_free_ex(wrld, true);
}
World *add_world(Main *bmain, const char *name)
void BKE_world_init(World *wrld)
{
World *wrld;
BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(wrld, id));
wrld = BKE_libblock_alloc(bmain, ID_WO, name);
wrld->horr = 0.05f;
wrld->horg = 0.05f;
wrld->horb = 0.05f;
@@ -113,6 +112,15 @@ World *add_world(Main *bmain, const char *name)
wrld->preview = NULL;
wrld->miststa = 5.0f;
wrld->mistdist = 25.0f;
}
World *add_world(Main *bmain, const char *name)
{
World *wrld;
wrld = BKE_libblock_alloc(bmain, ID_WO, name);
BKE_world_init(wrld);
return wrld;
}

View File

@@ -0,0 +1,34 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __BLI_MEMORY_UTILS_H__
#define __BLI_MEMORY_UTILS_H__
/** \file BLI_memory_utils.h
* \ingroup bli
* \brief Generic memory manipulation API.
*/
/* it may be defined already */
#ifndef __BLI_UTILDEFINES_H__
bool BLI_memory_is_zero(const void *arr, const size_t size);
#endif
#endif /* __BLI_MEMORY_UTILS_H__ */

View File

@@ -513,6 +513,17 @@ extern "C" {
sizeof(*(struct_var)) - OFFSETOF_STRUCT(struct_var, member)); \
} (void)0
/* defined
* in memory_utils.c for now. I do not know where we should put it actually... */
#ifndef __BLI_MEMORY_UTILS_H__
extern bool BLI_memory_is_zero(const void *arr, const size_t arr_size);
#endif
#define MEMCMP_STRUCT_OFS_IS_ZERO(struct_var, member) \
(BLI_memory_is_zero( \
(char *)(struct_var) + OFFSETOF_STRUCT(struct_var, member), \
sizeof(*(struct_var)) - OFFSETOF_STRUCT(struct_var, member)))
/* Warning-free macros for storing ints in pointers. Use these _only_
* for storing an int in a pointer, not a pointer in an int (64bit)! */
#define SET_INT_IN_POINTER(i) ((void *)(intptr_t)(i))

View File

@@ -88,6 +88,7 @@ set(SRC
intern/math_statistics.c
intern/math_vector.c
intern/math_vector_inline.c
intern/memory_utils.c
intern/noise.c
intern/path_util.c
intern/polyfill2d.c
@@ -169,6 +170,7 @@ set(SRC
BLI_math_statistics.h
BLI_math_vector.h
BLI_memarena.h
BLI_memory_utils.h
BLI_mempool.h
BLI_noise.h
BLI_path_util.h

View File

@@ -0,0 +1,50 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* ***** END GPL LICENSE BLOCK *****
*/
/** \file blender/blenlib/intern/memory_utils.c
* \ingroup bli
* \brief Generic memory manipulation API.
*
* This is to extend on existing functions
* such as ``memcpy`` & ``memcmp``.
*/
#include <string.h>
#include "BLI_sys_types.h"
#include "BLI_utildefines.h"
#include "BLI_memory_utils.h"
#include "BLI_strict_flags.h"
/**
* Check if memory is zero'd, as with memset(s, 0, nbytes)
*/
bool BLI_memory_is_zero(const void *s, const size_t nbytes)
{
const char *s_byte = s;
const char *s_end = (const char *)s + nbytes;
while ((s_byte != s_end) && (*s_byte == 0)) {
s_byte++;
}
return (s_byte == s_end);
}

View File

@@ -7937,7 +7937,7 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, int flag, ID
if (id->flag & LIB_FAKEUSER) id->us= 1;
else id->us = 0;
id->icon_id = 0;
id->flag &= ~(LIB_ID_RECALC|LIB_ID_RECALC_DATA|LIB_DOIT);
id->flag &= ~(LIB_ID_RECALC | LIB_ID_RECALC_DATA | LIB_DOIT | LIB_MISSING);
/* this case cannot be direct_linked: it's just the ID part */
if (bhead->code == ID_ID) {
@@ -9615,6 +9615,25 @@ static void give_base_to_groups(
}
}
static ID *create_placeholder(Main *mainvar, const char *idname, const short flag)
{
const short idcode = GS(idname);
ListBase *lb = which_libbase(mainvar, idcode);
ID *ph_id = BKE_libblock_alloc_notest(idcode);
memcpy(ph_id->name, idname, sizeof(ph_id->name));
BKE_libblock_init_empty(ph_id);
ph_id->lib = mainvar->curlib;
ph_id->flag = flag | LIB_MISSING;
ph_id->us = (flag & LIB_FAKEUSER) ? 1 : 0;
ph_id->icon_id = 0;
BLI_addtail(lb, ph_id);
id_sort_by_name(lb, ph_id);
return ph_id;
}
/* returns true if the item was found
* but it may already have already been appended/linked */
static ID *link_named_part(Main *mainl, FileData *fd, const short idcode, const char *name)
@@ -9758,16 +9777,35 @@ ID *BLO_library_link_named_part_ex(
return link_named_part_ex(mainl, fd, idcode, name, flag, scene, v3d);
}
static void link_id_part(FileData *fd, Main *mainvar, ID *id, ID **r_id)
static void link_id_part(ReportList *reports, FileData *fd, Main *mainvar, ID *id, ID **r_id)
{
BHead *bhead = find_bhead_from_idname(fd, id->name);
BHead *bhead = NULL;
if (fd) {
bhead = find_bhead_from_idname(fd, id->name);
}
id->flag &= ~LIB_READ;
if (bhead) {
id->flag &= ~LIB_READ;
id->flag |= LIB_NEED_EXPAND;
// printf("read lib block %s\n", id->name);
read_libblock(fd, mainvar, bhead, id->flag, r_id);
}
else {
blo_reportf_wrap(
reports, RPT_WARNING,
TIP_("LIB ERROR: %s: '%s' missing from '%s', parent '%s'"),
BKE_idcode_to_name(GS(id->name)),
id->name + 2,
mainvar->curlib->filepath,
library_parent_filepath(mainvar->curlib));
/* Generate a placeholder for this ID (simplified version of read_libblock actually...). */
if (r_id) {
*r_id = create_placeholder(mainvar, id->name, id->flag);
}
}
}
/* common routine to append/link something from a library */
@@ -10012,6 +10050,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
}
else {
mainptr->curlib->filedata = NULL;
mainptr->curlib->id.flag |= LIB_MISSING;
}
if (fd == NULL) {
@@ -10021,37 +10060,29 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
}
if (fd) {
do_it = true;
a = set_listbasepointers(mainptr, lbarray);
while (a--) {
ID *id = lbarray[a]->first;
while (id) {
ID *idn = id->next;
if (id->flag & LIB_READ) {
ID *realid = NULL;
BLI_remlink(lbarray[a], id);
link_id_part(fd, mainptr, id, &realid);
if (!realid) {
blo_reportf_wrap(
fd->reports, RPT_WARNING,
TIP_("LIB ERROR: %s: '%s' missing from '%s', parent '%s'"),
BKE_idcode_to_name(GS(id->name)),
id->name + 2,
mainptr->curlib->filepath,
library_parent_filepath(mainptr->curlib));
}
change_idid_adr(mainlist, basefd, id, realid);
MEM_freeN(id);
}
id = idn;
}
}
BLO_expand_main(fd, mainptr);
}
a = set_listbasepointers(mainptr, lbarray);
while (a--) {
ID *id = lbarray[a]->first;
while (id) {
ID *idn = id->next;
if (id->flag & LIB_READ) {
ID *realid = NULL;
BLI_remlink(lbarray[a], id);
link_id_part(basefd->reports, fd, mainptr, id, &realid);
BLI_assert(realid != NULL);
change_idid_adr(mainlist, basefd, id, realid);
MEM_freeN(id);
}
id = idn;
}
}
BLO_expand_main(fd, mainptr);
}
mainptr = mainptr->next;
@@ -10059,6 +10090,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
}
/* test if there are unread libblocks */
/* XXX This code block is kept for 2.77, until we are sure it never gets reached anymore. Can be removed later. */
for (mainptr = mainl->next; mainptr; mainptr = mainptr->next) {
a = set_listbasepointers(mainptr, lbarray);
while (a--) {
@@ -10067,10 +10099,12 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
for (id = lbarray[a]->first; id; id = idn) {
idn = id->next;
if (id->flag & LIB_READ) {
BLI_assert(0);
BLI_remlink(lbarray[a], id);
blo_reportf_wrap(
basefd->reports, RPT_WARNING,
TIP_("LIB ERROR: %s: '%s' unread lib block missing from '%s', parent '%s'"),
TIP_("LIB ERROR: %s: '%s' unread lib block missing from '%s', parent '%s' - "
"Please file a bug report if you see this message"),
BKE_idcode_to_name(GS(id->name)),
id->name + 2,
mainptr->curlib->filepath,

View File

@@ -1318,7 +1318,16 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto
case ID_GR:
tselem_draw_icon_uibut(&arg, ICON_GROUP); break;
case ID_LI:
tselem_draw_icon_uibut(&arg, ICON_LIBRARY_DATA_DIRECT); break;
if (tselem->id->flag & LIB_MISSING) {
tselem_draw_icon_uibut(&arg, ICON_LIBRARY_DATA_BROKEN);
}
else if (((Library *)tselem->id)->parent) {
tselem_draw_icon_uibut(&arg, ICON_LIBRARY_DATA_INDIRECT);
}
else {
tselem_draw_icon_uibut(&arg, ICON_LIBRARY_DATA_DIRECT);
}
break;
case ID_LS:
tselem_draw_icon_uibut(&arg, ICON_LINE_DATA); break;
case ID_GD:
@@ -1553,10 +1562,15 @@ static void outliner_draw_tree_element(
if (tselem->type == 0 && tselem->id->lib) {
glPixelTransferf(GL_ALPHA_SCALE, 0.5f);
if (tselem->id->flag & LIB_INDIRECT)
if (tselem->id->flag & LIB_MISSING) {
UI_icon_draw((float)startx + offsx, (float)*starty + 2 * ufac, ICON_LIBRARY_DATA_BROKEN);
}
else if (tselem->id->flag & LIB_INDIRECT) {
UI_icon_draw((float)startx + offsx, (float)*starty + 2 * ufac, ICON_LIBRARY_DATA_INDIRECT);
else
}
else {
UI_icon_draw((float)startx + offsx, (float)*starty + 2 * ufac, ICON_LIBRARY_DATA_DIRECT);
}
glPixelTransferf(GL_ALPHA_SCALE, 1.0f);
offsx += UI_UNIT_X;
}

View File

@@ -261,6 +261,8 @@ typedef struct PreviewImage {
#define ID_BLEND_PATH(_bmain, _id) ((_id)->lib ? (_id)->lib->filepath : (_bmain)->name)
#define ID_MISSING(_id) (((_id)->flag & LIB_MISSING) != 0)
#ifdef GS
# undef GS
#endif
@@ -280,6 +282,8 @@ enum {
LIB_TESTIND = (LIB_NEED_EXPAND | LIB_INDIRECT),
LIB_READ = 1 << 4,
LIB_NEED_LINK = 1 << 5,
/* tag datablock as a place-holder (because the real one could not be linked from its library e.g.). */
LIB_MISSING = 1 << 6,
LIB_NEW = 1 << 8,
LIB_FAKEUSER = 1 << 9,