Cleanup: replace more direct id->us handling by calls to BKE_library API.
This commit is contained in:
@@ -281,7 +281,7 @@ void BKE_brush_make_local(Brush *brush)
|
|||||||
}
|
}
|
||||||
else if (is_local && is_lib) {
|
else if (is_local && is_lib) {
|
||||||
Brush *brush_new = BKE_brush_copy(brush); /* Ensures FAKE_USER is set */
|
Brush *brush_new = BKE_brush_copy(brush); /* Ensures FAKE_USER is set */
|
||||||
brush_new->id.us = 1; /* only keep fake user */
|
id_us_min(&brush_new->id); /* Remove user added by standard BKE_libblock_copy(). */
|
||||||
|
|
||||||
/* Remap paths of new ID using old library as base. */
|
/* Remap paths of new ID using old library as base. */
|
||||||
BKE_id_lib_local_paths(bmain, brush->id.lib, &brush_new->id);
|
BKE_id_lib_local_paths(bmain, brush->id.lib, &brush_new->id);
|
||||||
|
|||||||
@@ -585,9 +585,7 @@ void BKE_image_make_local(struct Image *ima)
|
|||||||
for (a = 0; a < me->totface; a++, tface++) {
|
for (a = 0; a < me->totface; a++, tface++) {
|
||||||
if (tface->tpage == ima) {
|
if (tface->tpage == ima) {
|
||||||
tface->tpage = ima_new;
|
tface->tpage = ima_new;
|
||||||
if (ima_new->id.us == 0) {
|
id_us_ensure_real((ID *)ima_new);
|
||||||
tface->tpage->id.us = 1;
|
|
||||||
}
|
|
||||||
id_lib_extern((ID *)ima_new);
|
id_lib_extern((ID *)ima_new);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -606,9 +604,7 @@ void BKE_image_make_local(struct Image *ima)
|
|||||||
for (a = 0; a < me->totpoly; a++, mtpoly++) {
|
for (a = 0; a < me->totpoly; a++, mtpoly++) {
|
||||||
if (mtpoly->tpage == ima) {
|
if (mtpoly->tpage == ima) {
|
||||||
mtpoly->tpage = ima_new;
|
mtpoly->tpage = ima_new;
|
||||||
if (ima_new->id.us == 0) {
|
id_us_ensure_real((ID *)ima_new);
|
||||||
mtpoly->tpage->id.us = 1;
|
|
||||||
}
|
|
||||||
id_lib_extern((ID *)ima_new);
|
id_lib_extern((ID *)ima_new);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -428,7 +428,6 @@ Text *BKE_text_load_ex(Main *bmain, const char *file, const char *relpath, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
ta = BKE_libblock_alloc(bmain, ID_TXT, BLI_path_basename(str));
|
ta = BKE_libblock_alloc(bmain, ID_TXT, BLI_path_basename(str));
|
||||||
ta->id.us = 1;
|
|
||||||
|
|
||||||
BLI_listbase_clear(&ta->lines);
|
BLI_listbase_clear(&ta->lines);
|
||||||
ta->curl = ta->sell = NULL;
|
ta->curl = ta->sell = NULL;
|
||||||
|
|||||||
@@ -2184,10 +2184,7 @@ static bool make_local_all__instance_indirect_unused(Main *bmain, Scene *scene)
|
|||||||
if (ob->id.lib && (ob->id.us == 0)) {
|
if (ob->id.lib && (ob->id.us == 0)) {
|
||||||
Base *base;
|
Base *base;
|
||||||
|
|
||||||
ob->id.us = 1;
|
id_us_plus(&ob->id);
|
||||||
|
|
||||||
/* not essential, but for correctness */
|
|
||||||
id_lib_extern(&ob->id);
|
|
||||||
|
|
||||||
base = BKE_scene_base_add(scene, ob);
|
base = BKE_scene_base_add(scene, ob);
|
||||||
base->flag |= SELECT;
|
base->flag |= SELECT;
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
|
|
||||||
#include "BKE_context.h"
|
#include "BKE_context.h"
|
||||||
#include "BKE_depsgraph.h"
|
#include "BKE_depsgraph.h"
|
||||||
|
#include "BKE_library.h"
|
||||||
#include "BKE_main.h"
|
#include "BKE_main.h"
|
||||||
#include "BKE_node.h"
|
#include "BKE_node.h"
|
||||||
|
|
||||||
@@ -85,9 +86,7 @@ void ED_node_tree_update(const bContext *C)
|
|||||||
if (snode) {
|
if (snode) {
|
||||||
snode_set_context(C);
|
snode_set_context(C);
|
||||||
|
|
||||||
if (snode->nodetree && snode->nodetree->id.us == 0) {
|
id_us_ensure_real(&snode->nodetree->id);
|
||||||
snode->nodetree->id.us = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
|
|
||||||
#include "BKE_context.h"
|
#include "BKE_context.h"
|
||||||
#include "BKE_global.h"
|
#include "BKE_global.h"
|
||||||
|
#include "BKE_library.h"
|
||||||
#include "BKE_main.h"
|
#include "BKE_main.h"
|
||||||
#include "BKE_sequencer.h"
|
#include "BKE_sequencer.h"
|
||||||
#include "BKE_movieclip.h"
|
#include "BKE_movieclip.h"
|
||||||
@@ -385,8 +386,7 @@ static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op)
|
|||||||
seq->blend_mode = SEQ_TYPE_CROSS;
|
seq->blend_mode = SEQ_TYPE_CROSS;
|
||||||
seq->clip = clip;
|
seq->clip = clip;
|
||||||
|
|
||||||
if (seq->clip->id.us == 0)
|
id_us_ensure_real(&seq->clip->id);
|
||||||
seq->clip->id.us = 1;
|
|
||||||
|
|
||||||
/* basic defaults */
|
/* basic defaults */
|
||||||
seq->strip = strip = MEM_callocN(sizeof(Strip), "strip");
|
seq->strip = strip = MEM_callocN(sizeof(Strip), "strip");
|
||||||
@@ -470,8 +470,7 @@ static int sequencer_add_mask_strip_exec(bContext *C, wmOperator *op)
|
|||||||
seq->blend_mode = SEQ_TYPE_CROSS;
|
seq->blend_mode = SEQ_TYPE_CROSS;
|
||||||
seq->mask = mask;
|
seq->mask = mask;
|
||||||
|
|
||||||
if (seq->mask->id.us == 0)
|
id_us_ensure_real(&seq->mask->id);
|
||||||
seq->mask->id.us = 1;
|
|
||||||
|
|
||||||
/* basic defaults */
|
/* basic defaults */
|
||||||
seq->strip = strip = MEM_callocN(sizeof(Strip), "strip");
|
seq->strip = strip = MEM_callocN(sizeof(Strip), "strip");
|
||||||
|
|||||||
Reference in New Issue
Block a user