From 42d65dd7ffc360a2bc5c9b35eeaed29c01d4fe3c Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Tue, 19 Mar 2013 20:37:25 +0000 Subject: [PATCH] Fix #34697, Undoing a node group crashes Blender. The problem here was that the extra forward compatibility data for node groups (links to the node interface sockets) was written for files as well as undo memfiles. But only in the case of true .blend files is this data subsequently removed again after loading, which in the case of undo leaves invalid links hanging around in the node tree. Forward compat data is now skipped for undo. --- source/blender/blenloader/intern/writefile.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 9a4736449a2..008b3da1768 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -3112,8 +3112,11 @@ static int write_file_handle(Main *mainvar, int handle, MemFile *compare, MemFil #endif #ifdef USE_NODE_COMPAT_CUSTOMNODES - /* deprecated forward compat data is freed again below */ - customnodes_add_deprecated_data(mainvar); + /* don't write compatibility data on undo */ + if (!current) { + /* deprecated forward compat data is freed again below */ + customnodes_add_deprecated_data(mainvar); + } #endif sprintf(buf, "BLENDER%c%c%.3d", (sizeof(void*)==8)?'-':'_', (ENDIAN_ORDER==B_ENDIAN)?'V':'v', BLENDER_VERSION); @@ -3162,11 +3165,14 @@ static int write_file_handle(Main *mainvar, int handle, MemFile *compare, MemFil writedata(wd, DNA1, wd->sdna->datalen, wd->sdna->data); #ifdef USE_NODE_COMPAT_CUSTOMNODES - /* Ugly, forward compatibility code generates deprecated data during writing, - * this has to be freed again. Can not be done directly after writing, otherwise - * the data pointers could be reused and not be mapped correctly. - */ - customnodes_free_deprecated_data(mainvar); + /* compatibility data not created on undo */ + if (!current) { + /* Ugly, forward compatibility code generates deprecated data during writing, + * this has to be freed again. Can not be done directly after writing, otherwise + * the data pointers could be reused and not be mapped correctly. + */ + customnodes_free_deprecated_data(mainvar); + } #endif /* end of file */