Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/material.c')
-rw-r--r--source/blender/blenkernel/intern/material.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 1b21ff9b36e..d4de04a9e98 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -64,6 +64,7 @@
#include "BKE_idtype.h"
#include "BKE_image.h"
#include "BKE_lib_id.h"
+#include "BKE_lib_query.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_mesh.h"
@@ -130,7 +131,7 @@ static void material_free_data(ID *id)
/* is no lib link block, but material extension */
if (material->nodetree) {
- ntreeFreeNestedTree(material->nodetree);
+ ntreeFreeEmbeddedTree(material->nodetree);
MEM_freeN(material->nodetree);
material->nodetree = NULL;
}
@@ -143,6 +144,22 @@ static void material_free_data(ID *id)
BKE_previewimg_free(&material->preview);
}
+static void material_foreach_id(ID *id, LibraryForeachIDData *data)
+{
+ Material *material = (Material *)id;
+ /* Nodetrees **are owned by IDs**, treat them as mere sub-data and not real ID! */
+ if (!BKE_library_foreach_ID_embedded(data, (ID **)&material->nodetree)) {
+ return;
+ }
+ if (material->texpaintslot != NULL) {
+ BKE_LIB_FOREACHID_PROCESS(data, material->texpaintslot->ima, IDWALK_CB_NOP);
+ }
+ if (material->gp_style != NULL) {
+ BKE_LIB_FOREACHID_PROCESS(data, material->gp_style->sima, IDWALK_CB_USER);
+ BKE_LIB_FOREACHID_PROCESS(data, material->gp_style->ima, IDWALK_CB_USER);
+ }
+}
+
IDTypeInfo IDType_ID_MA = {
.id_code = ID_MA,
.id_filter = FILTER_ID_MA,
@@ -157,6 +174,7 @@ IDTypeInfo IDType_ID_MA = {
.copy_data = material_copy_data,
.free_data = material_free_data,
.make_local = NULL,
+ .foreach_id = material_foreach_id,
};
void BKE_gpencil_material_attr_init(Material *ma)
@@ -1601,7 +1619,7 @@ void BKE_material_copybuf_paste(Main *bmain, Material *ma)
GPU_material_free(&ma->gpumaterial);
if (ma->nodetree) {
- ntreeFreeNestedTree(ma->nodetree);
+ ntreeFreeEmbeddedTree(ma->nodetree);
MEM_freeN(ma->nodetree);
}