diff options
author | Joshua Leung <aligorith@gmail.com> | 2016-09-07 14:53:13 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-09-14 14:26:04 +0300 |
commit | b6508da38043622e840a7bbb174d8bfeb3ee84d4 (patch) | |
tree | f5c312326d349b7a709c9773e194ab2f9cc3efdf | |
parent | 929701931d9aba38d588a295315a483e2b442ff4 (diff) |
Code Cleanup: Deduplicate undo node freeing code
-rw-r--r-- | source/blender/editors/gpencil/gpencil_undo.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/source/blender/editors/gpencil/gpencil_undo.c b/source/blender/editors/gpencil/gpencil_undo.c index d346633e9e9..7a9ad2b32c0 100644 --- a/source/blender/editors/gpencil/gpencil_undo.c +++ b/source/blender/editors/gpencil/gpencil_undo.c @@ -124,6 +124,17 @@ void gpencil_undo_init(bGPdata *gpd) gpencil_undo_push(gpd); } +static void gpencil_undo_free_node(bGPundonode *undo_node) +{ + /* HACK: animdata wasn't duplicated, so it shouldn't be freed here, + * or else the real copy will segfault when accessed + */ + undo_node->gpd->adt = NULL; + + BKE_gpencil_free(undo_node->gpd, false); + MEM_freeN(undo_node->gpd); +} + void gpencil_undo_push(bGPdata *gpd) { bGPundonode *undo_node; @@ -137,14 +148,7 @@ void gpencil_undo_push(bGPdata *gpd) while (undo_node) { bGPundonode *next_node = undo_node->next; - /* HACK: animdata wasn't duplicated, so it shouldn't be freed here, - * or else the real copy will segfault when accessed - */ - undo_node->gpd->adt = NULL; - - BKE_gpencil_free(undo_node->gpd, false); - MEM_freeN(undo_node->gpd); - + gpencil_undo_free_node(undo_node); BLI_freelinkN(&undo_nodes, undo_node); undo_node = next_node; @@ -188,14 +192,7 @@ void gpencil_undo_finish(void) bGPundonode *undo_node = undo_nodes.first; while (undo_node) { - /* HACK: animdata wasn't duplicated, so it shouldn't be freed here, - * or else the real copy will segfault when accessed - */ - undo_node->gpd->adt = NULL; - - BKE_gpencil_free(undo_node->gpd, false); - MEM_freeN(undo_node->gpd); - + gpencil_undo_free_node(undo_node); undo_node = undo_node->next; } |