diff options
Diffstat (limited to 'source/blender/blenkernel/intern/text.c')
-rw-r--r-- | source/blender/blenkernel/intern/text.c | 104 |
1 files changed, 86 insertions, 18 deletions
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 3a311bfb23b..c5a8cbe68b2 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -508,10 +508,14 @@ void BKE_text_unlink(Main *bmain, Text *text) bNodeTree *ntree; bNode *node; Material *mat; + Lamp *la; + Tex *te; + World *wo; + FreestyleLineStyle *linestyle; Scene *sce; SceneRenderLayer *srl; FreestyleModuleConfig *module; - short update; + bool update; for (ob = bmain->object.first; ob; ob = ob->id.next) { /* game controllers */ @@ -563,23 +567,97 @@ void BKE_text_unlink(Main *bmain, Text *text) } /* nodes */ + for (la = bmain->lamp.first; la; la = la->id.next) { + ntree = la->nodetree; + if (!ntree) + continue; + for (node = ntree->nodes.first; node; node = node->next) { + if (node->type == NODE_FRAME) { + if ((Text *)node->id == text) { + node->id = NULL; + } + } + } + } + + for (linestyle = bmain->linestyle.first; linestyle; linestyle = linestyle->id.next) { + ntree = linestyle->nodetree; + if (!ntree) + continue; + for (node = ntree->nodes.first; node; node = node->next) { + if (node->type == NODE_FRAME) { + if ((Text *)node->id == text) { + node->id = NULL; + } + } + } + } + for (mat = bmain->mat.first; mat; mat = mat->id.next) { ntree = mat->nodetree; if (!ntree) continue; for (node = ntree->nodes.first; node; node = node->next) { - if (node->type == SH_NODE_SCRIPT) { + if (ELEM(node->type, SH_NODE_SCRIPT, NODE_FRAME)) { + if ((Text *)node->id == text) { + node->id = NULL; + } + } + } + } + + for (te = bmain->tex.first; te; te = te->id.next) { + ntree = te->nodetree; + if (!ntree) + continue; + for (node = ntree->nodes.first; node; node = node->next) { + if (node->type == NODE_FRAME) { + if ((Text *)node->id == text) { + node->id = NULL; + } + } + } + } + + for (wo = bmain->world.first; wo; wo = wo->id.next) { + ntree = wo->nodetree; + if (!ntree) + continue; + for (node = ntree->nodes.first; node; node = node->next) { + if (node->type == NODE_FRAME) { + if ((Text *)node->id == text) { + node->id = NULL; + } + } + } + } + + for (sce = bmain->scene.first; sce; sce = sce->id.next) { + ntree = sce->nodetree; + if (!ntree) + continue; + for (node = ntree->nodes.first; node; node = node->next) { + if (node->type == NODE_FRAME) { Text *ntext = (Text *)node->id; if (ntext == text) node->id = NULL; } } + + /* Freestyle (while looping oer the scene) */ + for (srl = sce->r.layers.first; srl; srl = srl->next) { + for (module = srl->freestyleConfig.modules.first; module; module = module->next) { + if (module->script == text) + module->script = NULL; + } + } } - + for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next) { for (node = ntree->nodes.first; node; node = node->next) { - if (node->type == SH_NODE_SCRIPT) { - Text *ntext = (Text *)node->id; - if (ntext == text) node->id = NULL; + if (ELEM(node->type, SH_NODE_SCRIPT, NODE_FRAME)) { + if ((Text *)node->id == text) { + node->id = NULL; + } } } } @@ -600,16 +678,6 @@ void BKE_text_unlink(Main *bmain, Text *text) } } - /* Freestyle */ - for (sce = bmain->scene.first; sce; sce = sce->id.next) { - for (srl = sce->r.layers.first; srl; srl = srl->next) { - for (module = srl->freestyleConfig.modules.first; module; module = module->next) { - if (module->script == text) - module->script = NULL; - } - } - } - text->id.us = 0; } @@ -617,7 +685,7 @@ void BKE_text_clear(Text *text) /* called directly from rna */ { int oldstate; - oldstate = txt_get_undostate( ); + oldstate = txt_get_undostate(); txt_set_undostate(1); txt_sel_all(text); txt_delete_sel(text); @@ -2740,7 +2808,7 @@ void txt_unindent(Text *text) while (true) { bool changed = false; - if (strncmp(text->curl->line, remove, indentlen) == 0) { + if (STREQLEN(text->curl->line, remove, indentlen)) { if (num == 0) unindented_first = true; text->curl->len -= indentlen; |