[Bf-blender-cvs] [38cb29d67e5] master: Cleanup: Nuke most of remaining evil G.main from RNA.
Bastien Montagne
noreply at git.blender.org
Sun May 27 18:47:41 CEST 2018
Commit: 38cb29d67e5947f99824987dcd567a82cfd51646
Author: Bastien Montagne
Date: Sun May 27 18:46:39 2018 +0200
Branches: master
https://developer.blender.org/rB38cb29d67e5947f99824987dcd567a82cfd51646
Cleanup: Nuke most of remaining evil G.main from RNA.
The few ones in getters/setters we cannot remove as easily, for now we
can live with those I think...
===================================================================
M source/blender/makesrna/intern/rna_ID.c
M source/blender/makesrna/intern/rna_nodetree.c
M source/blender/makesrna/intern/rna_object_api.c
M source/blender/makesrna/intern/rna_scene.c
M source/blender/makesrna/intern/rna_scene_api.c
===================================================================
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index cdea0502d12..a0d2a76a82d 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -458,9 +458,9 @@ static Material *rna_IDMaterials_pop_id(ID *id, Main *bmain, ReportList *reports
return ma;
}
-static void rna_IDMaterials_clear_id(ID *id, int remove_material_slot)
+static void rna_IDMaterials_clear_id(ID *id, Main *bmain, int remove_material_slot)
{
- BKE_material_clear_id(G.main, id, remove_material_slot);
+ BKE_material_clear_id(bmain, id, remove_material_slot);
DAG_id_tag_update(id, OB_RECALC_DATA);
WM_main_add_notifier(NC_OBJECT | ND_DRAW, id);
@@ -882,6 +882,7 @@ static void rna_def_ID_materials(BlenderRNA *brna)
RNA_def_function_return(func, parm);
func = RNA_def_function(srna, "clear", "rna_IDMaterials_clear_id");
+ RNA_def_function_flag(func, FUNC_USE_MAIN);
RNA_def_function_ui_description(func, "Remove all materials from the data-block");
RNA_def_boolean(func, "update_data", 0, "", "Update data by re-adjusting the material slots assigned");
}
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 8dbb133a8ac..6eaaf842cb9 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -726,7 +726,7 @@ static bNode *rna_NodeTree_node_new(bNodeTree *ntree, bContext *C, ReportList *r
return node;
}
-static void rna_NodeTree_node_remove(bNodeTree *ntree, ReportList *reports, PointerRNA *node_ptr)
+static void rna_NodeTree_node_remove(bNodeTree *ntree, Main *bmain, ReportList *reports, PointerRNA *node_ptr)
{
bNode *node = node_ptr->data;
@@ -742,11 +742,11 @@ static void rna_NodeTree_node_remove(bNodeTree *ntree, ReportList *reports, Poin
nodeFreeNode(ntree, node);
RNA_POINTER_INVALIDATE(node_ptr);
- ntreeUpdateTree(G.main, ntree); /* update group node socket links */
+ ntreeUpdateTree(bmain, ntree); /* update group node socket links */
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
}
-static void rna_NodeTree_node_clear(bNodeTree *ntree, ReportList *reports)
+static void rna_NodeTree_node_clear(bNodeTree *ntree, Main *bmain, ReportList *reports)
{
bNode *node = ntree->nodes.first;
@@ -764,7 +764,7 @@ static void rna_NodeTree_node_clear(bNodeTree *ntree, ReportList *reports)
node = next_node;
}
- ntreeUpdateTree(G.main, ntree);
+ ntreeUpdateTree(bmain, ntree);
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
}
@@ -787,7 +787,7 @@ static void rna_NodeTree_active_node_set(PointerRNA *ptr, const PointerRNA value
nodeClearActive(ntree);
}
-static bNodeLink *rna_NodeTree_link_new(bNodeTree *ntree, ReportList *reports,
+static bNodeLink *rna_NodeTree_link_new(bNodeTree *ntree, Main *bmain, ReportList *reports,
bNodeSocket *fromsock, bNodeSocket *tosock,
int verify_limits)
{
@@ -829,15 +829,15 @@ static bNodeLink *rna_NodeTree_link_new(bNodeTree *ntree, ReportList *reports,
if (tonode)
nodeUpdate(ntree, tonode);
- ntreeUpdateTree(G.main, ntree);
+ ntreeUpdateTree(bmain, ntree);
- ED_node_tag_update_nodetree(G.main, ntree, ret->tonode);
+ ED_node_tag_update_nodetree(bmain, ntree, ret->tonode);
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
}
return ret;
}
-static void rna_NodeTree_link_remove(bNodeTree *ntree, ReportList *reports, PointerRNA *link_ptr)
+static void rna_NodeTree_link_remove(bNodeTree *ntree, Main *bmain, ReportList *reports, PointerRNA *link_ptr)
{
bNodeLink *link = link_ptr->data;
@@ -852,11 +852,11 @@ static void rna_NodeTree_link_remove(bNodeTree *ntree, ReportList *reports, Poin
nodeRemLink(ntree, link);
RNA_POINTER_INVALIDATE(link_ptr);
- ntreeUpdateTree(G.main, ntree);
+ ntreeUpdateTree(bmain, ntree);
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
}
-static void rna_NodeTree_link_clear(bNodeTree *ntree, ReportList *reports)
+static void rna_NodeTree_link_clear(bNodeTree *ntree, Main *bmain, ReportList *reports)
{
bNodeLink *link = ntree->links.first;
@@ -870,7 +870,7 @@ static void rna_NodeTree_link_clear(bNodeTree *ntree, ReportList *reports)
link = next_link;
}
- ntreeUpdateTree(G.main, ntree);
+ ntreeUpdateTree(bmain, ntree);
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
}
@@ -933,7 +933,7 @@ static void rna_NodeTree_active_output_set(PointerRNA *ptr, int value)
}
}
-static bNodeSocket *rna_NodeTree_inputs_new(bNodeTree *ntree, ReportList *reports, const char *type, const char *name)
+static bNodeSocket *rna_NodeTree_inputs_new(bNodeTree *ntree, Main *bmain, ReportList *reports, const char *type, const char *name)
{
bNodeSocket *sock;
@@ -942,13 +942,13 @@ static bNodeSocket *rna_NodeTree_inputs_new(bNodeTree *ntree, ReportList *report
sock = ntreeAddSocketInterface(ntree, SOCK_IN, type, name);
- ntreeUpdateTree(G.main, ntree);
+ ntreeUpdateTree(bmain, ntree);
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
return sock;
}
-static bNodeSocket *rna_NodeTree_outputs_new(bNodeTree *ntree, ReportList *reports, const char *type, const char *name)
+static bNodeSocket *rna_NodeTree_outputs_new(bNodeTree *ntree, Main *bmain, ReportList *reports, const char *type, const char *name)
{
bNodeSocket *sock;
@@ -957,13 +957,13 @@ static bNodeSocket *rna_NodeTree_outputs_new(bNodeTree *ntree, ReportList *repor
sock = ntreeAddSocketInterface(ntree, SOCK_OUT, type, name);
- ntreeUpdateTree(G.main, ntree);
+ ntreeUpdateTree(bmain, ntree);
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
return sock;
}
-static void rna_NodeTree_socket_remove(bNodeTree *ntree, ReportList *reports, bNodeSocket *sock)
+static void rna_NodeTree_socket_remove(bNodeTree *ntree, Main *bmain, ReportList *reports, bNodeSocket *sock)
{
if (!rna_NodeTree_check(ntree, reports))
return;
@@ -974,12 +974,12 @@ static void rna_NodeTree_socket_remove(bNodeTree *ntree, ReportList *reports, bN
else {
ntreeRemoveSocketInterface(ntree, sock);
- ntreeUpdateTree(G.main, ntree);
+ ntreeUpdateTree(bmain, ntree);
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
}
}
-static void rna_NodeTree_inputs_clear(bNodeTree *ntree, ReportList *reports)
+static void rna_NodeTree_inputs_clear(bNodeTree *ntree, Main *bmain, ReportList *reports)
{
bNodeSocket *sock, *nextsock;
@@ -991,11 +991,11 @@ static void rna_NodeTree_inputs_clear(bNodeTree *ntree, ReportList *reports)
ntreeRemoveSocketInterface(ntree, sock);
}
- ntreeUpdateTree(G.main, ntree);
+ ntreeUpdateTree(bmain, ntree);
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
}
-static void rna_NodeTree_outputs_clear(bNodeTree *ntree, ReportList *reports)
+static void rna_NodeTree_outputs_clear(bNodeTree *ntree, Main *bmain, ReportList *reports)
{
bNodeSocket *sock, *nextsock;
@@ -1007,11 +1007,11 @@ static void rna_NodeTree_outputs_clear(bNodeTree *ntree, ReportList *reports)
ntreeRemoveSocketInterface(ntree, sock);
}
- ntreeUpdateTree(G.main, ntree);
+ ntreeUpdateTree(bmain, ntree);
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
}
-static void rna_NodeTree_inputs_move(bNodeTree *ntree, int from_index, int to_index)
+static void rna_NodeTree_inputs_move(bNodeTree *ntree, Main *bmain, int from_index, int to_index)
{
bNodeSocket *sock;
@@ -1038,11 +1038,11 @@ static void rna_NodeTree_inputs_move(bNodeTree *ntree, int from_index, int to_in
ntree->update |= NTREE_UPDATE_GROUP_IN;
- ntreeUpdateTree(G.main, ntree);
+ ntreeUpdateTree(bmain, ntree);
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
}
-static void rna_NodeTree_outputs_move(bNodeTree *ntree, int from_index, int to_index)
+static void rna_NodeTree_outputs_move(bNodeTree *ntree, Main *bmain, int from_index, int to_index)
{
bNodeSocket *sock;
@@ -1069,16 +1069,18 @@ static void rna_NodeTree_outputs_move(bNodeTree *ntree, int from_index, int to_i
ntree->update |= NTREE_UPDATE_GROUP_OUT;
- ntreeUpdateTree(G.main, ntree);
+ ntreeUpdateTree(bmain, ntree);
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
}
static void rna_NodeTree_interface_update(bNodeTree *ntree, bContext *C)
{
+ Main *bmain = CTX_data_main(C);
+
ntree->update |= NTREE_UPDATE_GROUP;
- ntreeUpdateTree(G.main, ntree);
+ ntreeUpdateTree(bmain, ntree);
- ED_node_tag_update_nodetree(CTX_data_main(C), ntree, NULL);
+ ED_node_tag_update_nodetree(bmain, ntree, NULL);
}
@@ -1608,7 +1610,7 @@ static void rna_Node_name_set(PointerRNA *ptr, const char *value)
BKE_animdata_fix_paths_rename_all(NULL, "nodes", oldname, node->name);
}
-static bNodeSocket *rna_Node_inputs_new(ID *id, bNode *node, ReportList *reports, const char *type, const char *name, const char *identifier)
+static bNodeSocket *rna_Node_inputs_new(ID *id, bNode *node, Main *bmain, ReportList *reports, const char *type, const char *name, const char *identifier)
{
bNodeTree *ntree = (bNodeTree *)id;
bNodeSocket *sock;
@@ -1619,14 +1621,14 @@ static bNodeSocket *rna_Node_inputs_new(ID *id, bNode *node, ReportList *reports
BKE_report(reports, RPT_ERROR, "Unable to create socket");
}
else {
- ntreeUpdateTree(G.main, ntree);
+ ntreeUpdateTree(bmain, ntree);
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
}
return sock;
}
-static bNodeSocket *rna_Node_outputs_new(ID *id, bNode *node, ReportList *reports, const char *type, const char *name, const char *identifier)
+static bNodeSocket *rna_Node_outputs_new(ID *id, bNode *node, Main *bmain, ReportList *reports, const char *type, const char *name, const char *identifier)
{
bNodeTree *ntree = (bNodeTree *)id;
bNodeSocket *sock;
@@ -1637,14 +1639,14 @@ static bNodeSocket *rna_Node_outputs_new(ID *id, bNode *node, ReportList *report
BKE_report(reports, RPT_ERROR, "Unable to create socket");
}
else {
- ntreeUpdateTree(G.main, ntree);
+ ntreeUpdateTree(bmain, ntree);
WM_main_add_notifier(NC_NODE | NA_EDITED, ntree);
}
return sock;
}
-static void rna_Node_socket_remove(ID *id, bNode *node, ReportList *reports, bNodeSocket *sock)
+static void rna_
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list