diff options
author | Joshua Leung <aligorith@gmail.com> | 2016-09-07 14:53:13 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2016-09-07 16:14:52 +0300 |
commit | 5b42e07e18c9f933d5e6d267f322822cc159183d (patch) | |
tree | 9462d9ec140ec9acac57face3d3452bf1f5f47af /source/blender/editors/gpencil | |
parent | bcc863993adfe019454d2da014528ac922fffd41 (diff) |
Code Cleanup: Deduplicate undo node freeing code
Diffstat (limited to 'source/blender/editors/gpencil')
-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 793ed2a07d0..196aec894b9 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; @@ -165,14 +169,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; } |