Writefile: Cleanup GPencil data.
authorBastien Montagne <b.mont29@gmail.com>
Wed, 1 Apr 2020 10:23:12 +0000 (12:23 +0200)
committerBastien Montagne <b.mont29@gmail.com>
Wed, 1 Apr 2020 10:39:06 +0000 (12:39 +0200)
Note: Not clearing the whole runtime data here, as this is not done in
matching read code, not sure why, needs further investigation...

source/blender/blenloader/intern/writefile.c

index fb6bd637a3b56b7c15025f2fb9ce19906337e21f..eb85fc95e4a026c21843a31fdba51ed88d14de06 100644 (file)
@@ -2824,6 +2824,14 @@ static void write_scene(WriteData *wd, Scene *sce, const void *id_address)
 static void write_gpencil(WriteData *wd, bGPdata *gpd, const void *id_address)
 {
   if (gpd->id.us > 0 || wd->use_memfile) {
+    /* Clean up, important in undo case to reduce false detection of changed datablocks. */
+    /* XXX not sure why the whole runtime data is not cleared in readcode, for now mimicking it
+     * here. */
+    gpd->runtime.sbuffer = NULL;
+    gpd->runtime.sbuffer_used = 0;
+    gpd->runtime.sbuffer_size = 0;
+    gpd->runtime.tot_cp_points = 0;
+
     /* write gpd data block to file */
     writestruct_at_address(wd, ID_GD, bGPdata, 1, id_address, gpd);
     write_iddata(wd, &gpd->id);