Fix for previous commit

gpencil_data_duplicate() was being used for gp drawing undo buffers, where using an
exact copy is exactly what we want/need. Instead, the code here now has an additional
arg for determining whether a direct copy is warranted or not.
This commit is contained in:
2014-11-22 18:03:37 +13:00
parent 8319a91ad4
commit 731f3476b7
4 changed files with 12 additions and 9 deletions

View File

@@ -49,11 +49,7 @@ struct bGPdata *gpencil_data_addnew(const char name[]);
struct bGPDframe *gpencil_frame_duplicate(struct bGPDframe *src);
struct bGPDlayer *gpencil_layer_duplicate(struct bGPDlayer *src);
struct bGPdata *gpencil_data_duplicate(struct bGPdata *gpd);
//struct bGPdata *gpencil_data_getactive(struct ScrArea *sa);
//short gpencil_data_setactive(struct ScrArea *sa, struct bGPdata *gpd);
//struct ScrArea *gpencil_data_findowner(struct bGPdata *gpd);
struct bGPdata *gpencil_data_duplicate(struct bGPdata *gpd, bool internal_copy);
void gpencil_frame_delete_laststroke(struct bGPDlayer *gpl, struct bGPDframe *gpf);

View File

@@ -276,7 +276,7 @@ bGPDlayer *gpencil_layer_duplicate(bGPDlayer *src)
}
/* make a copy of a given gpencil datablock */
bGPdata *gpencil_data_duplicate(bGPdata *src)
bGPdata *gpencil_data_duplicate(bGPdata *src, bool internal_copy)
{
bGPDlayer *gpl, *gpld;
bGPdata *dst;
@@ -286,7 +286,14 @@ bGPdata *gpencil_data_duplicate(bGPdata *src)
return NULL;
/* make a copy of the base-data */
dst = BKE_libblock_copy(&src->id);
if (internal_copy) {
/* make a straight copy for undo buffers used during stroke drawing */
dst = MEM_dupallocN(src);
}
else {
/* make a copy when others use this */
dst = BKE_libblock_copy(&src->id);
}
/* copy layers */
BLI_listbase_clear(&dst->layers);

View File

@@ -145,7 +145,7 @@ void gpencil_undo_push(bGPdata *gpd)
/* create new undo node */
undo_node = MEM_callocN(sizeof(bGPundonode), "gpencil undo node");
undo_node->gpd = gpencil_data_duplicate(gpd);
undo_node->gpd = gpencil_data_duplicate(gpd, true);
cur_node = undo_node;

View File

@@ -328,7 +328,7 @@ static SpaceLink *sequencer_duplicate(SpaceLink *sl)
SpaceSeq *sseqn = MEM_dupallocN(sl);
/* clear or remove stuff from old */
// XXX sseq->gpd = gpencil_data_duplicate(sseq->gpd);
// XXX sseq->gpd = gpencil_data_duplicate(sseq->gpd, false);
memset(&sseqn->scopes, 0, sizeof(sseqn->scopes));