diff options
Diffstat (limited to 'source/blender/blenkernel/intern/text.c')
-rw-r--r-- | source/blender/blenkernel/intern/text.c | 194 |
1 files changed, 6 insertions, 188 deletions
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 6def9e3e503..fdc2edba57f 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -171,14 +171,17 @@ void BKE_text_free_lines(Text *text) text->curl = text->sell = NULL; } +/** Free (or release) any data used by this text (does not free the text itself). */ void BKE_text_free(Text *text) { + /* No animdata here. */ + BKE_text_free_lines(text); - if (text->name) MEM_freeN(text->name); - MEM_freeN(text->undo_buf); + MEM_SAFE_FREE(text->name); + MEM_SAFE_FREE(text->undo_buf); #ifdef WITH_PYTHON - if (text->compiled) BPY_text_free_code(text); + BPY_text_free_code(text); #endif } @@ -495,191 +498,6 @@ Text *BKE_text_copy(Main *bmain, Text *ta) return tan; } -void BKE_text_unlink(Main *bmain, Text *text) -{ - bScreen *scr; - ScrArea *area; - SpaceLink *sl; - Object *ob; - bController *cont; - bActuator *act; - bConstraint *con; - bNodeTree *ntree; - bNode *node; - Material *mat; - Lamp *la; - Tex *te; - World *wo; - FreestyleLineStyle *linestyle; - Scene *sce; - SceneRenderLayer *srl; - FreestyleModuleConfig *module; - bool update; - - for (ob = bmain->object.first; ob; ob = ob->id.next) { - /* game controllers */ - for (cont = ob->controllers.first; cont; cont = cont->next) { - if (cont->type == CONT_PYTHON) { - bPythonCont *pc; - - pc = cont->data; - if (pc->text == text) pc->text = NULL; - } - } - /* game actuators */ - for (act = ob->actuators.first; act; act = act->next) { - if (act->type == ACT_2DFILTER) { - bTwoDFilterActuator *tfa; - - tfa = act->data; - if (tfa->text == text) tfa->text = NULL; - } - } - - /* pyconstraints */ - update = 0; - - if (ob->type == OB_ARMATURE && ob->pose) { - bPoseChannel *pchan; - for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { - for (con = pchan->constraints.first; con; con = con->next) { - if (con->type == CONSTRAINT_TYPE_PYTHON) { - bPythonConstraint *data = con->data; - if (data->text == text) data->text = NULL; - update = 1; - - } - } - } - } - - for (con = ob->constraints.first; con; con = con->next) { - if (con->type == CONSTRAINT_TYPE_PYTHON) { - bPythonConstraint *data = con->data; - if (data->text == text) data->text = NULL; - update = 1; - } - } - - if (update) - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - } - - /* 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 (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 over 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 (ELEM(node->type, SH_NODE_SCRIPT, NODE_FRAME)) { - if ((Text *)node->id == text) { - node->id = NULL; - } - } - } - } - - /* text space */ - for (scr = bmain->screen.first; scr; scr = scr->id.next) { - for (area = scr->areabase.first; area; area = area->next) { - for (sl = area->spacedata.first; sl; sl = sl->next) { - if (sl->spacetype == SPACE_TEXT) { - SpaceText *st = (SpaceText *) sl; - - if (st->text == text) { - st->text = NULL; - st->top = 0; - } - } - } - } - } - - text->id.us = 0; -} - void BKE_text_clear(Text *text) /* called directly from rna */ { int oldstate; |