diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_blender_version.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/text.c | 16 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 2 | ||||
-rw-r--r-- | source/blender/blenloader/intern/versioning_290.c | 10 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_ops.c | 2 |
6 files changed, 22 insertions, 12 deletions
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index 08aea043fc7..f74f7fe84de 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -39,7 +39,7 @@ extern "C" { /* Blender file format version. */ #define BLENDER_FILE_VERSION BLENDER_VERSION -#define BLENDER_FILE_SUBVERSION 19 +#define BLENDER_FILE_SUBVERSION 20 /* Minimum Blender version that supports reading file written with the current * version. Older Blender versions will test this and show a warning if the file diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 944e01321ce..27f5593c2ca 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -171,6 +171,9 @@ static void text_free_data(ID *id) static void text_blend_write(BlendWriter *writer, ID *id, const void *id_address) { + if (id->us < 1 && !BLO_write_is_undo(writer)) { + return; + } Text *text = (Text *)id; /* Note: we are clearing local temp data here, *not* the flag in the actual 'real' ID. */ @@ -231,8 +234,6 @@ static void text_blend_read_data(BlendDataReader *reader, ID *id) } text->flags = (text->flags) & ~TXT_ISEXT; - - id_us_ensure_real(&text->id); } IDTypeInfo IDType_ID_TXT = { @@ -293,8 +294,10 @@ Text *BKE_text_add(Main *bmain, const char *name) Text *ta; ta = BKE_id_new(bmain, ID_TXT, name); - /* Texts always have 'real' user (see also read code). */ - id_us_ensure_real(&ta->id); + /* Texts have no users by default... Set the fake user flag to ensure that this text block + * doesn't get deleted by default when cleaning up data blocks. */ + id_us_min(&ta->id); + id_fake_user_set(&ta->id); return ta; } @@ -468,7 +471,7 @@ bool BKE_text_reload(Text *text) * \param is_internal: If \a true, this text data-block only exists in memory, * not as a file on disk. * - * \note text data-blocks have no user by default, only the 'real user' flag. + * \note text data-blocks have no real user but have 'fake user' enabled by default */ Text *BKE_text_load_ex(Main *bmain, const char *file, const char *relpath, const bool is_internal) { @@ -489,9 +492,8 @@ Text *BKE_text_load_ex(Main *bmain, const char *file, const char *relpath, const } ta = BKE_libblock_alloc(bmain, ID_TXT, BLI_path_basename(filepath_abs), 0); - /* Texts have no user by default... Only the 'real' user flag. */ - id_us_ensure_real(&ta->id); id_us_min(&ta->id); + id_fake_user_set(&ta->id); BLI_listbase_clear(&ta->lines); ta->curl = ta->sell = NULL; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 85cf45bd868..19ae0014bb8 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2912,7 +2912,7 @@ static void lib_link_workspace_layout_restore(struct IDNameLib_Map *id_map, else if (sl->spacetype == SPACE_TEXT) { SpaceText *st = (SpaceText *)sl; - st->text = restore_pointer_by_name(id_map, (ID *)st->text, USER_REAL); + st->text = restore_pointer_by_name(id_map, (ID *)st->text, USER_IGNORE); if (st->text == NULL) { st->text = newmain->texts.first; } diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index fe8e46e8928..97fe9fb04c4 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -48,6 +48,7 @@ #include "DNA_screen_types.h" #include "DNA_shader_fx_types.h" #include "DNA_space_types.h" +#include "DNA_text_types.h" #include "DNA_tracking_types.h" #include "DNA_workspace_types.h" @@ -686,6 +687,15 @@ void do_versions_after_linking_290(Main *bmain, ReportList *UNUSED(reports)) } } + if (!MAIN_VERSION_ATLEAST(bmain, 293, 20)) { + /* Set zero user text objects to have a fake user. */ + LISTBASE_FOREACH (Text *, text, &bmain->texts) { + if (text->id.us == 0) { + id_fake_user_set(&text->id); + } + } + } + /** * Versioning code until next subversion bump goes here. * diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 760fbe75688..caeb52ab7e9 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1110,7 +1110,7 @@ static void template_ID(const bContext *C, UI_but_flag_enable(but, UI_BUT_REDALERT); } - if (id->lib == NULL && !(ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_TXT, ID_OB, ID_WS)) && + if (id->lib == NULL && !(ELEM(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_OB, ID_WS)) && (hide_buttons == false)) { uiDefIconButR(block, UI_BTYPE_ICON_TOGGLE, diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index e6803d12a42..9ec759ce4ae 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -266,8 +266,6 @@ static int text_new_exec(bContext *C, wmOperator *UNUSED(op)) PropertyRNA *prop; text = BKE_text_add(bmain, "Text"); - /* Texts have no user by default... Only the 'real' user flag. */ - id_us_min(&text->id); /* hook into UI */ UI_context_active_but_prop_get_templateID(C, &ptr, &prop); |