Fix crash when renaming metaballs

This handles both renaming via outliner and rna.

Metaballs as we all know have their geometry based on the metaballs that
share the same name with them.

Changing the name of a metaball without tagging its geometry to change
is asking for trouble.
This commit is contained in:
Dalai Felinto 2018-11-09 10:59:12 -02:00
parent 88d621a68f
commit 6c10ec74d5
2 changed files with 15 additions and 0 deletions

View File

@ -335,6 +335,14 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
WM_event_add_notifier(C, NC_IMAGE, NULL); break;
case ID_SCE:
WM_event_add_notifier(C, NC_SCENE, NULL); break;
case ID_OB:
{
Object *ob = (Object *)tselem->id;
if (ob->type == OB_MBALL) {
DEG_id_tag_update(&ob->id, DEG_TAG_GEOMETRY);
}
WM_event_add_notifier(C, NC_ID | NA_RENAME, NULL); break;
}
default:
WM_event_add_notifier(C, NC_ID | NA_RENAME, NULL); break;
}

View File

@ -153,6 +153,13 @@ void rna_ID_name_set(PointerRNA *ptr, const char *value)
BLI_strncpy_utf8(id->name + 2, value, sizeof(id->name) - 2);
BLI_assert(BKE_id_is_in_global_main(id));
BLI_libblock_ensure_unique_name(G_MAIN, id->name);
if (GS(id->name) == ID_OB) {
Object *ob = (Object *)id;
if (ob->type == OB_MBALL) {
DEG_id_tag_update(&ob->id, DEG_TAG_GEOMETRY);
}
}
}
static int rna_ID_name_editable(PointerRNA *ptr, const char **UNUSED(r_info))