Cleanup: Blendwrite: Move code deciding if an ID should be written out of ID callbacks.

This was not really useful, and added estra useless steps in case and ID
should not actually be written.

Further more, it prevented clearing the usercount on write, which can be
cause a false positive 'chanhged' detection in undo/redo case.
This commit is contained in:
2021-08-19 11:13:55 +02:00
parent d5776f4829
commit 0f49e4832c
35 changed files with 695 additions and 730 deletions

View File

@@ -186,7 +186,7 @@ static void action_foreach_id(ID *id, LibraryForeachIDData *data)
static void action_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
bAction *act = (bAction *)id;
if (act->id.us > 0 || BLO_write_is_undo(writer)) {
BLO_write_id_struct(writer, bAction, id_address, &act->id);
BKE_id_blend_write(writer, &act->id);
@@ -201,7 +201,6 @@ static void action_blend_write(BlendWriter *writer, ID *id, const void *id_addre
}
BKE_previewimg_blend_write(writer, act->preview);
}
}
static void action_blend_read_data(BlendDataReader *reader, ID *id)

View File

@@ -212,7 +212,7 @@ static void write_bone(BlendWriter *writer, Bone *bone)
static void armature_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
bArmature *arm = (bArmature *)id;
if (arm->id.us > 0 || BLO_write_is_undo(writer)) {
/* Clean up, important in undo case to reduce false detection of changed datablocks. */
arm->bonehash = NULL;
arm->edbo = NULL;
@@ -231,7 +231,6 @@ static void armature_blend_write(BlendWriter *writer, ID *id, const void *id_add
LISTBASE_FOREACH (Bone *, bone, &arm->bonebase) {
write_bone(writer, bone);
}
}
}
static void direct_link_bones(BlendDataReader *reader, Bone *bone)

View File

@@ -202,7 +202,7 @@ static void brush_foreach_id(ID *id, LibraryForeachIDData *data)
static void brush_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
Brush *brush = (Brush *)id;
if (brush->id.us > 0 || BLO_write_is_undo(writer)) {
BLO_write_id_struct(writer, Brush, id_address, &brush->id);
BKE_id_blend_write(writer, &brush->id);
@@ -244,7 +244,6 @@ static void brush_blend_write(BlendWriter *writer, ID *id, const void *id_addres
if (brush->gradient) {
BLO_write_struct(writer, ColorBand, brush->gradient);
}
}
}
static void brush_blend_read_data(BlendDataReader *reader, ID *id)

View File

@@ -97,7 +97,7 @@ static void cache_file_free_data(ID *id)
static void cache_file_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
CacheFile *cache_file = (CacheFile *)id;
if (cache_file->id.us > 0 || BLO_write_is_undo(writer)) {
/* Clean up, important in undo case to reduce false detection of changed datablocks. */
BLI_listbase_clear(&cache_file->object_paths);
cache_file->handle = NULL;
@@ -110,7 +110,6 @@ static void cache_file_blend_write(BlendWriter *writer, ID *id, const void *id_a
if (cache_file->adt) {
BKE_animdata_blend_write(writer, cache_file->adt);
}
}
}
static void cache_file_blend_read_data(BlendDataReader *reader, ID *id)

View File

@@ -122,7 +122,7 @@ static void camera_foreach_id(ID *id, LibraryForeachIDData *data)
static void camera_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
Camera *cam = (Camera *)id;
if (cam->id.us > 0 || BLO_write_is_undo(writer)) {
/* write LibData */
BLO_write_id_struct(writer, Camera, id_address, &cam->id);
BKE_id_blend_write(writer, &cam->id);
@@ -134,7 +134,6 @@ static void camera_blend_write(BlendWriter *writer, ID *id, const void *id_addre
LISTBASE_FOREACH (CameraBGImage *, bgpic, &cam->bg_images) {
BLO_write_struct(writer, CameraBGImage, bgpic);
}
}
}
static void camera_blend_read_data(BlendDataReader *reader, ID *id)

View File

@@ -214,7 +214,7 @@ void BKE_collection_blend_write_nolib(BlendWriter *writer, Collection *collectio
static void collection_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
Collection *collection = (Collection *)id;
if (collection->id.us > 0 || BLO_write_is_undo(writer)) {
/* Clean up, important in undo case to reduce false detection of changed data-blocks. */
collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE;
collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE_INSTANCED;
@@ -227,7 +227,6 @@ static void collection_blend_write(BlendWriter *writer, ID *id, const void *id_a
BLO_write_id_struct(writer, Collection, id_address, &collection->id);
BKE_collection_blend_write_nolib(writer, collection);
}
}
#ifdef USE_COLLECTION_COMPAT_28

View File

@@ -146,7 +146,7 @@ static void curve_foreach_id(ID *id, LibraryForeachIDData *data)
static void curve_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
Curve *cu = (Curve *)id;
if (cu->id.us > 0 || BLO_write_is_undo(writer)) {
/* Clean up, important in undo case to reduce false detection of changed datablocks. */
cu->editnurb = NULL;
cu->editfont = NULL;
@@ -191,7 +191,6 @@ static void curve_blend_write(BlendWriter *writer, ID *id, const void *id_addres
if (cu->bevel_profile != NULL) {
BKE_curveprofile_blend_write(writer, cu->bevel_profile);
}
}
}
static void switch_endian_knots(Nurb *nu)

View File

@@ -126,7 +126,7 @@ static void vfont_blend_write(BlendWriter *writer, ID *id, const void *id_addres
{
VFont *vf = (VFont *)id;
const bool is_undo = BLO_write_is_undo(writer);
if (vf->id.us > 0 || is_undo) {
/* Clean up, important in undo case to reduce false detection of changed datablocks. */
vf->data = NULL;
vf->temp_pf = NULL;
@@ -142,7 +142,6 @@ static void vfont_blend_write(BlendWriter *writer, ID *id, const void *id_addres
/* direct data */
BKE_packedfile_blend_write(writer, vf->packedfile);
}
}
static void vfont_blend_read_data(BlendDataReader *reader, ID *id)

View File

@@ -150,7 +150,7 @@ static void greasepencil_foreach_id(ID *id, LibraryForeachIDData *data)
static void greasepencil_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
bGPdata *gpd = (bGPdata *)id;
if (gpd->id.us > 0 || BLO_write_is_undo(writer)) {
/* Clean up, important in undo case to reduce false detection of changed data-blocks. */
/* XXX not sure why the whole run-time data is not cleared in reading code,
* for now mimicking it here. */
@@ -194,7 +194,6 @@ static void greasepencil_blend_write(BlendWriter *writer, ID *id, const void *id
}
}
}
}
}
void BKE_gpencil_blend_read_data(BlendDataReader *reader, bGPdata *gpd)

View File

@@ -114,7 +114,7 @@ static void hair_foreach_id(ID *id, LibraryForeachIDData *data)
static void hair_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
Hair *hair = (Hair *)id;
if (hair->id.us > 0 || BLO_write_is_undo(writer)) {
CustomDataLayer *players = NULL, players_buff[CD_TEMP_CHUNK_SIZE];
CustomDataLayer *clayers = NULL, clayers_buff[CD_TEMP_CHUNK_SIZE];
CustomData_blend_write_prepare(&hair->pdata, &players, players_buff, ARRAY_SIZE(players_buff));
@@ -140,7 +140,6 @@ static void hair_blend_write(BlendWriter *writer, ID *id, const void *id_address
if (clayers && clayers != clayers_buff) {
MEM_freeN(clayers);
}
}
}
static void hair_blend_read_data(BlendDataReader *reader, ID *id)

View File

@@ -229,7 +229,7 @@ static void image_blend_write(BlendWriter *writer, ID *id, const void *id_addres
{
Image *ima = (Image *)id;
const bool is_undo = BLO_write_is_undo(writer);
if (ima->id.us > 0 || is_undo) {
ImagePackedFile *imapf;
BLI_assert(ima->packedfile == NULL);
@@ -266,7 +266,6 @@ static void image_blend_write(BlendWriter *writer, ID *id, const void *id_addres
ima->packedfile = NULL;
BLO_write_struct_list(writer, RenderSlot, &ima->renderslots);
}
}
static void image_blend_read_data(BlendDataReader *reader, ID *id)

View File

@@ -114,7 +114,7 @@ static void shapekey_blend_write(BlendWriter *writer, ID *id, const void *id_add
{
Key *key = (Key *)id;
const bool is_undo = BLO_write_is_undo(writer);
if (key->id.us > 0 || is_undo) {
/* write LibData */
BLO_write_id_struct(writer, Key, id_address, &key->id);
BKE_id_blend_write(writer, &key->id);
@@ -136,7 +136,6 @@ static void shapekey_blend_write(BlendWriter *writer, ID *id, const void *id_add
BLO_write_raw(writer, tmp_kb.totelem * key->elemsize, tmp_kb.data);
}
}
}
}
/* old defines from DNA_ipo_types.h for data-type, stored in DNA - don't modify! */

View File

@@ -137,7 +137,7 @@ static void lattice_foreach_id(ID *id, LibraryForeachIDData *data)
static void lattice_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
Lattice *lt = (Lattice *)id;
if (lt->id.us > 0 || BLO_write_is_undo(writer)) {
/* Clean up, important in undo case to reduce false detection of changed datablocks. */
lt->editlatt = NULL;
lt->batch_cache = NULL;
@@ -156,7 +156,6 @@ static void lattice_blend_write(BlendWriter *writer, ID *id, const void *id_addr
BKE_defbase_blend_write(writer, &lt->vertex_group_names);
BKE_defvert_blend_write(writer, lt->pntsu * lt->pntsv * lt->pntsw, lt->dvert);
}
}
static void lattice_blend_read_data(BlendDataReader *reader, ID *id)

View File

@@ -136,7 +136,7 @@ static void light_foreach_id(ID *id, LibraryForeachIDData *data)
static void light_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
Light *la = (Light *)id;
if (la->id.us > 0 || BLO_write_is_undo(writer)) {
/* write LibData */
BLO_write_id_struct(writer, Light, id_address, &la->id);
BKE_id_blend_write(writer, &la->id);
@@ -156,7 +156,6 @@ static void light_blend_write(BlendWriter *writer, ID *id, const void *id_addres
}
BKE_previewimg_blend_write(writer, la->preview);
}
}
static void light_blend_read_data(BlendDataReader *reader, ID *id)

View File

@@ -60,7 +60,7 @@ static void lightprobe_foreach_id(ID *id, LibraryForeachIDData *data)
static void lightprobe_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
LightProbe *prb = (LightProbe *)id;
if (prb->id.us > 0 || BLO_write_is_undo(writer)) {
/* write LibData */
BLO_write_id_struct(writer, LightProbe, id_address, &prb->id);
BKE_id_blend_write(writer, &prb->id);
@@ -68,7 +68,6 @@ static void lightprobe_blend_write(BlendWriter *writer, ID *id, const void *id_a
if (prb->adt) {
BKE_animdata_blend_write(writer, prb->adt);
}
}
}
static void lightprobe_blend_read_data(BlendDataReader *reader, ID *id)

View File

@@ -457,7 +457,7 @@ static void write_linestyle_geometry_modifiers(BlendWriter *writer, ListBase *mo
static void linestyle_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
FreestyleLineStyle *linestyle = (FreestyleLineStyle *)id;
if (linestyle->id.us > 0 || BLO_write_is_undo(writer)) {
BLO_write_id_struct(writer, FreestyleLineStyle, id_address, &linestyle->id);
BKE_id_blend_write(writer, &linestyle->id);
@@ -478,7 +478,6 @@ static void linestyle_blend_write(BlendWriter *writer, ID *id, const void *id_ad
BLO_write_struct(writer, bNodeTree, linestyle->nodetree);
ntreeBlendWrite(writer, linestyle->nodetree);
}
}
}
static void direct_link_linestyle_color_modifier(BlendDataReader *reader,

View File

@@ -101,7 +101,7 @@ static void mask_foreach_id(ID *id, LibraryForeachIDData *data)
static void mask_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
Mask *mask = (Mask *)id;
if (mask->id.us > 0 || BLO_write_is_undo(writer)) {
MaskLayer *masklay;
BLO_write_id_struct(writer, Mask, id_address, &mask->id);
@@ -144,7 +144,6 @@ static void mask_blend_write(BlendWriter *writer, ID *id, const void *id_address
writer, masklay_shape->tot_vert * MASK_OBJECT_SHAPE_ELEM_SIZE, masklay_shape->data);
}
}
}
}
static void mask_blend_read_data(BlendDataReader *reader, ID *id)

View File

@@ -179,7 +179,7 @@ static void material_foreach_id(ID *id, LibraryForeachIDData *data)
static void material_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
Material *ma = (Material *)id;
if (ma->id.us > 0 || BLO_write_is_undo(writer)) {
/* Clean up, important in undo case to reduce false detection of changed datablocks. */
ma->texpaintslot = NULL;
BLI_listbase_clear(&ma->gpumaterial);
@@ -204,7 +204,6 @@ static void material_blend_write(BlendWriter *writer, ID *id, const void *id_add
if (ma->gp_style) {
BLO_write_struct(writer, MaterialGPencilStyle, ma->gp_style);
}
}
}
static void material_blend_read_data(BlendDataReader *reader, ID *id)

View File

@@ -119,7 +119,7 @@ static void metaball_foreach_id(ID *id, LibraryForeachIDData *data)
static void metaball_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
MetaBall *mb = (MetaBall *)id;
if (mb->id.us > 0 || BLO_write_is_undo(writer)) {
/* Clean up, important in undo case to reduce false detection of changed datablocks. */
BLI_listbase_clear(&mb->disp);
mb->editelems = NULL;
@@ -141,7 +141,6 @@ static void metaball_blend_write(BlendWriter *writer, ID *id, const void *id_add
LISTBASE_FOREACH (MetaElem *, ml, &mb->elems) {
BLO_write_struct(writer, MetaElem, ml);
}
}
}
static void metaball_blend_read_data(BlendDataReader *reader, ID *id)

View File

@@ -179,7 +179,7 @@ static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address
{
Mesh *mesh = (Mesh *)id;
const bool is_undo = BLO_write_is_undo(writer);
if (mesh->id.us > 0 || is_undo) {
CustomDataLayer *vlayers = NULL, vlayers_buff[CD_TEMP_CHUNK_SIZE];
CustomDataLayer *elayers = NULL, elayers_buff[CD_TEMP_CHUNK_SIZE];
CustomDataLayer *flayers = NULL, flayers_buff[CD_TEMP_CHUNK_SIZE];
@@ -216,14 +216,10 @@ static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address
players = players_buff;
}
else {
CustomData_blend_write_prepare(
&mesh->vdata, &vlayers, vlayers_buff, ARRAY_SIZE(vlayers_buff));
CustomData_blend_write_prepare(
&mesh->edata, &elayers, elayers_buff, ARRAY_SIZE(elayers_buff));
CustomData_blend_write_prepare(
&mesh->ldata, &llayers, llayers_buff, ARRAY_SIZE(llayers_buff));
CustomData_blend_write_prepare(
&mesh->pdata, &players, players_buff, ARRAY_SIZE(players_buff));
CustomData_blend_write_prepare(&mesh->vdata, &vlayers, vlayers_buff, ARRAY_SIZE(vlayers_buff));
CustomData_blend_write_prepare(&mesh->edata, &elayers, elayers_buff, ARRAY_SIZE(elayers_buff));
CustomData_blend_write_prepare(&mesh->ldata, &llayers, llayers_buff, ARRAY_SIZE(llayers_buff));
CustomData_blend_write_prepare(&mesh->pdata, &players, players_buff, ARRAY_SIZE(players_buff));
}
BLO_write_id_struct(writer, Mesh, id_address, &mesh->id);
@@ -253,7 +249,7 @@ static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address
/* Free temporary data */
/* Free custom-data layers, when not assigned a buffer value. */
/* Free custom-data layers, when not assigned a buffer value. */
#define CD_LAYERS_FREE(id) \
if (id && id != id##_buff) { \
MEM_freeN(id); \
@@ -267,7 +263,6 @@ static void mesh_blend_write(BlendWriter *writer, ID *id, const void *id_address
CD_LAYERS_FREE(players);
#undef CD_LAYERS_FREE
}
}
static void mesh_blend_read_data(BlendDataReader *reader, ID *id)

View File

@@ -206,7 +206,7 @@ static void write_movieReconstruction(BlendWriter *writer,
static void movieclip_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
MovieClip *clip = (MovieClip *)id;
if (clip->id.us > 0 || BLO_write_is_undo(writer)) {
/* Clean up, important in undo case to reduce false detection of changed datablocks. */
clip->anim = NULL;
clip->tracking_context = NULL;
@@ -236,7 +236,6 @@ static void movieclip_blend_write(BlendWriter *writer, ID *id, const void *id_ad
object = object->next;
}
}
}
static void direct_link_movieReconstruction(BlendDataReader *reader,

View File

@@ -606,7 +606,7 @@ void ntreeBlendWrite(BlendWriter *writer, bNodeTree *ntree)
static void ntree_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
bNodeTree *ntree = (bNodeTree *)id;
if (ntree->id.us > 0 || BLO_write_is_undo(writer)) {
/* Clean up, important in undo case to reduce false detection of changed datablocks. */
ntree->init = 0; /* to set callbacks and force setting types */
ntree->is_updating = false;
@@ -618,7 +618,6 @@ static void ntree_blend_write(BlendWriter *writer, ID *id, const void *id_addres
BLO_write_id_struct(writer, bNodeTree, id_address, &ntree->id);
ntreeBlendWrite(writer, ntree);
}
}
static void direct_link_node_socket(BlendDataReader *reader, bNodeSocket *sock)

View File

@@ -523,7 +523,7 @@ static void object_blend_write(BlendWriter *writer, ID *id, const void *id_addre
Object *ob = (Object *)id;
const bool is_undo = BLO_write_is_undo(writer);
if (ob->id.us > 0 || is_undo) {
/* Clean up, important in undo case to reduce false detection of changed data-blocks. */
BKE_object_runtime_reset(ob);
@@ -549,8 +549,7 @@ static void object_blend_write(BlendWriter *writer, ID *id, const void *id_addre
if (ob->type == OB_ARMATURE) {
arm = ob->data;
if (arm && ob->pose && arm->act_bone) {
BLI_strncpy(
ob->pose->proxy_act_bone, arm->act_bone->name, sizeof(ob->pose->proxy_act_bone));
BLI_strncpy(ob->pose->proxy_act_bone, arm->act_bone->name, sizeof(ob->pose->proxy_act_bone));
}
}
@@ -590,7 +589,6 @@ static void object_blend_write(BlendWriter *writer, ID *id, const void *id_addre
BLO_write_struct_list(writer, LinkData, &ob->pc_ids);
BKE_previewimg_blend_write(writer, ob->preview);
}
}
/* XXX deprecated - old animation system */

View File

@@ -108,7 +108,7 @@ static void palette_free_data(ID *id)
static void palette_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
Palette *palette = (Palette *)id;
if (palette->id.us > 0 || BLO_write_is_undo(writer)) {
PaletteColor *color;
BLO_write_id_struct(writer, Palette, id_address, &palette->id);
BKE_id_blend_write(writer, &palette->id);
@@ -116,7 +116,6 @@ static void palette_blend_write(BlendWriter *writer, ID *id, const void *id_addr
for (color = palette->colors.first; color; color = color->next) {
BLO_write_struct(writer, PaletteColor, color);
}
}
}
static void palette_blend_read_data(BlendDataReader *reader, ID *id)
@@ -187,12 +186,11 @@ static void paint_curve_free_data(ID *id)
static void paint_curve_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
PaintCurve *pc = (PaintCurve *)id;
if (pc->id.us > 0 || BLO_write_is_undo(writer)) {
BLO_write_id_struct(writer, PaintCurve, id_address, &pc->id);
BKE_id_blend_write(writer, &pc->id);
BLO_write_struct_array(writer, PaintCurvePoint, pc->tot_points, pc->points);
}
}
static void paint_curve_blend_read_data(BlendDataReader *reader, ID *id)

View File

@@ -255,7 +255,7 @@ static void write_boid_state(BlendWriter *writer, BoidState *state)
static void particle_settings_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
ParticleSettings *part = (ParticleSettings *)id;
if (part->id.us > 0 || BLO_write_is_undo(writer)) {
/* write LibData */
BLO_write_id_struct(writer, ParticleSettings, id_address, &part->id);
BKE_id_blend_write(writer, &part->id);
@@ -310,7 +310,6 @@ static void particle_settings_blend_write(BlendWriter *writer, ID *id, const voi
BLO_write_struct(writer, MTex, part->mtex[a]);
}
}
}
}
void BKE_particle_partdeflect_blend_read_data(BlendDataReader *UNUSED(reader), PartDeflect *pd)

View File

@@ -112,7 +112,7 @@ static void pointcloud_foreach_id(ID *id, LibraryForeachIDData *data)
static void pointcloud_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
PointCloud *pointcloud = (PointCloud *)id;
if (pointcloud->id.us > 0 || BLO_write_is_undo(writer)) {
CustomDataLayer *players = nullptr, players_buff[CD_TEMP_CHUNK_SIZE];
CustomData_blend_write_prepare(
&pointcloud->pdata, &players, players_buff, ARRAY_SIZE(players_buff));
@@ -134,7 +134,6 @@ static void pointcloud_blend_write(BlendWriter *writer, ID *id, const void *id_a
if (players && players != players_buff) {
MEM_freeN(players);
}
}
}
static void pointcloud_blend_read_data(BlendDataReader *reader, ID *id)

View File

@@ -255,8 +255,7 @@ static void screen_foreach_id(ID *id, LibraryForeachIDData *data)
static void screen_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
bScreen *screen = (bScreen *)id;
/* Screens are reference counted, only saved if used by a workspace. */
if (screen->id.us > 0 || BLO_write_is_undo(writer)) {
/* write LibData */
/* in 2.50+ files, the file identifier for screens is patched, forward compatibility */
BLO_write_struct_at_address_with_filecode(writer, ID_SCRN, bScreen, id_address, screen);
@@ -266,7 +265,6 @@ static void screen_blend_write(BlendWriter *writer, ID *id, const void *id_addre
/* direct data */
BKE_screen_area_map_blend_write(writer, AREAMAP_FROM_SCREEN(screen));
}
}
/* Cannot use IDTypeInfo callback yet, because of the return value. */

View File

@@ -114,7 +114,7 @@ static void simulation_foreach_id(ID *id, LibraryForeachIDData *data)
static void simulation_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
Simulation *simulation = (Simulation *)id;
if (simulation->id.us > 0 || BLO_write_is_undo(writer)) {
BLO_write_id_struct(writer, Simulation, id_address, &simulation->id);
BKE_id_blend_write(writer, &simulation->id);
@@ -127,7 +127,6 @@ static void simulation_blend_write(BlendWriter *writer, ID *id, const void *id_a
BLO_write_struct(writer, bNodeTree, simulation->nodetree);
ntreeBlendWrite(writer, simulation->nodetree);
}
}
}
static void simulation_blend_read_data(BlendDataReader *reader, ID *id)

View File

@@ -137,7 +137,7 @@ static void sound_blend_write(BlendWriter *writer, ID *id, const void *id_addres
{
bSound *sound = (bSound *)id;
const bool is_undo = BLO_write_is_undo(writer);
if (sound->id.us > 0 || is_undo) {
/* Clean up, important in undo case to reduce false detection of changed datablocks. */
sound->tags = 0;
sound->handle = NULL;
@@ -154,7 +154,6 @@ static void sound_blend_write(BlendWriter *writer, ID *id, const void *id_addres
BKE_id_blend_write(writer, &sound->id);
BKE_packedfile_blend_write(writer, sound->packedfile);
}
}
static void sound_blend_read_data(BlendDataReader *reader, ID *id)

View File

@@ -56,7 +56,7 @@ static void speaker_foreach_id(ID *id, LibraryForeachIDData *data)
static void speaker_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
Speaker *spk = (Speaker *)id;
if (spk->id.us > 0 || BLO_write_is_undo(writer)) {
/* write LibData */
BLO_write_id_struct(writer, Speaker, id_address, &spk->id);
BKE_id_blend_write(writer, &spk->id);
@@ -64,7 +64,6 @@ static void speaker_blend_write(BlendWriter *writer, ID *id, const void *id_addr
if (spk->adt) {
BKE_animdata_blend_write(writer, spk->adt);
}
}
}
static void speaker_blend_read_data(BlendDataReader *reader, ID *id)

View File

@@ -171,9 +171,6 @@ static void text_free_data(ID *id)
static void text_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
if (id->us < 1 && !BLO_write_is_undo(writer)) {
return;
}
Text *text = (Text *)id;
/* NOTE: we are clearing local temp data here, *not* the flag in the actual 'real' ID. */

View File

@@ -150,7 +150,7 @@ static void texture_foreach_id(ID *id, LibraryForeachIDData *data)
static void texture_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
Tex *tex = (Tex *)id;
if (tex->id.us > 0 || BLO_write_is_undo(writer)) {
/* write LibData */
BLO_write_id_struct(writer, Tex, id_address, &tex->id);
BKE_id_blend_write(writer, &tex->id);
@@ -171,7 +171,6 @@ static void texture_blend_write(BlendWriter *writer, ID *id, const void *id_addr
}
BKE_previewimg_blend_write(writer, tex->preview);
}
}
static void texture_blend_read_data(BlendDataReader *reader, ID *id)

View File

@@ -578,7 +578,7 @@ static void volume_blend_write(BlendWriter *writer, ID *id, const void *id_addre
{
Volume *volume = (Volume *)id;
const bool is_undo = BLO_write_is_undo(writer);
if (volume->id.us > 0 || is_undo) {
/* Clean up, important in undo case to reduce false detection of changed datablocks. */
volume->runtime.grids = nullptr;
@@ -598,7 +598,6 @@ static void volume_blend_write(BlendWriter *writer, ID *id, const void *id_addre
}
BKE_packedfile_blend_write(writer, volume->packedfile);
}
}
static void volume_blend_read_data(BlendDataReader *reader, ID *id)

View File

@@ -138,7 +138,7 @@ static void world_foreach_id(ID *id, LibraryForeachIDData *data)
static void world_blend_write(BlendWriter *writer, ID *id, const void *id_address)
{
World *wrld = (World *)id;
if (wrld->id.us > 0 || BLO_write_is_undo(writer)) {
/* Clean up, important in undo case to reduce false detection of changed datablocks. */
BLI_listbase_clear(&wrld->gpumaterial);
@@ -157,7 +157,6 @@ static void world_blend_write(BlendWriter *writer, ID *id, const void *id_addres
}
BKE_previewimg_blend_write(writer, wrld->preview);
}
}
static void world_blend_read_data(BlendDataReader *reader, ID *id)

View File

@@ -982,6 +982,14 @@ static bool write_file_handle(Main *mainvar,
BLI_assert(
(id->tag & (LIB_TAG_NO_MAIN | LIB_TAG_NO_USER_REFCOUNT | LIB_TAG_NOT_ALLOCATED)) == 0);
/* We only write unused IDs in undo case.
* NOTE: All Scenes, WindowManagers and WorkSpaces should always be written to disk, so
* their usercount should never be NULL currently. */
if (id->us == 0 && !wd->use_memfile) {
BLI_assert(!ELEM(GS(id->name), ID_SCE, ID_WM, ID_WS));
continue;
}
const bool do_override = !ELEM(override_storage, NULL, bmain) &&
ID_IS_OVERRIDE_LIBRARY_REAL(id);