Bugfix [#26269] Initiating a duplication with shift D and cancelling

in dope sheet/ graph editor leads to duplicated keys

The old hack using the transform "undostring" didn't work anymore, as
this wasn't set. Instead, I've added a special mode transform mode for
this that the duplicate operators can set to get this functionality.
This commit is contained in:
2011-03-02 23:39:08 +00:00
parent 9f397b3a3d
commit a19e917782
5 changed files with 36 additions and 5 deletions

View File

@@ -77,6 +77,7 @@ enum {
TFM_TIME_SLIDE,
TFM_TIME_SCALE,
TFM_TIME_EXTEND,
TFM_TIME_DUPLICATE,
TFM_BAKE_TIME,
TFM_BEVEL,
TFM_BWEIGHT,

View File

@@ -663,7 +663,7 @@ static int actkeys_duplicate_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED
{
actkeys_duplicate_exec(C, op);
RNA_int_set(op->ptr, "mode", TFM_TIME_TRANSLATE);
RNA_int_set(op->ptr, "mode", TFM_TIME_DUPLICATE);
WM_operator_name_call(C, "TRANSFORM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr);
return OPERATOR_FINISHED;

View File

@@ -782,7 +782,7 @@ static int graphkeys_duplicate_invoke(bContext *C, wmOperator *op, wmEvent *UNUS
{
graphkeys_duplicate_exec(C, op);
RNA_int_set(op->ptr, "mode", TFM_TRANSLATION);
RNA_int_set(op->ptr, "mode", TFM_TIME_DUPLICATE);
WM_operator_name_call(C, "TRANSFORM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr);
return OPERATOR_FINISHED;

View File

@@ -1677,6 +1677,16 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
case TFM_TIME_SCALE:
initTimeScale(t);
break;
case TFM_TIME_DUPLICATE:
/* same as TFM_TIME_EXTEND, but we need the mode info for later
* so that duplicate-culling will work properly
*/
if ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)
initTranslation(t);
else
initTimeTranslate(t);
t->mode = mode;
break;
case TFM_TIME_EXTEND:
/* now that transdata has been made, do like for TFM_TIME_TRANSLATE (for most Animation
* Editors because they have only 1D transforms for time values) or TFM_TRANSLATION

View File

@@ -4681,7 +4681,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
Object *ob;
// short redrawipo=0, resetslowpar=1;
int cancelled= (t->state == TRANS_CANCEL);
short duplicate= (t->undostr && strstr(t->undostr, "Duplicate")) ? 1 : 0; /* see bugreport #21229 for reasons for this data */
short duplicate= (t->mode == TFM_TIME_DUPLICATE);
/* early out when nothing happened */
if (t->total == 0 || t->mode == TFM_DUMMY)
@@ -4743,6 +4743,11 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
FCurve *fcu= (FCurve *)ale->key_data;
/* 3 cases here for curve cleanups:
* 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done
* 2) cancelled == 0 -> user confirmed the transform, so duplicates should be removed
* 3) cancelled + duplicate -> user cancelled the transform, but we made duplicates, so get rid of these
*/
if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 &&
((cancelled == 0) || (duplicate)) )
{
@@ -4769,7 +4774,11 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
DAG_id_tag_update(&ob->id, OB_RECALC_OB);
}
/* Do curve cleanups? */
/* 3 cases here for curve cleanups:
* 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done
* 2) cancelled == 0 -> user confirmed the transform, so duplicates should be removed
* 3) cancelled + duplicate -> user cancelled the transform, but we made duplicates, so get rid of these
*/
if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 &&
((cancelled == 0) || (duplicate)) )
{
@@ -4796,7 +4805,13 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
else if (ac.datatype == ANIMCONT_GPENCIL) {
/* remove duplicate frames and also make sure points are in order! */
if ((cancelled == 0) || (duplicate))
/* 3 cases here for curve cleanups:
* 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done
* 2) cancelled == 0 -> user confirmed the transform, so duplicates should be removed
* 3) cancelled + duplicate -> user cancelled the transform, but we made duplicates, so get rid of these
*/
if ( (saction->flag & SACTION_NOTRANSKEYCULL)==0 &&
((cancelled == 0) || (duplicate)) )
{
bGPdata *gpd;
@@ -4836,6 +4851,11 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
FCurve *fcu= (FCurve *)ale->key_data;
/* 3 cases here for curve cleanups:
* 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done
* 2) cancelled == 0 -> user confirmed the transform, so duplicates should be removed
* 3) cancelled + duplicate -> user cancelled the transform, but we made duplicates, so get rid of these
*/
if ( (sipo->flag & SIPO_NOTRANSKEYCULL)==0 &&
((cancelled == 0) || (duplicate)) )
{